babylon.d.txt 2.1 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655
  1. declare module 'babylonjs' {
  2. export = BABYLON;
  3. }
  4. declare module BABYLON {
  5. /**
  6. * Defines how the parser contract is defined.
  7. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  8. */
  9. type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  10. /**
  11. * Defines how the individual parser contract is defined.
  12. * These parser can parse an individual asset
  13. */
  14. type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  15. /**
  16. * Base class of the scene acting as a container for the different elements composing a scene.
  17. * This class is dynamically extended by the different components of the scene increasing
  18. * flexibility and reducing coupling
  19. */
  20. abstract class AbstractScene {
  21. /**
  22. * Stores the list of available parsers in the application.
  23. */
  24. private static _BabylonFileParsers;
  25. /**
  26. * Stores the list of available individual parsers in the application.
  27. */
  28. private static _IndividualBabylonFileParsers;
  29. /**
  30. * Adds a parser in the list of available ones
  31. * @param name Defines the name of the parser
  32. * @param parser Defines the parser to add
  33. */
  34. static AddParser(name: string, parser: BabylonFileParser): void;
  35. /**
  36. * Gets a general parser from the list of avaialble ones
  37. * @param name Defines the name of the parser
  38. * @returns the requested parser or null
  39. */
  40. static GetParser(name: string): Nullable<BabylonFileParser>;
  41. /**
  42. * Adds n individual parser in the list of available ones
  43. * @param name Defines the name of the parser
  44. * @param parser Defines the parser to add
  45. */
  46. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  47. /**
  48. * Gets an individual parser from the list of avaialble ones
  49. * @param name Defines the name of the parser
  50. * @returns the requested parser or null
  51. */
  52. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  53. /**
  54. * Parser json data and populate both a scene and its associated container object
  55. * @param jsonData Defines the data to parse
  56. * @param scene Defines the scene to parse the data for
  57. * @param container Defines the container attached to the parsing sequence
  58. * @param rootUrl Defines the root url of the data
  59. */
  60. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  61. /**
  62. * Gets the list of root nodes (ie. nodes with no parent)
  63. */
  64. rootNodes: Node[];
  65. /** All of the cameras added to this scene
  66. * @see http://doc.babylonjs.com/babylon101/cameras
  67. */
  68. cameras: Camera[];
  69. /**
  70. * All of the lights added to this scene
  71. * @see http://doc.babylonjs.com/babylon101/lights
  72. */
  73. lights: Light[];
  74. /**
  75. * All of the (abstract) meshes added to this scene
  76. */
  77. meshes: AbstractMesh[];
  78. /**
  79. * The list of skeletons added to the scene
  80. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  81. */
  82. skeletons: Skeleton[];
  83. /**
  84. * All of the particle systems added to this scene
  85. * @see http://doc.babylonjs.com/babylon101/particles
  86. */
  87. particleSystems: IParticleSystem[];
  88. /**
  89. * Gets a list of Animations associated with the scene
  90. */
  91. animations: Animation[];
  92. /**
  93. * All of the animation groups added to this scene
  94. * @see http://doc.babylonjs.com/how_to/group
  95. */
  96. animationGroups: AnimationGroup[];
  97. /**
  98. * All of the multi-materials added to this scene
  99. * @see http://doc.babylonjs.com/how_to/multi_materials
  100. */
  101. multiMaterials: MultiMaterial[];
  102. /**
  103. * All of the materials added to this scene
  104. * @see http://doc.babylonjs.com/babylon101/materials
  105. */
  106. materials: Material[];
  107. /**
  108. * The list of morph target managers added to the scene
  109. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  110. */
  111. morphTargetManagers: MorphTargetManager[];
  112. /**
  113. * The list of geometries used in the scene.
  114. */
  115. geometries: Geometry[];
  116. /**
  117. * All of the tranform nodes added to this scene
  118. * @see http://doc.babylonjs.com/how_to/transformnode
  119. */
  120. transformNodes: TransformNode[];
  121. /**
  122. * ActionManagers available on the scene.
  123. */
  124. actionManagers: ActionManager[];
  125. /**
  126. * Textures to keep.
  127. */
  128. textures: BaseTexture[];
  129. }
  130. }
  131. declare module BABYLON {
  132. /**
  133. * Set of assets to keep when moving a scene into an asset container.
  134. */
  135. class KeepAssets extends AbstractScene {
  136. }
  137. /**
  138. * Container with a set of assets that can be added or removed from a scene.
  139. */
  140. class AssetContainer extends AbstractScene {
  141. /**
  142. * The scene the AssetContainer belongs to.
  143. */
  144. scene: Scene;
  145. /**
  146. * Instantiates an AssetContainer.
  147. * @param scene The scene the AssetContainer belongs to.
  148. */
  149. constructor(scene: Scene);
  150. /**
  151. * Adds all the assets from the container to the scene.
  152. */
  153. addAllToScene(): void;
  154. /**
  155. * Removes all the assets in the container from the scene
  156. */
  157. removeAllFromScene(): void;
  158. private _moveAssets;
  159. /**
  160. * Removes all the assets contained in the scene and adds them to the container.
  161. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  162. */
  163. moveAllFromScene(keepAssets?: KeepAssets): void;
  164. /**
  165. * 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.
  166. * @returns the root mesh
  167. */
  168. createRootMesh(): Mesh;
  169. }
  170. }
  171. interface Window {
  172. mozIndexedDB: IDBFactory;
  173. webkitIndexedDB: IDBFactory;
  174. msIndexedDB: IDBFactory;
  175. webkitURL: typeof URL;
  176. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  177. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  178. WebGLRenderingContext: WebGLRenderingContext;
  179. MSGesture: MSGesture;
  180. CANNON: any;
  181. AudioContext: AudioContext;
  182. webkitAudioContext: AudioContext;
  183. PointerEvent: any;
  184. Math: Math;
  185. Uint8Array: Uint8ArrayConstructor;
  186. Float32Array: Float32ArrayConstructor;
  187. mozURL: typeof URL;
  188. msURL: typeof URL;
  189. VRFrameData: any;
  190. DracoDecoderModule: any;
  191. }
  192. interface WebGLRenderingContext {
  193. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  194. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  195. vertexAttribDivisor(index: number, divisor: number): void;
  196. createVertexArray(): any;
  197. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  198. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  199. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  200. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  201. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  202. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  203. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  204. createQuery(): WebGLQuery;
  205. deleteQuery(query: WebGLQuery): void;
  206. beginQuery(target: number, query: WebGLQuery): void;
  207. endQuery(target: number): void;
  208. getQueryParameter(query: WebGLQuery, pname: number): any;
  209. getQuery(target: number, pname: number): any;
  210. MAX_SAMPLES: number;
  211. RGBA8: number;
  212. READ_FRAMEBUFFER: number;
  213. DRAW_FRAMEBUFFER: number;
  214. UNIFORM_BUFFER: number;
  215. HALF_FLOAT_OES: number;
  216. RGBA16F: number;
  217. RGBA32F: number;
  218. R32F: number;
  219. RG32F: number;
  220. RGB32F: number;
  221. R16F: number;
  222. RG16F: number;
  223. RGB16F: number;
  224. RED: number;
  225. RG: number;
  226. R8: number;
  227. RG8: number;
  228. UNSIGNED_INT_24_8: number;
  229. DEPTH24_STENCIL8: number;
  230. drawBuffers(buffers: number[]): void;
  231. readBuffer(src: number): void;
  232. readonly COLOR_ATTACHMENT0: number;
  233. readonly COLOR_ATTACHMENT1: number;
  234. readonly COLOR_ATTACHMENT2: number;
  235. readonly COLOR_ATTACHMENT3: number;
  236. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  237. ANY_SAMPLES_PASSED: number;
  238. QUERY_RESULT_AVAILABLE: number;
  239. QUERY_RESULT: number;
  240. }
  241. interface Document {
  242. mozCancelFullScreen(): void;
  243. msCancelFullScreen(): void;
  244. mozFullScreen: boolean;
  245. msIsFullScreen: boolean;
  246. fullscreen: boolean;
  247. mozPointerLockElement: HTMLElement;
  248. msPointerLockElement: HTMLElement;
  249. webkitPointerLockElement: HTMLElement;
  250. }
  251. interface HTMLCanvasElement {
  252. msRequestPointerLock?(): void;
  253. mozRequestPointerLock?(): void;
  254. webkitRequestPointerLock?(): void;
  255. }
  256. interface CanvasRenderingContext2D {
  257. msImageSmoothingEnabled: boolean;
  258. }
  259. interface WebGLBuffer {
  260. references: number;
  261. capacity: number;
  262. is32Bits: boolean;
  263. }
  264. interface WebGLProgram {
  265. transformFeedback?: WebGLTransformFeedback | null;
  266. }
  267. interface MouseEvent {
  268. mozMovementX: number;
  269. mozMovementY: number;
  270. webkitMovementX: number;
  271. webkitMovementY: number;
  272. msMovementX: number;
  273. msMovementY: number;
  274. }
  275. interface Navigator {
  276. mozGetVRDevices: (any: any) => any;
  277. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  278. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  279. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  280. webkitGetGamepads(): Gamepad[];
  281. msGetGamepads(): Gamepad[];
  282. webkitGamepads(): Gamepad[];
  283. }
  284. interface HTMLVideoElement {
  285. mozSrcObject: any;
  286. }
  287. interface Screen {
  288. orientation: string;
  289. mozOrientation: string;
  290. }
  291. interface Math {
  292. fround(x: number): number;
  293. imul(a: number, b: number): number;
  294. }
  295. interface EXT_disjoint_timer_query {
  296. QUERY_COUNTER_BITS_EXT: number;
  297. TIME_ELAPSED_EXT: number;
  298. TIMESTAMP_EXT: number;
  299. GPU_DISJOINT_EXT: number;
  300. QUERY_RESULT_EXT: number;
  301. QUERY_RESULT_AVAILABLE_EXT: number;
  302. queryCounterEXT(query: WebGLQuery, target: number): void;
  303. createQueryEXT(): WebGLQuery;
  304. beginQueryEXT(target: number, query: WebGLQuery): void;
  305. endQueryEXT(target: number): void;
  306. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  307. deleteQueryEXT(query: WebGLQuery): void;
  308. }
  309. interface WebGLUniformLocation {
  310. }
  311. declare module BABYLON {
  312. /**
  313. * Defines how a node can be built from a string name.
  314. */
  315. type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  316. /**
  317. * Node is the basic class for all scene objects (Mesh, Light Camera).
  318. */
  319. class Node implements IBehaviorAware<Node> {
  320. private static _NodeConstructors;
  321. /**
  322. * Add a new node constructor
  323. * @param type defines the type name of the node to construct
  324. * @param constructorFunc defines the constructor function
  325. */
  326. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  327. /**
  328. * Returns a node constructor based on type name
  329. * @param type defines the type name
  330. * @param name defines the new node name
  331. * @param scene defines the hosting scene
  332. * @param options defines optional options to transmit to constructors
  333. * @returns the new constructor or null
  334. */
  335. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  336. /**
  337. * Gets or sets the name of the node
  338. */
  339. name: string;
  340. /**
  341. * Gets or sets the id of the node
  342. */
  343. id: string;
  344. /**
  345. * Gets or sets the unique id of the node
  346. */
  347. uniqueId: number;
  348. /**
  349. * Gets or sets a string used to store user defined state for the node
  350. */
  351. state: string;
  352. /**
  353. * Gets or sets an object used to store user defined information for the node
  354. */
  355. metadata: any;
  356. /**
  357. * Gets or sets a boolean used to define if the node must be serialized
  358. */
  359. doNotSerialize: boolean;
  360. /** @hidden */
  361. /**
  362. * Gets a list of Animations associated with the node
  363. */
  364. animations: Animation[];
  365. protected _ranges: {
  366. [name: string]: Nullable<AnimationRange>;
  367. };
  368. /**
  369. * Callback raised when the node is ready to be used
  370. */
  371. onReady: (node: Node) => void;
  372. private _isEnabled;
  373. private _isParentEnabled;
  374. private _isReady;
  375. /** @hidden */
  376. private _parentRenderId;
  377. protected _childRenderId: number;
  378. /** @hidden */
  379. /** @hidden */
  380. /** @hidden */
  381. private _parentNode;
  382. private _children;
  383. /** @hidden */
  384. /** @hidden */
  385. /**
  386. * Gets a boolean indicating if the node has been disposed
  387. * @returns true if the node was disposed
  388. */
  389. isDisposed(): boolean;
  390. /**
  391. * Gets or sets the parent of the node
  392. */
  393. parent: Nullable<Node>;
  394. private _animationPropertiesOverride;
  395. /**
  396. * Gets or sets the animation properties override
  397. */
  398. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  399. /**
  400. * Gets a string idenfifying the name of the class
  401. * @returns "Node" string
  402. */
  403. getClassName(): string;
  404. /**
  405. * An event triggered when the mesh is disposed
  406. */
  407. onDisposeObservable: Observable<Node>;
  408. private _onDisposeObserver;
  409. /**
  410. * Sets a callback that will be raised when the node will be disposed
  411. */
  412. onDispose: () => void;
  413. /**
  414. * Creates a new Node
  415. * @param {string} name - the name and id to be given to this node
  416. * @param {BABYLON.Scene} the scene this node will be added to
  417. */
  418. constructor(name: string, scene?: Nullable<Scene>);
  419. /**
  420. * Gets the scene of the node
  421. * @returns a {BABYLON.Scene}
  422. */
  423. getScene(): Scene;
  424. /**
  425. * Gets the engine of the node
  426. * @returns a {BABYLON.Engine}
  427. */
  428. getEngine(): Engine;
  429. private _behaviors;
  430. /**
  431. * Attach a behavior to the node
  432. * @see http://doc.babylonjs.com/features/behaviour
  433. * @param behavior defines the behavior to attach
  434. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  435. * @returns the current Node
  436. */
  437. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  438. /**
  439. * Remove an attached behavior
  440. * @see http://doc.babylonjs.com/features/behaviour
  441. * @param behavior defines the behavior to attach
  442. * @returns the current Node
  443. */
  444. removeBehavior(behavior: Behavior<Node>): Node;
  445. /**
  446. * Gets the list of attached behaviors
  447. * @see http://doc.babylonjs.com/features/behaviour
  448. */
  449. readonly behaviors: Behavior<Node>[];
  450. /**
  451. * Gets an attached behavior by name
  452. * @param name defines the name of the behavior to look for
  453. * @see http://doc.babylonjs.com/features/behaviour
  454. * @returns null if behavior was not found else the requested behavior
  455. */
  456. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  457. /**
  458. * Returns the latest update of the World matrix
  459. * @returns a Matrix
  460. */
  461. getWorldMatrix(): Matrix;
  462. /** @hidden */
  463. /**
  464. * Returns directly the latest state of the mesh World matrix.
  465. * A Matrix is returned.
  466. */
  467. readonly worldMatrixFromCache: Matrix;
  468. /** @hidden */
  469. /** @hidden */
  470. updateCache(force?: boolean): void;
  471. /** @hidden */
  472. /** @hidden */
  473. /** @hidden */
  474. /** @hidden */
  475. isSynchronizedWithParent(): boolean;
  476. /** @hidden */
  477. isSynchronized(): boolean;
  478. /**
  479. * Is this node ready to be used/rendered
  480. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  481. * @return true if the node is ready
  482. */
  483. isReady(completeCheck?: boolean): boolean;
  484. /**
  485. * Is this node enabled?
  486. * 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
  487. * @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
  488. * @return whether this node (and its parent) is enabled
  489. */
  490. isEnabled(checkAncestors?: boolean): boolean;
  491. /** @hidden */
  492. protected _syncParentEnabledState(): void;
  493. /**
  494. * Set the enabled state of this node
  495. * @param value defines the new enabled state
  496. */
  497. setEnabled(value: boolean): void;
  498. /**
  499. * Is this node a descendant of the given node?
  500. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  501. * @param ancestor defines the parent node to inspect
  502. * @returns a boolean indicating if this node is a descendant of the given node
  503. */
  504. isDescendantOf(ancestor: Node): boolean;
  505. /** @hidden */
  506. /**
  507. * Will return all nodes that have this node as ascendant
  508. * @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
  509. * @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
  510. * @return all children nodes of all types
  511. */
  512. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  513. /**
  514. * Get all child-meshes of this node
  515. * @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
  516. * @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
  517. * @returns an array of {BABYLON.AbstractMesh}
  518. */
  519. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  520. /**
  521. * Get all child-transformNodes of this node
  522. * @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
  523. * @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
  524. * @returns an array of {BABYLON.TransformNode}
  525. */
  526. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  527. /**
  528. * Get all direct children of this node
  529. * @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
  530. * @returns an array of {BABYLON.Node}
  531. */
  532. getChildren(predicate?: (node: Node) => boolean): Node[];
  533. /** @hidden */
  534. /**
  535. * Get an animation by name
  536. * @param name defines the name of the animation to look for
  537. * @returns null if not found else the requested animation
  538. */
  539. getAnimationByName(name: string): Nullable<Animation>;
  540. /**
  541. * Creates an animation range for this node
  542. * @param name defines the name of the range
  543. * @param from defines the starting key
  544. * @param to defines the end key
  545. */
  546. createAnimationRange(name: string, from: number, to: number): void;
  547. /**
  548. * Delete a specific animation range
  549. * @param name defines the name of the range to delete
  550. * @param deleteFrames defines if animation frames from the range must be deleted as well
  551. */
  552. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  553. /**
  554. * Get an animation range by name
  555. * @param name defines the name of the animation range to look for
  556. * @returns null if not found else the requested animation range
  557. */
  558. getAnimationRange(name: string): Nullable<AnimationRange>;
  559. /**
  560. * Will start the animation sequence
  561. * @param name defines the range frames for animation sequence
  562. * @param loop defines if the animation should loop (false by default)
  563. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  564. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  565. * @returns the object created for this animation. If range does not exist, it will return null
  566. */
  567. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  568. /**
  569. * Serialize animation ranges into a JSON compatible object
  570. * @returns serialization object
  571. */
  572. serializeAnimationRanges(): any;
  573. /**
  574. * Computes the world matrix of the node
  575. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  576. * @returns the world matrix
  577. */
  578. computeWorldMatrix(force?: boolean): Matrix;
  579. /**
  580. * Releases resources associated with this node.
  581. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  582. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  583. */
  584. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  585. /**
  586. * Parse animation range data from a serialization object and store them into a given node
  587. * @param node defines where to store the animation ranges
  588. * @param parsedNode defines the serialization object to read data from
  589. * @param scene defines the hosting scene
  590. */
  591. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  592. }
  593. }
  594. declare module BABYLON {
  595. /**
  596. * Define an interface for all classes that will hold resources
  597. */
  598. interface IDisposable {
  599. /**
  600. * Releases all held resources
  601. */
  602. dispose(): void;
  603. }
  604. /**
  605. * This class is used by the onRenderingGroupObservable
  606. */
  607. class RenderingGroupInfo {
  608. /**
  609. * The Scene that being rendered
  610. */
  611. scene: Scene;
  612. /**
  613. * The camera currently used for the rendering pass
  614. */
  615. camera: Nullable<Camera>;
  616. /**
  617. * The ID of the renderingGroup being processed
  618. */
  619. renderingGroupId: number;
  620. }
  621. /**
  622. * Represents a scene to be rendered by the engine.
  623. * @see http://doc.babylonjs.com/features/scene
  624. */
  625. class Scene extends AbstractScene implements IAnimatable {
  626. private static _uniqueIdCounter;
  627. /** The fog is deactivated */
  628. static readonly FOGMODE_NONE: number;
  629. /** The fog density is following an exponential function */
  630. static readonly FOGMODE_EXP: number;
  631. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  632. static readonly FOGMODE_EXP2: number;
  633. /** The fog density is following a linear function. */
  634. static readonly FOGMODE_LINEAR: number;
  635. /**
  636. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  637. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  638. */
  639. static MinDeltaTime: number;
  640. /**
  641. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  642. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  643. */
  644. static MaxDeltaTime: number;
  645. /**
  646. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  647. */
  648. autoClear: boolean;
  649. /**
  650. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  651. */
  652. autoClearDepthAndStencil: boolean;
  653. /**
  654. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  655. */
  656. clearColor: Color4;
  657. /**
  658. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  659. */
  660. ambientColor: Color3;
  661. /** @hidden */
  662. /** @hidden */
  663. protected _environmentTexture: BaseTexture;
  664. /**
  665. * Texture used in all pbr material as the reflection texture.
  666. * As in the majority of the scene they are the same (exception for multi room and so on),
  667. * this is easier to reference from here than from all the materials.
  668. */
  669. /**
  670. * Texture used in all pbr material as the reflection texture.
  671. * As in the majority of the scene they are the same (exception for multi room and so on),
  672. * this is easier to set here than in all the materials.
  673. */
  674. environmentTexture: BaseTexture;
  675. /** @hidden */
  676. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  677. /**
  678. * Default image processing configuration used either in the rendering
  679. * Forward main pass or through the imageProcessingPostProcess if present.
  680. * As in the majority of the scene they are the same (exception for multi camera),
  681. * this is easier to reference from here than from all the materials and post process.
  682. *
  683. * No setter as we it is a shared configuration, you can set the values instead.
  684. */
  685. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  686. private _forceWireframe;
  687. /**
  688. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  689. */
  690. forceWireframe: boolean;
  691. private _forcePointsCloud;
  692. /**
  693. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  694. */
  695. forcePointsCloud: boolean;
  696. /**
  697. * Gets or sets the active clipplane 1
  698. */
  699. clipPlane: Nullable<Plane>;
  700. /**
  701. * Gets or sets the active clipplane 2
  702. */
  703. clipPlane2: Nullable<Plane>;
  704. /**
  705. * Gets or sets the active clipplane 3
  706. */
  707. clipPlane3: Nullable<Plane>;
  708. /**
  709. * Gets or sets the active clipplane 4
  710. */
  711. clipPlane4: Nullable<Plane>;
  712. /**
  713. * Gets or sets a boolean indicating if animations are enabled
  714. */
  715. animationsEnabled: boolean;
  716. private _animationPropertiesOverride;
  717. /**
  718. * Gets or sets the animation properties override
  719. */
  720. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  721. /**
  722. * Gets or sets a boolean indicating if a constant deltatime has to be used
  723. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  724. */
  725. useConstantAnimationDeltaTime: boolean;
  726. /**
  727. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  728. * Please note that it requires to run a ray cast through the scene on every frame
  729. */
  730. constantlyUpdateMeshUnderPointer: boolean;
  731. /**
  732. * Defines the HTML cursor to use when hovering over interactive elements
  733. */
  734. hoverCursor: string;
  735. /**
  736. * Defines the HTML default cursor to use (empty by default)
  737. */
  738. defaultCursor: string;
  739. /**
  740. * This is used to call preventDefault() on pointer down
  741. * in order to block unwanted artifacts like system double clicks
  742. */
  743. preventDefaultOnPointerDown: boolean;
  744. /**
  745. * Gets or sets user defined metadata
  746. */
  747. metadata: any;
  748. /**
  749. * Gets the name of the plugin used to load this scene (null by default)
  750. */
  751. loadingPluginName: string;
  752. /**
  753. * Use this array to add regular expressions used to disable offline support for specific urls
  754. */
  755. disableOfflineSupportExceptionRules: RegExp[];
  756. /**
  757. * An event triggered when the scene is disposed.
  758. */
  759. onDisposeObservable: Observable<Scene>;
  760. private _onDisposeObserver;
  761. /** Sets a function to be executed when this scene is disposed. */
  762. onDispose: () => void;
  763. /**
  764. * An event triggered before rendering the scene (right after animations and physics)
  765. */
  766. onBeforeRenderObservable: Observable<Scene>;
  767. private _onBeforeRenderObserver;
  768. /** Sets a function to be executed before rendering this scene */
  769. beforeRender: Nullable<() => void>;
  770. /**
  771. * An event triggered after rendering the scene
  772. */
  773. onAfterRenderObservable: Observable<Scene>;
  774. private _onAfterRenderObserver;
  775. /** Sets a function to be executed after rendering this scene */
  776. afterRender: Nullable<() => void>;
  777. /**
  778. * An event triggered before animating the scene
  779. */
  780. onBeforeAnimationsObservable: Observable<Scene>;
  781. /**
  782. * An event triggered after animations processing
  783. */
  784. onAfterAnimationsObservable: Observable<Scene>;
  785. /**
  786. * An event triggered before draw calls are ready to be sent
  787. */
  788. onBeforeDrawPhaseObservable: Observable<Scene>;
  789. /**
  790. * An event triggered after draw calls have been sent
  791. */
  792. onAfterDrawPhaseObservable: Observable<Scene>;
  793. /**
  794. * An event triggered when the scene is ready
  795. */
  796. onReadyObservable: Observable<Scene>;
  797. /**
  798. * An event triggered before rendering a camera
  799. */
  800. onBeforeCameraRenderObservable: Observable<Camera>;
  801. private _onBeforeCameraRenderObserver;
  802. /** Sets a function to be executed before rendering a camera*/
  803. beforeCameraRender: () => void;
  804. /**
  805. * An event triggered after rendering a camera
  806. */
  807. onAfterCameraRenderObservable: Observable<Camera>;
  808. private _onAfterCameraRenderObserver;
  809. /** Sets a function to be executed after rendering a camera*/
  810. afterCameraRender: () => void;
  811. /**
  812. * An event triggered when active meshes evaluation is about to start
  813. */
  814. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  815. /**
  816. * An event triggered when active meshes evaluation is done
  817. */
  818. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  819. /**
  820. * An event triggered when particles rendering is about to start
  821. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  822. */
  823. onBeforeParticlesRenderingObservable: Observable<Scene>;
  824. /**
  825. * An event triggered when particles rendering is done
  826. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  827. */
  828. onAfterParticlesRenderingObservable: Observable<Scene>;
  829. /**
  830. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  831. */
  832. onDataLoadedObservable: Observable<Scene>;
  833. /**
  834. * An event triggered when a camera is created
  835. */
  836. onNewCameraAddedObservable: Observable<Camera>;
  837. /**
  838. * An event triggered when a camera is removed
  839. */
  840. onCameraRemovedObservable: Observable<Camera>;
  841. /**
  842. * An event triggered when a light is created
  843. */
  844. onNewLightAddedObservable: Observable<Light>;
  845. /**
  846. * An event triggered when a light is removed
  847. */
  848. onLightRemovedObservable: Observable<Light>;
  849. /**
  850. * An event triggered when a geometry is created
  851. */
  852. onNewGeometryAddedObservable: Observable<Geometry>;
  853. /**
  854. * An event triggered when a geometry is removed
  855. */
  856. onGeometryRemovedObservable: Observable<Geometry>;
  857. /**
  858. * An event triggered when a transform node is created
  859. */
  860. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  861. /**
  862. * An event triggered when a transform node is removed
  863. */
  864. onTransformNodeRemovedObservable: Observable<TransformNode>;
  865. /**
  866. * An event triggered when a mesh is created
  867. */
  868. onNewMeshAddedObservable: Observable<AbstractMesh>;
  869. /**
  870. * An event triggered when a mesh is removed
  871. */
  872. onMeshRemovedObservable: Observable<AbstractMesh>;
  873. /**
  874. * An event triggered when a material is created
  875. */
  876. onNewMaterialAddedObservable: Observable<Material>;
  877. /**
  878. * An event triggered when a material is removed
  879. */
  880. onMaterialRemovedObservable: Observable<Material>;
  881. /**
  882. * An event triggered when a texture is created
  883. */
  884. onNewTextureAddedObservable: Observable<BaseTexture>;
  885. /**
  886. * An event triggered when a texture is removed
  887. */
  888. onTextureRemovedObservable: Observable<BaseTexture>;
  889. /**
  890. * An event triggered when render targets are about to be rendered
  891. * Can happen multiple times per frame.
  892. */
  893. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  894. /**
  895. * An event triggered when render targets were rendered.
  896. * Can happen multiple times per frame.
  897. */
  898. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  899. /**
  900. * An event triggered before calculating deterministic simulation step
  901. */
  902. onBeforeStepObservable: Observable<Scene>;
  903. /**
  904. * An event triggered after calculating deterministic simulation step
  905. */
  906. onAfterStepObservable: Observable<Scene>;
  907. /**
  908. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  909. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  910. * 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)
  911. */
  912. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  913. /**
  914. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  915. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  916. * 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)
  917. */
  918. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  919. /**
  920. * This Observable will when a mesh has been imported into the scene.
  921. */
  922. onMeshImportedObservable: Observable<AbstractMesh>;
  923. private _registeredForLateAnimationBindings;
  924. /**
  925. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  926. */
  927. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  928. /**
  929. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  930. */
  931. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  932. /**
  933. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  934. */
  935. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  936. private _onPointerMove;
  937. private _onPointerDown;
  938. private _onPointerUp;
  939. /** Deprecated. Use onPointerObservable instead */
  940. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  941. /** Deprecated. Use onPointerObservable instead */
  942. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  943. /** Deprecated. Use onPointerObservable instead */
  944. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  945. /** Deprecated. Use onPointerObservable instead */
  946. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  947. /**
  948. * 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).
  949. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  950. */
  951. onPrePointerObservable: Observable<PointerInfoPre>;
  952. /**
  953. * Observable event triggered each time an input event is received from the rendering canvas
  954. */
  955. onPointerObservable: Observable<PointerInfo>;
  956. /**
  957. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  958. */
  959. readonly unTranslatedPointer: Vector2;
  960. /** The distance in pixel that you have to move to prevent some events */
  961. static DragMovementThreshold: number;
  962. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  963. static LongPressDelay: number;
  964. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  965. static DoubleClickDelay: number;
  966. /** If you need to check double click without raising a single click at first click, enable this flag */
  967. static ExclusiveDoubleClickMode: boolean;
  968. private _initClickEvent;
  969. private _initActionManager;
  970. private _delayedSimpleClick;
  971. private _delayedSimpleClickTimeout;
  972. private _previousDelayedSimpleClickTimeout;
  973. private _meshPickProceed;
  974. private _previousButtonPressed;
  975. private _currentPickResult;
  976. private _previousPickResult;
  977. private _totalPointersPressed;
  978. private _doubleClickOccured;
  979. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  980. cameraToUseForPointers: Nullable<Camera>;
  981. private _pointerX;
  982. private _pointerY;
  983. private _unTranslatedPointerX;
  984. private _unTranslatedPointerY;
  985. private _startingPointerPosition;
  986. private _previousStartingPointerPosition;
  987. private _startingPointerTime;
  988. private _previousStartingPointerTime;
  989. private _pointerCaptures;
  990. private _timeAccumulator;
  991. private _currentStepId;
  992. private _currentInternalStep;
  993. /** @hidden */
  994. /**
  995. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  996. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  997. */
  998. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  999. /**
  1000. * Observable event triggered each time an keyboard event is received from the hosting window
  1001. */
  1002. onKeyboardObservable: Observable<KeyboardInfo>;
  1003. private _onKeyDown;
  1004. private _onKeyUp;
  1005. private _onCanvasFocusObserver;
  1006. private _onCanvasBlurObserver;
  1007. private _useRightHandedSystem;
  1008. /**
  1009. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  1010. */
  1011. useRightHandedSystem: boolean;
  1012. /**
  1013. * Sets the step Id used by deterministic lock step
  1014. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  1015. * @param newStepId defines the step Id
  1016. */
  1017. setStepId(newStepId: number): void;
  1018. /**
  1019. * Gets the step Id used by deterministic lock step
  1020. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  1021. * @returns the step Id
  1022. */
  1023. getStepId(): number;
  1024. /**
  1025. * Gets the internal step used by deterministic lock step
  1026. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  1027. * @returns the internal step
  1028. */
  1029. getInternalStep(): number;
  1030. private _fogEnabled;
  1031. /**
  1032. * Gets or sets a boolean indicating if fog is enabled on this scene
  1033. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1034. */
  1035. fogEnabled: boolean;
  1036. private _fogMode;
  1037. /**
  1038. * Gets or sets the fog mode to use
  1039. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1040. */
  1041. fogMode: number;
  1042. /**
  1043. * Gets or sets the fog color to use
  1044. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1045. */
  1046. fogColor: Color3;
  1047. /**
  1048. * Gets or sets the fog density to use
  1049. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1050. */
  1051. fogDensity: number;
  1052. /**
  1053. * Gets or sets the fog start distance to use
  1054. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1055. */
  1056. fogStart: number;
  1057. /**
  1058. * Gets or sets the fog end distance to use
  1059. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1060. */
  1061. fogEnd: number;
  1062. private _shadowsEnabled;
  1063. /**
  1064. * Gets or sets a boolean indicating if shadows are enabled on this scene
  1065. */
  1066. shadowsEnabled: boolean;
  1067. private _lightsEnabled;
  1068. /**
  1069. * Gets or sets a boolean indicating if lights are enabled on this scene
  1070. */
  1071. lightsEnabled: boolean;
  1072. /** All of the active cameras added to this scene. */
  1073. activeCameras: Camera[];
  1074. /** The current active camera */
  1075. activeCamera: Nullable<Camera>;
  1076. private _defaultMaterial;
  1077. /** The default material used on meshes when no material is affected */
  1078. /** The default material used on meshes when no material is affected */
  1079. defaultMaterial: Material;
  1080. private _texturesEnabled;
  1081. /**
  1082. * Gets or sets a boolean indicating if textures are enabled on this scene
  1083. */
  1084. texturesEnabled: boolean;
  1085. /**
  1086. * Gets or sets a boolean indicating if particles are enabled on this scene
  1087. */
  1088. particlesEnabled: boolean;
  1089. /**
  1090. * Gets or sets a boolean indicating if sprites are enabled on this scene
  1091. */
  1092. spritesEnabled: boolean;
  1093. private _skeletonsEnabled;
  1094. /**
  1095. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  1096. */
  1097. skeletonsEnabled: boolean;
  1098. /**
  1099. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  1100. */
  1101. lensFlaresEnabled: boolean;
  1102. /**
  1103. * Gets or sets a boolean indicating if collisions are enabled on this scene
  1104. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  1105. */
  1106. collisionsEnabled: boolean;
  1107. private _workerCollisions;
  1108. /** @hidden */
  1109. collisionCoordinator: ICollisionCoordinator;
  1110. /**
  1111. * Defines the gravity applied to this scene (used only for collisions)
  1112. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  1113. */
  1114. gravity: Vector3;
  1115. /**
  1116. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  1117. */
  1118. postProcessesEnabled: boolean;
  1119. /**
  1120. * The list of postprocesses added to the scene
  1121. */
  1122. postProcesses: PostProcess[];
  1123. /**
  1124. * Gets the current postprocess manager
  1125. */
  1126. postProcessManager: PostProcessManager;
  1127. /**
  1128. * Gets or sets a boolean indicating if render targets are enabled on this scene
  1129. */
  1130. renderTargetsEnabled: boolean;
  1131. /**
  1132. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  1133. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  1134. */
  1135. dumpNextRenderTargets: boolean;
  1136. /**
  1137. * The list of user defined render targets added to the scene
  1138. */
  1139. customRenderTargets: RenderTargetTexture[];
  1140. /**
  1141. * Defines if texture loading must be delayed
  1142. * If true, textures will only be loaded when they need to be rendered
  1143. */
  1144. useDelayedTextureLoading: boolean;
  1145. /**
  1146. * Gets the list of meshes imported to the scene through SceneLoader
  1147. */
  1148. importedMeshesFiles: String[];
  1149. /**
  1150. * Gets or sets a boolean indicating if probes are enabled on this scene
  1151. */
  1152. probesEnabled: boolean;
  1153. /**
  1154. * @hidden
  1155. */
  1156. database: Database;
  1157. /**
  1158. * Gets or sets the action manager associated with the scene
  1159. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1160. */
  1161. actionManager: ActionManager;
  1162. private _meshesForIntersections;
  1163. /**
  1164. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  1165. */
  1166. proceduralTexturesEnabled: boolean;
  1167. private _engine;
  1168. private _totalVertices;
  1169. /** @hidden */
  1170. /** @hidden */
  1171. /** @hidden */
  1172. private _animationRatio;
  1173. private _animationTimeLast;
  1174. private _animationTime;
  1175. /**
  1176. * Gets or sets a general scale for animation speed
  1177. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  1178. */
  1179. animationTimeScale: number;
  1180. /** @hidden */
  1181. /** @hidden */
  1182. /** @hidden */
  1183. private _renderId;
  1184. private _frameId;
  1185. private _executeWhenReadyTimeoutId;
  1186. private _intermediateRendering;
  1187. private _viewUpdateFlag;
  1188. private _projectionUpdateFlag;
  1189. private _alternateViewUpdateFlag;
  1190. private _alternateProjectionUpdateFlag;
  1191. /** @hidden */
  1192. private _activeRequests;
  1193. private _pendingData;
  1194. private _isDisposed;
  1195. /**
  1196. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  1197. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  1198. */
  1199. dispatchAllSubMeshesOfActiveMeshes: boolean;
  1200. private _activeMeshes;
  1201. private _processedMaterials;
  1202. private _renderTargets;
  1203. /** @hidden */
  1204. private _activeSkeletons;
  1205. private _softwareSkinnedMeshes;
  1206. private _renderingManager;
  1207. /** @hidden */
  1208. private _transformMatrix;
  1209. private _sceneUbo;
  1210. private _alternateSceneUbo;
  1211. private _pickWithRayInverseMatrix;
  1212. private _viewMatrix;
  1213. private _projectionMatrix;
  1214. private _alternateViewMatrix;
  1215. private _alternateProjectionMatrix;
  1216. private _alternateTransformMatrix;
  1217. private _useAlternateCameraConfiguration;
  1218. private _alternateRendering;
  1219. /** @hidden */
  1220. /** @hidden */
  1221. protected readonly _isAlternateRenderingEnabled: boolean;
  1222. private _frustumPlanes;
  1223. /**
  1224. * Gets the list of frustum planes (built from the active camera)
  1225. */
  1226. readonly frustumPlanes: Plane[];
  1227. /**
  1228. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  1229. * This is useful if there are more lights that the maximum simulteanous authorized
  1230. */
  1231. requireLightSorting: boolean;
  1232. private _pointerOverMesh;
  1233. private _pickedDownMesh;
  1234. private _pickedUpMesh;
  1235. private _externalData;
  1236. private _uid;
  1237. /**
  1238. * @hidden
  1239. * Backing store of defined scene components.
  1240. */
  1241. /**
  1242. * @hidden
  1243. * Backing store of defined scene components.
  1244. */
  1245. /**
  1246. * List of components to register on the next registration step.
  1247. */
  1248. private _transientComponents;
  1249. /**
  1250. * Registers the transient components if needed.
  1251. */
  1252. private _registerTransientComponents;
  1253. /**
  1254. * @hidden
  1255. * Add a component to the scene.
  1256. * Note that the ccomponent could be registered on th next frame if this is called after
  1257. * the register component stage.
  1258. * @param component Defines the component to add to the scene
  1259. */
  1260. /**
  1261. * @hidden
  1262. * Gets a component from the scene.
  1263. * @param name defines the name of the component to retrieve
  1264. * @returns the component or null if not present
  1265. */
  1266. /**
  1267. * @hidden
  1268. * Defines the actions happening before camera updates.
  1269. */
  1270. /**
  1271. * @hidden
  1272. * Defines the actions happening before clear the canvas.
  1273. */
  1274. /**
  1275. * @hidden
  1276. * Defines the actions when collecting render targets for the frame.
  1277. */
  1278. /**
  1279. * @hidden
  1280. * Defines the actions happening for one camera in the frame.
  1281. */
  1282. /**
  1283. * @hidden
  1284. * Defines the actions happening during the per mesh ready checks.
  1285. */
  1286. /**
  1287. * @hidden
  1288. * Defines the actions happening before evaluate active mesh checks.
  1289. */
  1290. /**
  1291. * @hidden
  1292. * Defines the actions happening during the evaluate sub mesh checks.
  1293. */
  1294. /**
  1295. * @hidden
  1296. * Defines the actions happening during the active mesh stage.
  1297. */
  1298. /**
  1299. * @hidden
  1300. * Defines the actions happening during the per camera render target step.
  1301. */
  1302. /**
  1303. * @hidden
  1304. * Defines the actions happening just before the active camera is drawing.
  1305. */
  1306. /**
  1307. * @hidden
  1308. * Defines the actions happening just before a rendering group is drawing.
  1309. */
  1310. /**
  1311. * @hidden
  1312. * Defines the actions happening just before a mesh is drawing.
  1313. */
  1314. /**
  1315. * @hidden
  1316. * Defines the actions happening just after a mesh has been drawn.
  1317. */
  1318. /**
  1319. * @hidden
  1320. * Defines the actions happening just after a rendering group has been drawn.
  1321. */
  1322. /**
  1323. * @hidden
  1324. * Defines the actions happening just after the active camera has been drawn.
  1325. */
  1326. /**
  1327. * @hidden
  1328. * Defines the actions happening just after rendering all cameras and computing intersections.
  1329. */
  1330. /**
  1331. * @hidden
  1332. * Defines the actions happening when a pointer move event happens.
  1333. */
  1334. /**
  1335. * @hidden
  1336. * Defines the actions happening when a pointer down event happens.
  1337. */
  1338. /**
  1339. * @hidden
  1340. * Defines the actions happening when a pointer up event happens.
  1341. */
  1342. /**
  1343. * Creates a new Scene
  1344. * @param engine defines the engine to use to render this scene
  1345. */
  1346. constructor(engine: Engine);
  1347. private _defaultMeshCandidates;
  1348. /**
  1349. * @hidden
  1350. */
  1351. private _defaultSubMeshCandidates;
  1352. /**
  1353. * @hidden
  1354. */
  1355. /**
  1356. * Sets the default candidate providers for the scene.
  1357. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  1358. * and getCollidingSubMeshCandidates to their default function
  1359. */
  1360. setDefaultCandidateProviders(): void;
  1361. /**
  1362. * Gets a boolean indicating if collisions are processed on a web worker
  1363. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#web-worker-based-collision-system-since-21
  1364. */
  1365. workerCollisions: boolean;
  1366. /**
  1367. * Gets the mesh that is currently under the pointer
  1368. */
  1369. readonly meshUnderPointer: Nullable<AbstractMesh>;
  1370. /**
  1371. * Gets the current on-screen X position of the pointer
  1372. */
  1373. readonly pointerX: number;
  1374. /**
  1375. * Gets the current on-screen Y position of the pointer
  1376. */
  1377. readonly pointerY: number;
  1378. /**
  1379. * Gets the cached material (ie. the latest rendered one)
  1380. * @returns the cached material
  1381. */
  1382. getCachedMaterial(): Nullable<Material>;
  1383. /**
  1384. * Gets the cached effect (ie. the latest rendered one)
  1385. * @returns the cached effect
  1386. */
  1387. getCachedEffect(): Nullable<Effect>;
  1388. /**
  1389. * Gets the cached visibility state (ie. the latest rendered one)
  1390. * @returns the cached visibility state
  1391. */
  1392. getCachedVisibility(): Nullable<number>;
  1393. /**
  1394. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  1395. * @param material defines the current material
  1396. * @param effect defines the current effect
  1397. * @param visibility defines the current visibility state
  1398. * @returns true if one parameter is not cached
  1399. */
  1400. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  1401. /**
  1402. * Gets the engine associated with the scene
  1403. * @returns an Engine
  1404. */
  1405. getEngine(): Engine;
  1406. /**
  1407. * Gets the total number of vertices rendered per frame
  1408. * @returns the total number of vertices rendered per frame
  1409. */
  1410. getTotalVertices(): number;
  1411. /**
  1412. * Gets the performance counter for total vertices
  1413. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1414. */
  1415. readonly totalVerticesPerfCounter: PerfCounter;
  1416. /**
  1417. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  1418. * @returns the total number of active indices rendered per frame
  1419. */
  1420. getActiveIndices(): number;
  1421. /**
  1422. * Gets the performance counter for active indices
  1423. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1424. */
  1425. readonly totalActiveIndicesPerfCounter: PerfCounter;
  1426. /**
  1427. * Gets the total number of active particles rendered per frame
  1428. * @returns the total number of active particles rendered per frame
  1429. */
  1430. getActiveParticles(): number;
  1431. /**
  1432. * Gets the performance counter for active particles
  1433. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1434. */
  1435. readonly activeParticlesPerfCounter: PerfCounter;
  1436. /**
  1437. * Gets the total number of active bones rendered per frame
  1438. * @returns the total number of active bones rendered per frame
  1439. */
  1440. getActiveBones(): number;
  1441. /**
  1442. * Gets the performance counter for active bones
  1443. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1444. */
  1445. readonly activeBonesPerfCounter: PerfCounter;
  1446. /** @hidden */
  1447. getInterFramePerfCounter(): number;
  1448. /** @hidden */
  1449. readonly interFramePerfCounter: Nullable<PerfCounter>;
  1450. /** @hidden */
  1451. getLastFrameDuration(): number;
  1452. /** @hidden */
  1453. readonly lastFramePerfCounter: Nullable<PerfCounter>;
  1454. /** @hidden */
  1455. getEvaluateActiveMeshesDuration(): number;
  1456. /** @hidden */
  1457. readonly evaluateActiveMeshesDurationPerfCounter: Nullable<PerfCounter>;
  1458. /**
  1459. * Gets the array of active meshes
  1460. * @returns an array of AbstractMesh
  1461. */
  1462. getActiveMeshes(): SmartArray<AbstractMesh>;
  1463. /** @hidden */
  1464. getRenderTargetsDuration(): number;
  1465. /** @hidden */
  1466. getRenderDuration(): number;
  1467. /** @hidden */
  1468. readonly renderDurationPerfCounter: Nullable<PerfCounter>;
  1469. /** @hidden */
  1470. getParticlesDuration(): number;
  1471. /** @hidden */
  1472. readonly particlesDurationPerfCounter: Nullable<PerfCounter>;
  1473. /** @hidden */
  1474. getSpritesDuration(): number;
  1475. /** @hidden */
  1476. readonly spriteDuractionPerfCounter: Nullable<PerfCounter>;
  1477. /**
  1478. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  1479. * @returns a number
  1480. */
  1481. getAnimationRatio(): number;
  1482. /**
  1483. * Gets an unique Id for the current render phase
  1484. * @returns a number
  1485. */
  1486. getRenderId(): number;
  1487. /**
  1488. * Gets an unique Id for the current frame
  1489. * @returns a number
  1490. */
  1491. getFrameId(): number;
  1492. /** Call this function if you want to manually increment the render Id*/
  1493. incrementRenderId(): void;
  1494. private _updatePointerPosition;
  1495. private _createUbo;
  1496. private _createAlternateUbo;
  1497. private _setRayOnPointerInfo;
  1498. /**
  1499. * Use this method to simulate a pointer move on a mesh
  1500. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1501. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  1502. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  1503. * @returns the current scene
  1504. */
  1505. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  1506. private _processPointerMove;
  1507. private _checkPrePointerObservable;
  1508. /**
  1509. * Use this method to simulate a pointer down on a mesh
  1510. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1511. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  1512. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  1513. * @returns the current scene
  1514. */
  1515. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  1516. private _processPointerDown;
  1517. /**
  1518. * Use this method to simulate a pointer up on a mesh
  1519. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1520. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  1521. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  1522. * @returns the current scene
  1523. */
  1524. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  1525. private _processPointerUp;
  1526. /**
  1527. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  1528. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  1529. * @returns true if the pointer was captured
  1530. */
  1531. isPointerCaptured(pointerId?: number): boolean;
  1532. /** @hidden */
  1533. /**
  1534. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  1535. * @param attachUp defines if you want to attach events to pointerup
  1536. * @param attachDown defines if you want to attach events to pointerdown
  1537. * @param attachMove defines if you want to attach events to pointermove
  1538. */
  1539. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  1540. /** Detaches all event handlers*/
  1541. detachControl(): void;
  1542. /**
  1543. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  1544. * Delay loaded resources are not taking in account
  1545. * @return true if all required resources are ready
  1546. */
  1547. isReady(): boolean;
  1548. /** Resets all cached information relative to material (including effect and visibility) */
  1549. resetCachedMaterial(): void;
  1550. /**
  1551. * Registers a function to be called before every frame render
  1552. * @param func defines the function to register
  1553. */
  1554. registerBeforeRender(func: () => void): void;
  1555. /**
  1556. * Unregisters a function called before every frame render
  1557. * @param func defines the function to unregister
  1558. */
  1559. unregisterBeforeRender(func: () => void): void;
  1560. /**
  1561. * Registers a function to be called after every frame render
  1562. * @param func defines the function to register
  1563. */
  1564. registerAfterRender(func: () => void): void;
  1565. /**
  1566. * Unregisters a function called after every frame render
  1567. * @param func defines the function to unregister
  1568. */
  1569. unregisterAfterRender(func: () => void): void;
  1570. private _executeOnceBeforeRender;
  1571. /**
  1572. * The provided function will run before render once and will be disposed afterwards.
  1573. * A timeout delay can be provided so that the function will be executed in N ms.
  1574. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  1575. * @param func The function to be executed.
  1576. * @param timeout optional delay in ms
  1577. */
  1578. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  1579. /** @hidden */
  1580. /** @hidden */
  1581. /**
  1582. * Returns the number of items waiting to be loaded
  1583. * @returns the number of items waiting to be loaded
  1584. */
  1585. getWaitingItemsCount(): number;
  1586. /**
  1587. * Returns a boolean indicating if the scene is still loading data
  1588. */
  1589. readonly isLoading: boolean;
  1590. /**
  1591. * Registers a function to be executed when the scene is ready
  1592. * @param {Function} func - the function to be executed
  1593. */
  1594. executeWhenReady(func: () => void): void;
  1595. /**
  1596. * Returns a promise that resolves when the scene is ready
  1597. * @returns A promise that resolves when the scene is ready
  1598. */
  1599. whenReadyAsync(): Promise<void>;
  1600. /** @hidden */
  1601. /**
  1602. * Will start the animation sequence of a given target
  1603. * @param target defines the target
  1604. * @param from defines from which frame should animation start
  1605. * @param to defines until which frame should animation run.
  1606. * @param weight defines the weight to apply to the animation (1.0 by default)
  1607. * @param loop defines if the animation loops
  1608. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  1609. * @param onAnimationEnd defines the function to be executed when the animation ends
  1610. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  1611. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  1612. * @returns the animatable object created for this animation
  1613. */
  1614. beginWeightedAnimation(target: any, from: number, to: number, weight?: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean): Animatable;
  1615. /**
  1616. * Will start the animation sequence of a given target
  1617. * @param target defines the target
  1618. * @param from defines from which frame should animation start
  1619. * @param to defines until which frame should animation run.
  1620. * @param loop defines if the animation loops
  1621. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  1622. * @param onAnimationEnd defines the function to be executed when the animation ends
  1623. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  1624. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  1625. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  1626. * @returns the animatable object created for this animation
  1627. */
  1628. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean): Animatable;
  1629. /**
  1630. * Begin a new animation on a given node
  1631. * @param target defines the target where the animation will take place
  1632. * @param animations defines the list of animations to start
  1633. * @param from defines the initial value
  1634. * @param to defines the final value
  1635. * @param loop defines if you want animation to loop (off by default)
  1636. * @param speedRatio defines the speed ratio to apply to all animations
  1637. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  1638. * @returns the list of created animatables
  1639. */
  1640. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Animatable;
  1641. /**
  1642. * Begin a new animation on a given node and its hierarchy
  1643. * @param target defines the root node where the animation will take place
  1644. * @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.
  1645. * @param animations defines the list of animations to start
  1646. * @param from defines the initial value
  1647. * @param to defines the final value
  1648. * @param loop defines if you want animation to loop (off by default)
  1649. * @param speedRatio defines the speed ratio to apply to all animations
  1650. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  1651. * @returns the list of animatables created for all nodes
  1652. */
  1653. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Animatable[];
  1654. /**
  1655. * Gets the animatable associated with a specific target
  1656. * @param target defines the target of the animatable
  1657. * @returns the required animatable if found
  1658. */
  1659. getAnimatableByTarget(target: any): Nullable<Animatable>;
  1660. /**
  1661. * Gets all animatables associated with a given target
  1662. * @param target defines the target to look animatables for
  1663. * @returns an array of Animatables
  1664. */
  1665. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  1666. /**
  1667. * Gets all animatable attached to the scene
  1668. */
  1669. readonly animatables: Animatable[];
  1670. /**
  1671. * Will stop the animation of the given target
  1672. * @param target - the target
  1673. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  1674. * @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)
  1675. */
  1676. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  1677. /**
  1678. * Stops and removes all animations that have been applied to the scene
  1679. */
  1680. stopAllAnimations(): void;
  1681. private _animate;
  1682. /** @hidden */
  1683. private _processLateAnimationBindingsForMatrices;
  1684. private _processLateAnimationBindingsForQuaternions;
  1685. private _processLateAnimationBindings;
  1686. /** @hidden */
  1687. /**
  1688. * Gets the current view matrix
  1689. * @returns a Matrix
  1690. */
  1691. getViewMatrix(): Matrix;
  1692. /**
  1693. * Gets the current projection matrix
  1694. * @returns a Matrix
  1695. */
  1696. getProjectionMatrix(): Matrix;
  1697. /**
  1698. * Gets the current transform matrix
  1699. * @returns a Matrix made of View * Projection
  1700. */
  1701. getTransformMatrix(): Matrix;
  1702. /**
  1703. * Sets the current transform matrix
  1704. * @param view defines the View matrix to use
  1705. * @param projection defines the Projection matrix to use
  1706. */
  1707. setTransformMatrix(view: Matrix, projection: Matrix): void;
  1708. /** @hidden */
  1709. /**
  1710. * Gets the uniform buffer used to store scene data
  1711. * @returns a UniformBuffer
  1712. */
  1713. getSceneUniformBuffer(): UniformBuffer;
  1714. /**
  1715. * Gets an unique (relatively to the current scene) Id
  1716. * @returns an unique number for the scene
  1717. */
  1718. getUniqueId(): number;
  1719. /**
  1720. * Add a mesh to the list of scene's meshes
  1721. * @param newMesh defines the mesh to add
  1722. * @param recursive if all child meshes should also be added to the scene
  1723. */
  1724. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  1725. /**
  1726. * Remove a mesh for the list of scene's meshes
  1727. * @param toRemove defines the mesh to remove
  1728. * @param recursive if all child meshes should also be removed from the scene
  1729. * @returns the index where the mesh was in the mesh list
  1730. */
  1731. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  1732. /**
  1733. * Add a transform node to the list of scene's transform nodes
  1734. * @param newTransformNode defines the transform node to add
  1735. */
  1736. addTransformNode(newTransformNode: TransformNode): void;
  1737. /**
  1738. * Remove a transform node for the list of scene's transform nodes
  1739. * @param toRemove defines the transform node to remove
  1740. * @returns the index where the transform node was in the transform node list
  1741. */
  1742. removeTransformNode(toRemove: TransformNode): number;
  1743. /**
  1744. * Remove a skeleton for the list of scene's skeletons
  1745. * @param toRemove defines the skeleton to remove
  1746. * @returns the index where the skeleton was in the skeleton list
  1747. */
  1748. removeSkeleton(toRemove: Skeleton): number;
  1749. /**
  1750. * Remove a morph target for the list of scene's morph targets
  1751. * @param toRemove defines the morph target to remove
  1752. * @returns the index where the morph target was in the morph target list
  1753. */
  1754. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  1755. /**
  1756. * Remove a light for the list of scene's lights
  1757. * @param toRemove defines the light to remove
  1758. * @returns the index where the light was in the light list
  1759. */
  1760. removeLight(toRemove: Light): number;
  1761. /**
  1762. * Remove a camera for the list of scene's cameras
  1763. * @param toRemove defines the camera to remove
  1764. * @returns the index where the camera was in the camera list
  1765. */
  1766. removeCamera(toRemove: Camera): number;
  1767. /**
  1768. * Remove a particle system for the list of scene's particle systems
  1769. * @param toRemove defines the particle system to remove
  1770. * @returns the index where the particle system was in the particle system list
  1771. */
  1772. removeParticleSystem(toRemove: IParticleSystem): number;
  1773. /**
  1774. * Remove a animation for the list of scene's animations
  1775. * @param toRemove defines the animation to remove
  1776. * @returns the index where the animation was in the animation list
  1777. */
  1778. removeAnimation(toRemove: Animation): number;
  1779. /**
  1780. * Removes the given animation group from this scene.
  1781. * @param toRemove The animation group to remove
  1782. * @returns The index of the removed animation group
  1783. */
  1784. removeAnimationGroup(toRemove: AnimationGroup): number;
  1785. /**
  1786. * Removes the given multi-material from this scene.
  1787. * @param toRemove The multi-material to remove
  1788. * @returns The index of the removed multi-material
  1789. */
  1790. removeMultiMaterial(toRemove: MultiMaterial): number;
  1791. /**
  1792. * Removes the given material from this scene.
  1793. * @param toRemove The material to remove
  1794. * @returns The index of the removed material
  1795. */
  1796. removeMaterial(toRemove: Material): number;
  1797. /**
  1798. * Removes the given action manager from this scene.
  1799. * @param toRemove The action manager to remove
  1800. * @returns The index of the removed action manager
  1801. */
  1802. removeActionManager(toRemove: ActionManager): number;
  1803. /**
  1804. * Removes the given texture from this scene.
  1805. * @param toRemove The texture to remove
  1806. * @returns The index of the removed texture
  1807. */
  1808. removeTexture(toRemove: BaseTexture): number;
  1809. /**
  1810. * Adds the given light to this scene
  1811. * @param newLight The light to add
  1812. */
  1813. addLight(newLight: Light): void;
  1814. /**
  1815. * Sorts the list list based on light priorities
  1816. */
  1817. sortLightsByPriority(): void;
  1818. /**
  1819. * Adds the given camera to this scene
  1820. * @param newCamera The camera to add
  1821. */
  1822. addCamera(newCamera: Camera): void;
  1823. /**
  1824. * Adds the given skeleton to this scene
  1825. * @param newSkeleton The skeleton to add
  1826. */
  1827. addSkeleton(newSkeleton: Skeleton): void;
  1828. /**
  1829. * Adds the given particle system to this scene
  1830. * @param newParticleSystem The particle system to add
  1831. */
  1832. addParticleSystem(newParticleSystem: IParticleSystem): void;
  1833. /**
  1834. * Adds the given animation to this scene
  1835. * @param newAnimation The animation to add
  1836. */
  1837. addAnimation(newAnimation: Animation): void;
  1838. /**
  1839. * Adds the given animation group to this scene.
  1840. * @param newAnimationGroup The animation group to add
  1841. */
  1842. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  1843. /**
  1844. * Adds the given multi-material to this scene
  1845. * @param newMultiMaterial The multi-material to add
  1846. */
  1847. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  1848. /**
  1849. * Adds the given material to this scene
  1850. * @param newMaterial The material to add
  1851. */
  1852. addMaterial(newMaterial: Material): void;
  1853. /**
  1854. * Adds the given morph target to this scene
  1855. * @param newMorphTargetManager The morph target to add
  1856. */
  1857. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  1858. /**
  1859. * Adds the given geometry to this scene
  1860. * @param newGeometry The geometry to add
  1861. */
  1862. addGeometry(newGeometry: Geometry): void;
  1863. /**
  1864. * Adds the given action manager to this scene
  1865. * @param newActionManager The action manager to add
  1866. */
  1867. addActionManager(newActionManager: ActionManager): void;
  1868. /**
  1869. * Adds the given texture to this scene.
  1870. * @param newTexture The texture to add
  1871. */
  1872. addTexture(newTexture: BaseTexture): void;
  1873. /**
  1874. * Switch active camera
  1875. * @param newCamera defines the new active camera
  1876. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  1877. */
  1878. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  1879. /**
  1880. * sets the active camera of the scene using its ID
  1881. * @param id defines the camera's ID
  1882. * @return the new active camera or null if none found.
  1883. */
  1884. setActiveCameraByID(id: string): Nullable<Camera>;
  1885. /**
  1886. * sets the active camera of the scene using its name
  1887. * @param name defines the camera's name
  1888. * @returns the new active camera or null if none found.
  1889. */
  1890. setActiveCameraByName(name: string): Nullable<Camera>;
  1891. /**
  1892. * get an animation group using its name
  1893. * @param name defines the material's name
  1894. * @return the animation group or null if none found.
  1895. */
  1896. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  1897. /**
  1898. * get a material using its id
  1899. * @param id defines the material's ID
  1900. * @return the material or null if none found.
  1901. */
  1902. getMaterialByID(id: string): Nullable<Material>;
  1903. /**
  1904. * Gets a material using its name
  1905. * @param name defines the material's name
  1906. * @return the material or null if none found.
  1907. */
  1908. getMaterialByName(name: string): Nullable<Material>;
  1909. /**
  1910. * Gets a camera using its id
  1911. * @param id defines the id to look for
  1912. * @returns the camera or null if not found
  1913. */
  1914. getCameraByID(id: string): Nullable<Camera>;
  1915. /**
  1916. * Gets a camera using its unique id
  1917. * @param uniqueId defines the unique id to look for
  1918. * @returns the camera or null if not found
  1919. */
  1920. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  1921. /**
  1922. * Gets a camera using its name
  1923. * @param name defines the camera's name
  1924. * @return the camera or null if none found.
  1925. */
  1926. getCameraByName(name: string): Nullable<Camera>;
  1927. /**
  1928. * Gets a bone using its id
  1929. * @param id defines the bone's id
  1930. * @return the bone or null if not found
  1931. */
  1932. getBoneByID(id: string): Nullable<Bone>;
  1933. /**
  1934. * Gets a bone using its id
  1935. * @param name defines the bone's name
  1936. * @return the bone or null if not found
  1937. */
  1938. getBoneByName(name: string): Nullable<Bone>;
  1939. /**
  1940. * Gets a light node using its name
  1941. * @param name defines the the light's name
  1942. * @return the light or null if none found.
  1943. */
  1944. getLightByName(name: string): Nullable<Light>;
  1945. /**
  1946. * Gets a light node using its id
  1947. * @param id defines the light's id
  1948. * @return the light or null if none found.
  1949. */
  1950. getLightByID(id: string): Nullable<Light>;
  1951. /**
  1952. * Gets a light node using its scene-generated unique ID
  1953. * @param uniqueId defines the light's unique id
  1954. * @return the light or null if none found.
  1955. */
  1956. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  1957. /**
  1958. * Gets a particle system by id
  1959. * @param id defines the particle system id
  1960. * @return the corresponding system or null if none found
  1961. */
  1962. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  1963. /**
  1964. * Gets a geometry using its ID
  1965. * @param id defines the geometry's id
  1966. * @return the geometry or null if none found.
  1967. */
  1968. getGeometryByID(id: string): Nullable<Geometry>;
  1969. /**
  1970. * Add a new geometry to this scene
  1971. * @param geometry defines the geometry to be added to the scene.
  1972. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  1973. * @return a boolean defining if the geometry was added or not
  1974. */
  1975. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  1976. /**
  1977. * Removes an existing geometry
  1978. * @param geometry defines the geometry to be removed from the scene
  1979. * @return a boolean defining if the geometry was removed or not
  1980. */
  1981. removeGeometry(geometry: Geometry): boolean;
  1982. /**
  1983. * Gets the list of geometries attached to the scene
  1984. * @returns an array of Geometry
  1985. */
  1986. getGeometries(): Geometry[];
  1987. /**
  1988. * Gets the first added mesh found of a given ID
  1989. * @param id defines the id to search for
  1990. * @return the mesh found or null if not found at all
  1991. */
  1992. getMeshByID(id: string): Nullable<AbstractMesh>;
  1993. /**
  1994. * Gets a list of meshes using their id
  1995. * @param id defines the id to search for
  1996. * @returns a list of meshes
  1997. */
  1998. getMeshesByID(id: string): Array<AbstractMesh>;
  1999. /**
  2000. * Gets the first added transform node found of a given ID
  2001. * @param id defines the id to search for
  2002. * @return the found transform node or null if not found at all.
  2003. */
  2004. getTransformNodeByID(id: string): Nullable<TransformNode>;
  2005. /**
  2006. * Gets a list of transform nodes using their id
  2007. * @param id defines the id to search for
  2008. * @returns a list of transform nodes
  2009. */
  2010. getTransformNodesByID(id: string): Array<TransformNode>;
  2011. /**
  2012. * Gets a mesh with its auto-generated unique id
  2013. * @param uniqueId defines the unique id to search for
  2014. * @return the found mesh or null if not found at all.
  2015. */
  2016. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  2017. /**
  2018. * Gets a the last added mesh using a given id
  2019. * @param id defines the id to search for
  2020. * @return the found mesh or null if not found at all.
  2021. */
  2022. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  2023. /**
  2024. * Gets a the last added node (Mesh, Camera, Light) using a given id
  2025. * @param id defines the id to search for
  2026. * @return the found node or null if not found at all
  2027. */
  2028. getLastEntryByID(id: string): Nullable<Node>;
  2029. /**
  2030. * Gets a node (Mesh, Camera, Light) using a given id
  2031. * @param id defines the id to search for
  2032. * @return the found node or null if not found at all
  2033. */
  2034. getNodeByID(id: string): Nullable<Node>;
  2035. /**
  2036. * Gets a node (Mesh, Camera, Light) using a given name
  2037. * @param name defines the name to search for
  2038. * @return the found node or null if not found at all.
  2039. */
  2040. getNodeByName(name: string): Nullable<Node>;
  2041. /**
  2042. * Gets a mesh using a given name
  2043. * @param name defines the name to search for
  2044. * @return the found mesh or null if not found at all.
  2045. */
  2046. getMeshByName(name: string): Nullable<AbstractMesh>;
  2047. /**
  2048. * Gets a transform node using a given name
  2049. * @param name defines the name to search for
  2050. * @return the found transform node or null if not found at all.
  2051. */
  2052. getTransformNodeByName(name: string): Nullable<TransformNode>;
  2053. /**
  2054. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  2055. * @param id defines the id to search for
  2056. * @return the found skeleton or null if not found at all.
  2057. */
  2058. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  2059. /**
  2060. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  2061. * @param id defines the id to search for
  2062. * @return the found skeleton or null if not found at all.
  2063. */
  2064. getSkeletonById(id: string): Nullable<Skeleton>;
  2065. /**
  2066. * Gets a skeleton using a given name
  2067. * @param name defines the name to search for
  2068. * @return the found skeleton or null if not found at all.
  2069. */
  2070. getSkeletonByName(name: string): Nullable<Skeleton>;
  2071. /**
  2072. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  2073. * @param id defines the id to search for
  2074. * @return the found morph target manager or null if not found at all.
  2075. */
  2076. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  2077. /**
  2078. * Gets a boolean indicating if the given mesh is active
  2079. * @param mesh defines the mesh to look for
  2080. * @returns true if the mesh is in the active list
  2081. */
  2082. isActiveMesh(mesh: AbstractMesh): boolean;
  2083. /**
  2084. * Return a unique id as a string which can serve as an identifier for the scene
  2085. */
  2086. readonly uid: string;
  2087. /**
  2088. * Add an externaly attached data from its key.
  2089. * This method call will fail and return false, if such key already exists.
  2090. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  2091. * @param key the unique key that identifies the data
  2092. * @param data the data object to associate to the key for this Engine instance
  2093. * @return true if no such key were already present and the data was added successfully, false otherwise
  2094. */
  2095. addExternalData<T>(key: string, data: T): boolean;
  2096. /**
  2097. * Get an externaly attached data from its key
  2098. * @param key the unique key that identifies the data
  2099. * @return the associated data, if present (can be null), or undefined if not present
  2100. */
  2101. getExternalData<T>(key: string): Nullable<T>;
  2102. /**
  2103. * Get an externaly attached data from its key, create it using a factory if it's not already present
  2104. * @param key the unique key that identifies the data
  2105. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  2106. * @return the associated data, can be null if the factory returned null.
  2107. */
  2108. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  2109. /**
  2110. * Remove an externaly attached data from the Engine instance
  2111. * @param key the unique key that identifies the data
  2112. * @return true if the data was successfully removed, false if it doesn't exist
  2113. */
  2114. removeExternalData(key: string): boolean;
  2115. private _evaluateSubMesh;
  2116. /**
  2117. * Clear the processed materials smart array preventing retention point in material dispose.
  2118. */
  2119. freeProcessedMaterials(): void;
  2120. /**
  2121. * Clear the active meshes smart array preventing retention point in mesh dispose.
  2122. */
  2123. freeActiveMeshes(): void;
  2124. /**
  2125. * Clear the info related to rendering groups preventing retention points during dispose.
  2126. */
  2127. freeRenderingGroups(): void;
  2128. /** @hidden */
  2129. /**
  2130. * Lambda returning the list of potentially active meshes.
  2131. */
  2132. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  2133. /**
  2134. * Lambda returning the list of potentially active sub meshes.
  2135. */
  2136. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  2137. /**
  2138. * Lambda returning the list of potentially intersecting sub meshes.
  2139. */
  2140. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  2141. /**
  2142. * Lambda returning the list of potentially colliding sub meshes.
  2143. */
  2144. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  2145. private _activeMeshesFrozen;
  2146. /**
  2147. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  2148. * @returns the current scene
  2149. */
  2150. freezeActiveMeshes(): Scene;
  2151. /**
  2152. * Use this function to restart evaluating active meshes on every frame
  2153. * @returns the current scene
  2154. */
  2155. unfreezeActiveMeshes(): Scene;
  2156. private _evaluateActiveMeshes;
  2157. private _activeMesh;
  2158. /**
  2159. * Update the transform matrix to update from the current active camera
  2160. * @param force defines a boolean used to force the update even if cache is up to date
  2161. */
  2162. updateTransformMatrix(force?: boolean): void;
  2163. /**
  2164. * Defines an alternate camera (used mostly in VR-like scenario where two cameras can render the same scene from a slightly different point of view)
  2165. * @param alternateCamera defines the camera to use
  2166. */
  2167. updateAlternateTransformMatrix(alternateCamera: Camera): void;
  2168. /** @hidden */
  2169. private _renderForCamera;
  2170. private _processSubCameras;
  2171. private _checkIntersections;
  2172. /** @hidden */
  2173. /**
  2174. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  2175. */
  2176. getDeterministicFrameTime: () => number;
  2177. /**
  2178. * Render the scene
  2179. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  2180. */
  2181. render(updateCameras?: boolean): void;
  2182. /**
  2183. * Freeze all materials
  2184. * A frozen material will not be updatable but should be faster to render
  2185. */
  2186. freezeMaterials(): void;
  2187. /**
  2188. * Unfreeze all materials
  2189. * A frozen material will not be updatable but should be faster to render
  2190. */
  2191. unfreezeMaterials(): void;
  2192. /**
  2193. * Releases all held ressources
  2194. */
  2195. dispose(): void;
  2196. /**
  2197. * Gets if the scene is already disposed
  2198. */
  2199. readonly isDisposed: boolean;
  2200. /**
  2201. * Call this function to reduce memory footprint of the scene.
  2202. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  2203. */
  2204. clearCachedVertexData(): void;
  2205. /**
  2206. * This function will remove the local cached buffer data from texture.
  2207. * It will save memory but will prevent the texture from being rebuilt
  2208. */
  2209. cleanCachedTextureBuffer(): void;
  2210. /**
  2211. * Get the world extend vectors with an optional filter
  2212. *
  2213. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  2214. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  2215. */
  2216. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  2217. min: Vector3;
  2218. max: Vector3;
  2219. };
  2220. /**
  2221. * Creates a ray that can be used to pick in the scene
  2222. * @param x defines the x coordinate of the origin (on-screen)
  2223. * @param y defines the y coordinate of the origin (on-screen)
  2224. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  2225. * @param camera defines the camera to use for the picking
  2226. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  2227. * @returns a Ray
  2228. */
  2229. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  2230. /**
  2231. * Creates a ray that can be used to pick in the scene
  2232. * @param x defines the x coordinate of the origin (on-screen)
  2233. * @param y defines the y coordinate of the origin (on-screen)
  2234. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  2235. * @param result defines the ray where to store the picking ray
  2236. * @param camera defines the camera to use for the picking
  2237. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  2238. * @returns the current scene
  2239. */
  2240. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  2241. /**
  2242. * Creates a ray that can be used to pick in the scene
  2243. * @param x defines the x coordinate of the origin (on-screen)
  2244. * @param y defines the y coordinate of the origin (on-screen)
  2245. * @param camera defines the camera to use for the picking
  2246. * @returns a Ray
  2247. */
  2248. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  2249. /**
  2250. * Creates a ray that can be used to pick in the scene
  2251. * @param x defines the x coordinate of the origin (on-screen)
  2252. * @param y defines the y coordinate of the origin (on-screen)
  2253. * @param result defines the ray where to store the picking ray
  2254. * @param camera defines the camera to use for the picking
  2255. * @returns the current scene
  2256. */
  2257. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  2258. private _internalPick;
  2259. private _internalMultiPick;
  2260. private _tempPickingRay;
  2261. /** Launch a ray to try to pick a mesh in the scene
  2262. * @param x position on screen
  2263. * @param y position on screen
  2264. * @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
  2265. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  2266. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  2267. * @returns a PickingInfo
  2268. */
  2269. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  2270. private _cachedRayForTransform;
  2271. /** Use the given ray to pick a mesh in the scene
  2272. * @param ray The ray to use to pick meshes
  2273. * @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
  2274. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  2275. * @returns a PickingInfo
  2276. */
  2277. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  2278. /**
  2279. * Launch a ray to try to pick a mesh in the scene
  2280. * @param x X position on screen
  2281. * @param y Y position on screen
  2282. * @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
  2283. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  2284. * @returns an array of PickingInfo
  2285. */
  2286. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  2287. /**
  2288. * Launch a ray to try to pick a mesh in the scene
  2289. * @param ray Ray to use
  2290. * @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
  2291. * @returns an array of PickingInfo
  2292. */
  2293. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean): Nullable<PickingInfo[]>;
  2294. /**
  2295. * Force the value of meshUnderPointer
  2296. * @param mesh defines the mesh to use
  2297. */
  2298. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  2299. /**
  2300. * Gets the mesh under the pointer
  2301. * @returns a Mesh or null if no mesh is under the pointer
  2302. */
  2303. getPointerOverMesh(): Nullable<AbstractMesh>;
  2304. /** @hidden */
  2305. /** @hidden */
  2306. private _getByTags;
  2307. /**
  2308. * Get a list of meshes by tags
  2309. * @param tagsQuery defines the tags query to use
  2310. * @param forEach defines a predicate used to filter results
  2311. * @returns an array of Mesh
  2312. */
  2313. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  2314. /**
  2315. * Get a list of cameras by tags
  2316. * @param tagsQuery defines the tags query to use
  2317. * @param forEach defines a predicate used to filter results
  2318. * @returns an array of Camera
  2319. */
  2320. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  2321. /**
  2322. * Get a list of lights by tags
  2323. * @param tagsQuery defines the tags query to use
  2324. * @param forEach defines a predicate used to filter results
  2325. * @returns an array of Light
  2326. */
  2327. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  2328. /**
  2329. * Get a list of materials by tags
  2330. * @param tagsQuery defines the tags query to use
  2331. * @param forEach defines a predicate used to filter results
  2332. * @returns an array of Material
  2333. */
  2334. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  2335. /**
  2336. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  2337. * This allowed control for front to back rendering or reversly depending of the special needs.
  2338. *
  2339. * @param renderingGroupId The rendering group id corresponding to its index
  2340. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  2341. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  2342. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  2343. */
  2344. 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;
  2345. /**
  2346. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  2347. *
  2348. * @param renderingGroupId The rendering group id corresponding to its index
  2349. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  2350. * @param depth Automatically clears depth between groups if true and autoClear is true.
  2351. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  2352. */
  2353. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  2354. /**
  2355. * Gets the current auto clear configuration for one rendering group of the rendering
  2356. * manager.
  2357. * @param index the rendering group index to get the information for
  2358. * @returns The auto clear setup for the requested rendering group
  2359. */
  2360. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  2361. private _blockMaterialDirtyMechanism;
  2362. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  2363. blockMaterialDirtyMechanism: boolean;
  2364. /**
  2365. * Will flag all materials as dirty to trigger new shader compilation
  2366. * @param flag defines the flag used to specify which material part must be marked as dirty
  2367. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  2368. */
  2369. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  2370. /** @hidden */
  2371. /** @hidden */
  2372. }
  2373. }
  2374. declare module BABYLON {
  2375. /**
  2376. * Groups all the scene component constants in one place to ease maintenance.
  2377. * @hidden
  2378. */
  2379. class SceneComponentConstants {
  2380. static readonly NAME_EFFECTLAYER: string;
  2381. static readonly NAME_LAYER: string;
  2382. static readonly NAME_LENSFLARESYSTEM: string;
  2383. static readonly NAME_BOUNDINGBOXRENDERER: string;
  2384. static readonly NAME_PARTICLESYSTEM: string;
  2385. static readonly NAME_GAMEPAD: string;
  2386. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  2387. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  2388. static readonly NAME_DEPTHRENDERER: string;
  2389. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  2390. static readonly NAME_SPRITE: string;
  2391. static readonly NAME_OUTLINERENDERER: string;
  2392. static readonly NAME_PROCEDURALTEXTURE: string;
  2393. static readonly NAME_SHADOWGENERATOR: string;
  2394. static readonly NAME_OCTREE: string;
  2395. static readonly NAME_PHYSICSENGINE: string;
  2396. static readonly NAME_AUDIO: string;
  2397. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  2398. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  2399. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  2400. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  2401. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  2402. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  2403. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  2404. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  2405. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  2406. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  2407. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  2408. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  2409. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  2410. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  2411. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  2412. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  2413. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  2414. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  2415. static readonly STEP_AFTERRENDER_AUDIO: number;
  2416. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  2417. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  2418. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  2419. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  2420. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  2421. static readonly STEP_POINTERMOVE_SPRITE: number;
  2422. static readonly STEP_POINTERDOWN_SPRITE: number;
  2423. static readonly STEP_POINTERUP_SPRITE: number;
  2424. }
  2425. /**
  2426. * This represents a scene component.
  2427. *
  2428. * This is used to decouple the dependency the scene is having on the different workloads like
  2429. * layers, post processes...
  2430. */
  2431. interface ISceneComponent {
  2432. /**
  2433. * The name of the component. Each component must have a unique name.
  2434. */
  2435. name: string;
  2436. /**
  2437. * The scene the component belongs to.
  2438. */
  2439. scene: Scene;
  2440. /**
  2441. * Register the component to one instance of a scene.
  2442. */
  2443. register(): void;
  2444. /**
  2445. * Rebuilds the elements related to this component in case of
  2446. * context lost for instance.
  2447. */
  2448. rebuild(): void;
  2449. /**
  2450. * Disposes the component and the associated ressources.
  2451. */
  2452. dispose(): void;
  2453. }
  2454. /**
  2455. * This represents a SERIALIZABLE scene component.
  2456. *
  2457. * This extends Scene Component to add Serialization methods on top.
  2458. */
  2459. interface ISceneSerializableComponent extends ISceneComponent {
  2460. /**
  2461. * Adds all the element from the container to the scene
  2462. * @param container the container holding the elements
  2463. */
  2464. addFromContainer(container: AbstractScene): void;
  2465. /**
  2466. * Removes all the elements in the container from the scene
  2467. * @param container contains the elements to remove
  2468. */
  2469. removeFromContainer(container: AbstractScene): void;
  2470. /**
  2471. * Serializes the component data to the specified json object
  2472. * @param serializationObject The object to serialize to
  2473. */
  2474. serialize(serializationObject: any): void;
  2475. }
  2476. /**
  2477. * Strong typing of a Mesh related stage step action
  2478. */
  2479. type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  2480. /**
  2481. * Strong typing of a Evaluate Sub Mesh related stage step action
  2482. */
  2483. type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  2484. /**
  2485. * Strong typing of a Active Mesh related stage step action
  2486. */
  2487. type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  2488. /**
  2489. * Strong typing of a Camera related stage step action
  2490. */
  2491. type CameraStageAction = (camera: Camera) => void;
  2492. /**
  2493. * Strong typing of a RenderingGroup related stage step action
  2494. */
  2495. type RenderingGroupStageAction = (renderingGroupId: number) => void;
  2496. /**
  2497. * Strong typing of a Mesh Render related stage step action
  2498. */
  2499. type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  2500. /**
  2501. * Strong typing of a simple stage step action
  2502. */
  2503. type SimpleStageAction = () => void;
  2504. /**
  2505. * Strong typing of a render target action.
  2506. */
  2507. type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  2508. /**
  2509. * Strong typing of a pointer move action.
  2510. */
  2511. type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  2512. /**
  2513. * Strong typing of a pointer up/down action.
  2514. */
  2515. type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  2516. /**
  2517. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  2518. * @hidden
  2519. */
  2520. class Stage<T extends Function> extends Array<{
  2521. index: number;
  2522. component: ISceneComponent;
  2523. action: T;
  2524. }> {
  2525. /**
  2526. * Hide ctor from the rest of the world.
  2527. * @param items The items to add.
  2528. */
  2529. private constructor();
  2530. /**
  2531. * Creates a new Stage.
  2532. * @returns A new instance of a Stage
  2533. */
  2534. static Create<T extends Function>(): Stage<T>;
  2535. /**
  2536. * Registers a step in an ordered way in the targeted stage.
  2537. * @param index Defines the position to register the step in
  2538. * @param component Defines the component attached to the step
  2539. * @param action Defines the action to launch during the step
  2540. */
  2541. registerStep(index: number, component: ISceneComponent, action: T): void;
  2542. /**
  2543. * Clears all the steps from the stage.
  2544. */
  2545. clear(): void;
  2546. }
  2547. }
  2548. declare module BABYLON {
  2549. /** Alias type for value that can be null */
  2550. type Nullable<T> = T | null;
  2551. /**
  2552. * Alias type for number that are floats
  2553. * @ignorenaming
  2554. */
  2555. type float = number;
  2556. /**
  2557. * Alias type for number that are doubles.
  2558. * @ignorenaming
  2559. */
  2560. type double = number;
  2561. /**
  2562. * Alias type for number that are integer
  2563. * @ignorenaming
  2564. */
  2565. type int = number;
  2566. /** Alias type for number array or Float32Array */
  2567. type FloatArray = number[] | Float32Array;
  2568. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  2569. type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  2570. /**
  2571. * Alias for types that can be used by a Buffer or VertexBuffer.
  2572. */
  2573. type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  2574. }
  2575. declare module BABYLON {
  2576. /**
  2577. * The action to be carried out following a trigger
  2578. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  2579. */
  2580. class Action {
  2581. /** the trigger, with or without parameters, for the action */
  2582. triggerOptions: any;
  2583. /**
  2584. * Trigger for the action
  2585. */
  2586. trigger: number;
  2587. /**
  2588. * Internal only - manager for action
  2589. * @hidden
  2590. */
  2591. private _nextActiveAction;
  2592. private _child;
  2593. private _condition?;
  2594. private _triggerParameter;
  2595. /**
  2596. * An event triggered prior to action being executed.
  2597. */
  2598. onBeforeExecuteObservable: Observable<Action>;
  2599. /**
  2600. * Creates a new Action
  2601. * @param triggerOptions the trigger, with or without parameters, for the action
  2602. * @param condition an optional determinant of action
  2603. */
  2604. constructor(
  2605. /** the trigger, with or without parameters, for the action */
  2606. triggerOptions: any, condition?: Condition);
  2607. /**
  2608. * Internal only
  2609. * @hidden
  2610. */
  2611. /**
  2612. * Gets the trigger parameters
  2613. * @returns the trigger parameters
  2614. */
  2615. getTriggerParameter(): any;
  2616. /**
  2617. * Internal only - executes current action event
  2618. * @hidden
  2619. */
  2620. /**
  2621. * Execute placeholder for child classes
  2622. * @param evt optional action event
  2623. */
  2624. execute(evt?: ActionEvent): void;
  2625. /**
  2626. * Skips to next active action
  2627. */
  2628. skipToNextActiveAction(): void;
  2629. /**
  2630. * Adds action to chain of actions, may be a DoNothingAction
  2631. * @param action defines the next action to execute
  2632. * @returns The action passed in
  2633. * @see https://www.babylonjs-playground.com/#1T30HR#0
  2634. */
  2635. then(action: Action): Action;
  2636. /**
  2637. * Internal only
  2638. * @hidden
  2639. */
  2640. /**
  2641. * Internal only
  2642. * @hidden
  2643. */
  2644. /**
  2645. * Serialize placeholder for child classes
  2646. * @param parent of child
  2647. * @returns the serialized object
  2648. */
  2649. serialize(parent: any): any;
  2650. /**
  2651. * Internal only called by serialize
  2652. * @hidden
  2653. */
  2654. protected _serialize(serializedAction: any, parent?: any): any;
  2655. /**
  2656. * Internal only
  2657. * @hidden
  2658. */
  2659. private static _SerializeValueAsString: (value: any) => string;
  2660. /**
  2661. * Internal only
  2662. * @hidden
  2663. */
  2664. private static _GetTargetProperty: (target: Scene | Node) => {
  2665. name: string;
  2666. targetType: string;
  2667. value: string;
  2668. };
  2669. }
  2670. }
  2671. declare module BABYLON {
  2672. /**
  2673. * ActionEvent is the event being sent when an action is triggered.
  2674. */
  2675. class ActionEvent {
  2676. /** The mesh or sprite that triggered the action */
  2677. source: any;
  2678. /** The X mouse cursor position at the time of the event */
  2679. pointerX: number;
  2680. /** The Y mouse cursor position at the time of the event */
  2681. pointerY: number;
  2682. /** The mesh that is currently pointed at (can be null) */
  2683. meshUnderPointer: Nullable<AbstractMesh>;
  2684. /** the original (browser) event that triggered the ActionEvent */
  2685. sourceEvent?: any;
  2686. /** additional data for the event */
  2687. additionalData?: any;
  2688. /**
  2689. * Creates a new ActionEvent
  2690. * @param source The mesh or sprite that triggered the action
  2691. * @param pointerX The X mouse cursor position at the time of the event
  2692. * @param pointerY The Y mouse cursor position at the time of the event
  2693. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  2694. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  2695. * @param additionalData additional data for the event
  2696. */
  2697. constructor(
  2698. /** The mesh or sprite that triggered the action */
  2699. source: any,
  2700. /** The X mouse cursor position at the time of the event */
  2701. pointerX: number,
  2702. /** The Y mouse cursor position at the time of the event */
  2703. pointerY: number,
  2704. /** The mesh that is currently pointed at (can be null) */
  2705. meshUnderPointer: Nullable<AbstractMesh>,
  2706. /** the original (browser) event that triggered the ActionEvent */
  2707. sourceEvent?: any,
  2708. /** additional data for the event */
  2709. additionalData?: any);
  2710. /**
  2711. * Helper function to auto-create an ActionEvent from a source mesh.
  2712. * @param source The source mesh that triggered the event
  2713. * @param evt The original (browser) event
  2714. * @param additionalData additional data for the event
  2715. * @returns the new ActionEvent
  2716. */
  2717. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  2718. /**
  2719. * Helper function to auto-create an ActionEvent from a source sprite
  2720. * @param source The source sprite that triggered the event
  2721. * @param scene Scene associated with the sprite
  2722. * @param evt The original (browser) event
  2723. * @param additionalData additional data for the event
  2724. * @returns the new ActionEvent
  2725. */
  2726. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  2727. /**
  2728. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  2729. * @param scene the scene where the event occurred
  2730. * @param evt The original (browser) event
  2731. * @returns the new ActionEvent
  2732. */
  2733. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  2734. /**
  2735. * Helper function to auto-create an ActionEvent from a primitive
  2736. * @param prim defines the target primitive
  2737. * @param pointerPos defines the pointer position
  2738. * @param evt The original (browser) event
  2739. * @param additionalData additional data for the event
  2740. * @returns the new ActionEvent
  2741. */
  2742. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  2743. }
  2744. /**
  2745. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  2746. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  2747. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  2748. */
  2749. class ActionManager {
  2750. /**
  2751. * Nothing
  2752. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2753. */
  2754. static readonly NothingTrigger: number;
  2755. /**
  2756. * On pick
  2757. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2758. */
  2759. static readonly OnPickTrigger: number;
  2760. /**
  2761. * On left pick
  2762. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2763. */
  2764. static readonly OnLeftPickTrigger: number;
  2765. /**
  2766. * On right pick
  2767. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2768. */
  2769. static readonly OnRightPickTrigger: number;
  2770. /**
  2771. * On center pick
  2772. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2773. */
  2774. static readonly OnCenterPickTrigger: number;
  2775. /**
  2776. * On pick down
  2777. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2778. */
  2779. static readonly OnPickDownTrigger: number;
  2780. /**
  2781. * On double pick
  2782. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2783. */
  2784. static readonly OnDoublePickTrigger: number;
  2785. /**
  2786. * On pick up
  2787. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2788. */
  2789. static readonly OnPickUpTrigger: number;
  2790. /**
  2791. * On pick out.
  2792. * This trigger will only be raised if you also declared a OnPickDown
  2793. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2794. */
  2795. static readonly OnPickOutTrigger: number;
  2796. /**
  2797. * On long press
  2798. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2799. */
  2800. static readonly OnLongPressTrigger: number;
  2801. /**
  2802. * On pointer over
  2803. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2804. */
  2805. static readonly OnPointerOverTrigger: number;
  2806. /**
  2807. * On pointer out
  2808. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2809. */
  2810. static readonly OnPointerOutTrigger: number;
  2811. /**
  2812. * On every frame
  2813. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2814. */
  2815. static readonly OnEveryFrameTrigger: number;
  2816. /**
  2817. * On intersection enter
  2818. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2819. */
  2820. static readonly OnIntersectionEnterTrigger: number;
  2821. /**
  2822. * On intersection exit
  2823. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2824. */
  2825. static readonly OnIntersectionExitTrigger: number;
  2826. /**
  2827. * On key down
  2828. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2829. */
  2830. static readonly OnKeyDownTrigger: number;
  2831. /**
  2832. * On key up
  2833. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2834. */
  2835. static readonly OnKeyUpTrigger: number;
  2836. /** Gets the list of active triggers */
  2837. static Triggers: {
  2838. [key: string]: number;
  2839. };
  2840. /** Gets the list of actions */
  2841. actions: Action[];
  2842. /** Gets the cursor to use when hovering items */
  2843. hoverCursor: string;
  2844. private _scene;
  2845. /**
  2846. * Creates a new action manager
  2847. * @param scene defines the hosting scene
  2848. */
  2849. constructor(scene: Scene);
  2850. /**
  2851. * Releases all associated resources
  2852. */
  2853. dispose(): void;
  2854. /**
  2855. * Gets hosting scene
  2856. * @returns the hosting scene
  2857. */
  2858. getScene(): Scene;
  2859. /**
  2860. * Does this action manager handles actions of any of the given triggers
  2861. * @param triggers defines the triggers to be tested
  2862. * @return a boolean indicating whether one (or more) of the triggers is handled
  2863. */
  2864. hasSpecificTriggers(triggers: number[]): boolean;
  2865. /**
  2866. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  2867. * speed.
  2868. * @param triggerA defines the trigger to be tested
  2869. * @param triggerB defines the trigger to be tested
  2870. * @return a boolean indicating whether one (or more) of the triggers is handled
  2871. */
  2872. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  2873. /**
  2874. * Does this action manager handles actions of a given trigger
  2875. * @param trigger defines the trigger to be tested
  2876. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  2877. * @return whether the trigger is handled
  2878. */
  2879. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  2880. /**
  2881. * Does this action manager has pointer triggers
  2882. */
  2883. readonly hasPointerTriggers: boolean;
  2884. /**
  2885. * Does this action manager has pick triggers
  2886. */
  2887. readonly hasPickTriggers: boolean;
  2888. /**
  2889. * Does exist one action manager with at least one trigger
  2890. **/
  2891. static readonly HasTriggers: boolean;
  2892. /**
  2893. * Does exist one action manager with at least one pick trigger
  2894. **/
  2895. static readonly HasPickTriggers: boolean;
  2896. /**
  2897. * Does exist one action manager that handles actions of a given trigger
  2898. * @param trigger defines the trigger to be tested
  2899. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  2900. **/
  2901. static HasSpecificTrigger(trigger: number): boolean;
  2902. /**
  2903. * Registers an action to this action manager
  2904. * @param action defines the action to be registered
  2905. * @return the action amended (prepared) after registration
  2906. */
  2907. registerAction(action: Action): Nullable<Action>;
  2908. /**
  2909. * Unregisters an action to this action manager
  2910. * @param action defines the action to be unregistered
  2911. * @return a boolean indicating whether the action has been unregistered
  2912. */
  2913. unregisterAction(action: Action): Boolean;
  2914. /**
  2915. * Process a specific trigger
  2916. * @param trigger defines the trigger to process
  2917. * @param evt defines the event details to be processed
  2918. */
  2919. processTrigger(trigger: number, evt?: ActionEvent): void;
  2920. /** @hidden */
  2921. /** @hidden */
  2922. /**
  2923. * Serialize this manager to a JSON object
  2924. * @param name defines the property name to store this manager
  2925. * @returns a JSON representation of this manager
  2926. */
  2927. serialize(name: string): any;
  2928. /**
  2929. * Creates a new ActionManager from a JSON data
  2930. * @param parsedActions defines the JSON data to read from
  2931. * @param object defines the hosting mesh
  2932. * @param scene defines the hosting scene
  2933. */
  2934. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  2935. /**
  2936. * Get a trigger name by index
  2937. * @param trigger defines the trigger index
  2938. * @returns a trigger name
  2939. */
  2940. static GetTriggerName(trigger: number): string;
  2941. }
  2942. }
  2943. declare module BABYLON {
  2944. /**
  2945. * A Condition applied to an Action
  2946. */
  2947. class Condition {
  2948. /**
  2949. * Internal only - manager for action
  2950. * @hidden
  2951. */
  2952. /**
  2953. * Internal only
  2954. * @hidden
  2955. */
  2956. /**
  2957. * Internal only
  2958. * @hidden
  2959. */
  2960. /**
  2961. * Creates a new Condition
  2962. * @param actionManager the manager of the action the condition is applied to
  2963. */
  2964. constructor(actionManager: ActionManager);
  2965. /**
  2966. * Check if the current condition is valid
  2967. * @returns a boolean
  2968. */
  2969. isValid(): boolean;
  2970. /**
  2971. * Internal only
  2972. * @hidden
  2973. */
  2974. /**
  2975. * Internal only
  2976. * @hidden
  2977. */
  2978. /**
  2979. * Serialize placeholder for child classes
  2980. * @returns the serialized object
  2981. */
  2982. serialize(): any;
  2983. /**
  2984. * Internal only
  2985. * @hidden
  2986. */
  2987. protected _serialize(serializedCondition: any): any;
  2988. }
  2989. /**
  2990. * Defines specific conditional operators as extensions of Condition
  2991. */
  2992. class ValueCondition extends Condition {
  2993. /** path to specify the property of the target the conditional operator uses */
  2994. propertyPath: string;
  2995. /** the value compared by the conditional operator against the current value of the property */
  2996. value: any;
  2997. /** the conditional operator, default ValueCondition.IsEqual */
  2998. operator: number;
  2999. /**
  3000. * Internal only
  3001. * @hidden
  3002. */
  3003. private static _IsEqual;
  3004. /**
  3005. * Internal only
  3006. * @hidden
  3007. */
  3008. private static _IsDifferent;
  3009. /**
  3010. * Internal only
  3011. * @hidden
  3012. */
  3013. private static _IsGreater;
  3014. /**
  3015. * Internal only
  3016. * @hidden
  3017. */
  3018. private static _IsLesser;
  3019. /**
  3020. * returns the number for IsEqual
  3021. */
  3022. static readonly IsEqual: number;
  3023. /**
  3024. * Returns the number for IsDifferent
  3025. */
  3026. static readonly IsDifferent: number;
  3027. /**
  3028. * Returns the number for IsGreater
  3029. */
  3030. static readonly IsGreater: number;
  3031. /**
  3032. * Returns the number for IsLesser
  3033. */
  3034. static readonly IsLesser: number;
  3035. /**
  3036. * Internal only The action manager for the condition
  3037. * @hidden
  3038. */
  3039. /**
  3040. * Internal only
  3041. * @hidden
  3042. */
  3043. private _target;
  3044. /**
  3045. * Internal only
  3046. * @hidden
  3047. */
  3048. private _effectiveTarget;
  3049. /**
  3050. * Internal only
  3051. * @hidden
  3052. */
  3053. private _property;
  3054. /**
  3055. * Creates a new ValueCondition
  3056. * @param actionManager manager for the action the condition applies to
  3057. * @param target for the action
  3058. * @param propertyPath path to specify the property of the target the conditional operator uses
  3059. * @param value the value compared by the conditional operator against the current value of the property
  3060. * @param operator the conditional operator, default ValueCondition.IsEqual
  3061. */
  3062. constructor(actionManager: ActionManager, target: any,
  3063. /** path to specify the property of the target the conditional operator uses */
  3064. propertyPath: string,
  3065. /** the value compared by the conditional operator against the current value of the property */
  3066. value: any,
  3067. /** the conditional operator, default ValueCondition.IsEqual */
  3068. operator?: number);
  3069. /**
  3070. * Compares the given value with the property value for the specified conditional operator
  3071. * @returns the result of the comparison
  3072. */
  3073. isValid(): boolean;
  3074. /**
  3075. * Serialize the ValueCondition into a JSON compatible object
  3076. * @returns serialization object
  3077. */
  3078. serialize(): any;
  3079. /**
  3080. * Gets the name of the conditional operator for the ValueCondition
  3081. * @param operator the conditional operator
  3082. * @returns the name
  3083. */
  3084. static GetOperatorName(operator: number): string;
  3085. }
  3086. /**
  3087. * Defines a predicate condition as an extension of Condition
  3088. */
  3089. class PredicateCondition extends Condition {
  3090. /** defines the predicate function used to validate the condition */
  3091. predicate: () => boolean;
  3092. /**
  3093. * Internal only - manager for action
  3094. * @hidden
  3095. */
  3096. /**
  3097. * Creates a new PredicateCondition
  3098. * @param actionManager manager for the action the condition applies to
  3099. * @param predicate defines the predicate function used to validate the condition
  3100. */
  3101. constructor(actionManager: ActionManager,
  3102. /** defines the predicate function used to validate the condition */
  3103. predicate: () => boolean);
  3104. /**
  3105. * @returns the validity of the predicate condition
  3106. */
  3107. isValid(): boolean;
  3108. }
  3109. /**
  3110. * Defines a state condition as an extension of Condition
  3111. */
  3112. class StateCondition extends Condition {
  3113. value: string;
  3114. /**
  3115. * Internal only - manager for action
  3116. * @hidden
  3117. */
  3118. /**
  3119. * Internal only
  3120. * @hidden
  3121. */
  3122. private _target;
  3123. /**
  3124. * Creates a new StateCondition
  3125. * @param actionManager manager for the action the condition applies to
  3126. * @param target of the condition
  3127. * @param value to compare with target state
  3128. */
  3129. constructor(actionManager: ActionManager, target: any, value: string);
  3130. /**
  3131. * @returns the validity of the state
  3132. */
  3133. isValid(): boolean;
  3134. /**
  3135. * Serialize the StateCondition into a JSON compatible object
  3136. * @returns serialization object
  3137. */
  3138. serialize(): any;
  3139. }
  3140. }
  3141. declare module BABYLON {
  3142. /**
  3143. * This defines an action responsible to toggle a boolean once triggered.
  3144. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3145. */
  3146. class SwitchBooleanAction extends Action {
  3147. /**
  3148. * The path to the boolean property in the target object
  3149. */
  3150. propertyPath: string;
  3151. private _target;
  3152. private _effectiveTarget;
  3153. private _property;
  3154. /**
  3155. * Instantiate the action
  3156. * @param triggerOptions defines the trigger options
  3157. * @param target defines the object containing the boolean
  3158. * @param propertyPath defines the path to the boolean property in the target object
  3159. * @param condition defines the trigger related conditions
  3160. */
  3161. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  3162. /** @hidden */
  3163. /**
  3164. * Execute the action toggle the boolean value.
  3165. */
  3166. execute(): void;
  3167. /**
  3168. * Serializes the actions and its related information.
  3169. * @param parent defines the object to serialize in
  3170. * @returns the serialized object
  3171. */
  3172. serialize(parent: any): any;
  3173. }
  3174. /**
  3175. * This defines an action responsible to set a the state field of the target
  3176. * to a desired value once triggered.
  3177. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3178. */
  3179. class SetStateAction extends Action {
  3180. /**
  3181. * The value to store in the state field.
  3182. */
  3183. value: string;
  3184. private _target;
  3185. /**
  3186. * Instantiate the action
  3187. * @param triggerOptions defines the trigger options
  3188. * @param target defines the object containing the state property
  3189. * @param value defines the value to store in the state field
  3190. * @param condition defines the trigger related conditions
  3191. */
  3192. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  3193. /**
  3194. * Execute the action and store the value on the target state property.
  3195. */
  3196. execute(): void;
  3197. /**
  3198. * Serializes the actions and its related information.
  3199. * @param parent defines the object to serialize in
  3200. * @returns the serialized object
  3201. */
  3202. serialize(parent: any): any;
  3203. }
  3204. /**
  3205. * This defines an action responsible to set a property of the target
  3206. * to a desired value once triggered.
  3207. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3208. */
  3209. class SetValueAction extends Action {
  3210. /**
  3211. * The path of the property to set in the target.
  3212. */
  3213. propertyPath: string;
  3214. /**
  3215. * The value to set in the property
  3216. */
  3217. value: any;
  3218. private _target;
  3219. private _effectiveTarget;
  3220. private _property;
  3221. /**
  3222. * Instantiate the action
  3223. * @param triggerOptions defines the trigger options
  3224. * @param target defines the object containing the property
  3225. * @param propertyPath defines the path of the property to set in the target
  3226. * @param value defines the value to set in the property
  3227. * @param condition defines the trigger related conditions
  3228. */
  3229. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  3230. /** @hidden */
  3231. /**
  3232. * Execute the action and set the targetted property to the desired value.
  3233. */
  3234. execute(): void;
  3235. /**
  3236. * Serializes the actions and its related information.
  3237. * @param parent defines the object to serialize in
  3238. * @returns the serialized object
  3239. */
  3240. serialize(parent: any): any;
  3241. }
  3242. /**
  3243. * This defines an action responsible to increment the target value
  3244. * to a desired value once triggered.
  3245. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3246. */
  3247. class IncrementValueAction extends Action {
  3248. /**
  3249. * The path of the property to increment in the target.
  3250. */
  3251. propertyPath: string;
  3252. /**
  3253. * The value we should increment the property by.
  3254. */
  3255. value: any;
  3256. private _target;
  3257. private _effectiveTarget;
  3258. private _property;
  3259. /**
  3260. * Instantiate the action
  3261. * @param triggerOptions defines the trigger options
  3262. * @param target defines the object containing the property
  3263. * @param propertyPath defines the path of the property to increment in the target
  3264. * @param value defines the value value we should increment the property by
  3265. * @param condition defines the trigger related conditions
  3266. */
  3267. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  3268. /** @hidden */
  3269. /**
  3270. * Execute the action and increment the target of the value amount.
  3271. */
  3272. execute(): void;
  3273. /**
  3274. * Serializes the actions and its related information.
  3275. * @param parent defines the object to serialize in
  3276. * @returns the serialized object
  3277. */
  3278. serialize(parent: any): any;
  3279. }
  3280. /**
  3281. * This defines an action responsible to start an animation once triggered.
  3282. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3283. */
  3284. class PlayAnimationAction extends Action {
  3285. /**
  3286. * Where the animation should start (animation frame)
  3287. */
  3288. from: number;
  3289. /**
  3290. * Where the animation should stop (animation frame)
  3291. */
  3292. to: number;
  3293. /**
  3294. * Define if the animation should loop or stop after the first play.
  3295. */
  3296. loop?: boolean;
  3297. private _target;
  3298. /**
  3299. * Instantiate the action
  3300. * @param triggerOptions defines the trigger options
  3301. * @param target defines the target animation or animation name
  3302. * @param from defines from where the animation should start (animation frame)
  3303. * @param end defines where the animation should stop (animation frame)
  3304. * @param loop defines if the animation should loop or stop after the first play
  3305. * @param condition defines the trigger related conditions
  3306. */
  3307. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  3308. /** @hidden */
  3309. /**
  3310. * Execute the action and play the animation.
  3311. */
  3312. execute(): void;
  3313. /**
  3314. * Serializes the actions and its related information.
  3315. * @param parent defines the object to serialize in
  3316. * @returns the serialized object
  3317. */
  3318. serialize(parent: any): any;
  3319. }
  3320. /**
  3321. * This defines an action responsible to stop an animation once triggered.
  3322. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3323. */
  3324. class StopAnimationAction extends Action {
  3325. private _target;
  3326. /**
  3327. * Instantiate the action
  3328. * @param triggerOptions defines the trigger options
  3329. * @param target defines the target animation or animation name
  3330. * @param condition defines the trigger related conditions
  3331. */
  3332. constructor(triggerOptions: any, target: any, condition?: Condition);
  3333. /** @hidden */
  3334. /**
  3335. * Execute the action and stop the animation.
  3336. */
  3337. execute(): void;
  3338. /**
  3339. * Serializes the actions and its related information.
  3340. * @param parent defines the object to serialize in
  3341. * @returns the serialized object
  3342. */
  3343. serialize(parent: any): any;
  3344. }
  3345. /**
  3346. * This defines an action responsible that does nothing once triggered.
  3347. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3348. */
  3349. class DoNothingAction extends Action {
  3350. /**
  3351. * Instantiate the action
  3352. * @param triggerOptions defines the trigger options
  3353. * @param condition defines the trigger related conditions
  3354. */
  3355. constructor(triggerOptions?: any, condition?: Condition);
  3356. /**
  3357. * Execute the action and do nothing.
  3358. */
  3359. execute(): void;
  3360. /**
  3361. * Serializes the actions and its related information.
  3362. * @param parent defines the object to serialize in
  3363. * @returns the serialized object
  3364. */
  3365. serialize(parent: any): any;
  3366. }
  3367. /**
  3368. * This defines an action responsible to trigger several actions once triggered.
  3369. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3370. */
  3371. class CombineAction extends Action {
  3372. /**
  3373. * The list of aggregated animations to run.
  3374. */
  3375. children: Action[];
  3376. /**
  3377. * Instantiate the action
  3378. * @param triggerOptions defines the trigger options
  3379. * @param children defines the list of aggregated animations to run
  3380. * @param condition defines the trigger related conditions
  3381. */
  3382. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  3383. /** @hidden */
  3384. /**
  3385. * Execute the action and executes all the aggregated actions.
  3386. */
  3387. execute(evt: ActionEvent): void;
  3388. /**
  3389. * Serializes the actions and its related information.
  3390. * @param parent defines the object to serialize in
  3391. * @returns the serialized object
  3392. */
  3393. serialize(parent: any): any;
  3394. }
  3395. /**
  3396. * This defines an action responsible to run code (external event) once triggered.
  3397. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3398. */
  3399. class ExecuteCodeAction extends Action {
  3400. /**
  3401. * The callback function to run.
  3402. */
  3403. func: (evt: ActionEvent) => void;
  3404. /**
  3405. * Instantiate the action
  3406. * @param triggerOptions defines the trigger options
  3407. * @param func defines the callback function to run
  3408. * @param condition defines the trigger related conditions
  3409. */
  3410. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  3411. /**
  3412. * Execute the action and run the attached code.
  3413. */
  3414. execute(evt: ActionEvent): void;
  3415. }
  3416. /**
  3417. * This defines an action responsible to set the parent property of the target once triggered.
  3418. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3419. */
  3420. class SetParentAction extends Action {
  3421. private _parent;
  3422. private _target;
  3423. /**
  3424. * Instantiate the action
  3425. * @param triggerOptions defines the trigger options
  3426. * @param target defines the target containing the parent property
  3427. * @param parent defines from where the animation should start (animation frame)
  3428. * @param condition defines the trigger related conditions
  3429. */
  3430. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  3431. /** @hidden */
  3432. /**
  3433. * Execute the action and set the parent property.
  3434. */
  3435. execute(): void;
  3436. /**
  3437. * Serializes the actions and its related information.
  3438. * @param parent defines the object to serialize in
  3439. * @returns the serialized object
  3440. */
  3441. serialize(parent: any): any;
  3442. }
  3443. }
  3444. declare module BABYLON {
  3445. /**
  3446. * This defines an action helpful to play a defined sound on a triggered action.
  3447. */
  3448. class PlaySoundAction extends Action {
  3449. private _sound;
  3450. /**
  3451. * Instantiate the action
  3452. * @param triggerOptions defines the trigger options
  3453. * @param sound defines the sound to play
  3454. * @param condition defines the trigger related conditions
  3455. */
  3456. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  3457. /** @hidden */
  3458. /**
  3459. * Execute the action and play the sound.
  3460. */
  3461. execute(): void;
  3462. /**
  3463. * Serializes the actions and its related information.
  3464. * @param parent defines the object to serialize in
  3465. * @returns the serialized object
  3466. */
  3467. serialize(parent: any): any;
  3468. }
  3469. /**
  3470. * This defines an action helpful to stop a defined sound on a triggered action.
  3471. */
  3472. class StopSoundAction extends Action {
  3473. private _sound;
  3474. /**
  3475. * Instantiate the action
  3476. * @param triggerOptions defines the trigger options
  3477. * @param sound defines the sound to stop
  3478. * @param condition defines the trigger related conditions
  3479. */
  3480. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  3481. /** @hidden */
  3482. /**
  3483. * Execute the action and stop the sound.
  3484. */
  3485. execute(): void;
  3486. /**
  3487. * Serializes the actions and its related information.
  3488. * @param parent defines the object to serialize in
  3489. * @returns the serialized object
  3490. */
  3491. serialize(parent: any): any;
  3492. }
  3493. }
  3494. declare module BABYLON {
  3495. /**
  3496. * This defines an action responsible to change the value of a property
  3497. * by interpolating between its current value and the newly set one once triggered.
  3498. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3499. */
  3500. class InterpolateValueAction extends Action {
  3501. /**
  3502. * Defines the path of the property where the value should be interpolated
  3503. */
  3504. propertyPath: string;
  3505. /**
  3506. * Defines the target value at the end of the interpolation.
  3507. */
  3508. value: any;
  3509. /**
  3510. * Defines the time it will take for the property to interpolate to the value.
  3511. */
  3512. duration: number;
  3513. /**
  3514. * Defines if the other scene animations should be stopped when the action has been triggered
  3515. */
  3516. stopOtherAnimations?: boolean;
  3517. /**
  3518. * Defines a callback raised once the interpolation animation has been done.
  3519. */
  3520. onInterpolationDone?: () => void;
  3521. /**
  3522. * Observable triggered once the interpolation animation has been done.
  3523. */
  3524. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  3525. private _target;
  3526. private _effectiveTarget;
  3527. private _property;
  3528. /**
  3529. * Instantiate the action
  3530. * @param triggerOptions defines the trigger options
  3531. * @param target defines the object containing the value to interpolate
  3532. * @param propertyPath defines the path to the property in the target object
  3533. * @param value defines the target value at the end of the interpolation
  3534. * @param duration deines the time it will take for the property to interpolate to the value.
  3535. * @param condition defines the trigger related conditions
  3536. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  3537. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  3538. */
  3539. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  3540. /** @hidden */
  3541. /**
  3542. * Execute the action starts the value interpolation.
  3543. */
  3544. execute(): void;
  3545. /**
  3546. * Serializes the actions and its related information.
  3547. * @param parent defines the object to serialize in
  3548. * @returns the serialized object
  3549. */
  3550. serialize(parent: any): any;
  3551. }
  3552. }
  3553. declare module BABYLON {
  3554. /**
  3555. * Class used to store an actual running animation
  3556. */
  3557. class Animatable {
  3558. /** defines the target object */
  3559. target: any;
  3560. /** defines the starting frame number (default is 0) */
  3561. fromFrame: number;
  3562. /** defines the ending frame number (default is 100) */
  3563. toFrame: number;
  3564. /** defines if the animation must loop (default is false) */
  3565. loopAnimation: boolean;
  3566. /** defines a callback to call when animation ends if it is not looping */
  3567. onAnimationEnd?: (() => void) | null | undefined;
  3568. private _localDelayOffset;
  3569. private _pausedDelay;
  3570. private _runtimeAnimations;
  3571. private _paused;
  3572. private _scene;
  3573. private _speedRatio;
  3574. private _weight;
  3575. private _syncRoot;
  3576. /**
  3577. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  3578. * This will only apply for non looping animation (default is true)
  3579. */
  3580. disposeOnEnd: boolean;
  3581. /**
  3582. * Gets a boolean indicating if the animation has started
  3583. */
  3584. animationStarted: boolean;
  3585. /**
  3586. * Observer raised when the animation ends
  3587. */
  3588. onAnimationEndObservable: Observable<Animatable>;
  3589. /**
  3590. * Gets the root Animatable used to synchronize and normalize animations
  3591. */
  3592. readonly syncRoot: Animatable;
  3593. /**
  3594. * Gets the current frame of the first RuntimeAnimation
  3595. * Used to synchronize Animatables
  3596. */
  3597. readonly masterFrame: number;
  3598. /**
  3599. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  3600. */
  3601. weight: number;
  3602. /**
  3603. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  3604. */
  3605. speedRatio: number;
  3606. /**
  3607. * Creates a new Animatable
  3608. * @param scene defines the hosting scene
  3609. * @param target defines the target object
  3610. * @param fromFrame defines the starting frame number (default is 0)
  3611. * @param toFrame defines the ending frame number (default is 100)
  3612. * @param loopAnimation defines if the animation must loop (default is false)
  3613. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  3614. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  3615. * @param animations defines a group of animation to add to the new Animatable
  3616. */
  3617. constructor(scene: Scene,
  3618. /** defines the target object */
  3619. target: any,
  3620. /** defines the starting frame number (default is 0) */
  3621. fromFrame?: number,
  3622. /** defines the ending frame number (default is 100) */
  3623. toFrame?: number,
  3624. /** defines if the animation must loop (default is false) */
  3625. loopAnimation?: boolean, speedRatio?: number,
  3626. /** defines a callback to call when animation ends if it is not looping */
  3627. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[]);
  3628. /**
  3629. * Synchronize and normalize current Animatable with a source Animatable
  3630. * This is useful when using animation weights and when animations are not of the same length
  3631. * @param root defines the root Animatable to synchronize with
  3632. * @returns the current Animatable
  3633. */
  3634. syncWith(root: Animatable): Animatable;
  3635. /**
  3636. * Gets the list of runtime animations
  3637. * @returns an array of RuntimeAnimation
  3638. */
  3639. getAnimations(): RuntimeAnimation[];
  3640. /**
  3641. * Adds more animations to the current animatable
  3642. * @param target defines the target of the animations
  3643. * @param animations defines the new animations to add
  3644. */
  3645. appendAnimations(target: any, animations: Animation[]): void;
  3646. /**
  3647. * Gets the source animation for a specific property
  3648. * @param property defines the propertyu to look for
  3649. * @returns null or the source animation for the given property
  3650. */
  3651. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  3652. /**
  3653. * Gets the runtime animation for a specific property
  3654. * @param property defines the propertyu to look for
  3655. * @returns null or the runtime animation for the given property
  3656. */
  3657. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  3658. /**
  3659. * Resets the animatable to its original state
  3660. */
  3661. reset(): void;
  3662. /**
  3663. * Allows the animatable to blend with current running animations
  3664. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  3665. * @param blendingSpeed defines the blending speed to use
  3666. */
  3667. enableBlending(blendingSpeed: number): void;
  3668. /**
  3669. * Disable animation blending
  3670. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  3671. */
  3672. disableBlending(): void;
  3673. /**
  3674. * Jump directly to a given frame
  3675. * @param frame defines the frame to jump to
  3676. */
  3677. goToFrame(frame: number): void;
  3678. /**
  3679. * Pause the animation
  3680. */
  3681. pause(): void;
  3682. /**
  3683. * Restart the animation
  3684. */
  3685. restart(): void;
  3686. private _raiseOnAnimationEnd;
  3687. /**
  3688. * Stop and delete the current animation
  3689. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  3690. * @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)
  3691. */
  3692. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  3693. /**
  3694. * Wait asynchronously for the animation to end
  3695. * @returns a promise which will be fullfilled when the animation ends
  3696. */
  3697. waitAsync(): Promise<Animatable>;
  3698. /** @hidden */
  3699. }
  3700. }
  3701. declare module BABYLON {
  3702. /**
  3703. * Represents the range of an animation
  3704. */
  3705. class AnimationRange {
  3706. /**The name of the animation range**/
  3707. name: string;
  3708. /**The starting frame of the animation */
  3709. from: number;
  3710. /**The ending frame of the animation*/
  3711. to: number;
  3712. /**
  3713. * Initializes the range of an animation
  3714. * @param name The name of the animation range
  3715. * @param from The starting frame of the animation
  3716. * @param to The ending frame of the animation
  3717. */
  3718. constructor(
  3719. /**The name of the animation range**/
  3720. name: string,
  3721. /**The starting frame of the animation */
  3722. from: number,
  3723. /**The ending frame of the animation*/
  3724. to: number);
  3725. /**
  3726. * Makes a copy of the animation range
  3727. * @returns A copy of the animation range
  3728. */
  3729. clone(): AnimationRange;
  3730. }
  3731. /**
  3732. * Composed of a frame, and an action function
  3733. */
  3734. class AnimationEvent {
  3735. /** The frame for which the event is triggered **/
  3736. frame: number;
  3737. /** The event to perform when triggered **/
  3738. action: (currentFrame: number) => void;
  3739. /** Specifies if the event should be triggered only once**/
  3740. onlyOnce?: boolean | undefined;
  3741. /**
  3742. * Specifies if the animation event is done
  3743. */
  3744. isDone: boolean;
  3745. /**
  3746. * Initializes the animation event
  3747. * @param frame The frame for which the event is triggered
  3748. * @param action The event to perform when triggered
  3749. * @param onlyOnce Specifies if the event should be triggered only once
  3750. */
  3751. constructor(
  3752. /** The frame for which the event is triggered **/
  3753. frame: number,
  3754. /** The event to perform when triggered **/
  3755. action: (currentFrame: number) => void,
  3756. /** Specifies if the event should be triggered only once**/
  3757. onlyOnce?: boolean | undefined);
  3758. /** @hidden */
  3759. }
  3760. /**
  3761. * A cursor which tracks a point on a path
  3762. */
  3763. class PathCursor {
  3764. private path;
  3765. /**
  3766. * Stores path cursor callbacks for when an onchange event is triggered
  3767. */
  3768. private _onchange;
  3769. /**
  3770. * The value of the path cursor
  3771. */
  3772. value: number;
  3773. /**
  3774. * The animation array of the path cursor
  3775. */
  3776. animations: Animation[];
  3777. /**
  3778. * Initializes the path cursor
  3779. * @param path The path to track
  3780. */
  3781. constructor(path: Path2);
  3782. /**
  3783. * Gets the cursor point on the path
  3784. * @returns A point on the path cursor at the cursor location
  3785. */
  3786. getPoint(): Vector3;
  3787. /**
  3788. * Moves the cursor ahead by the step amount
  3789. * @param step The amount to move the cursor forward
  3790. * @returns This path cursor
  3791. */
  3792. moveAhead(step?: number): PathCursor;
  3793. /**
  3794. * Moves the cursor behind by the step amount
  3795. * @param step The amount to move the cursor back
  3796. * @returns This path cursor
  3797. */
  3798. moveBack(step?: number): PathCursor;
  3799. /**
  3800. * Moves the cursor by the step amount
  3801. * If the step amount is greater than one, an exception is thrown
  3802. * @param step The amount to move the cursor
  3803. * @returns This path cursor
  3804. */
  3805. move(step: number): PathCursor;
  3806. /**
  3807. * Ensures that the value is limited between zero and one
  3808. * @returns This path cursor
  3809. */
  3810. private ensureLimits;
  3811. /**
  3812. * Runs onchange callbacks on change (used by the animation engine)
  3813. * @returns This path cursor
  3814. */
  3815. private raiseOnChange;
  3816. /**
  3817. * Executes a function on change
  3818. * @param f A path cursor onchange callback
  3819. * @returns This path cursor
  3820. */
  3821. onchange(f: (cursor: PathCursor) => void): PathCursor;
  3822. }
  3823. /**
  3824. * Defines an interface which represents an animation key frame
  3825. */
  3826. interface IAnimationKey {
  3827. /**
  3828. * Frame of the key frame
  3829. */
  3830. frame: number;
  3831. /**
  3832. * Value at the specifies key frame
  3833. */
  3834. value: any;
  3835. /**
  3836. * The input tangent for the cubic hermite spline
  3837. */
  3838. inTangent?: any;
  3839. /**
  3840. * The output tangent for the cubic hermite spline
  3841. */
  3842. outTangent?: any;
  3843. /**
  3844. * The animation interpolation type
  3845. */
  3846. interpolation?: AnimationKeyInterpolation;
  3847. }
  3848. /**
  3849. * Enum for the animation key frame interpolation type
  3850. */
  3851. enum AnimationKeyInterpolation {
  3852. /**
  3853. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  3854. */
  3855. STEP = 1
  3856. }
  3857. /**
  3858. * Class used to store any kind of animation
  3859. */
  3860. class Animation {
  3861. /**Name of the animation */
  3862. name: string;
  3863. /**Property to animate */
  3864. targetProperty: string;
  3865. /**The frames per second of the animation */
  3866. framePerSecond: number;
  3867. /**The data type of the animation */
  3868. dataType: number;
  3869. /**The loop mode of the animation */
  3870. loopMode?: number | undefined;
  3871. /**Specifies if blending should be enabled */
  3872. enableBlending?: boolean | undefined;
  3873. /**
  3874. * Use matrix interpolation instead of using direct key value when animating matrices
  3875. */
  3876. static AllowMatricesInterpolation: boolean;
  3877. /**
  3878. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  3879. */
  3880. static AllowMatrixDecomposeForInterpolation: boolean;
  3881. /**
  3882. * Stores the key frames of the animation
  3883. */
  3884. private _keys;
  3885. /**
  3886. * Stores the easing function of the animation
  3887. */
  3888. private _easingFunction;
  3889. /**
  3890. * @hidden Internal use only
  3891. */
  3892. /**
  3893. * The set of event that will be linked to this animation
  3894. */
  3895. private _events;
  3896. /**
  3897. * Stores an array of target property paths
  3898. */
  3899. targetPropertyPath: string[];
  3900. /**
  3901. * Stores the blending speed of the animation
  3902. */
  3903. blendingSpeed: number;
  3904. /**
  3905. * Stores the animation ranges for the animation
  3906. */
  3907. private _ranges;
  3908. /**
  3909. * @hidden Internal use
  3910. */
  3911. private static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  3912. /**
  3913. * Sets up an animation
  3914. * @param property The property to animate
  3915. * @param animationType The animation type to apply
  3916. * @param framePerSecond The frames per second of the animation
  3917. * @param easingFunction The easing function used in the animation
  3918. * @returns The created animation
  3919. */
  3920. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  3921. /**
  3922. * Create and start an animation on a node
  3923. * @param name defines the name of the global animation that will be run on all nodes
  3924. * @param node defines the root node where the animation will take place
  3925. * @param targetProperty defines property to animate
  3926. * @param framePerSecond defines the number of frame per second yo use
  3927. * @param totalFrame defines the number of frames in total
  3928. * @param from defines the initial value
  3929. * @param to defines the final value
  3930. * @param loopMode defines which loop mode you want to use (off by default)
  3931. * @param easingFunction defines the easing function to use (linear by default)
  3932. * @param onAnimationEnd defines the callback to call when animation end
  3933. * @returns the animatable created for this animation
  3934. */
  3935. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  3936. /**
  3937. * Create and start an animation on a node and its descendants
  3938. * @param name defines the name of the global animation that will be run on all nodes
  3939. * @param node defines the root node where the animation will take place
  3940. * @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
  3941. * @param targetProperty defines property to animate
  3942. * @param framePerSecond defines the number of frame per second to use
  3943. * @param totalFrame defines the number of frames in total
  3944. * @param from defines the initial value
  3945. * @param to defines the final value
  3946. * @param loopMode defines which loop mode you want to use (off by default)
  3947. * @param easingFunction defines the easing function to use (linear by default)
  3948. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  3949. * @returns the list of animatables created for all nodes
  3950. * @example https://www.babylonjs-playground.com/#MH0VLI
  3951. */
  3952. 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[]>;
  3953. /**
  3954. * Creates a new animation, merges it with the existing animations and starts it
  3955. * @param name Name of the animation
  3956. * @param node Node which contains the scene that begins the animations
  3957. * @param targetProperty Specifies which property to animate
  3958. * @param framePerSecond The frames per second of the animation
  3959. * @param totalFrame The total number of frames
  3960. * @param from The frame at the beginning of the animation
  3961. * @param to The frame at the end of the animation
  3962. * @param loopMode Specifies the loop mode of the animation
  3963. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  3964. * @param onAnimationEnd Callback to run once the animation is complete
  3965. * @returns Nullable animation
  3966. */
  3967. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  3968. /**
  3969. * Transition property of an host to the target Value
  3970. * @param property The property to transition
  3971. * @param targetValue The target Value of the property
  3972. * @param host The object where the property to animate belongs
  3973. * @param scene Scene used to run the animation
  3974. * @param frameRate Framerate (in frame/s) to use
  3975. * @param transition The transition type we want to use
  3976. * @param duration The duration of the animation, in milliseconds
  3977. * @param onAnimationEnd Callback trigger at the end of the animation
  3978. * @returns Nullable animation
  3979. */
  3980. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  3981. /**
  3982. * Return the array of runtime animations currently using this animation
  3983. */
  3984. readonly runtimeAnimations: RuntimeAnimation[];
  3985. /**
  3986. * Specifies if any of the runtime animations are currently running
  3987. */
  3988. readonly hasRunningRuntimeAnimations: boolean;
  3989. /**
  3990. * Initializes the animation
  3991. * @param name Name of the animation
  3992. * @param targetProperty Property to animate
  3993. * @param framePerSecond The frames per second of the animation
  3994. * @param dataType The data type of the animation
  3995. * @param loopMode The loop mode of the animation
  3996. * @param enableBlendings Specifies if blending should be enabled
  3997. */
  3998. constructor(
  3999. /**Name of the animation */
  4000. name: string,
  4001. /**Property to animate */
  4002. targetProperty: string,
  4003. /**The frames per second of the animation */
  4004. framePerSecond: number,
  4005. /**The data type of the animation */
  4006. dataType: number,
  4007. /**The loop mode of the animation */
  4008. loopMode?: number | undefined,
  4009. /**Specifies if blending should be enabled */
  4010. enableBlending?: boolean | undefined);
  4011. /**
  4012. * Converts the animation to a string
  4013. * @param fullDetails support for multiple levels of logging within scene loading
  4014. * @returns String form of the animation
  4015. */
  4016. toString(fullDetails?: boolean): string;
  4017. /**
  4018. * Add an event to this animation
  4019. * @param event Event to add
  4020. */
  4021. addEvent(event: AnimationEvent): void;
  4022. /**
  4023. * Remove all events found at the given frame
  4024. * @param frame The frame to remove events from
  4025. */
  4026. removeEvents(frame: number): void;
  4027. /**
  4028. * Retrieves all the events from the animation
  4029. * @returns Events from the animation
  4030. */
  4031. getEvents(): AnimationEvent[];
  4032. /**
  4033. * Creates an animation range
  4034. * @param name Name of the animation range
  4035. * @param from Starting frame of the animation range
  4036. * @param to Ending frame of the animation
  4037. */
  4038. createRange(name: string, from: number, to: number): void;
  4039. /**
  4040. * Deletes an animation range by name
  4041. * @param name Name of the animation range to delete
  4042. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  4043. */
  4044. deleteRange(name: string, deleteFrames?: boolean): void;
  4045. /**
  4046. * Gets the animation range by name, or null if not defined
  4047. * @param name Name of the animation range
  4048. * @returns Nullable animation range
  4049. */
  4050. getRange(name: string): Nullable<AnimationRange>;
  4051. /**
  4052. * Gets the key frames from the animation
  4053. * @returns The key frames of the animation
  4054. */
  4055. getKeys(): Array<IAnimationKey>;
  4056. /**
  4057. * Gets the highest frame rate of the animation
  4058. * @returns Highest frame rate of the animation
  4059. */
  4060. getHighestFrame(): number;
  4061. /**
  4062. * Gets the easing function of the animation
  4063. * @returns Easing function of the animation
  4064. */
  4065. getEasingFunction(): IEasingFunction;
  4066. /**
  4067. * Sets the easing function of the animation
  4068. * @param easingFunction A custom mathematical formula for animation
  4069. */
  4070. setEasingFunction(easingFunction: EasingFunction): void;
  4071. /**
  4072. * Interpolates a scalar linearly
  4073. * @param startValue Start value of the animation curve
  4074. * @param endValue End value of the animation curve
  4075. * @param gradient Scalar amount to interpolate
  4076. * @returns Interpolated scalar value
  4077. */
  4078. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  4079. /**
  4080. * Interpolates a scalar cubically
  4081. * @param startValue Start value of the animation curve
  4082. * @param outTangent End tangent of the animation
  4083. * @param endValue End value of the animation curve
  4084. * @param inTangent Start tangent of the animation curve
  4085. * @param gradient Scalar amount to interpolate
  4086. * @returns Interpolated scalar value
  4087. */
  4088. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  4089. /**
  4090. * Interpolates a quaternion using a spherical linear interpolation
  4091. * @param startValue Start value of the animation curve
  4092. * @param endValue End value of the animation curve
  4093. * @param gradient Scalar amount to interpolate
  4094. * @returns Interpolated quaternion value
  4095. */
  4096. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  4097. /**
  4098. * Interpolates a quaternion cubically
  4099. * @param startValue Start value of the animation curve
  4100. * @param outTangent End tangent of the animation curve
  4101. * @param endValue End value of the animation curve
  4102. * @param inTangent Start tangent of the animation curve
  4103. * @param gradient Scalar amount to interpolate
  4104. * @returns Interpolated quaternion value
  4105. */
  4106. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  4107. /**
  4108. * Interpolates a Vector3 linearl
  4109. * @param startValue Start value of the animation curve
  4110. * @param endValue End value of the animation curve
  4111. * @param gradient Scalar amount to interpolate
  4112. * @returns Interpolated scalar value
  4113. */
  4114. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  4115. /**
  4116. * Interpolates a Vector3 cubically
  4117. * @param startValue Start value of the animation curve
  4118. * @param outTangent End tangent of the animation
  4119. * @param endValue End value of the animation curve
  4120. * @param inTangent Start tangent of the animation curve
  4121. * @param gradient Scalar amount to interpolate
  4122. * @returns InterpolatedVector3 value
  4123. */
  4124. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  4125. /**
  4126. * Interpolates a Vector2 linearly
  4127. * @param startValue Start value of the animation curve
  4128. * @param endValue End value of the animation curve
  4129. * @param gradient Scalar amount to interpolate
  4130. * @returns Interpolated Vector2 value
  4131. */
  4132. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  4133. /**
  4134. * Interpolates a Vector2 cubically
  4135. * @param startValue Start value of the animation curve
  4136. * @param outTangent End tangent of the animation
  4137. * @param endValue End value of the animation curve
  4138. * @param inTangent Start tangent of the animation curve
  4139. * @param gradient Scalar amount to interpolate
  4140. * @returns Interpolated Vector2 value
  4141. */
  4142. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  4143. /**
  4144. * Interpolates a size linearly
  4145. * @param startValue Start value of the animation curve
  4146. * @param endValue End value of the animation curve
  4147. * @param gradient Scalar amount to interpolate
  4148. * @returns Interpolated Size value
  4149. */
  4150. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  4151. /**
  4152. * Interpolates a Color3 linearly
  4153. * @param startValue Start value of the animation curve
  4154. * @param endValue End value of the animation curve
  4155. * @param gradient Scalar amount to interpolate
  4156. * @returns Interpolated Color3 value
  4157. */
  4158. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  4159. /**
  4160. * @hidden Internal use only
  4161. */
  4162. /**
  4163. * @hidden Internal use only
  4164. */
  4165. /**
  4166. * Defines the function to use to interpolate matrices
  4167. * @param startValue defines the start matrix
  4168. * @param endValue defines the end matrix
  4169. * @param gradient defines the gradient between both matrices
  4170. * @param result defines an optional target matrix where to store the interpolation
  4171. * @returns the interpolated matrix
  4172. */
  4173. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  4174. /**
  4175. * Makes a copy of the animation
  4176. * @returns Cloned animation
  4177. */
  4178. clone(): Animation;
  4179. /**
  4180. * Sets the key frames of the animation
  4181. * @param values The animation key frames to set
  4182. */
  4183. setKeys(values: Array<IAnimationKey>): void;
  4184. /**
  4185. * Serializes the animation to an object
  4186. * @returns Serialized object
  4187. */
  4188. serialize(): any;
  4189. /**
  4190. * Float animation type
  4191. */
  4192. private static _ANIMATIONTYPE_FLOAT;
  4193. /**
  4194. * Vector3 animation type
  4195. */
  4196. private static _ANIMATIONTYPE_VECTOR3;
  4197. /**
  4198. * Quaternion animation type
  4199. */
  4200. private static _ANIMATIONTYPE_QUATERNION;
  4201. /**
  4202. * Matrix animation type
  4203. */
  4204. private static _ANIMATIONTYPE_MATRIX;
  4205. /**
  4206. * Color3 animation type
  4207. */
  4208. private static _ANIMATIONTYPE_COLOR3;
  4209. /**
  4210. * Vector2 animation type
  4211. */
  4212. private static _ANIMATIONTYPE_VECTOR2;
  4213. /**
  4214. * Size animation type
  4215. */
  4216. private static _ANIMATIONTYPE_SIZE;
  4217. /**
  4218. * Relative Loop Mode
  4219. */
  4220. private static _ANIMATIONLOOPMODE_RELATIVE;
  4221. /**
  4222. * Cycle Loop Mode
  4223. */
  4224. private static _ANIMATIONLOOPMODE_CYCLE;
  4225. /**
  4226. * Constant Loop Mode
  4227. */
  4228. private static _ANIMATIONLOOPMODE_CONSTANT;
  4229. /**
  4230. * Get the float animation type
  4231. */
  4232. static readonly ANIMATIONTYPE_FLOAT: number;
  4233. /**
  4234. * Get the Vector3 animation type
  4235. */
  4236. static readonly ANIMATIONTYPE_VECTOR3: number;
  4237. /**
  4238. * Get the Vector2 animation type
  4239. */
  4240. static readonly ANIMATIONTYPE_VECTOR2: number;
  4241. /**
  4242. * Get the Size animation type
  4243. */
  4244. static readonly ANIMATIONTYPE_SIZE: number;
  4245. /**
  4246. * Get the Quaternion animation type
  4247. */
  4248. static readonly ANIMATIONTYPE_QUATERNION: number;
  4249. /**
  4250. * Get the Matrix animation type
  4251. */
  4252. static readonly ANIMATIONTYPE_MATRIX: number;
  4253. /**
  4254. * Get the Color3 animation type
  4255. */
  4256. static readonly ANIMATIONTYPE_COLOR3: number;
  4257. /**
  4258. * Get the Relative Loop Mode
  4259. */
  4260. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  4261. /**
  4262. * Get the Cycle Loop Mode
  4263. */
  4264. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  4265. /**
  4266. * Get the Constant Loop Mode
  4267. */
  4268. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  4269. /** @hidden */
  4270. private static _UniversalLerp(left: any, right: any, amount: number): any;
  4271. /**
  4272. * Parses an animation object and creates an animation
  4273. * @param parsedAnimation Parsed animation object
  4274. * @returns Animation object
  4275. */
  4276. static Parse(parsedAnimation: any): Animation;
  4277. /**
  4278. * Appends the serialized animations from the source animations
  4279. * @param source Source containing the animations
  4280. * @param destination Target to store the animations
  4281. */
  4282. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  4283. }
  4284. }
  4285. declare module BABYLON {
  4286. /**
  4287. * This class defines the direct association between an animation and a target
  4288. */
  4289. class TargetedAnimation {
  4290. animation: Animation;
  4291. target: any;
  4292. }
  4293. /**
  4294. * Use this class to create coordinated animations on multiple targets
  4295. */
  4296. class AnimationGroup implements IDisposable {
  4297. /** The name of the animation group */
  4298. name: string;
  4299. private _scene;
  4300. private _targetedAnimations;
  4301. private _animatables;
  4302. private _from;
  4303. private _to;
  4304. private _isStarted;
  4305. private _speedRatio;
  4306. /**
  4307. * This observable will notify when one animation have ended.
  4308. */
  4309. onAnimationEndObservable: Observable<TargetedAnimation>;
  4310. /**
  4311. * This observable will notify when all animations have ended.
  4312. */
  4313. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  4314. /**
  4315. * This observable will notify when all animations have paused.
  4316. */
  4317. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  4318. /**
  4319. * Gets the first frame
  4320. */
  4321. readonly from: number;
  4322. /**
  4323. * Gets the last frame
  4324. */
  4325. readonly to: number;
  4326. /**
  4327. * Define if the animations are started
  4328. */
  4329. readonly isStarted: boolean;
  4330. /**
  4331. * Gets or sets the speed ratio to use for all animations
  4332. */
  4333. /**
  4334. * Gets or sets the speed ratio to use for all animations
  4335. */
  4336. speedRatio: number;
  4337. /**
  4338. * Gets the targeted animations for this animation group
  4339. */
  4340. readonly targetedAnimations: Array<TargetedAnimation>;
  4341. /**
  4342. * returning the list of animatables controlled by this animation group.
  4343. */
  4344. readonly animatables: Array<Animatable>;
  4345. /**
  4346. * Instantiates a new Animation Group.
  4347. * This helps managing several animations at once.
  4348. * @see http://doc.babylonjs.com/how_to/group
  4349. * @param name Defines the name of the group
  4350. * @param scene Defines the scene the group belongs to
  4351. */
  4352. constructor(
  4353. /** The name of the animation group */
  4354. name: string, scene?: Nullable<Scene>);
  4355. /**
  4356. * Add an animation (with its target) in the group
  4357. * @param animation defines the animation we want to add
  4358. * @param target defines the target of the animation
  4359. * @returns the {BABYLON.TargetedAnimation} object
  4360. */
  4361. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  4362. /**
  4363. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  4364. * It can add constant keys at begin or end
  4365. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  4366. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  4367. * @returns the animation group
  4368. */
  4369. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  4370. /**
  4371. * Start all animations on given targets
  4372. * @param loop defines if animations must loop
  4373. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  4374. * @param from defines the from key (optional)
  4375. * @param to defines the to key (optional)
  4376. * @returns the current animation group
  4377. */
  4378. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  4379. /**
  4380. * Pause all animations
  4381. * @returns the animation group
  4382. */
  4383. pause(): AnimationGroup;
  4384. /**
  4385. * Play all animations to initial state
  4386. * This function will start() the animations if they were not started or will restart() them if they were paused
  4387. * @param loop defines if animations must loop
  4388. * @returns the animation group
  4389. */
  4390. play(loop?: boolean): AnimationGroup;
  4391. /**
  4392. * Reset all animations to initial state
  4393. * @returns the animation group
  4394. */
  4395. reset(): AnimationGroup;
  4396. /**
  4397. * Restart animations from key 0
  4398. * @returns the animation group
  4399. */
  4400. restart(): AnimationGroup;
  4401. /**
  4402. * Stop all animations
  4403. * @returns the animation group
  4404. */
  4405. stop(): AnimationGroup;
  4406. /**
  4407. * Set animation weight for all animatables
  4408. * @param weight defines the weight to use
  4409. * @return the animationGroup
  4410. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  4411. */
  4412. setWeightForAllAnimatables(weight: number): AnimationGroup;
  4413. /**
  4414. * Synchronize and normalize all animatables with a source animatable
  4415. * @param root defines the root animatable to synchronize with
  4416. * @return the animationGroup
  4417. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  4418. */
  4419. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  4420. /**
  4421. * Goes to a specific frame in this animation group
  4422. * @param frame the frame number to go to
  4423. * @return the animationGroup
  4424. */
  4425. goToFrame(frame: number): AnimationGroup;
  4426. /**
  4427. * Dispose all associated resources
  4428. */
  4429. dispose(): void;
  4430. private _checkAnimationGroupEnded;
  4431. /**
  4432. * Returns a new AnimationGroup object parsed from the source provided.
  4433. * @param parsedAnimationGroup defines the source
  4434. * @param scene defines the scene that will receive the animationGroup
  4435. * @returns a new AnimationGroup
  4436. */
  4437. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  4438. /**
  4439. * Returns the string "AnimationGroup"
  4440. * @returns "AnimationGroup"
  4441. */
  4442. getClassName(): string;
  4443. /**
  4444. * Creates a detailled string about the object
  4445. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  4446. * @returns a string representing the object
  4447. */
  4448. toString(fullDetails?: boolean): string;
  4449. }
  4450. }
  4451. declare module BABYLON {
  4452. /**
  4453. * Class used to override all child animations of a given target
  4454. */
  4455. class AnimationPropertiesOverride {
  4456. /**
  4457. * Gets or sets a value indicating if animation blending must be used
  4458. */
  4459. enableBlending: boolean;
  4460. /**
  4461. * Gets or sets the blending speed to use when enableBlending is true
  4462. */
  4463. blendingSpeed: number;
  4464. /**
  4465. * Gets or sets the default loop mode to use
  4466. */
  4467. loopMode: number;
  4468. }
  4469. }
  4470. declare module BABYLON {
  4471. /**
  4472. * This represents the main contract an easing function should follow.
  4473. * Easing functions are used throughout the animation system.
  4474. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4475. */
  4476. interface IEasingFunction {
  4477. /**
  4478. * Given an input gradient between 0 and 1, this returns the corrseponding value
  4479. * of the easing function.
  4480. * The link below provides some of the most common examples of easing functions.
  4481. * @see https://easings.net/
  4482. * @param gradient Defines the value between 0 and 1 we want the easing value for
  4483. * @returns the corresponding value on the curve defined by the easing function
  4484. */
  4485. ease(gradient: number): number;
  4486. }
  4487. /**
  4488. * Base class used for every default easing function.
  4489. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4490. */
  4491. class EasingFunction implements IEasingFunction {
  4492. /**
  4493. * Interpolation follows the mathematical formula associated with the easing function.
  4494. */
  4495. static readonly EASINGMODE_EASEIN: number;
  4496. /**
  4497. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  4498. */
  4499. static readonly EASINGMODE_EASEOUT: number;
  4500. /**
  4501. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  4502. */
  4503. static readonly EASINGMODE_EASEINOUT: number;
  4504. private _easingMode;
  4505. /**
  4506. * Sets the easing mode of the current function.
  4507. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  4508. */
  4509. setEasingMode(easingMode: number): void;
  4510. /**
  4511. * Gets the current easing mode.
  4512. * @returns the easing mode
  4513. */
  4514. getEasingMode(): number;
  4515. /**
  4516. * @hidden
  4517. */
  4518. easeInCore(gradient: number): number;
  4519. /**
  4520. * Given an input gradient between 0 and 1, this returns the corrseponding value
  4521. * of the easing function.
  4522. * @param gradient Defines the value between 0 and 1 we want the easing value for
  4523. * @returns the corresponding value on the curve defined by the easing function
  4524. */
  4525. ease(gradient: number): number;
  4526. }
  4527. /**
  4528. * Easing function with a circle shape (see link below).
  4529. * @see https://easings.net/#easeInCirc
  4530. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4531. */
  4532. class CircleEase extends EasingFunction implements IEasingFunction {
  4533. /** @hidden */
  4534. easeInCore(gradient: number): number;
  4535. }
  4536. /**
  4537. * Easing function with a ease back shape (see link below).
  4538. * @see https://easings.net/#easeInBack
  4539. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4540. */
  4541. class BackEase extends EasingFunction implements IEasingFunction {
  4542. /** Defines the amplitude of the function */
  4543. amplitude: number;
  4544. /**
  4545. * Instantiates a back ease easing
  4546. * @see https://easings.net/#easeInBack
  4547. * @param amplitude Defines the amplitude of the function
  4548. */
  4549. constructor(
  4550. /** Defines the amplitude of the function */
  4551. amplitude?: number);
  4552. /** @hidden */
  4553. easeInCore(gradient: number): number;
  4554. }
  4555. /**
  4556. * Easing function with a bouncing shape (see link below).
  4557. * @see https://easings.net/#easeInBounce
  4558. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4559. */
  4560. class BounceEase extends EasingFunction implements IEasingFunction {
  4561. /** Defines the number of bounces */
  4562. bounces: number;
  4563. /** Defines the amplitude of the bounce */
  4564. bounciness: number;
  4565. /**
  4566. * Instantiates a bounce easing
  4567. * @see https://easings.net/#easeInBounce
  4568. * @param bounces Defines the number of bounces
  4569. * @param bounciness Defines the amplitude of the bounce
  4570. */
  4571. constructor(
  4572. /** Defines the number of bounces */
  4573. bounces?: number,
  4574. /** Defines the amplitude of the bounce */
  4575. bounciness?: number);
  4576. /** @hidden */
  4577. easeInCore(gradient: number): number;
  4578. }
  4579. /**
  4580. * Easing function with a power of 3 shape (see link below).
  4581. * @see https://easings.net/#easeInCubic
  4582. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4583. */
  4584. class CubicEase extends EasingFunction implements IEasingFunction {
  4585. /** @hidden */
  4586. easeInCore(gradient: number): number;
  4587. }
  4588. /**
  4589. * Easing function with an elastic shape (see link below).
  4590. * @see https://easings.net/#easeInElastic
  4591. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4592. */
  4593. class ElasticEase extends EasingFunction implements IEasingFunction {
  4594. /** Defines the number of oscillations*/
  4595. oscillations: number;
  4596. /** Defines the amplitude of the oscillations*/
  4597. springiness: number;
  4598. /**
  4599. * Instantiates an elastic easing function
  4600. * @see https://easings.net/#easeInElastic
  4601. * @param oscillations Defines the number of oscillations
  4602. * @param springiness Defines the amplitude of the oscillations
  4603. */
  4604. constructor(
  4605. /** Defines the number of oscillations*/
  4606. oscillations?: number,
  4607. /** Defines the amplitude of the oscillations*/
  4608. springiness?: number);
  4609. /** @hidden */
  4610. easeInCore(gradient: number): number;
  4611. }
  4612. /**
  4613. * Easing function with an exponential shape (see link below).
  4614. * @see https://easings.net/#easeInExpo
  4615. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4616. */
  4617. class ExponentialEase extends EasingFunction implements IEasingFunction {
  4618. /** Defines the exponent of the function */
  4619. exponent: number;
  4620. /**
  4621. * Instantiates an exponential easing function
  4622. * @see https://easings.net/#easeInExpo
  4623. * @param exponent Defines the exponent of the function
  4624. */
  4625. constructor(
  4626. /** Defines the exponent of the function */
  4627. exponent?: number);
  4628. /** @hidden */
  4629. easeInCore(gradient: number): number;
  4630. }
  4631. /**
  4632. * Easing function with a power shape (see link below).
  4633. * @see https://easings.net/#easeInQuad
  4634. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4635. */
  4636. class PowerEase extends EasingFunction implements IEasingFunction {
  4637. /** Defines the power of the function */
  4638. power: number;
  4639. /**
  4640. * Instantiates an power base easing function
  4641. * @see https://easings.net/#easeInQuad
  4642. * @param power Defines the power of the function
  4643. */
  4644. constructor(
  4645. /** Defines the power of the function */
  4646. power?: number);
  4647. /** @hidden */
  4648. easeInCore(gradient: number): number;
  4649. }
  4650. /**
  4651. * Easing function with a power of 2 shape (see link below).
  4652. * @see https://easings.net/#easeInQuad
  4653. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4654. */
  4655. class QuadraticEase extends EasingFunction implements IEasingFunction {
  4656. /** @hidden */
  4657. easeInCore(gradient: number): number;
  4658. }
  4659. /**
  4660. * Easing function with a power of 4 shape (see link below).
  4661. * @see https://easings.net/#easeInQuart
  4662. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4663. */
  4664. class QuarticEase extends EasingFunction implements IEasingFunction {
  4665. /** @hidden */
  4666. easeInCore(gradient: number): number;
  4667. }
  4668. /**
  4669. * Easing function with a power of 5 shape (see link below).
  4670. * @see https://easings.net/#easeInQuint
  4671. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4672. */
  4673. class QuinticEase extends EasingFunction implements IEasingFunction {
  4674. /** @hidden */
  4675. easeInCore(gradient: number): number;
  4676. }
  4677. /**
  4678. * Easing function with a sin shape (see link below).
  4679. * @see https://easings.net/#easeInSine
  4680. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4681. */
  4682. class SineEase extends EasingFunction implements IEasingFunction {
  4683. /** @hidden */
  4684. easeInCore(gradient: number): number;
  4685. }
  4686. /**
  4687. * Easing function with a bezier shape (see link below).
  4688. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  4689. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4690. */
  4691. class BezierCurveEase extends EasingFunction implements IEasingFunction {
  4692. /** Defines the x component of the start tangent in the bezier curve */
  4693. x1: number;
  4694. /** Defines the y component of the start tangent in the bezier curve */
  4695. y1: number;
  4696. /** Defines the x component of the end tangent in the bezier curve */
  4697. x2: number;
  4698. /** Defines the y component of the end tangent in the bezier curve */
  4699. y2: number;
  4700. /**
  4701. * Instantiates a bezier function
  4702. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  4703. * @param x1 Defines the x component of the start tangent in the bezier curve
  4704. * @param y1 Defines the y component of the start tangent in the bezier curve
  4705. * @param x2 Defines the x component of the end tangent in the bezier curve
  4706. * @param y2 Defines the y component of the end tangent in the bezier curve
  4707. */
  4708. constructor(
  4709. /** Defines the x component of the start tangent in the bezier curve */
  4710. x1?: number,
  4711. /** Defines the y component of the start tangent in the bezier curve */
  4712. y1?: number,
  4713. /** Defines the x component of the end tangent in the bezier curve */
  4714. x2?: number,
  4715. /** Defines the y component of the end tangent in the bezier curve */
  4716. y2?: number);
  4717. /** @hidden */
  4718. easeInCore(gradient: number): number;
  4719. }
  4720. }
  4721. declare module BABYLON {
  4722. /**
  4723. * Defines a runtime animation
  4724. */
  4725. class RuntimeAnimation {
  4726. private _events;
  4727. /**
  4728. * The current frame of the runtime animation
  4729. */
  4730. private _currentFrame;
  4731. /**
  4732. * The animation used by the runtime animation
  4733. */
  4734. private _animation;
  4735. /**
  4736. * The target of the runtime animation
  4737. */
  4738. private _target;
  4739. /**
  4740. * The initiating animatable
  4741. */
  4742. private _host;
  4743. /**
  4744. * The original value of the runtime animation
  4745. */
  4746. private _originalValue;
  4747. /**
  4748. * The original blend value of the runtime animation
  4749. */
  4750. private _originalBlendValue;
  4751. /**
  4752. * The offsets cache of the runtime animation
  4753. */
  4754. private _offsetsCache;
  4755. /**
  4756. * The high limits cache of the runtime animation
  4757. */
  4758. private _highLimitsCache;
  4759. /**
  4760. * Specifies if the runtime animation has been stopped
  4761. */
  4762. private _stopped;
  4763. /**
  4764. * The blending factor of the runtime animation
  4765. */
  4766. private _blendingFactor;
  4767. /**
  4768. * The BabylonJS scene
  4769. */
  4770. private _scene;
  4771. /**
  4772. * The current value of the runtime animation
  4773. */
  4774. private _currentValue;
  4775. /** @hidden */
  4776. /**
  4777. * The active target of the runtime animation
  4778. */
  4779. private _activeTarget;
  4780. /**
  4781. * The target path of the runtime animation
  4782. */
  4783. private _targetPath;
  4784. /**
  4785. * The weight of the runtime animation
  4786. */
  4787. private _weight;
  4788. /**
  4789. * The ratio offset of the runtime animation
  4790. */
  4791. private _ratioOffset;
  4792. /**
  4793. * The previous delay of the runtime animation
  4794. */
  4795. private _previousDelay;
  4796. /**
  4797. * The previous ratio of the runtime animation
  4798. */
  4799. private _previousRatio;
  4800. /**
  4801. * Gets the current frame of the runtime animation
  4802. */
  4803. readonly currentFrame: number;
  4804. /**
  4805. * Gets the weight of the runtime animation
  4806. */
  4807. readonly weight: number;
  4808. /**
  4809. * Gets the current value of the runtime animation
  4810. */
  4811. readonly currentValue: any;
  4812. /**
  4813. * Gets the target path of the runtime animation
  4814. */
  4815. readonly targetPath: string;
  4816. /**
  4817. * Gets the actual target of the runtime animation
  4818. */
  4819. readonly target: any;
  4820. /**
  4821. * Create a new RuntimeAnimation object
  4822. * @param target defines the target of the animation
  4823. * @param animation defines the source animation object
  4824. * @param scene defines the hosting scene
  4825. * @param host defines the initiating Animatable
  4826. */
  4827. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  4828. /**
  4829. * Gets the animation from the runtime animation
  4830. */
  4831. readonly animation: Animation;
  4832. /**
  4833. * Resets the runtime animation to the beginning
  4834. * @param restoreOriginal defines whether to restore the target property to the original value
  4835. */
  4836. reset(restoreOriginal?: boolean): void;
  4837. /**
  4838. * Specifies if the runtime animation is stopped
  4839. * @returns Boolean specifying if the runtime animation is stopped
  4840. */
  4841. isStopped(): boolean;
  4842. /**
  4843. * Disposes of the runtime animation
  4844. */
  4845. dispose(): void;
  4846. /**
  4847. * Interpolates the animation from the current frame
  4848. * @param currentFrame The frame to interpolate the animation to
  4849. * @param repeatCount The number of times that the animation should loop
  4850. * @param loopMode The type of looping mode to use
  4851. * @param offsetValue Animation offset value
  4852. * @param highLimitValue The high limit value
  4853. * @returns The interpolated value
  4854. */
  4855. private _interpolate;
  4856. /**
  4857. * Apply the interpolated value to the target
  4858. * @param currentValue defines the value computed by the animation
  4859. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  4860. */
  4861. setValue(currentValue: any, weight?: number): void;
  4862. private _setValue;
  4863. /**
  4864. * Gets the loop pmode of the runtime animation
  4865. * @returns Loop Mode
  4866. */
  4867. private _getCorrectLoopMode;
  4868. /**
  4869. * Move the current animation to a given frame
  4870. * @param frame defines the frame to move to
  4871. */
  4872. goToFrame(frame: number): void;
  4873. /**
  4874. * @hidden Internal use only
  4875. */
  4876. /**
  4877. * Execute the current animation
  4878. * @param delay defines the delay to add to the current frame
  4879. * @param from defines the lower bound of the animation range
  4880. * @param to defines the upper bound of the animation range
  4881. * @param loop defines if the current animation must loop
  4882. * @param speedRatio defines the current speed ratio
  4883. * @param weight defines the weight of the animation (default is -1 so no weight)
  4884. * @returns a boolean indicating if the animation is running
  4885. */
  4886. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  4887. }
  4888. }
  4889. declare module BABYLON {
  4890. /**
  4891. * Class used to work with sound analyzer using fast fourier transform (FFT)
  4892. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  4893. */
  4894. class Analyser {
  4895. /**
  4896. * Gets or sets the smoothing
  4897. * @ignorenaming
  4898. */
  4899. SMOOTHING: number;
  4900. /**
  4901. * Gets or sets the FFT table size
  4902. * @ignorenaming
  4903. */
  4904. FFT_SIZE: number;
  4905. /**
  4906. * Gets or sets the bar graph amplitude
  4907. * @ignorenaming
  4908. */
  4909. BARGRAPHAMPLITUDE: number;
  4910. /**
  4911. * Gets or sets the position of the debug canvas
  4912. * @ignorenaming
  4913. */
  4914. DEBUGCANVASPOS: {
  4915. x: number;
  4916. y: number;
  4917. };
  4918. /**
  4919. * Gets or sets the debug canvas size
  4920. * @ignorenaming
  4921. */
  4922. DEBUGCANVASSIZE: {
  4923. width: number;
  4924. height: number;
  4925. };
  4926. private _byteFreqs;
  4927. private _byteTime;
  4928. private _floatFreqs;
  4929. private _webAudioAnalyser;
  4930. private _debugCanvas;
  4931. private _debugCanvasContext;
  4932. private _scene;
  4933. private _registerFunc;
  4934. private _audioEngine;
  4935. /**
  4936. * Creates a new analyser
  4937. * @param scene defines hosting scene
  4938. */
  4939. constructor(scene: Scene);
  4940. /**
  4941. * Get the number of data values you will have to play with for the visualization
  4942. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  4943. * @returns a number
  4944. */
  4945. getFrequencyBinCount(): number;
  4946. /**
  4947. * Gets the current frequency data as a byte array
  4948. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  4949. * @returns a Uint8Array
  4950. */
  4951. getByteFrequencyData(): Uint8Array;
  4952. /**
  4953. * Gets the current waveform as a byte array
  4954. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  4955. * @returns a Uint8Array
  4956. */
  4957. getByteTimeDomainData(): Uint8Array;
  4958. /**
  4959. * Gets the current frequency data as a float array
  4960. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  4961. * @returns a Float32Array
  4962. */
  4963. getFloatFrequencyData(): Float32Array;
  4964. /**
  4965. * Renders the debug canvas
  4966. */
  4967. drawDebugCanvas(): void;
  4968. /**
  4969. * Stops rendering the debug canvas and removes it
  4970. */
  4971. stopDebugCanvas(): void;
  4972. /**
  4973. * Connects two audio nodes
  4974. * @param inputAudioNode defines first node to connect
  4975. * @param outputAudioNode defines second node to connect
  4976. */
  4977. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  4978. /**
  4979. * Releases all associated resources
  4980. */
  4981. dispose(): void;
  4982. }
  4983. }
  4984. declare module BABYLON {
  4985. /**
  4986. * This represents an audio engine and it is responsible
  4987. * to play, synchronize and analyse sounds throughout the application.
  4988. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  4989. */
  4990. interface IAudioEngine extends IDisposable {
  4991. /**
  4992. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  4993. */
  4994. readonly canUseWebAudio: boolean;
  4995. /**
  4996. * Gets the current AudioContext if available.
  4997. */
  4998. readonly audioContext: Nullable<AudioContext>;
  4999. /**
  5000. * The master gain node defines the global audio volume of your audio engine.
  5001. */
  5002. readonly masterGain: GainNode;
  5003. /**
  5004. * Gets whether or not mp3 are supported by your browser.
  5005. */
  5006. readonly isMP3supported: boolean;
  5007. /**
  5008. * Gets whether or not ogg are supported by your browser.
  5009. */
  5010. readonly isOGGsupported: boolean;
  5011. /**
  5012. * Defines if Babylon should emit a warning if WebAudio is not supported.
  5013. * @ignoreNaming
  5014. */
  5015. WarnedWebAudioUnsupported: boolean;
  5016. /**
  5017. * Defines if the audio engine relies on a custom unlocked button.
  5018. * In this case, the embedded button will not be displayed.
  5019. */
  5020. useCustomUnlockedButton: boolean;
  5021. /**
  5022. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  5023. */
  5024. readonly unlocked: boolean;
  5025. /**
  5026. * Event raised when audio has been unlocked on the browser.
  5027. */
  5028. onAudioUnlockedObservable: Observable<AudioEngine>;
  5029. /**
  5030. * Event raised when audio has been locked on the browser.
  5031. */
  5032. onAudioLockedObservable: Observable<AudioEngine>;
  5033. /**
  5034. * Flags the audio engine in Locked state.
  5035. * This happens due to new browser policies preventing audio to autoplay.
  5036. */
  5037. lock(): void;
  5038. /**
  5039. * Unlocks the audio engine once a user action has been done on the dom.
  5040. * This is helpful to resume play once browser policies have been satisfied.
  5041. */
  5042. unlock(): void;
  5043. }
  5044. /**
  5045. * This represents the default audio engine used in babylon.
  5046. * It is responsible to play, synchronize and analyse sounds throughout the application.
  5047. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5048. */
  5049. class AudioEngine implements IAudioEngine {
  5050. private _audioContext;
  5051. private _audioContextInitialized;
  5052. private _muteButton;
  5053. private _engine;
  5054. /**
  5055. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  5056. */
  5057. canUseWebAudio: boolean;
  5058. /**
  5059. * The master gain node defines the global audio volume of your audio engine.
  5060. */
  5061. masterGain: GainNode;
  5062. /**
  5063. * Defines if Babylon should emit a warning if WebAudio is not supported.
  5064. * @ignoreNaming
  5065. */
  5066. WarnedWebAudioUnsupported: boolean;
  5067. /**
  5068. * Gets whether or not mp3 are supported by your browser.
  5069. */
  5070. isMP3supported: boolean;
  5071. /**
  5072. * Gets whether or not ogg are supported by your browser.
  5073. */
  5074. isOGGsupported: boolean;
  5075. private _canvas;
  5076. /**
  5077. * Gets whether audio has been unlocked on the device.
  5078. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  5079. * a user interaction has happened.
  5080. */
  5081. unlocked: boolean;
  5082. /**
  5083. * Defines if the audio engine relies on a custom unlocked button.
  5084. * In this case, the embedded button will not be displayed.
  5085. */
  5086. useCustomUnlockedButton: boolean;
  5087. /**
  5088. * Event raised when audio has been unlocked on the browser.
  5089. */
  5090. onAudioUnlockedObservable: Observable<AudioEngine>;
  5091. /**
  5092. * Event raised when audio has been locked on the browser.
  5093. */
  5094. onAudioLockedObservable: Observable<AudioEngine>;
  5095. /**
  5096. * Gets the current AudioContext if available.
  5097. */
  5098. readonly audioContext: Nullable<AudioContext>;
  5099. private _connectedAnalyser;
  5100. /**
  5101. * Instantiates a new audio engine.
  5102. *
  5103. * There should be only one per page as some browsers restrict the number
  5104. * of audio contexts you can create.
  5105. * @param engine defines the hosting engine
  5106. */
  5107. constructor(engine?: Nullable<Engine>);
  5108. /**
  5109. * Flags the audio engine in Locked state.
  5110. * This happens due to new browser policies preventing audio to autoplay.
  5111. */
  5112. lock(): void;
  5113. /**
  5114. * Unlocks the audio engine once a user action has been done on the dom.
  5115. * This is helpful to resume play once browser policies have been satisfied.
  5116. */
  5117. unlock(): void;
  5118. private _resumeAudioContext;
  5119. private _initializeAudioContext;
  5120. private _tryToRun;
  5121. private _triggerRunningState;
  5122. private _triggerSuspendedState;
  5123. private _displayMuteButton;
  5124. private _moveButtonToTopLeft;
  5125. private _onResize;
  5126. private _hideMuteButton;
  5127. /**
  5128. * Destroy and release the resources associated with the audio ccontext.
  5129. */
  5130. dispose(): void;
  5131. /**
  5132. * Gets the global volume sets on the master gain.
  5133. * @returns the global volume if set or -1 otherwise
  5134. */
  5135. getGlobalVolume(): number;
  5136. /**
  5137. * Sets the global volume of your experience (sets on the master gain).
  5138. * @param newVolume Defines the new global volume of the application
  5139. */
  5140. setGlobalVolume(newVolume: number): void;
  5141. /**
  5142. * Connect the audio engine to an audio analyser allowing some amazing
  5143. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  5144. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  5145. * @param analyser The analyser to connect to the engine
  5146. */
  5147. connectToAnalyser(analyser: Analyser): void;
  5148. }
  5149. }
  5150. declare module BABYLON {
  5151. interface AbstractScene {
  5152. /**
  5153. * The list of sounds used in the scene.
  5154. */
  5155. sounds: Nullable<Array<Sound>>;
  5156. }
  5157. interface Scene {
  5158. /**
  5159. * @hidden
  5160. * Backing field
  5161. */
  5162. /**
  5163. * The main sound track played by the scene.
  5164. * It cotains your primary collection of sounds.
  5165. */
  5166. mainSoundTrack: SoundTrack;
  5167. /**
  5168. * The list of sound tracks added to the scene
  5169. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5170. */
  5171. soundTracks: Nullable<Array<SoundTrack>>;
  5172. /**
  5173. * Gets a sound using a given name
  5174. * @param name defines the name to search for
  5175. * @return the found sound or null if not found at all.
  5176. */
  5177. getSoundByName(name: string): Nullable<Sound>;
  5178. /**
  5179. * Gets or sets if audio support is enabled
  5180. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5181. */
  5182. audioEnabled: boolean;
  5183. /**
  5184. * Gets or sets if audio will be output to headphones
  5185. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5186. */
  5187. headphone: boolean;
  5188. }
  5189. /**
  5190. * Defines the sound scene component responsible to manage any sounds
  5191. * in a given scene.
  5192. */
  5193. class AudioSceneComponent implements ISceneSerializableComponent {
  5194. /**
  5195. * The component name helpfull to identify the component in the list of scene components.
  5196. */
  5197. readonly name: string;
  5198. /**
  5199. * The scene the component belongs to.
  5200. */
  5201. scene: Scene;
  5202. private _audioEnabled;
  5203. /**
  5204. * Gets whether audio is enabled or not.
  5205. * Please use related enable/disable method to switch state.
  5206. */
  5207. readonly audioEnabled: boolean;
  5208. private _headphone;
  5209. /**
  5210. * Gets whether audio is outputing to headphone or not.
  5211. * Please use the according Switch methods to change output.
  5212. */
  5213. readonly headphone: boolean;
  5214. /**
  5215. * Creates a new instance of the component for the given scene
  5216. * @param scene Defines the scene to register the component in
  5217. */
  5218. constructor(scene: Scene);
  5219. /**
  5220. * Registers the component in a given scene
  5221. */
  5222. register(): void;
  5223. /**
  5224. * Rebuilds the elements related to this component in case of
  5225. * context lost for instance.
  5226. */
  5227. rebuild(): void;
  5228. /**
  5229. * Serializes the component data to the specified json object
  5230. * @param serializationObject The object to serialize to
  5231. */
  5232. serialize(serializationObject: any): void;
  5233. /**
  5234. * Adds all the element from the container to the scene
  5235. * @param container the container holding the elements
  5236. */
  5237. addFromContainer(container: AbstractScene): void;
  5238. /**
  5239. * Removes all the elements in the container from the scene
  5240. * @param container contains the elements to remove
  5241. */
  5242. removeFromContainer(container: AbstractScene): void;
  5243. /**
  5244. * Disposes the component and the associated ressources.
  5245. */
  5246. dispose(): void;
  5247. /**
  5248. * Disables audio in the associated scene.
  5249. */
  5250. disableAudio(): void;
  5251. /**
  5252. * Enables audio in the associated scene.
  5253. */
  5254. enableAudio(): void;
  5255. /**
  5256. * Switch audio to headphone output.
  5257. */
  5258. switchAudioModeForHeadphones(): void;
  5259. /**
  5260. * Switch audio to normal speakers.
  5261. */
  5262. switchAudioModeForNormalSpeakers(): void;
  5263. private _afterRender;
  5264. }
  5265. }
  5266. declare module BABYLON {
  5267. /**
  5268. * Defines a sound that can be played in the application.
  5269. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  5270. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5271. */
  5272. class Sound {
  5273. /**
  5274. * The name of the sound in the scene.
  5275. */
  5276. name: string;
  5277. /**
  5278. * Does the sound autoplay once loaded.
  5279. */
  5280. autoplay: boolean;
  5281. /**
  5282. * Does the sound loop after it finishes playing once.
  5283. */
  5284. loop: boolean;
  5285. /**
  5286. * Does the sound use a custom attenuation curve to simulate the falloff
  5287. * happening when the source gets further away from the camera.
  5288. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  5289. */
  5290. useCustomAttenuation: boolean;
  5291. /**
  5292. * The sound track id this sound belongs to.
  5293. */
  5294. soundTrackId: number;
  5295. /**
  5296. * Is this sound currently played.
  5297. */
  5298. isPlaying: boolean;
  5299. /**
  5300. * Is this sound currently paused.
  5301. */
  5302. isPaused: boolean;
  5303. /**
  5304. * Does this sound enables spatial sound.
  5305. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5306. */
  5307. spatialSound: boolean;
  5308. /**
  5309. * Define the reference distance the sound should be heard perfectly.
  5310. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5311. */
  5312. refDistance: number;
  5313. /**
  5314. * Define the roll off factor of spatial sounds.
  5315. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5316. */
  5317. rolloffFactor: number;
  5318. /**
  5319. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  5320. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5321. */
  5322. maxDistance: number;
  5323. /**
  5324. * Define the distance attenuation model the sound will follow.
  5325. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5326. */
  5327. distanceModel: string;
  5328. /**
  5329. * @hidden
  5330. * Back Compat
  5331. **/
  5332. onended: () => any;
  5333. /**
  5334. * Observable event when the current playing sound finishes.
  5335. */
  5336. onEndedObservable: Observable<Sound>;
  5337. private _panningModel;
  5338. private _playbackRate;
  5339. private _streaming;
  5340. private _startTime;
  5341. private _startOffset;
  5342. private _position;
  5343. /** @hidden */
  5344. private _localDirection;
  5345. private _volume;
  5346. private _isReadyToPlay;
  5347. private _isDirectional;
  5348. private _readyToPlayCallback;
  5349. private _audioBuffer;
  5350. private _soundSource;
  5351. private _streamingSource;
  5352. private _soundPanner;
  5353. private _soundGain;
  5354. private _inputAudioNode;
  5355. private _outputAudioNode;
  5356. private _coneInnerAngle;
  5357. private _coneOuterAngle;
  5358. private _coneOuterGain;
  5359. private _scene;
  5360. private _connectedMesh;
  5361. private _customAttenuationFunction;
  5362. private _registerFunc;
  5363. private _isOutputConnected;
  5364. private _htmlAudioElement;
  5365. private _urlType;
  5366. /**
  5367. * Create a sound and attach it to a scene
  5368. * @param name Name of your sound
  5369. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  5370. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  5371. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  5372. */
  5373. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  5374. /**
  5375. * Release the sound and its associated resources
  5376. */
  5377. dispose(): void;
  5378. /**
  5379. * Gets if the sounds is ready to be played or not.
  5380. * @returns true if ready, otherwise false
  5381. */
  5382. isReady(): boolean;
  5383. private _soundLoaded;
  5384. /**
  5385. * Sets the data of the sound from an audiobuffer
  5386. * @param audioBuffer The audioBuffer containing the data
  5387. */
  5388. setAudioBuffer(audioBuffer: AudioBuffer): void;
  5389. /**
  5390. * Updates the current sounds options such as maxdistance, loop...
  5391. * @param options A JSON object containing values named as the object properties
  5392. */
  5393. updateOptions(options: any): void;
  5394. private _createSpatialParameters;
  5395. private _updateSpatialParameters;
  5396. /**
  5397. * Switch the panning model to HRTF:
  5398. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  5399. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5400. */
  5401. switchPanningModelToHRTF(): void;
  5402. /**
  5403. * Switch the panning model to Equal Power:
  5404. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  5405. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5406. */
  5407. switchPanningModelToEqualPower(): void;
  5408. private _switchPanningModel;
  5409. /**
  5410. * Connect this sound to a sound track audio node like gain...
  5411. * @param soundTrackAudioNode the sound track audio node to connect to
  5412. */
  5413. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  5414. /**
  5415. * Transform this sound into a directional source
  5416. * @param coneInnerAngle Size of the inner cone in degree
  5417. * @param coneOuterAngle Size of the outer cone in degree
  5418. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  5419. */
  5420. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  5421. /**
  5422. * Gets or sets the inner angle for the directional cone.
  5423. */
  5424. /**
  5425. * Gets or sets the inner angle for the directional cone.
  5426. */
  5427. directionalConeInnerAngle: number;
  5428. /**
  5429. * Gets or sets the outer angle for the directional cone.
  5430. */
  5431. /**
  5432. * Gets or sets the outer angle for the directional cone.
  5433. */
  5434. directionalConeOuterAngle: number;
  5435. /**
  5436. * Sets the position of the emitter if spatial sound is enabled
  5437. * @param newPosition Defines the new posisiton
  5438. */
  5439. setPosition(newPosition: Vector3): void;
  5440. /**
  5441. * Sets the local direction of the emitter if spatial sound is enabled
  5442. * @param newLocalDirection Defines the new local direction
  5443. */
  5444. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  5445. private _updateDirection;
  5446. /** @hidden */
  5447. updateDistanceFromListener(): void;
  5448. /**
  5449. * Sets a new custom attenuation function for the sound.
  5450. * @param callback Defines the function used for the attenuation
  5451. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  5452. */
  5453. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  5454. /**
  5455. * Play the sound
  5456. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  5457. * @param offset (optional) Start the sound setting it at a specific time
  5458. */
  5459. play(time?: number, offset?: number): void;
  5460. private _onended;
  5461. /**
  5462. * Stop the sound
  5463. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  5464. */
  5465. stop(time?: number): void;
  5466. /**
  5467. * Put the sound in pause
  5468. */
  5469. pause(): void;
  5470. /**
  5471. * Sets a dedicated volume for this sounds
  5472. * @param newVolume Define the new volume of the sound
  5473. * @param time Define in how long the sound should be at this value
  5474. */
  5475. setVolume(newVolume: number, time?: number): void;
  5476. /**
  5477. * Set the sound play back rate
  5478. * @param newPlaybackRate Define the playback rate the sound should be played at
  5479. */
  5480. setPlaybackRate(newPlaybackRate: number): void;
  5481. /**
  5482. * Gets the volume of the sound.
  5483. * @returns the volume of the sound
  5484. */
  5485. getVolume(): number;
  5486. /**
  5487. * Attach the sound to a dedicated mesh
  5488. * @param meshToConnectTo The mesh to connect the sound with
  5489. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  5490. */
  5491. attachToMesh(meshToConnectTo: AbstractMesh): void;
  5492. /**
  5493. * Detach the sound from the previously attached mesh
  5494. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  5495. */
  5496. detachFromMesh(): void;
  5497. private _onRegisterAfterWorldMatrixUpdate;
  5498. /**
  5499. * Clone the current sound in the scene.
  5500. * @returns the new sound clone
  5501. */
  5502. clone(): Nullable<Sound>;
  5503. /**
  5504. * Gets the current underlying audio buffer containing the data
  5505. * @returns the audio buffer
  5506. */
  5507. getAudioBuffer(): Nullable<AudioBuffer>;
  5508. /**
  5509. * Serializes the Sound in a JSON representation
  5510. * @returns the JSON representation of the sound
  5511. */
  5512. serialize(): any;
  5513. /**
  5514. * Parse a JSON representation of a sound to innstantiate in a given scene
  5515. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  5516. * @param scene Define the scene the new parsed sound should be created in
  5517. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  5518. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  5519. * @returns the newly parsed sound
  5520. */
  5521. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  5522. }
  5523. }
  5524. declare module BABYLON {
  5525. /**
  5526. * Options allowed during the creation of a sound track.
  5527. */
  5528. interface ISoundTrackOptions {
  5529. /**
  5530. * The volume the sound track should take during creation
  5531. */
  5532. volume?: number;
  5533. /**
  5534. * Define if the sound track is the main sound track of the scene
  5535. */
  5536. mainTrack?: boolean;
  5537. }
  5538. /**
  5539. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  5540. * It will be also used in a future release to apply effects on a specific track.
  5541. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  5542. */
  5543. class SoundTrack {
  5544. /**
  5545. * The unique identifier of the sound track in the scene.
  5546. */
  5547. id: number;
  5548. /**
  5549. * The list of sounds included in the sound track.
  5550. */
  5551. soundCollection: Array<Sound>;
  5552. private _outputAudioNode;
  5553. private _scene;
  5554. private _isMainTrack;
  5555. private _connectedAnalyser;
  5556. private _options;
  5557. private _isInitialized;
  5558. /**
  5559. * Creates a new sound track.
  5560. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  5561. * @param scene Define the scene the sound track belongs to
  5562. * @param options
  5563. */
  5564. constructor(scene: Scene, options?: ISoundTrackOptions);
  5565. private _initializeSoundTrackAudioGraph;
  5566. /**
  5567. * Release the sound track and its associated resources
  5568. */
  5569. dispose(): void;
  5570. /**
  5571. * Adds a sound to this sound track
  5572. * @param sound define the cound to add
  5573. * @ignoreNaming
  5574. */
  5575. AddSound(sound: Sound): void;
  5576. /**
  5577. * Removes a sound to this sound track
  5578. * @param sound define the cound to remove
  5579. * @ignoreNaming
  5580. */
  5581. RemoveSound(sound: Sound): void;
  5582. /**
  5583. * Set a global volume for the full sound track.
  5584. * @param newVolume Define the new volume of the sound track
  5585. */
  5586. setVolume(newVolume: number): void;
  5587. /**
  5588. * Switch the panning model to HRTF:
  5589. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  5590. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5591. */
  5592. switchPanningModelToHRTF(): void;
  5593. /**
  5594. * Switch the panning model to Equal Power:
  5595. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  5596. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5597. */
  5598. switchPanningModelToEqualPower(): void;
  5599. /**
  5600. * Connect the sound track to an audio analyser allowing some amazing
  5601. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  5602. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  5603. * @param analyser The analyser to connect to the engine
  5604. */
  5605. connectToAnalyser(analyser: Analyser): void;
  5606. }
  5607. }
  5608. declare module BABYLON {
  5609. /**
  5610. * Wraps one or more Sound objects and selects one with random weight for playback.
  5611. */
  5612. class WeightedSound {
  5613. /** When true a Sound will be selected and played when the current playing Sound completes. */
  5614. loop: boolean;
  5615. private _coneInnerAngle;
  5616. private _coneOuterAngle;
  5617. private _volume;
  5618. /** A Sound is currently playing. */
  5619. isPlaying: boolean;
  5620. /** A Sound is currently paused. */
  5621. isPaused: boolean;
  5622. private _sounds;
  5623. private _weights;
  5624. private _currentIndex?;
  5625. /**
  5626. * Creates a new WeightedSound from the list of sounds given.
  5627. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  5628. * @param sounds Array of Sounds that will be selected from.
  5629. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  5630. */
  5631. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  5632. /**
  5633. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  5634. */
  5635. /**
  5636. * The size of cone in degress for a directional sound in which there will be no attenuation.
  5637. */
  5638. directionalConeInnerAngle: number;
  5639. /**
  5640. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  5641. * Listener angles between innerAngle and outerAngle will falloff linearly.
  5642. */
  5643. /**
  5644. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  5645. * Listener angles between innerAngle and outerAngle will falloff linearly.
  5646. */
  5647. directionalConeOuterAngle: number;
  5648. /**
  5649. * Playback volume.
  5650. */
  5651. /**
  5652. * Playback volume.
  5653. */
  5654. volume: number;
  5655. private _onended;
  5656. /**
  5657. * Suspend playback
  5658. */
  5659. pause(): void;
  5660. /**
  5661. * Stop playback
  5662. */
  5663. stop(): void;
  5664. /**
  5665. * Start playback.
  5666. * @param startOffset Position the clip head at a specific time in seconds.
  5667. */
  5668. play(startOffset?: number): void;
  5669. }
  5670. }
  5671. declare module BABYLON {
  5672. /**
  5673. * Class used to store bone information
  5674. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  5675. */
  5676. class Bone extends Node {
  5677. /**
  5678. * defines the bone name
  5679. */
  5680. name: string;
  5681. private static _tmpVecs;
  5682. private static _tmpQuat;
  5683. private static _tmpMats;
  5684. /**
  5685. * Gets the list of child bones
  5686. */
  5687. children: Bone[];
  5688. /** Gets the animations associated with this bone */
  5689. animations: Animation[];
  5690. /**
  5691. * Gets or sets bone length
  5692. */
  5693. length: number;
  5694. /**
  5695. * @hidden Internal only
  5696. * Set this value to map this bone to a different index in the transform matrices
  5697. * Set this value to -1 to exclude the bone from the transform matrices
  5698. */
  5699. private _skeleton;
  5700. private _localMatrix;
  5701. private _restPose;
  5702. private _baseMatrix;
  5703. private _absoluteTransform;
  5704. private _invertedAbsoluteTransform;
  5705. private _parent;
  5706. private _scalingDeterminant;
  5707. private _worldTransform;
  5708. private _localScaling;
  5709. private _localRotation;
  5710. private _localPosition;
  5711. private _needToDecompose;
  5712. private _needToCompose;
  5713. /** @hidden */
  5714. /** @hidden */
  5715. /**
  5716. * Create a new bone
  5717. * @param name defines the bone name
  5718. * @param skeleton defines the parent skeleton
  5719. * @param parentBone defines the parent (can be null if the bone is the root)
  5720. * @param localMatrix defines the local matrix
  5721. * @param restPose defines the rest pose matrix
  5722. * @param baseMatrix defines the base matrix
  5723. * @param index defines index of the bone in the hiearchy
  5724. */
  5725. constructor(
  5726. /**
  5727. * defines the bone name
  5728. */
  5729. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  5730. /**
  5731. * Gets the parent skeleton
  5732. * @returns a skeleton
  5733. */
  5734. getSkeleton(): Skeleton;
  5735. /**
  5736. * Gets parent bone
  5737. * @returns a bone or null if the bone is the root of the bone hierarchy
  5738. */
  5739. getParent(): Nullable<Bone>;
  5740. /**
  5741. * Sets the parent bone
  5742. * @param parent defines the parent (can be null if the bone is the root)
  5743. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  5744. */
  5745. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  5746. /**
  5747. * Gets the local matrix
  5748. * @returns a matrix
  5749. */
  5750. getLocalMatrix(): Matrix;
  5751. /**
  5752. * Gets the base matrix (initial matrix which remains unchanged)
  5753. * @returns a matrix
  5754. */
  5755. getBaseMatrix(): Matrix;
  5756. /**
  5757. * Gets the rest pose matrix
  5758. * @returns a matrix
  5759. */
  5760. getRestPose(): Matrix;
  5761. /**
  5762. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  5763. */
  5764. getWorldMatrix(): Matrix;
  5765. /**
  5766. * Sets the local matrix to rest pose matrix
  5767. */
  5768. returnToRest(): void;
  5769. /**
  5770. * Gets the inverse of the absolute transform matrix.
  5771. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  5772. * @returns a matrix
  5773. */
  5774. getInvertedAbsoluteTransform(): Matrix;
  5775. /**
  5776. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  5777. * @returns a matrix
  5778. */
  5779. getAbsoluteTransform(): Matrix;
  5780. /** Gets or sets current position (in local space) */
  5781. position: Vector3;
  5782. /** Gets or sets current rotation (in local space) */
  5783. rotation: Vector3;
  5784. /** Gets or sets current rotation quaternion (in local space) */
  5785. rotationQuaternion: Quaternion;
  5786. /** Gets or sets current scaling (in local space) */
  5787. scaling: Vector3;
  5788. /**
  5789. * Gets the animation properties override
  5790. */
  5791. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  5792. private _decompose;
  5793. private _compose;
  5794. /**
  5795. * Update the base and local matrices
  5796. * @param matrix defines the new base or local matrix
  5797. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  5798. * @param updateLocalMatrix defines if the local matrix should be updated
  5799. */
  5800. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  5801. /** @hidden */
  5802. /**
  5803. * Flag the bone as dirty (Forcing it to update everything)
  5804. */
  5805. markAsDirty(): void;
  5806. private _markAsDirtyAndCompose;
  5807. private _markAsDirtyAndDecompose;
  5808. /**
  5809. * Copy an animation range from another bone
  5810. * @param source defines the source bone
  5811. * @param rangeName defines the range name to copy
  5812. * @param frameOffset defines the frame offset
  5813. * @param rescaleAsRequired defines if rescaling must be applied if required
  5814. * @param skelDimensionsRatio defines the scaling ratio
  5815. * @returns true if operation was successful
  5816. */
  5817. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired?: boolean, skelDimensionsRatio?: Nullable<Vector3>): boolean;
  5818. /**
  5819. * Translate the bone in local or world space
  5820. * @param vec The amount to translate the bone
  5821. * @param space The space that the translation is in
  5822. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5823. */
  5824. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  5825. /**
  5826. * Set the postion of the bone in local or world space
  5827. * @param position The position to set the bone
  5828. * @param space The space that the position is in
  5829. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5830. */
  5831. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  5832. /**
  5833. * Set the absolute position of the bone (world space)
  5834. * @param position The position to set the bone
  5835. * @param mesh The mesh that this bone is attached to
  5836. */
  5837. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  5838. /**
  5839. * Scale the bone on the x, y and z axes (in local space)
  5840. * @param x The amount to scale the bone on the x axis
  5841. * @param y The amount to scale the bone on the y axis
  5842. * @param z The amount to scale the bone on the z axis
  5843. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  5844. */
  5845. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  5846. /**
  5847. * Set the bone scaling in local space
  5848. * @param scale defines the scaling vector
  5849. */
  5850. setScale(scale: Vector3): void;
  5851. /**
  5852. * Gets the current scaling in local space
  5853. * @returns the current scaling vector
  5854. */
  5855. getScale(): Vector3;
  5856. /**
  5857. * Gets the current scaling in local space and stores it in a target vector
  5858. * @param result defines the target vector
  5859. */
  5860. getScaleToRef(result: Vector3): void;
  5861. /**
  5862. * Set the yaw, pitch, and roll of the bone in local or world space
  5863. * @param yaw The rotation of the bone on the y axis
  5864. * @param pitch The rotation of the bone on the x axis
  5865. * @param roll The rotation of the bone on the z axis
  5866. * @param space The space that the axes of rotation are in
  5867. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5868. */
  5869. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  5870. /**
  5871. * Add a rotation to the bone on an axis in local or world space
  5872. * @param axis The axis to rotate the bone on
  5873. * @param amount The amount to rotate the bone
  5874. * @param space The space that the axis is in
  5875. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5876. */
  5877. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  5878. /**
  5879. * Set the rotation of the bone to a particular axis angle in local or world space
  5880. * @param axis The axis to rotate the bone on
  5881. * @param angle The angle that the bone should be rotated to
  5882. * @param space The space that the axis is in
  5883. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5884. */
  5885. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  5886. /**
  5887. * Set the euler rotation of the bone in local of world space
  5888. * @param rotation The euler rotation that the bone should be set to
  5889. * @param space The space that the rotation is in
  5890. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5891. */
  5892. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  5893. /**
  5894. * Set the quaternion rotation of the bone in local of world space
  5895. * @param quat The quaternion rotation that the bone should be set to
  5896. * @param space The space that the rotation is in
  5897. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5898. */
  5899. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  5900. /**
  5901. * Set the rotation matrix of the bone in local of world space
  5902. * @param rotMat The rotation matrix that the bone should be set to
  5903. * @param space The space that the rotation is in
  5904. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5905. */
  5906. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  5907. private _rotateWithMatrix;
  5908. private _getNegativeRotationToRef;
  5909. /**
  5910. * Get the position of the bone in local or world space
  5911. * @param space The space that the returned position is in
  5912. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5913. * @returns The position of the bone
  5914. */
  5915. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  5916. /**
  5917. * Copy the position of the bone to a vector3 in local or world space
  5918. * @param space The space that the returned position is in
  5919. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5920. * @param result The vector3 to copy the position to
  5921. */
  5922. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  5923. /**
  5924. * Get the absolute position of the bone (world space)
  5925. * @param mesh The mesh that this bone is attached to
  5926. * @returns The absolute position of the bone
  5927. */
  5928. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  5929. /**
  5930. * Copy the absolute position of the bone (world space) to the result param
  5931. * @param mesh The mesh that this bone is attached to
  5932. * @param result The vector3 to copy the absolute position to
  5933. */
  5934. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  5935. /**
  5936. * Compute the absolute transforms of this bone and its children
  5937. */
  5938. computeAbsoluteTransforms(): void;
  5939. /**
  5940. * Get the world direction from an axis that is in the local space of the bone
  5941. * @param localAxis The local direction that is used to compute the world direction
  5942. * @param mesh The mesh that this bone is attached to
  5943. * @returns The world direction
  5944. */
  5945. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  5946. /**
  5947. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  5948. * @param localAxis The local direction that is used to compute the world direction
  5949. * @param mesh The mesh that this bone is attached to
  5950. * @param result The vector3 that the world direction will be copied to
  5951. */
  5952. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  5953. /**
  5954. * Get the euler rotation of the bone in local or world space
  5955. * @param space The space that the rotation should be in
  5956. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5957. * @returns The euler rotation
  5958. */
  5959. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  5960. /**
  5961. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  5962. * @param space The space that the rotation should be in
  5963. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5964. * @param result The vector3 that the rotation should be copied to
  5965. */
  5966. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  5967. /**
  5968. * Get the quaternion rotation of the bone in either local or world space
  5969. * @param space The space that the rotation should be in
  5970. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5971. * @returns The quaternion rotation
  5972. */
  5973. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  5974. /**
  5975. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  5976. * @param space The space that the rotation should be in
  5977. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5978. * @param result The quaternion that the rotation should be copied to
  5979. */
  5980. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  5981. /**
  5982. * Get the rotation matrix of the bone in local or world space
  5983. * @param space The space that the rotation should be in
  5984. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5985. * @returns The rotation matrix
  5986. */
  5987. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  5988. /**
  5989. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  5990. * @param space The space that the rotation should be in
  5991. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5992. * @param result The quaternion that the rotation should be copied to
  5993. */
  5994. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  5995. /**
  5996. * Get the world position of a point that is in the local space of the bone
  5997. * @param position The local position
  5998. * @param mesh The mesh that this bone is attached to
  5999. * @returns The world position
  6000. */
  6001. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  6002. /**
  6003. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  6004. * @param position The local position
  6005. * @param mesh The mesh that this bone is attached to
  6006. * @param result The vector3 that the world position should be copied to
  6007. */
  6008. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  6009. /**
  6010. * Get the local position of a point that is in world space
  6011. * @param position The world position
  6012. * @param mesh The mesh that this bone is attached to
  6013. * @returns The local position
  6014. */
  6015. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  6016. /**
  6017. * Get the local position of a point that is in world space and copy it to the result param
  6018. * @param position The world position
  6019. * @param mesh The mesh that this bone is attached to
  6020. * @param result The vector3 that the local position should be copied to
  6021. */
  6022. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  6023. }
  6024. }
  6025. declare module BABYLON {
  6026. /**
  6027. * Class used to apply inverse kinematics to bones
  6028. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  6029. */
  6030. class BoneIKController {
  6031. private static _tmpVecs;
  6032. private static _tmpQuat;
  6033. private static _tmpMats;
  6034. /**
  6035. * Gets or sets the target mesh
  6036. */
  6037. targetMesh: AbstractMesh;
  6038. /** Gets or sets the mesh used as pole */
  6039. poleTargetMesh: AbstractMesh;
  6040. /**
  6041. * Gets or sets the bone used as pole
  6042. */
  6043. poleTargetBone: Nullable<Bone>;
  6044. /**
  6045. * Gets or sets the target position
  6046. */
  6047. targetPosition: Vector3;
  6048. /**
  6049. * Gets or sets the pole target position
  6050. */
  6051. poleTargetPosition: Vector3;
  6052. /**
  6053. * Gets or sets the pole target local offset
  6054. */
  6055. poleTargetLocalOffset: Vector3;
  6056. /**
  6057. * Gets or sets the pole angle
  6058. */
  6059. poleAngle: number;
  6060. /**
  6061. * Gets or sets the mesh associated with the controller
  6062. */
  6063. mesh: AbstractMesh;
  6064. /**
  6065. * 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)
  6066. */
  6067. slerpAmount: number;
  6068. private _bone1Quat;
  6069. private _bone1Mat;
  6070. private _bone2Ang;
  6071. private _bone1;
  6072. private _bone2;
  6073. private _bone1Length;
  6074. private _bone2Length;
  6075. private _maxAngle;
  6076. private _maxReach;
  6077. private _rightHandedSystem;
  6078. private _bendAxis;
  6079. private _slerping;
  6080. private _adjustRoll;
  6081. /**
  6082. * Gets or sets maximum allowed angle
  6083. */
  6084. maxAngle: number;
  6085. /**
  6086. * Creates a new BoneIKController
  6087. * @param mesh defines the mesh to control
  6088. * @param bone defines the bone to control
  6089. * @param options defines options to set up the controller
  6090. */
  6091. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  6092. targetMesh?: AbstractMesh;
  6093. poleTargetMesh?: AbstractMesh;
  6094. poleTargetBone?: Bone;
  6095. poleTargetLocalOffset?: Vector3;
  6096. poleAngle?: number;
  6097. bendAxis?: Vector3;
  6098. maxAngle?: number;
  6099. slerpAmount?: number;
  6100. });
  6101. private _setMaxAngle;
  6102. /**
  6103. * Force the controller to update the bones
  6104. */
  6105. update(): void;
  6106. }
  6107. }
  6108. declare module BABYLON {
  6109. /**
  6110. * Class used to make a bone look toward a point in space
  6111. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  6112. */
  6113. class BoneLookController {
  6114. private static _tmpVecs;
  6115. private static _tmpQuat;
  6116. private static _tmpMats;
  6117. /**
  6118. * The target Vector3 that the bone will look at
  6119. */
  6120. target: Vector3;
  6121. /**
  6122. * The mesh that the bone is attached to
  6123. */
  6124. mesh: AbstractMesh;
  6125. /**
  6126. * The bone that will be looking to the target
  6127. */
  6128. bone: Bone;
  6129. /**
  6130. * The up axis of the coordinate system that is used when the bone is rotated
  6131. */
  6132. upAxis: Vector3;
  6133. /**
  6134. * The space that the up axis is in - BABYLON.Space.BONE, BABYLON.Space.LOCAL (default), or BABYLON.Space.WORLD
  6135. */
  6136. upAxisSpace: Space;
  6137. /**
  6138. * Used to make an adjustment to the yaw of the bone
  6139. */
  6140. adjustYaw: number;
  6141. /**
  6142. * Used to make an adjustment to the pitch of the bone
  6143. */
  6144. adjustPitch: number;
  6145. /**
  6146. * Used to make an adjustment to the roll of the bone
  6147. */
  6148. adjustRoll: number;
  6149. /**
  6150. * 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)
  6151. */
  6152. slerpAmount: number;
  6153. private _minYaw;
  6154. private _maxYaw;
  6155. private _minPitch;
  6156. private _maxPitch;
  6157. private _minYawSin;
  6158. private _minYawCos;
  6159. private _maxYawSin;
  6160. private _maxYawCos;
  6161. private _midYawConstraint;
  6162. private _minPitchTan;
  6163. private _maxPitchTan;
  6164. private _boneQuat;
  6165. private _slerping;
  6166. private _transformYawPitch;
  6167. private _transformYawPitchInv;
  6168. private _firstFrameSkipped;
  6169. private _yawRange;
  6170. private _fowardAxis;
  6171. /**
  6172. * Gets or sets the minimum yaw angle that the bone can look to
  6173. */
  6174. minYaw: number;
  6175. /**
  6176. * Gets or sets the maximum yaw angle that the bone can look to
  6177. */
  6178. maxYaw: number;
  6179. /**
  6180. * Gets or sets the minimum pitch angle that the bone can look to
  6181. */
  6182. minPitch: number;
  6183. /**
  6184. * Gets or sets the maximum pitch angle that the bone can look to
  6185. */
  6186. maxPitch: number;
  6187. /**
  6188. * Create a BoneLookController
  6189. * @param mesh the mesh that the bone belongs to
  6190. * @param bone the bone that will be looking to the target
  6191. * @param target the target Vector3 to look at
  6192. * @param settings optional settings:
  6193. * * maxYaw: the maximum angle the bone will yaw to
  6194. * * minYaw: the minimum angle the bone will yaw to
  6195. * * maxPitch: the maximum angle the bone will pitch to
  6196. * * minPitch: the minimum angle the bone will yaw to
  6197. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  6198. * * upAxis: the up axis of the coordinate system
  6199. * * upAxisSpace: the space that the up axis is in - BABYLON.Space.BONE, BABYLON.Space.LOCAL (default), or BABYLON.Space.WORLD.
  6200. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  6201. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  6202. * * adjustYaw: used to make an adjustment to the yaw of the bone
  6203. * * adjustPitch: used to make an adjustment to the pitch of the bone
  6204. * * adjustRoll: used to make an adjustment to the roll of the bone
  6205. **/
  6206. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  6207. maxYaw?: number;
  6208. minYaw?: number;
  6209. maxPitch?: number;
  6210. minPitch?: number;
  6211. slerpAmount?: number;
  6212. upAxis?: Vector3;
  6213. upAxisSpace?: Space;
  6214. yawAxis?: Vector3;
  6215. pitchAxis?: Vector3;
  6216. adjustYaw?: number;
  6217. adjustPitch?: number;
  6218. adjustRoll?: number;
  6219. });
  6220. /**
  6221. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  6222. */
  6223. update(): void;
  6224. private _getAngleDiff;
  6225. private _getAngleBetween;
  6226. private _isAngleBetween;
  6227. }
  6228. }
  6229. declare module BABYLON {
  6230. /**
  6231. * Class used to handle skinning animations
  6232. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  6233. */
  6234. class Skeleton implements IAnimatable {
  6235. /** defines the skeleton name */
  6236. name: string;
  6237. /** defines the skeleton Id */
  6238. id: string;
  6239. /**
  6240. * Gets the list of child bones
  6241. */
  6242. bones: Bone[];
  6243. /**
  6244. * Gets an estimate of the dimension of the skeleton at rest
  6245. */
  6246. dimensionsAtRest: Vector3;
  6247. /**
  6248. * Gets a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  6249. */
  6250. needInitialSkinMatrix: boolean;
  6251. /**
  6252. * Gets the list of animations attached to this skeleton
  6253. */
  6254. animations: Array<Animation>;
  6255. private _scene;
  6256. private _isDirty;
  6257. private _transformMatrices;
  6258. private _meshesWithPoseMatrix;
  6259. private _animatables;
  6260. private _identity;
  6261. private _synchronizedWithMesh;
  6262. private _ranges;
  6263. private _lastAbsoluteTransformsUpdateId;
  6264. /**
  6265. * Specifies if the skeleton should be serialized
  6266. */
  6267. doNotSerialize: boolean;
  6268. private _animationPropertiesOverride;
  6269. /**
  6270. * Gets or sets the animation properties override
  6271. */
  6272. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  6273. /**
  6274. * An observable triggered before computing the skeleton's matrices
  6275. */
  6276. onBeforeComputeObservable: Observable<Skeleton>;
  6277. /**
  6278. * Creates a new skeleton
  6279. * @param name defines the skeleton name
  6280. * @param id defines the skeleton Id
  6281. * @param scene defines the hosting scene
  6282. */
  6283. constructor(
  6284. /** defines the skeleton name */
  6285. name: string,
  6286. /** defines the skeleton Id */
  6287. id: string, scene: Scene);
  6288. /**
  6289. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  6290. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  6291. * @returns a Float32Array containing matrices data
  6292. */
  6293. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  6294. /**
  6295. * Gets the current hosting scene
  6296. * @returns a scene object
  6297. */
  6298. getScene(): Scene;
  6299. /**
  6300. * Gets a string representing the current skeleton data
  6301. * @param fullDetails defines a boolean indicating if we want a verbose version
  6302. * @returns a string representing the current skeleton data
  6303. */
  6304. toString(fullDetails?: boolean): string;
  6305. /**
  6306. * Get bone's index searching by name
  6307. * @param name defines bone's name to search for
  6308. * @return the indice of the bone. Returns -1 if not found
  6309. */
  6310. getBoneIndexByName(name: string): number;
  6311. /**
  6312. * Creater a new animation range
  6313. * @param name defines the name of the range
  6314. * @param from defines the start key
  6315. * @param to defines the end key
  6316. */
  6317. createAnimationRange(name: string, from: number, to: number): void;
  6318. /**
  6319. * Delete a specific animation range
  6320. * @param name defines the name of the range
  6321. * @param deleteFrames defines if frames must be removed as well
  6322. */
  6323. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  6324. /**
  6325. * Gets a specific animation range
  6326. * @param name defines the name of the range to look for
  6327. * @returns the requested animation range or null if not found
  6328. */
  6329. getAnimationRange(name: string): Nullable<AnimationRange>;
  6330. /**
  6331. * Gets the list of all animation ranges defined on this skeleton
  6332. * @returns an array
  6333. */
  6334. getAnimationRanges(): Nullable<AnimationRange>[];
  6335. /**
  6336. * Copy animation range from a source skeleton.
  6337. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  6338. * @param source defines the source skeleton
  6339. * @param name defines the name of the range to copy
  6340. * @param rescaleAsRequired defines if rescaling must be applied if required
  6341. * @returns true if operation was successful
  6342. */
  6343. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  6344. /**
  6345. * Forces the skeleton to go to rest pose
  6346. */
  6347. returnToRest(): void;
  6348. private _getHighestAnimationFrame;
  6349. /**
  6350. * Begin a specific animation range
  6351. * @param name defines the name of the range to start
  6352. * @param loop defines if looping must be turned on (false by default)
  6353. * @param speedRatio defines the speed ratio to apply (1 by default)
  6354. * @param onAnimationEnd defines a callback which will be called when animation will end
  6355. * @returns a new animatable
  6356. */
  6357. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  6358. /** @hidden */
  6359. /** @hidden */
  6360. /** @hidden */
  6361. /** @hidden */
  6362. /**
  6363. * Build all resources required to render a skeleton
  6364. */
  6365. prepare(): void;
  6366. /**
  6367. * Gets the list of animatables currently running for this skeleton
  6368. * @returns an array of animatables
  6369. */
  6370. getAnimatables(): IAnimatable[];
  6371. /**
  6372. * Clone the current skeleton
  6373. * @param name defines the name of the new skeleton
  6374. * @param id defines the id of the enw skeleton
  6375. * @returns the new skeleton
  6376. */
  6377. clone(name: string, id: string): Skeleton;
  6378. /**
  6379. * Enable animation blending for this skeleton
  6380. * @param blendingSpeed defines the blending speed to apply
  6381. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  6382. */
  6383. enableBlending(blendingSpeed?: number): void;
  6384. /**
  6385. * Releases all resources associated with the current skeleton
  6386. */
  6387. dispose(): void;
  6388. /**
  6389. * Serialize the skeleton in a JSON object
  6390. * @returns a JSON object
  6391. */
  6392. serialize(): any;
  6393. /**
  6394. * Creates a new skeleton from serialized data
  6395. * @param parsedSkeleton defines the serialized data
  6396. * @param scene defines the hosting scene
  6397. * @returns a new skeleton
  6398. */
  6399. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  6400. /**
  6401. * Compute all node absolute transforms
  6402. * @param forceUpdate defines if computation must be done even if cache is up to date
  6403. */
  6404. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  6405. /**
  6406. * Gets the root pose matrix
  6407. * @returns a matrix
  6408. */
  6409. getPoseMatrix(): Nullable<Matrix>;
  6410. /**
  6411. * Sorts bones per internal index
  6412. */
  6413. sortBones(): void;
  6414. private _sortBones;
  6415. }
  6416. }
  6417. declare module BABYLON {
  6418. /**
  6419. * Interface used to define a behavior
  6420. */
  6421. interface Behavior<T> {
  6422. /** gets or sets behavior's name */
  6423. name: string;
  6424. /**
  6425. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6426. */
  6427. init(): void;
  6428. /**
  6429. * Called when the behavior is attached to a target
  6430. * @param target defines the target where the behavior is attached to
  6431. */
  6432. attach(target: T): void;
  6433. /**
  6434. * Called when the behavior is detached from its target
  6435. */
  6436. detach(): void;
  6437. }
  6438. /**
  6439. * Interface implemented by classes supporting behaviors
  6440. */
  6441. interface IBehaviorAware<T> {
  6442. /**
  6443. * Attach a behavior
  6444. * @param behavior defines the behavior to attach
  6445. * @returns the current host
  6446. */
  6447. addBehavior(behavior: Behavior<T>): T;
  6448. /**
  6449. * Remove a behavior from the current object
  6450. * @param behavior defines the behavior to detach
  6451. * @returns the current host
  6452. */
  6453. removeBehavior(behavior: Behavior<T>): T;
  6454. /**
  6455. * Gets a behavior using its name to search
  6456. * @param name defines the name to search
  6457. * @returns the behavior or null if not found
  6458. */
  6459. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6460. }
  6461. }
  6462. declare module BABYLON {
  6463. /**
  6464. * This represents an orbital type of camera.
  6465. *
  6466. * 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.
  6467. * 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.
  6468. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  6469. */
  6470. class ArcRotateCamera extends TargetCamera {
  6471. /**
  6472. * Defines the rotation angle of the camera along the longitudinal axis.
  6473. */
  6474. alpha: number;
  6475. /**
  6476. * Defines the rotation angle of the camera along the latitudinal axis.
  6477. */
  6478. beta: number;
  6479. /**
  6480. * Defines the radius of the camera from it s target point.
  6481. */
  6482. radius: number;
  6483. protected _target: Vector3;
  6484. protected _targetHost: Nullable<AbstractMesh>;
  6485. /**
  6486. * Defines the target point of the camera.
  6487. * The camera looks towards it form the radius distance.
  6488. */
  6489. target: Vector3;
  6490. /**
  6491. * Current inertia value on the longitudinal axis.
  6492. * The bigger this number the longer it will take for the camera to stop.
  6493. */
  6494. inertialAlphaOffset: number;
  6495. /**
  6496. * Current inertia value on the latitudinal axis.
  6497. * The bigger this number the longer it will take for the camera to stop.
  6498. */
  6499. inertialBetaOffset: number;
  6500. /**
  6501. * Current inertia value on the radius axis.
  6502. * The bigger this number the longer it will take for the camera to stop.
  6503. */
  6504. inertialRadiusOffset: number;
  6505. /**
  6506. * Minimum allowed angle on the longitudinal axis.
  6507. * This can help limiting how the Camera is able to move in the scene.
  6508. */
  6509. lowerAlphaLimit: Nullable<number>;
  6510. /**
  6511. * Maximum allowed angle on the longitudinal axis.
  6512. * This can help limiting how the Camera is able to move in the scene.
  6513. */
  6514. upperAlphaLimit: Nullable<number>;
  6515. /**
  6516. * Minimum allowed angle on the latitudinal axis.
  6517. * This can help limiting how the Camera is able to move in the scene.
  6518. */
  6519. lowerBetaLimit: number;
  6520. /**
  6521. * Maximum allowed angle on the latitudinal axis.
  6522. * This can help limiting how the Camera is able to move in the scene.
  6523. */
  6524. upperBetaLimit: number;
  6525. /**
  6526. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  6527. * This can help limiting how the Camera is able to move in the scene.
  6528. */
  6529. lowerRadiusLimit: Nullable<number>;
  6530. /**
  6531. * Maximum allowed distance of the camera to the target (The camera can not get further).
  6532. * This can help limiting how the Camera is able to move in the scene.
  6533. */
  6534. upperRadiusLimit: Nullable<number>;
  6535. /**
  6536. * Defines the current inertia value used during panning of the camera along the X axis.
  6537. */
  6538. inertialPanningX: number;
  6539. /**
  6540. * Defines the current inertia value used during panning of the camera along the Y axis.
  6541. */
  6542. inertialPanningY: number;
  6543. /**
  6544. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  6545. * Basically if your fingers moves away from more than this distance you will be considered
  6546. * in pinch mode.
  6547. */
  6548. pinchToPanMaxDistance: number;
  6549. /**
  6550. * Defines the maximum distance the camera can pan.
  6551. * This could help keeping the cammera always in your scene.
  6552. */
  6553. panningDistanceLimit: Nullable<number>;
  6554. /**
  6555. * Defines the target of the camera before paning.
  6556. */
  6557. panningOriginTarget: Vector3;
  6558. /**
  6559. * Defines the value of the inertia used during panning.
  6560. * 0 would mean stop inertia and one would mean no decelleration at all.
  6561. */
  6562. panningInertia: number;
  6563. /**
  6564. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  6565. */
  6566. angularSensibilityX: number;
  6567. /**
  6568. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  6569. */
  6570. angularSensibilityY: number;
  6571. /**
  6572. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  6573. */
  6574. pinchPrecision: number;
  6575. /**
  6576. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  6577. * It will be used instead of pinchDeltaPrecision if different from 0.
  6578. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  6579. */
  6580. pinchDeltaPercentage: number;
  6581. /**
  6582. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  6583. */
  6584. panningSensibility: number;
  6585. /**
  6586. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  6587. */
  6588. keysUp: number[];
  6589. /**
  6590. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  6591. */
  6592. keysDown: number[];
  6593. /**
  6594. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  6595. */
  6596. keysLeft: number[];
  6597. /**
  6598. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  6599. */
  6600. keysRight: number[];
  6601. /**
  6602. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  6603. */
  6604. wheelPrecision: number;
  6605. /**
  6606. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  6607. * It will be used instead of pinchDeltaPrecision if different from 0.
  6608. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  6609. */
  6610. wheelDeltaPercentage: number;
  6611. /**
  6612. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  6613. */
  6614. zoomOnFactor: number;
  6615. /**
  6616. * Defines a screen offset for the camera position.
  6617. */
  6618. targetScreenOffset: Vector2;
  6619. /**
  6620. * Allows the camera to be completely reversed.
  6621. * If false the camera can not arrive upside down.
  6622. */
  6623. allowUpsideDown: boolean;
  6624. /**
  6625. * Define if double tap/click is used to restore the previously saved state of the camera.
  6626. */
  6627. useInputToRestoreState: boolean;
  6628. /** @hidden */
  6629. /** @hidden */
  6630. /** @hidden */
  6631. /**
  6632. * Defines the inpute associated to the camera.
  6633. */
  6634. inputs: ArcRotateCameraInputsManager;
  6635. /** @hidden */
  6636. /**
  6637. * Defines the allowed panning axis.
  6638. */
  6639. panningAxis: Vector3;
  6640. protected _localDirection: Vector3;
  6641. protected _transformedDirection: Vector3;
  6642. private _bouncingBehavior;
  6643. /**
  6644. * Gets the bouncing behavior of the camera if it has been enabled.
  6645. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  6646. */
  6647. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  6648. /**
  6649. * Defines if the bouncing behavior of the camera is enabled on the camera.
  6650. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  6651. */
  6652. useBouncingBehavior: boolean;
  6653. private _framingBehavior;
  6654. /**
  6655. * Gets the framing behavior of the camera if it has been enabled.
  6656. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  6657. */
  6658. readonly framingBehavior: Nullable<FramingBehavior>;
  6659. /**
  6660. * Defines if the framing behavior of the camera is enabled on the camera.
  6661. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  6662. */
  6663. useFramingBehavior: boolean;
  6664. private _autoRotationBehavior;
  6665. /**
  6666. * Gets the auto rotation behavior of the camera if it has been enabled.
  6667. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  6668. */
  6669. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  6670. /**
  6671. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  6672. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  6673. */
  6674. useAutoRotationBehavior: boolean;
  6675. /**
  6676. * Observable triggered when the mesh target has been changed on the camera.
  6677. */
  6678. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  6679. /**
  6680. * Event raised when the camera is colliding with a mesh.
  6681. */
  6682. onCollide: (collidedMesh: AbstractMesh) => void;
  6683. /**
  6684. * Defines whether the camera should check collision with the objects oh the scene.
  6685. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  6686. */
  6687. checkCollisions: boolean;
  6688. /**
  6689. * Defines the collision radius of the camera.
  6690. * This simulates a sphere around the camera.
  6691. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  6692. */
  6693. collisionRadius: Vector3;
  6694. protected _collider: Collider;
  6695. protected _previousPosition: Vector3;
  6696. protected _collisionVelocity: Vector3;
  6697. protected _newPosition: Vector3;
  6698. protected _previousAlpha: number;
  6699. protected _previousBeta: number;
  6700. protected _previousRadius: number;
  6701. protected _collisionTriggered: boolean;
  6702. protected _targetBoundingCenter: Nullable<Vector3>;
  6703. private _computationVector;
  6704. /**
  6705. * Instantiates a new ArcRotateCamera in a given scene
  6706. * @param name Defines the name of the camera
  6707. * @param alpha Defines the camera rotation along the logitudinal axis
  6708. * @param beta Defines the camera rotation along the latitudinal axis
  6709. * @param radius Defines the camera distance from its target
  6710. * @param target Defines the camera target
  6711. * @param scene Defines the scene the camera belongs to
  6712. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  6713. */
  6714. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  6715. /** @hidden */
  6716. /** @hidden */
  6717. protected _getTargetPosition(): Vector3;
  6718. private _storedAlpha;
  6719. private _storedBeta;
  6720. private _storedRadius;
  6721. private _storedTarget;
  6722. /**
  6723. * Stores the current state of the camera (alpha, beta, radius and target)
  6724. * @returns the camera itself
  6725. */
  6726. storeState(): Camera;
  6727. /**
  6728. * @hidden
  6729. * Restored camera state. You must call storeState() first
  6730. */
  6731. /** @hidden */
  6732. /**
  6733. * Attached controls to the current camera.
  6734. * @param element Defines the element the controls should be listened from
  6735. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6736. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  6737. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  6738. */
  6739. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  6740. /**
  6741. * Detach the current controls from the camera.
  6742. * The camera will stop reacting to inputs.
  6743. * @param element Defines the element to stop listening the inputs from
  6744. */
  6745. detachControl(element: HTMLElement): void;
  6746. /** @hidden */
  6747. protected _checkLimits(): void;
  6748. /**
  6749. * Rebuilds angles (alpha, beta) and radius from the give position and target.
  6750. */
  6751. rebuildAnglesAndRadius(): void;
  6752. /**
  6753. * Use a position to define the current camera related information like aplha, beta and radius
  6754. * @param position Defines the position to set the camera at
  6755. */
  6756. setPosition(position: Vector3): void;
  6757. /**
  6758. * Defines the target the camera should look at.
  6759. * This will automatically adapt alpha beta and radius to fit within the new target.
  6760. * @param target Defines the new target as a Vector or a mesh
  6761. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  6762. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  6763. */
  6764. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  6765. /** @hidden */
  6766. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  6767. /**
  6768. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  6769. * @param meshes Defines the mesh to zoom on
  6770. * @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)
  6771. */
  6772. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  6773. /**
  6774. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  6775. * The target will be changed but the radius
  6776. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  6777. * @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)
  6778. */
  6779. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  6780. min: Vector3;
  6781. max: Vector3;
  6782. distance: number;
  6783. }, doNotUpdateMaxZ?: boolean): void;
  6784. /**
  6785. * @override
  6786. * Override Camera.createRigCamera
  6787. */
  6788. createRigCamera(name: string, cameraIndex: number): Camera;
  6789. /**
  6790. * @hidden
  6791. * @override
  6792. * Override Camera._updateRigCameras
  6793. */
  6794. /**
  6795. * Destroy the camera and release the current resources hold by it.
  6796. */
  6797. dispose(): void;
  6798. /**
  6799. * Gets the current object class name.
  6800. * @return the class name
  6801. */
  6802. getClassName(): string;
  6803. }
  6804. }
  6805. declare module BABYLON {
  6806. /**
  6807. * Default Inputs manager for the ArcRotateCamera.
  6808. * It groups all the default supported inputs for ease of use.
  6809. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6810. */
  6811. class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  6812. /**
  6813. * Instantiates a new ArcRotateCameraInputsManager.
  6814. * @param camera Defines the camera the inputs belong to
  6815. */
  6816. constructor(camera: ArcRotateCamera);
  6817. /**
  6818. * Add mouse wheel input support to the input manager.
  6819. * @returns the current input manager
  6820. */
  6821. addMouseWheel(): ArcRotateCameraInputsManager;
  6822. /**
  6823. * Add pointers input support to the input manager.
  6824. * @returns the current input manager
  6825. */
  6826. addPointers(): ArcRotateCameraInputsManager;
  6827. /**
  6828. * Add keyboard input support to the input manager.
  6829. * @returns the current input manager
  6830. */
  6831. addKeyboard(): ArcRotateCameraInputsManager;
  6832. /**
  6833. * Add orientation input support to the input manager.
  6834. * @returns the current input manager
  6835. */
  6836. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  6837. }
  6838. }
  6839. declare module BABYLON {
  6840. /**
  6841. * This is the base class of all the camera used in the application.
  6842. * @see http://doc.babylonjs.com/features/cameras
  6843. */
  6844. class Camera extends Node {
  6845. /**
  6846. * This is the default projection mode used by the cameras.
  6847. * It helps recreating a feeling of perspective and better appreciate depth.
  6848. * This is the best way to simulate real life cameras.
  6849. */
  6850. static readonly PERSPECTIVE_CAMERA: number;
  6851. /**
  6852. * This helps creating camera with an orthographic mode.
  6853. * 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.
  6854. */
  6855. static readonly ORTHOGRAPHIC_CAMERA: number;
  6856. /**
  6857. * This is the default FOV mode for perspective cameras.
  6858. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  6859. */
  6860. static readonly FOVMODE_VERTICAL_FIXED: number;
  6861. /**
  6862. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  6863. */
  6864. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  6865. /**
  6866. * This specifies ther is no need for a camera rig.
  6867. * Basically only one eye is rendered corresponding to the camera.
  6868. */
  6869. static readonly RIG_MODE_NONE: number;
  6870. /**
  6871. * Simulates a camera Rig with one blue eye and one red eye.
  6872. * This can be use with 3d blue and red glasses.
  6873. */
  6874. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  6875. /**
  6876. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  6877. */
  6878. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  6879. /**
  6880. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  6881. */
  6882. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  6883. /**
  6884. * Defines that both eyes of the camera will be rendered over under each other.
  6885. */
  6886. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  6887. /**
  6888. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  6889. */
  6890. static readonly RIG_MODE_VR: number;
  6891. /**
  6892. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  6893. */
  6894. static readonly RIG_MODE_WEBVR: number;
  6895. /**
  6896. * Defines if by default attaching controls should prevent the default javascript event to continue.
  6897. */
  6898. static ForceAttachControlToAlwaysPreventDefault: boolean;
  6899. /**
  6900. * @hidden
  6901. * Might be removed once multiview will be a thing
  6902. */
  6903. static UseAlternateWebVRRendering: boolean;
  6904. /**
  6905. * Define the input manager associated with the camera.
  6906. */
  6907. inputs: CameraInputsManager<Camera>;
  6908. /**
  6909. * Define the current local position of the camera in the scene
  6910. */
  6911. position: Vector3;
  6912. /**
  6913. * The vector the camera should consider as up.
  6914. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  6915. */
  6916. upVector: Vector3;
  6917. /**
  6918. * Define the current limit on the left side for an orthographic camera
  6919. * In scene unit
  6920. */
  6921. orthoLeft: Nullable<number>;
  6922. /**
  6923. * Define the current limit on the right side for an orthographic camera
  6924. * In scene unit
  6925. */
  6926. orthoRight: Nullable<number>;
  6927. /**
  6928. * Define the current limit on the bottom side for an orthographic camera
  6929. * In scene unit
  6930. */
  6931. orthoBottom: Nullable<number>;
  6932. /**
  6933. * Define the current limit on the top side for an orthographic camera
  6934. * In scene unit
  6935. */
  6936. orthoTop: Nullable<number>;
  6937. /**
  6938. * Field Of View is set in Radians. (default is 0.8)
  6939. */
  6940. fov: number;
  6941. /**
  6942. * Define the minimum distance the camera can see from.
  6943. * This is important to note that the depth buffer are not infinite and the closer it starts
  6944. * the more your scene might encounter depth fighting issue.
  6945. */
  6946. minZ: number;
  6947. /**
  6948. * Define the maximum distance the camera can see to.
  6949. * This is important to note that the depth buffer are not infinite and the further it end
  6950. * the more your scene might encounter depth fighting issue.
  6951. */
  6952. maxZ: number;
  6953. /**
  6954. * Define the default inertia of the camera.
  6955. * This helps giving a smooth feeling to the camera movement.
  6956. */
  6957. inertia: number;
  6958. /**
  6959. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  6960. */
  6961. mode: number;
  6962. /**
  6963. * Define wether the camera is intermediate.
  6964. * This is usefull to not present the output directly to the screen in case of rig without post process for instance
  6965. */
  6966. isIntermediate: boolean;
  6967. /**
  6968. * Define the viewport of the camera.
  6969. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  6970. */
  6971. viewport: Viewport;
  6972. /**
  6973. * Restricts the camera to viewing objects with the same layerMask.
  6974. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  6975. */
  6976. layerMask: number;
  6977. /**
  6978. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  6979. */
  6980. fovMode: number;
  6981. /**
  6982. * Rig mode of the camera.
  6983. * This is usefull to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  6984. * This is normally controlled byt the camera themselves as internal use.
  6985. */
  6986. cameraRigMode: number;
  6987. /**
  6988. * Defines the distance between both "eyes" in case of a RIG
  6989. */
  6990. interaxialDistance: number;
  6991. /**
  6992. * Defines if stereoscopic rendering is done side by side or over under.
  6993. */
  6994. isStereoscopicSideBySide: boolean;
  6995. /**
  6996. * Defines the list of custom render target the camera should render to.
  6997. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  6998. * else in the scene.
  6999. */
  7000. customRenderTargets: RenderTargetTexture[];
  7001. /**
  7002. * Observable triggered when the camera view matrix has changed.
  7003. */
  7004. onViewMatrixChangedObservable: Observable<Camera>;
  7005. /**
  7006. * Observable triggered when the camera Projection matrix has changed.
  7007. */
  7008. onProjectionMatrixChangedObservable: Observable<Camera>;
  7009. /**
  7010. * Observable triggered when the inputs have been processed.
  7011. */
  7012. onAfterCheckInputsObservable: Observable<Camera>;
  7013. /**
  7014. * Observable triggered when reset has been called and applied to the camera.
  7015. */
  7016. onRestoreStateObservable: Observable<Camera>;
  7017. /** @hidden */
  7018. /** @hidden */
  7019. /** @hidden */
  7020. protected _webvrViewMatrix: Matrix;
  7021. /** @hidden */
  7022. /** @hidden */
  7023. /** @hidden */
  7024. /** @hidden */
  7025. /** @hidden */
  7026. protected _globalPosition: Vector3;
  7027. private _computedViewMatrix;
  7028. private _doNotComputeProjectionMatrix;
  7029. private _transformMatrix;
  7030. private _frustumPlanes;
  7031. private _refreshFrustumPlanes;
  7032. private _storedFov;
  7033. private _stateStored;
  7034. /**
  7035. * Instantiates a new camera object.
  7036. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  7037. * @see http://doc.babylonjs.com/features/cameras
  7038. * @param name Defines the name of the camera in the scene
  7039. * @param position Defines the position of the camera
  7040. * @param scene Defines the scene the camera belongs too
  7041. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  7042. */
  7043. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  7044. /**
  7045. * Store current camera state (fov, position, etc..)
  7046. * @returns the camera
  7047. */
  7048. storeState(): Camera;
  7049. /**
  7050. * Restores the camera state values if it has been stored. You must call storeState() first
  7051. */
  7052. protected _restoreStateValues(): boolean;
  7053. /**
  7054. * Restored camera state. You must call storeState() first.
  7055. * @returns true if restored and false otherwise
  7056. */
  7057. restoreState(): boolean;
  7058. /**
  7059. * Gets the class name of the camera.
  7060. * @returns the class name
  7061. */
  7062. getClassName(): string;
  7063. /**
  7064. * Gets a string representation of the camera usefull for debug purpose.
  7065. * @param fullDetails Defines that a more verboe level of logging is required
  7066. * @returns the string representation
  7067. */
  7068. toString(fullDetails?: boolean): string;
  7069. /**
  7070. * Gets the current world space position of the camera.
  7071. */
  7072. readonly globalPosition: Vector3;
  7073. /**
  7074. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  7075. * @returns the active meshe list
  7076. */
  7077. getActiveMeshes(): SmartArray<AbstractMesh>;
  7078. /**
  7079. * Check wether a mesh is part of the current active mesh list of the camera
  7080. * @param mesh Defines the mesh to check
  7081. * @returns true if active, false otherwise
  7082. */
  7083. isActiveMesh(mesh: Mesh): boolean;
  7084. /**
  7085. * Is this camera ready to be used/rendered
  7086. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  7087. * @return true if the camera is ready
  7088. */
  7089. isReady(completeCheck?: boolean): boolean;
  7090. /** @hidden */
  7091. /** @hidden */
  7092. /** @hidden */
  7093. /** @hidden */
  7094. /** @hidden */
  7095. /**
  7096. * Attach the input controls to a specific dom element to get the input from.
  7097. * @param element Defines the element the controls should be listened from
  7098. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  7099. */
  7100. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  7101. /**
  7102. * Detach the current controls from the specified dom element.
  7103. * @param element Defines the element to stop listening the inputs from
  7104. */
  7105. detachControl(element: HTMLElement): void;
  7106. /**
  7107. * Update the camera state according to the different inputs gathered during the frame.
  7108. */
  7109. update(): void;
  7110. /** @hidden */
  7111. /** @hidden */
  7112. readonly rigCameras: Camera[];
  7113. readonly rigPostProcess: Nullable<PostProcess>;
  7114. /**
  7115. * Internal, gets the first post proces.
  7116. * @returns the first post process to be run on this camera.
  7117. */
  7118. private _cascadePostProcessesToRigCams;
  7119. /**
  7120. * Attach a post process to the camera.
  7121. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  7122. * @param postProcess The post process to attach to the camera
  7123. * @param insertAt The position of the post process in case several of them are in use in the scene
  7124. * @returns the position the post process has been inserted at
  7125. */
  7126. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  7127. /**
  7128. * Detach a post process to the camera.
  7129. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  7130. * @param postProcess The post process to detach from the camera
  7131. */
  7132. detachPostProcess(postProcess: PostProcess): void;
  7133. /**
  7134. * Gets the current world matrix of the camera
  7135. */
  7136. getWorldMatrix(): Matrix;
  7137. /** @hidden */
  7138. protected _getViewMatrix(): Matrix;
  7139. /**
  7140. * Gets the current view matrix of the camera.
  7141. * @param force forces the camera to recompute the matrix without looking at the cached state
  7142. * @returns the view matrix
  7143. */
  7144. getViewMatrix(force?: boolean): Matrix;
  7145. /**
  7146. * Freeze the projection matrix.
  7147. * It will prevent the cache check of the camera projection compute and can speed up perf
  7148. * if no parameter of the camera are meant to change
  7149. * @param projection Defines manually a projection if necessary
  7150. */
  7151. freezeProjectionMatrix(projection?: Matrix): void;
  7152. /**
  7153. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  7154. */
  7155. unfreezeProjectionMatrix(): void;
  7156. /**
  7157. * Gets the current projection matrix of the camera.
  7158. * @param force forces the camera to recompute the matrix without looking at the cached state
  7159. * @returns the projection matrix
  7160. */
  7161. getProjectionMatrix(force?: boolean): Matrix;
  7162. /**
  7163. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  7164. * @returns a Matrix
  7165. */
  7166. getTransformationMatrix(): Matrix;
  7167. private _updateFrustumPlanes;
  7168. /**
  7169. * Checks if a cullable object (mesh...) is in the camera frustum
  7170. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  7171. * @param target The object to check
  7172. * @returns true if the object is in frustum otherwise false
  7173. */
  7174. isInFrustum(target: ICullable): boolean;
  7175. /**
  7176. * Checks if a cullable object (mesh...) is in the camera frustum
  7177. * Unlike isInFrustum this cheks the full bounding box
  7178. * @param target The object to check
  7179. * @returns true if the object is in frustum otherwise false
  7180. */
  7181. isCompletelyInFrustum(target: ICullable): boolean;
  7182. /**
  7183. * Gets a ray in the forward direction from the camera.
  7184. * @param length Defines the length of the ray to create
  7185. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  7186. * @param origin Defines the start point of the ray which defaults to the camera position
  7187. * @returns the forward ray
  7188. */
  7189. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  7190. /**
  7191. * Releases resources associated with this node.
  7192. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  7193. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  7194. */
  7195. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  7196. /**
  7197. * Gets the left camera of a rig setup in case of Rigged Camera
  7198. */
  7199. readonly leftCamera: Nullable<FreeCamera>;
  7200. /**
  7201. * Gets the right camera of a rig setup in case of Rigged Camera
  7202. */
  7203. readonly rightCamera: Nullable<FreeCamera>;
  7204. /**
  7205. * Gets the left camera target of a rig setup in case of Rigged Camera
  7206. * @returns the target position
  7207. */
  7208. getLeftTarget(): Nullable<Vector3>;
  7209. /**
  7210. * Gets the right camera target of a rig setup in case of Rigged Camera
  7211. * @returns the target position
  7212. */
  7213. getRightTarget(): Nullable<Vector3>;
  7214. /**
  7215. * @hidden
  7216. */
  7217. setCameraRigMode(mode: number, rigParams: any): void;
  7218. private _getVRProjectionMatrix;
  7219. protected _updateCameraRotationMatrix(): void;
  7220. protected _updateWebVRCameraRotationMatrix(): void;
  7221. /**
  7222. * This function MUST be overwritten by the different WebVR cameras available.
  7223. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  7224. */
  7225. protected _getWebVRProjectionMatrix(): Matrix;
  7226. /**
  7227. * This function MUST be overwritten by the different WebVR cameras available.
  7228. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  7229. */
  7230. protected _getWebVRViewMatrix(): Matrix;
  7231. /** @hidden */
  7232. setCameraRigParameter(name: string, value: any): void;
  7233. /**
  7234. * needs to be overridden by children so sub has required properties to be copied
  7235. * @hidden
  7236. */
  7237. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  7238. /**
  7239. * May need to be overridden by children
  7240. * @hidden
  7241. */
  7242. /** @hidden */
  7243. /**
  7244. * Serialiaze the camera setup to a json represention
  7245. * @returns the JSON representation
  7246. */
  7247. serialize(): any;
  7248. /**
  7249. * Clones the current camera.
  7250. * @param name The cloned camera name
  7251. * @returns the cloned camera
  7252. */
  7253. clone(name: string): Camera;
  7254. /**
  7255. * Gets the direction of the camera relative to a given local axis.
  7256. * @param localAxis Defines the reference axis to provide a relative direction.
  7257. * @return the direction
  7258. */
  7259. getDirection(localAxis: Vector3): Vector3;
  7260. /**
  7261. * Gets the direction of the camera relative to a given local axis into a passed vector.
  7262. * @param localAxis Defines the reference axis to provide a relative direction.
  7263. * @param result Defines the vector to store the result in
  7264. */
  7265. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  7266. /**
  7267. * Gets a camera constructor for a given camera type
  7268. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  7269. * @param name The name of the camera the result will be able to instantiate
  7270. * @param scene The scene the result will construct the camera in
  7271. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  7272. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  7273. * @returns a factory method to construc the camera
  7274. */
  7275. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  7276. /**
  7277. * Compute the world matrix of the camera.
  7278. * @returns the camera workd matrix
  7279. */
  7280. computeWorldMatrix(): Matrix;
  7281. /**
  7282. * Parse a JSON and creates the camera from the parsed information
  7283. * @param parsedCamera The JSON to parse
  7284. * @param scene The scene to instantiate the camera in
  7285. * @returns the newly constructed camera
  7286. */
  7287. static Parse(parsedCamera: any, scene: Scene): Camera;
  7288. }
  7289. }
  7290. declare module BABYLON {
  7291. /**
  7292. * This is a list of all the different input types that are available in the application.
  7293. * Fo instance: ArcRotateCameraGamepadInput...
  7294. */
  7295. var CameraInputTypes: {};
  7296. /**
  7297. * This is the contract to implement in order to create a new input class.
  7298. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  7299. */
  7300. interface ICameraInput<TCamera extends Camera> {
  7301. /**
  7302. * Defines the camera the input is attached to.
  7303. */
  7304. camera: Nullable<TCamera>;
  7305. /**
  7306. * Gets the class name of the current intput.
  7307. * @returns the class name
  7308. */
  7309. getClassName(): string;
  7310. /**
  7311. * Get the friendly name associated with the input class.
  7312. * @returns the input friendly name
  7313. */
  7314. getSimpleName(): string;
  7315. /**
  7316. * Attach the input controls to a specific dom element to get the input from.
  7317. * @param element Defines the element the controls should be listened from
  7318. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  7319. */
  7320. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  7321. /**
  7322. * Detach the current controls from the specified dom element.
  7323. * @param element Defines the element to stop listening the inputs from
  7324. */
  7325. detachControl(element: Nullable<HTMLElement>): void;
  7326. /**
  7327. * Update the current camera state depending on the inputs that have been used this frame.
  7328. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  7329. */
  7330. checkInputs?: () => void;
  7331. }
  7332. /**
  7333. * Represents a map of input types to input instance or input index to input instance.
  7334. */
  7335. interface CameraInputsMap<TCamera extends Camera> {
  7336. /**
  7337. * Accessor to the input by input type.
  7338. */
  7339. [name: string]: ICameraInput<TCamera>;
  7340. /**
  7341. * Accessor to the input by input index.
  7342. */
  7343. [idx: number]: ICameraInput<TCamera>;
  7344. }
  7345. /**
  7346. * This represents the input manager used within a camera.
  7347. * It helps dealing with all the different kind of input attached to a camera.
  7348. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  7349. */
  7350. class CameraInputsManager<TCamera extends Camera> {
  7351. /**
  7352. * Defines the list of inputs attahed to the camera.
  7353. */
  7354. attached: CameraInputsMap<TCamera>;
  7355. /**
  7356. * Defines the dom element the camera is collecting inputs from.
  7357. * This is null if the controls have not been attached.
  7358. */
  7359. attachedElement: Nullable<HTMLElement>;
  7360. /**
  7361. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  7362. */
  7363. noPreventDefault: boolean;
  7364. /**
  7365. * Defined the camera the input manager belongs to.
  7366. */
  7367. camera: TCamera;
  7368. /**
  7369. * Update the current camera state depending on the inputs that have been used this frame.
  7370. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  7371. */
  7372. checkInputs: () => void;
  7373. /**
  7374. * Instantiate a new Camera Input Manager.
  7375. * @param camera Defines the camera the input manager blongs to
  7376. */
  7377. constructor(camera: TCamera);
  7378. /**
  7379. * Add an input method to a camera
  7380. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  7381. * @param input camera input method
  7382. */
  7383. add(input: ICameraInput<TCamera>): void;
  7384. /**
  7385. * Remove a specific input method from a camera
  7386. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  7387. * @param inputToRemove camera input method
  7388. */
  7389. remove(inputToRemove: ICameraInput<TCamera>): void;
  7390. /**
  7391. * Remove a specific input type from a camera
  7392. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  7393. * @param inputType the type of the input to remove
  7394. */
  7395. removeByType(inputType: string): void;
  7396. private _addCheckInputs;
  7397. /**
  7398. * Attach the input controls to the currently attached dom element to listen the events from.
  7399. * @param input Defines the input to attach
  7400. */
  7401. attachInput(input: ICameraInput<TCamera>): void;
  7402. /**
  7403. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  7404. * @param element Defines the dom element to collect the events from
  7405. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  7406. */
  7407. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  7408. /**
  7409. * Detach the current manager inputs controls from a specific dom element.
  7410. * @param element Defines the dom element to collect the events from
  7411. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  7412. */
  7413. detachElement(element: HTMLElement, disconnect?: boolean): void;
  7414. /**
  7415. * Rebuild the dynamic inputCheck function from the current list of
  7416. * defined inputs in the manager.
  7417. */
  7418. rebuildInputCheck(): void;
  7419. /**
  7420. * Remove all attached input methods from a camera
  7421. */
  7422. clear(): void;
  7423. /**
  7424. * Serialize the current input manager attached to a camera.
  7425. * This ensures than once parsed,
  7426. * the input associated to the camera will be identical to the current ones
  7427. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  7428. */
  7429. serialize(serializedCamera: any): void;
  7430. /**
  7431. * Parses an input manager serialized JSON to restore the previous list of inputs
  7432. * and states associated to a camera.
  7433. * @param parsedCamera Defines the JSON to parse
  7434. */
  7435. parse(parsedCamera: any): void;
  7436. }
  7437. }
  7438. declare module BABYLON {
  7439. /**
  7440. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  7441. * being tilted forward or back and left or right.
  7442. */
  7443. class DeviceOrientationCamera extends FreeCamera {
  7444. private _initialQuaternion;
  7445. private _quaternionCache;
  7446. /**
  7447. * Creates a new device orientation camera
  7448. * @param name The name of the camera
  7449. * @param position The start position camera
  7450. * @param scene The scene the camera belongs to
  7451. */
  7452. constructor(name: string, position: Vector3, scene: Scene);
  7453. /**
  7454. * Gets the current instance class name ("DeviceOrientationCamera").
  7455. * This helps avoiding instanceof at run time.
  7456. * @returns the class name
  7457. */
  7458. getClassName(): string;
  7459. /**
  7460. * @hidden
  7461. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  7462. */
  7463. /**
  7464. * Reset the camera to its default orientation on the specified axis only.
  7465. * @param axis The axis to reset
  7466. */
  7467. resetToCurrentRotation(axis?: Axis): void;
  7468. }
  7469. }
  7470. declare module BABYLON {
  7471. /**
  7472. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  7473. * an arc rotate version arcFollowCamera are available.
  7474. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  7475. */
  7476. class FollowCamera extends TargetCamera {
  7477. /**
  7478. * Distance the follow camera should follow an object at
  7479. */
  7480. radius: number;
  7481. /**
  7482. * Define a rotation offset between the camera and the object it follows
  7483. */
  7484. rotationOffset: number;
  7485. /**
  7486. * Define a height offset between the camera and the object it follows.
  7487. * It can help following an object from the top (like a car chaing a plane)
  7488. */
  7489. heightOffset: number;
  7490. /**
  7491. * Define how fast the camera can accelerate to follow it s target.
  7492. */
  7493. cameraAcceleration: number;
  7494. /**
  7495. * Define the speed limit of the camera following an object.
  7496. */
  7497. maxCameraSpeed: number;
  7498. /**
  7499. * Define the target of the camera.
  7500. */
  7501. lockedTarget: Nullable<AbstractMesh>;
  7502. /**
  7503. * Instantiates the follow camera.
  7504. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  7505. * @param name Define the name of the camera in the scene
  7506. * @param position Define the position of the camera
  7507. * @param scene Define the scene the camera belong to
  7508. * @param lockedTarget Define the target of the camera
  7509. */
  7510. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  7511. private _follow;
  7512. /** @hidden */
  7513. /**
  7514. * Gets the camera class name.
  7515. * @returns the class name
  7516. */
  7517. getClassName(): string;
  7518. }
  7519. /**
  7520. * Arc Rotate version of the follow camera.
  7521. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  7522. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  7523. */
  7524. class ArcFollowCamera extends TargetCamera {
  7525. /** The longitudinal angle of the camera */
  7526. alpha: number;
  7527. /** The latitudinal angle of the camera */
  7528. beta: number;
  7529. /** The radius of the camera from its target */
  7530. radius: number;
  7531. /** Define the camera target (the messh it should follow) */
  7532. target: Nullable<AbstractMesh>;
  7533. private _cartesianCoordinates;
  7534. /**
  7535. * Instantiates a new ArcFollowCamera
  7536. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  7537. * @param name Define the name of the camera
  7538. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  7539. * @param beta Define the rotation angle of the camera around the elevation axis
  7540. * @param radius Define the radius of the camera from its target point
  7541. * @param target Define the target of the camera
  7542. * @param scene Define the scene the camera belongs to
  7543. */
  7544. constructor(name: string,
  7545. /** The longitudinal angle of the camera */
  7546. alpha: number,
  7547. /** The latitudinal angle of the camera */
  7548. beta: number,
  7549. /** The radius of the camera from its target */
  7550. radius: number,
  7551. /** Define the camera target (the messh it should follow) */
  7552. target: Nullable<AbstractMesh>, scene: Scene);
  7553. private _follow;
  7554. /** @hidden */
  7555. /**
  7556. * Returns the class name of the object.
  7557. * It is mostly used internally for serialization purposes.
  7558. */
  7559. getClassName(): string;
  7560. }
  7561. }
  7562. declare module BABYLON {
  7563. /**
  7564. * This represents a free type of camera. It can be usefull in First Person Shooter game for instance.
  7565. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  7566. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  7567. */
  7568. class FreeCamera extends TargetCamera {
  7569. /**
  7570. * Define the collision ellipsoid of the camera.
  7571. * This is helpful to simulate a camera body like the player body around the camera
  7572. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  7573. */
  7574. ellipsoid: Vector3;
  7575. /**
  7576. * Define an offset for the position of the ellipsoid around the camera.
  7577. * This can be helpful to determine the center of the body near the gravity center of the body
  7578. * instead of its head.
  7579. */
  7580. ellipsoidOffset: Vector3;
  7581. /**
  7582. * Enable or disable collisions of the camera with the rest of the scene objects.
  7583. */
  7584. checkCollisions: boolean;
  7585. /**
  7586. * Enable or disable gravity on the camera.
  7587. */
  7588. applyGravity: boolean;
  7589. /**
  7590. * Define the input manager associated to the camera.
  7591. */
  7592. inputs: FreeCameraInputsManager;
  7593. /**
  7594. * Gets the input sensibility for a mouse input. (default is 2000.0)
  7595. * Higher values reduce sensitivity.
  7596. */
  7597. /**
  7598. * Sets the input sensibility for a mouse input. (default is 2000.0)
  7599. * Higher values reduce sensitivity.
  7600. */
  7601. angularSensibility: number;
  7602. /**
  7603. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  7604. */
  7605. keysUp: number[];
  7606. /**
  7607. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  7608. */
  7609. keysDown: number[];
  7610. /**
  7611. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  7612. */
  7613. keysLeft: number[];
  7614. /**
  7615. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  7616. */
  7617. keysRight: number[];
  7618. /**
  7619. * Event raised when the camera collide with a mesh in the scene.
  7620. */
  7621. onCollide: (collidedMesh: AbstractMesh) => void;
  7622. private _collider;
  7623. private _needMoveForGravity;
  7624. private _oldPosition;
  7625. private _diffPosition;
  7626. private _newPosition;
  7627. /** @hidden */
  7628. /** @hidden */
  7629. /**
  7630. * Instantiates a Free Camera.
  7631. * This represents a free type of camera. It can be usefull in First Person Shooter game for instance.
  7632. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  7633. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  7634. * @param name Define the name of the camera in the scene
  7635. * @param position Define the start position of the camera in the scene
  7636. * @param scene Define the scene the camera belongs to
  7637. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  7638. */
  7639. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  7640. /**
  7641. * Attached controls to the current camera.
  7642. * @param element Defines the element the controls should be listened from
  7643. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  7644. */
  7645. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  7646. /**
  7647. * Detach the current controls from the camera.
  7648. * The camera will stop reacting to inputs.
  7649. * @param element Defines the element to stop listening the inputs from
  7650. */
  7651. detachControl(element: HTMLElement): void;
  7652. private _collisionMask;
  7653. /**
  7654. * Define a collision mask to limit the list of object the camera can collide with
  7655. */
  7656. collisionMask: number;
  7657. /** @hidden */
  7658. private _onCollisionPositionChange;
  7659. /** @hidden */
  7660. /** @hidden */
  7661. /** @hidden */
  7662. /**
  7663. * Destroy the camera and release the current resources hold by it.
  7664. */
  7665. dispose(): void;
  7666. /**
  7667. * Gets the current object class name.
  7668. * @return the class name
  7669. */
  7670. getClassName(): string;
  7671. }
  7672. }
  7673. declare module BABYLON {
  7674. /**
  7675. * Default Inputs manager for the FreeCamera.
  7676. * It groups all the default supported inputs for ease of use.
  7677. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  7678. */
  7679. class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  7680. /**
  7681. * Instantiates a new FreeCameraInputsManager.
  7682. * @param camera Defines the camera the inputs belong to
  7683. */
  7684. constructor(camera: FreeCamera);
  7685. /**
  7686. * Add keyboard input support to the input manager.
  7687. * @returns the current input manager
  7688. */
  7689. addKeyboard(): FreeCameraInputsManager;
  7690. /**
  7691. * Add mouse input support to the input manager.
  7692. * @returns the current input manager
  7693. */
  7694. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  7695. /**
  7696. * Add orientation input support to the input manager.
  7697. * @returns the current input manager
  7698. */
  7699. addDeviceOrientation(): FreeCameraInputsManager;
  7700. /**
  7701. * Add touch input support to the input manager.
  7702. * @returns the current input manager
  7703. */
  7704. addTouch(): FreeCameraInputsManager;
  7705. /**
  7706. * Add virtual joystick input support to the input manager.
  7707. * @returns the current input manager
  7708. */
  7709. addVirtualJoystick(): FreeCameraInputsManager;
  7710. }
  7711. }
  7712. declare module BABYLON {
  7713. /**
  7714. * This represents a FPS type of camera. This is only here for back compat purpose.
  7715. * Please use the UniversalCamera instead as both are identical.
  7716. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  7717. */
  7718. class GamepadCamera extends UniversalCamera {
  7719. /**
  7720. * Instantiates a new Gamepad Camera
  7721. * This represents a FPS type of camera. This is only here for back compat purpose.
  7722. * Please use the UniversalCamera instead as both are identical.
  7723. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  7724. * @param name Define the name of the camera in the scene
  7725. * @param position Define the start position of the camera in the scene
  7726. * @param scene Define the scene the camera belongs to
  7727. */
  7728. constructor(name: string, position: Vector3, scene: Scene);
  7729. /**
  7730. * Gets the current object class name.
  7731. * @return the class name
  7732. */
  7733. getClassName(): string;
  7734. }
  7735. }
  7736. declare module BABYLON {
  7737. /**
  7738. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  7739. * This is the base of the follow, arc rotate cameras and Free camera
  7740. * @see http://doc.babylonjs.com/features/cameras
  7741. */
  7742. class TargetCamera extends Camera {
  7743. /**
  7744. * Define the current direction the camera is moving to
  7745. */
  7746. cameraDirection: Vector3;
  7747. /**
  7748. * Define the current rotation the camera is rotating to
  7749. */
  7750. cameraRotation: Vector2;
  7751. /**
  7752. * Define the current rotation of the camera
  7753. */
  7754. rotation: Vector3;
  7755. /**
  7756. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  7757. */
  7758. rotationQuaternion: Quaternion;
  7759. /**
  7760. * Define the current speed of the camera
  7761. */
  7762. speed: number;
  7763. /**
  7764. * Add cconstraint to the camera to prevent it to move freely in all directions and
  7765. * around all axis.
  7766. */
  7767. noRotationConstraint: boolean;
  7768. /**
  7769. * Define the current target of the camera as an object or a position.
  7770. */
  7771. lockedTarget: any;
  7772. /** @hidden */
  7773. /** @hidden */
  7774. /** @hidden */
  7775. /** @hidden */
  7776. /** @hidden */
  7777. private _rigCamTransformMatrix;
  7778. /** @hidden */
  7779. /** @hidden */
  7780. protected _globalCurrentTarget: Vector3;
  7781. protected _globalCurrentUpVector: Vector3;
  7782. /** @hidden */
  7783. private _defaultUp;
  7784. /**
  7785. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  7786. * This is the base of the follow, arc rotate cameras and Free camera
  7787. * @see http://doc.babylonjs.com/features/cameras
  7788. * @param name Defines the name of the camera in the scene
  7789. * @param position Defines the start position of the camera in the scene
  7790. * @param scene Defines the scene the camera belongs to
  7791. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  7792. */
  7793. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  7794. /**
  7795. * Gets the position in front of the camera at a given distance.
  7796. * @param distance The distance from the camera we want the position to be
  7797. * @returns the position
  7798. */
  7799. getFrontPosition(distance: number): Vector3;
  7800. /** @hidden */
  7801. private _storedPosition;
  7802. private _storedRotation;
  7803. private _storedRotationQuaternion;
  7804. /**
  7805. * Store current camera state of the camera (fov, position, rotation, etc..)
  7806. * @returns the camera
  7807. */
  7808. storeState(): Camera;
  7809. /**
  7810. * Restored camera state. You must call storeState() first
  7811. * @returns whether it was successful or not
  7812. * @hidden
  7813. */
  7814. /** @hidden */
  7815. /** @hidden */
  7816. /** @hidden */
  7817. /** @hidden */
  7818. /** @hidden */
  7819. setTarget(target: Vector3): void;
  7820. /**
  7821. * Return the current target position of the camera. This value is expressed in local space.
  7822. * @returns the target position
  7823. */
  7824. getTarget(): Vector3;
  7825. /** @hidden */
  7826. /** @hidden */
  7827. /** @hidden */
  7828. protected _updateCameraRotationMatrix(): void;
  7829. /**
  7830. * 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)
  7831. * @returns the current camera
  7832. */
  7833. private _rotateUpVectorWithCameraRotationMatrix;
  7834. private _cachedRotationZ;
  7835. /** @hidden */
  7836. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  7837. /**
  7838. * @hidden
  7839. */
  7840. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  7841. /**
  7842. * @hidden
  7843. */
  7844. private _getRigCamPosition;
  7845. /**
  7846. * Gets the current object class name.
  7847. * @return the class name
  7848. */
  7849. getClassName(): string;
  7850. }
  7851. }
  7852. declare module BABYLON {
  7853. /**
  7854. * This represents a FPS type of camera controlled by touch.
  7855. * This is like a universal camera minus the Gamepad controls.
  7856. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  7857. */
  7858. class TouchCamera extends FreeCamera {
  7859. /**
  7860. * Defines the touch sensibility for rotation.
  7861. * The higher the faster.
  7862. */
  7863. touchAngularSensibility: number;
  7864. /**
  7865. * Defines the touch sensibility for move.
  7866. * The higher the faster.
  7867. */
  7868. touchMoveSensibility: number;
  7869. /**
  7870. * Instantiates a new touch camera.
  7871. * This represents a FPS type of camera controlled by touch.
  7872. * This is like a universal camera minus the Gamepad controls.
  7873. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  7874. * @param name Define the name of the camera in the scene
  7875. * @param position Define the start position of the camera in the scene
  7876. * @param scene Define the scene the camera belongs to
  7877. */
  7878. constructor(name: string, position: Vector3, scene: Scene);
  7879. /**
  7880. * Gets the current object class name.
  7881. * @return the class name
  7882. */
  7883. getClassName(): string;
  7884. /** @hidden */
  7885. }
  7886. }
  7887. declare module BABYLON {
  7888. /**
  7889. * 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,
  7890. * which still works and will still be found in many Playgrounds.
  7891. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  7892. */
  7893. class UniversalCamera extends TouchCamera {
  7894. /**
  7895. * Defines the gamepad rotation sensiblity.
  7896. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  7897. */
  7898. gamepadAngularSensibility: number;
  7899. /**
  7900. * Defines the gamepad move sensiblity.
  7901. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  7902. */
  7903. gamepadMoveSensibility: number;
  7904. /**
  7905. * 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,
  7906. * which still works and will still be found in many Playgrounds.
  7907. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  7908. * @param name Define the name of the camera in the scene
  7909. * @param position Define the start position of the camera in the scene
  7910. * @param scene Define the scene the camera belongs to
  7911. */
  7912. constructor(name: string, position: Vector3, scene: Scene);
  7913. /**
  7914. * Gets the current object class name.
  7915. * @return the class name
  7916. */
  7917. getClassName(): string;
  7918. }
  7919. }
  7920. declare module BABYLON {
  7921. /**
  7922. * This represents a free type of camera. It can be usefull in First Person Shooter game for instance.
  7923. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  7924. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  7925. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  7926. */
  7927. class VirtualJoysticksCamera extends FreeCamera {
  7928. /**
  7929. * Intantiates a VirtualJoysticksCamera. It can be usefull in First Person Shooter game for instance.
  7930. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  7931. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  7932. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  7933. * @param name Define the name of the camera in the scene
  7934. * @param position Define the start position of the camera in the scene
  7935. * @param scene Define the scene the camera belongs to
  7936. */
  7937. constructor(name: string, position: Vector3, scene: Scene);
  7938. /**
  7939. * Gets the current object class name.
  7940. * @return the class name
  7941. */
  7942. getClassName(): string;
  7943. }
  7944. }
  7945. interface VRDisplay extends EventTarget {
  7946. /**
  7947. * Dictionary of capabilities describing the VRDisplay.
  7948. */
  7949. readonly capabilities: VRDisplayCapabilities;
  7950. /**
  7951. * z-depth defining the far plane of the eye view frustum
  7952. * enables mapping of values in the render target depth
  7953. * attachment to scene coordinates. Initially set to 10000.0.
  7954. */
  7955. depthFar: number;
  7956. /**
  7957. * z-depth defining the near plane of the eye view frustum
  7958. * enables mapping of values in the render target depth
  7959. * attachment to scene coordinates. Initially set to 0.01.
  7960. */
  7961. depthNear: number;
  7962. /**
  7963. * An identifier for this distinct VRDisplay. Used as an
  7964. * association point in the Gamepad API.
  7965. */
  7966. readonly displayId: number;
  7967. /**
  7968. * A display name, a user-readable name identifying it.
  7969. */
  7970. readonly displayName: string;
  7971. readonly isConnected: boolean;
  7972. readonly isPresenting: boolean;
  7973. /**
  7974. * If this VRDisplay supports room-scale experiences, the optional
  7975. * stage attribute contains details on the room-scale parameters.
  7976. */
  7977. readonly stageParameters: VRStageParameters | null;
  7978. /**
  7979. * Passing the value returned by `requestAnimationFrame` to
  7980. * `cancelAnimationFrame` will unregister the callback.
  7981. * @param handle Define the hanle of the request to cancel
  7982. */
  7983. cancelAnimationFrame(handle: number): void;
  7984. /**
  7985. * Stops presenting to the VRDisplay.
  7986. * @returns a promise to know when it stopped
  7987. */
  7988. exitPresent(): Promise<void>;
  7989. /**
  7990. * Return the current VREyeParameters for the given eye.
  7991. * @param whichEye Define the eye we want the parameter for
  7992. * @returns the eye parameters
  7993. */
  7994. getEyeParameters(whichEye: string): VREyeParameters;
  7995. /**
  7996. * Populates the passed VRFrameData with the information required to render
  7997. * the current frame.
  7998. * @param frameData Define the data structure to populate
  7999. * @returns true if ok otherwise false
  8000. */
  8001. getFrameData(frameData: VRFrameData): boolean;
  8002. /**
  8003. * Get the layers currently being presented.
  8004. * @returns the list of VR layers
  8005. */
  8006. getLayers(): VRLayer[];
  8007. /**
  8008. * Return a VRPose containing the future predicted pose of the VRDisplay
  8009. * when the current frame will be presented. The value returned will not
  8010. * change until JavaScript has returned control to the browser.
  8011. *
  8012. * The VRPose will contain the position, orientation, velocity,
  8013. * and acceleration of each of these properties.
  8014. * @returns the pose object
  8015. */
  8016. getPose(): VRPose;
  8017. /**
  8018. * Return the current instantaneous pose of the VRDisplay, with no
  8019. * prediction applied.
  8020. * @returns the current instantaneous pose
  8021. */
  8022. getImmediatePose(): VRPose;
  8023. /**
  8024. * The callback passed to `requestAnimationFrame` will be called
  8025. * any time a new frame should be rendered. When the VRDisplay is
  8026. * presenting the callback will be called at the native refresh
  8027. * rate of the HMD. When not presenting this function acts
  8028. * identically to how window.requestAnimationFrame acts. Content should
  8029. * make no assumptions of frame rate or vsync behavior as the HMD runs
  8030. * asynchronously from other displays and at differing refresh rates.
  8031. * @param callback Define the eaction to run next frame
  8032. * @returns the request handle it
  8033. */
  8034. requestAnimationFrame(callback: FrameRequestCallback): number;
  8035. /**
  8036. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  8037. * Repeat calls while already presenting will update the VRLayers being displayed.
  8038. * @param layers Define the list of layer to present
  8039. * @returns a promise to know when the request has been fulfilled
  8040. */
  8041. requestPresent(layers: VRLayer[]): Promise<void>;
  8042. /**
  8043. * Reset the pose for this display, treating its current position and
  8044. * orientation as the "origin/zero" values. VRPose.position,
  8045. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  8046. * updated when calling resetPose(). This should be called in only
  8047. * sitting-space experiences.
  8048. */
  8049. resetPose(): void;
  8050. /**
  8051. * The VRLayer provided to the VRDisplay will be captured and presented
  8052. * in the HMD. Calling this function has the same effect on the source
  8053. * canvas as any other operation that uses its source image, and canvases
  8054. * created without preserveDrawingBuffer set to true will be cleared.
  8055. * @param pose Define the pose to submit
  8056. */
  8057. submitFrame(pose?: VRPose): void;
  8058. }
  8059. declare var VRDisplay: {
  8060. prototype: VRDisplay;
  8061. new (): VRDisplay;
  8062. };
  8063. interface VRLayer {
  8064. leftBounds?: number[] | Float32Array | null;
  8065. rightBounds?: number[] | Float32Array | null;
  8066. source?: HTMLCanvasElement | null;
  8067. }
  8068. interface VRDisplayCapabilities {
  8069. readonly canPresent: boolean;
  8070. readonly hasExternalDisplay: boolean;
  8071. readonly hasOrientation: boolean;
  8072. readonly hasPosition: boolean;
  8073. readonly maxLayers: number;
  8074. }
  8075. interface VREyeParameters {
  8076. /** @deprecated */
  8077. readonly fieldOfView: VRFieldOfView;
  8078. readonly offset: Float32Array;
  8079. readonly renderHeight: number;
  8080. readonly renderWidth: number;
  8081. }
  8082. interface VRFieldOfView {
  8083. readonly downDegrees: number;
  8084. readonly leftDegrees: number;
  8085. readonly rightDegrees: number;
  8086. readonly upDegrees: number;
  8087. }
  8088. interface VRFrameData {
  8089. readonly leftProjectionMatrix: Float32Array;
  8090. readonly leftViewMatrix: Float32Array;
  8091. readonly pose: VRPose;
  8092. readonly rightProjectionMatrix: Float32Array;
  8093. readonly rightViewMatrix: Float32Array;
  8094. readonly timestamp: number;
  8095. }
  8096. interface VRPose {
  8097. readonly angularAcceleration: Float32Array | null;
  8098. readonly angularVelocity: Float32Array | null;
  8099. readonly linearAcceleration: Float32Array | null;
  8100. readonly linearVelocity: Float32Array | null;
  8101. readonly orientation: Float32Array | null;
  8102. readonly position: Float32Array | null;
  8103. readonly timestamp: number;
  8104. }
  8105. interface VRStageParameters {
  8106. sittingToStandingTransform?: Float32Array;
  8107. sizeX?: number;
  8108. sizeY?: number;
  8109. }
  8110. interface Navigator {
  8111. getVRDisplays(): Promise<VRDisplay[]>;
  8112. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  8113. }
  8114. interface Window {
  8115. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  8116. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  8117. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  8118. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  8119. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  8120. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  8121. }
  8122. interface Gamepad {
  8123. readonly displayId: number;
  8124. }
  8125. declare module BABYLON {
  8126. /** @hidden */
  8127. class Collider {
  8128. /** Define if a collision was found */
  8129. collisionFound: boolean;
  8130. /**
  8131. * Define last intersection point in local space
  8132. */
  8133. intersectionPoint: Vector3;
  8134. /**
  8135. * Define last collided mesh
  8136. */
  8137. collidedMesh: Nullable<AbstractMesh>;
  8138. private _collisionPoint;
  8139. private _planeIntersectionPoint;
  8140. private _tempVector;
  8141. private _tempVector2;
  8142. private _tempVector3;
  8143. private _tempVector4;
  8144. private _edge;
  8145. private _baseToVertex;
  8146. private _destinationPoint;
  8147. private _slidePlaneNormal;
  8148. private _displacementVector;
  8149. /** @hidden */
  8150. /** @hidden */
  8151. private _velocity;
  8152. private _basePoint;
  8153. private _epsilon;
  8154. /** @hidden */
  8155. /** @hidden */
  8156. private _velocityWorld;
  8157. private _normalizedVelocity;
  8158. /** @hidden */
  8159. /** @hidden */
  8160. private _nearestDistance;
  8161. private _collisionMask;
  8162. collisionMask: number;
  8163. /**
  8164. * Gets the plane normal used to compute the sliding response (in local space)
  8165. */
  8166. readonly slidePlaneNormal: Vector3;
  8167. /** @hidden */
  8168. /** @hidden */
  8169. /** @hidden */
  8170. /** @hidden */
  8171. /** @hidden */
  8172. /** @hidden */
  8173. }
  8174. }
  8175. declare module BABYLON {
  8176. /** @hidden */
  8177. var CollisionWorker: string;
  8178. /** @hidden */
  8179. interface ICollisionCoordinator {
  8180. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  8181. init(scene: Scene): void;
  8182. destroy(): void;
  8183. onMeshAdded(mesh: AbstractMesh): void;
  8184. onMeshUpdated(mesh: AbstractMesh): void;
  8185. onMeshRemoved(mesh: AbstractMesh): void;
  8186. onGeometryAdded(geometry: Geometry): void;
  8187. onGeometryUpdated(geometry: Geometry): void;
  8188. onGeometryDeleted(geometry: Geometry): void;
  8189. }
  8190. /** @hidden */
  8191. interface SerializedMesh {
  8192. id: string;
  8193. name: string;
  8194. uniqueId: number;
  8195. geometryId: Nullable<string>;
  8196. sphereCenter: Array<number>;
  8197. sphereRadius: number;
  8198. boxMinimum: Array<number>;
  8199. boxMaximum: Array<number>;
  8200. worldMatrixFromCache: any;
  8201. subMeshes: Array<SerializedSubMesh>;
  8202. checkCollisions: boolean;
  8203. }
  8204. /** @hidden */
  8205. interface SerializedSubMesh {
  8206. position: number;
  8207. verticesStart: number;
  8208. verticesCount: number;
  8209. indexStart: number;
  8210. indexCount: number;
  8211. hasMaterial: boolean;
  8212. sphereCenter: Array<number>;
  8213. sphereRadius: number;
  8214. boxMinimum: Array<number>;
  8215. boxMaximum: Array<number>;
  8216. }
  8217. /**
  8218. * Interface describing the value associated with a geometry.
  8219. * @hidden
  8220. */
  8221. interface SerializedGeometry {
  8222. /**
  8223. * Defines the unique ID of the geometry
  8224. */
  8225. id: string;
  8226. /**
  8227. * Defines the array containing the positions
  8228. */
  8229. positions: Float32Array;
  8230. /**
  8231. * Defines the array containing the indices
  8232. */
  8233. indices: Uint32Array;
  8234. /**
  8235. * Defines the array containing the normals
  8236. */
  8237. normals: Float32Array;
  8238. }
  8239. /** @hidden */
  8240. interface BabylonMessage {
  8241. taskType: WorkerTaskType;
  8242. payload: InitPayload | CollidePayload | UpdatePayload;
  8243. }
  8244. /** @hidden */
  8245. interface SerializedColliderToWorker {
  8246. position: Array<number>;
  8247. velocity: Array<number>;
  8248. radius: Array<number>;
  8249. }
  8250. /** Defines supported task for worker process */
  8251. enum WorkerTaskType {
  8252. /** Initialization */
  8253. INIT = 0,
  8254. /** Update of geometry */
  8255. UPDATE = 1,
  8256. /** Evaluate collision */
  8257. COLLIDE = 2
  8258. }
  8259. /** @hidden */
  8260. interface WorkerReply {
  8261. error: WorkerReplyType;
  8262. taskType: WorkerTaskType;
  8263. payload?: any;
  8264. }
  8265. /** @hidden */
  8266. interface CollisionReplyPayload {
  8267. newPosition: Array<number>;
  8268. collisionId: number;
  8269. collidedMeshUniqueId: number;
  8270. }
  8271. /** @hidden */
  8272. interface InitPayload {
  8273. }
  8274. /** @hidden */
  8275. interface CollidePayload {
  8276. collisionId: number;
  8277. collider: SerializedColliderToWorker;
  8278. maximumRetry: number;
  8279. excludedMeshUniqueId: Nullable<number>;
  8280. }
  8281. /** @hidden */
  8282. interface UpdatePayload {
  8283. updatedMeshes: {
  8284. [n: number]: SerializedMesh;
  8285. };
  8286. updatedGeometries: {
  8287. [s: string]: SerializedGeometry;
  8288. };
  8289. removedMeshes: Array<number>;
  8290. removedGeometries: Array<string>;
  8291. }
  8292. /** Defines kind of replies returned by worker */
  8293. enum WorkerReplyType {
  8294. /** Success */
  8295. SUCCESS = 0,
  8296. /** Unkown error */
  8297. UNKNOWN_ERROR = 1
  8298. }
  8299. /** @hidden */
  8300. class CollisionCoordinatorWorker implements ICollisionCoordinator {
  8301. private _scene;
  8302. private _scaledPosition;
  8303. private _scaledVelocity;
  8304. private _collisionsCallbackArray;
  8305. private _init;
  8306. private _runningUpdated;
  8307. private _worker;
  8308. private _addUpdateMeshesList;
  8309. private _addUpdateGeometriesList;
  8310. private _toRemoveMeshesArray;
  8311. private _toRemoveGeometryArray;
  8312. constructor();
  8313. static SerializeMesh: (mesh: AbstractMesh) => SerializedMesh;
  8314. static SerializeGeometry: (geometry: Geometry) => SerializedGeometry;
  8315. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  8316. init(scene: Scene): void;
  8317. destroy(): void;
  8318. onMeshAdded(mesh: AbstractMesh): void;
  8319. onMeshUpdated: (transformNode: TransformNode) => void;
  8320. onMeshRemoved(mesh: AbstractMesh): void;
  8321. onGeometryAdded(geometry: Geometry): void;
  8322. onGeometryUpdated: (geometry: Geometry) => void;
  8323. onGeometryDeleted(geometry: Geometry): void;
  8324. private _afterRender;
  8325. private _onMessageFromWorker;
  8326. }
  8327. /** @hidden */
  8328. class CollisionCoordinatorLegacy implements ICollisionCoordinator {
  8329. private _scene;
  8330. private _scaledPosition;
  8331. private _scaledVelocity;
  8332. private _finalPosition;
  8333. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  8334. init(scene: Scene): void;
  8335. destroy(): void;
  8336. onMeshAdded(mesh: AbstractMesh): void;
  8337. onMeshUpdated(mesh: AbstractMesh): void;
  8338. onMeshRemoved(mesh: AbstractMesh): void;
  8339. onGeometryAdded(geometry: Geometry): void;
  8340. onGeometryUpdated(geometry: Geometry): void;
  8341. onGeometryDeleted(geometry: Geometry): void;
  8342. private _collideWithWorld;
  8343. }
  8344. }
  8345. declare function importScripts(...urls: string[]): void;
  8346. declare const safePostMessage: any;
  8347. declare module BABYLON {
  8348. /** @hidden */
  8349. var WorkerIncluded: boolean;
  8350. /** @hidden */
  8351. class CollisionCache {
  8352. private _meshes;
  8353. private _geometries;
  8354. getMeshes(): {
  8355. [n: number]: SerializedMesh;
  8356. };
  8357. getGeometries(): {
  8358. [s: number]: SerializedGeometry;
  8359. };
  8360. getMesh(id: any): SerializedMesh;
  8361. addMesh(mesh: SerializedMesh): void;
  8362. removeMesh(uniqueId: number): void;
  8363. getGeometry(id: string): SerializedGeometry;
  8364. addGeometry(geometry: SerializedGeometry): void;
  8365. removeGeometry(id: string): void;
  8366. }
  8367. /** @hidden */
  8368. class CollideWorker {
  8369. collider: Collider;
  8370. private _collisionCache;
  8371. private finalPosition;
  8372. private collisionsScalingMatrix;
  8373. private collisionTranformationMatrix;
  8374. constructor(collider: Collider, _collisionCache: CollisionCache, finalPosition: Vector3);
  8375. collideWithWorld(position: Vector3, velocity: Vector3, maximumRetry: number, excludedMeshUniqueId: Nullable<number>): void;
  8376. private checkCollision;
  8377. private processCollisionsForSubMeshes;
  8378. private collideForSubMesh;
  8379. private checkSubmeshCollision;
  8380. }
  8381. /** @hidden */
  8382. interface ICollisionDetector {
  8383. onInit(payload: InitPayload): void;
  8384. onUpdate(payload: UpdatePayload): void;
  8385. onCollision(payload: CollidePayload): void;
  8386. }
  8387. /** @hidden */
  8388. class CollisionDetectorTransferable implements ICollisionDetector {
  8389. private _collisionCache;
  8390. onInit(payload: InitPayload): void;
  8391. onUpdate(payload: UpdatePayload): void;
  8392. onCollision(payload: CollidePayload): void;
  8393. }
  8394. }
  8395. declare module BABYLON {
  8396. /**
  8397. * @hidden
  8398. */
  8399. class IntersectionInfo {
  8400. bu: Nullable<number>;
  8401. bv: Nullable<number>;
  8402. distance: number;
  8403. faceId: number;
  8404. subMeshId: number;
  8405. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  8406. }
  8407. /**
  8408. * Information about the result of picking within a scene
  8409. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  8410. */
  8411. class PickingInfo {
  8412. /**
  8413. * If the pick collided with an object
  8414. */
  8415. hit: boolean;
  8416. /**
  8417. * Distance away where the pick collided
  8418. */
  8419. distance: number;
  8420. /**
  8421. * The location of pick collision
  8422. */
  8423. pickedPoint: Nullable<Vector3>;
  8424. /**
  8425. * The mesh corresponding the the pick collision
  8426. */
  8427. pickedMesh: Nullable<AbstractMesh>;
  8428. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  8429. bu: number;
  8430. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  8431. bv: number;
  8432. /** The id of the face on the mesh that was picked */
  8433. faceId: number;
  8434. /** Id of the the submesh that was picked */
  8435. subMeshId: number;
  8436. /** If a sprite was picked, this will be the sprite the pick collided with */
  8437. pickedSprite: Nullable<Sprite>;
  8438. /**
  8439. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  8440. */
  8441. originMesh: Nullable<AbstractMesh>;
  8442. /**
  8443. * The ray that was used to perform the picking.
  8444. */
  8445. ray: Nullable<Ray>;
  8446. /**
  8447. * Gets the normal correspodning to the face the pick collided with
  8448. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  8449. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  8450. * @returns The normal correspodning to the face the pick collided with
  8451. */
  8452. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  8453. /**
  8454. * Gets the texture coordinates of where the pick occured
  8455. * @returns the vector containing the coordnates of the texture
  8456. */
  8457. getTextureCoordinates(): Nullable<Vector2>;
  8458. }
  8459. }
  8460. declare module BABYLON {
  8461. /**
  8462. * Class used to store bounding box information
  8463. */
  8464. class BoundingBox implements ICullable {
  8465. /**
  8466. * Gets the 8 vectors representing the bounding box in local space
  8467. */
  8468. vectors: Vector3[];
  8469. /**
  8470. * Gets the center of the bounding box in local space
  8471. */
  8472. center: Vector3;
  8473. /**
  8474. * Gets the center of the bounding box in world space
  8475. */
  8476. centerWorld: Vector3;
  8477. /**
  8478. * Gets the extend size in local space
  8479. */
  8480. extendSize: Vector3;
  8481. /**
  8482. * Gets the extend size in world space
  8483. */
  8484. extendSizeWorld: Vector3;
  8485. /**
  8486. * Gets the OBB (object bounding box) directions
  8487. */
  8488. directions: Vector3[];
  8489. /**
  8490. * Gets the 8 vectors representing the bounding box in world space
  8491. */
  8492. vectorsWorld: Vector3[];
  8493. /**
  8494. * Gets the minimum vector in world space
  8495. */
  8496. minimumWorld: Vector3;
  8497. /**
  8498. * Gets the maximum vector in world space
  8499. */
  8500. maximumWorld: Vector3;
  8501. /**
  8502. * Gets the minimum vector in local space
  8503. */
  8504. minimum: Vector3;
  8505. /**
  8506. * Gets the maximum vector in local space
  8507. */
  8508. maximum: Vector3;
  8509. private _worldMatrix;
  8510. /**
  8511. * @hidden
  8512. */
  8513. /**
  8514. * Creates a new bounding box
  8515. * @param min defines the minimum vector (in local space)
  8516. * @param max defines the maximum vector (in local space)
  8517. */
  8518. constructor(min: Vector3, max: Vector3);
  8519. /**
  8520. * Recreates the entire bounding box from scratch
  8521. * @param min defines the new minimum vector (in local space)
  8522. * @param max defines the new maximum vector (in local space)
  8523. */
  8524. reConstruct(min: Vector3, max: Vector3): void;
  8525. /**
  8526. * Scale the current bounding box by applying a scale factor
  8527. * @param factor defines the scale factor to apply
  8528. * @returns the current bounding box
  8529. */
  8530. scale(factor: number): BoundingBox;
  8531. /**
  8532. * Gets the world matrix of the bounding box
  8533. * @returns a matrix
  8534. */
  8535. getWorldMatrix(): Matrix;
  8536. /**
  8537. * Sets the world matrix stored in the bounding box
  8538. * @param matrix defines the matrix to store
  8539. * @returns current bounding box
  8540. */
  8541. setWorldMatrix(matrix: Matrix): BoundingBox;
  8542. /** @hidden */
  8543. /**
  8544. * Tests if the bounding box is intersecting the frustum planes
  8545. * @param frustumPlanes defines the frustum planes to test
  8546. * @returns true if there is an intersection
  8547. */
  8548. isInFrustum(frustumPlanes: Plane[]): boolean;
  8549. /**
  8550. * Tests if the bounding box is entirely inside the frustum planes
  8551. * @param frustumPlanes defines the frustum planes to test
  8552. * @returns true if there is an inclusion
  8553. */
  8554. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  8555. /**
  8556. * Tests if a point is inside the bounding box
  8557. * @param point defines the point to test
  8558. * @returns true if the point is inside the bounding box
  8559. */
  8560. intersectsPoint(point: Vector3): boolean;
  8561. /**
  8562. * Tests if the bounding box intersects with a bounding sphere
  8563. * @param sphere defines the sphere to test
  8564. * @returns true if there is an intersection
  8565. */
  8566. intersectsSphere(sphere: BoundingSphere): boolean;
  8567. /**
  8568. * Tests if the bounding box intersects with a box defined by a min and max vectors
  8569. * @param min defines the min vector to use
  8570. * @param max defines the max vector to use
  8571. * @returns true if there is an intersection
  8572. */
  8573. intersectsMinMax(min: Vector3, max: Vector3): boolean;
  8574. /**
  8575. * Tests if two bounding boxes are intersections
  8576. * @param box0 defines the first box to test
  8577. * @param box1 defines the second box to test
  8578. * @returns true if there is an intersection
  8579. */
  8580. static Intersects(box0: BoundingBox, box1: BoundingBox): boolean;
  8581. /**
  8582. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  8583. * @param minPoint defines the minimum vector of the bounding box
  8584. * @param maxPoint defines the maximum vector of the bounding box
  8585. * @param sphereCenter defines the sphere center
  8586. * @param sphereRadius defines the sphere radius
  8587. * @returns true if there is an intersection
  8588. */
  8589. static IntersectsSphere(minPoint: Vector3, maxPoint: Vector3, sphereCenter: Vector3, sphereRadius: number): boolean;
  8590. /**
  8591. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  8592. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  8593. * @param frustumPlanes defines the frustum planes to test
  8594. * @return true if there is an inclusion
  8595. */
  8596. static IsCompletelyInFrustum(boundingVectors: Vector3[], frustumPlanes: Plane[]): boolean;
  8597. /**
  8598. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  8599. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  8600. * @param frustumPlanes defines the frustum planes to test
  8601. * @return true if there is an intersection
  8602. */
  8603. static IsInFrustum(boundingVectors: Vector3[], frustumPlanes: Plane[]): boolean;
  8604. }
  8605. }
  8606. declare module BABYLON {
  8607. interface ICullable {
  8608. isInFrustum(frustumPlanes: Plane[]): boolean;
  8609. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  8610. }
  8611. class BoundingInfo implements ICullable {
  8612. minimum: Vector3;
  8613. maximum: Vector3;
  8614. boundingBox: BoundingBox;
  8615. boundingSphere: BoundingSphere;
  8616. private _isLocked;
  8617. constructor(minimum: Vector3, maximum: Vector3);
  8618. isLocked: boolean;
  8619. update(world: Matrix): void;
  8620. /**
  8621. * Recreate the bounding info to be centered around a specific point given a specific extend.
  8622. * @param center New center of the bounding info
  8623. * @param extend New extend of the bounding info
  8624. */
  8625. centerOn(center: Vector3, extend: Vector3): BoundingInfo;
  8626. /**
  8627. * Scale the current bounding info by applying a scale factor
  8628. * @param factor defines the scale factor to apply
  8629. * @returns the current bounding info
  8630. */
  8631. scale(factor: number): BoundingInfo;
  8632. /**
  8633. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  8634. * @param frustumPlanes defines the frustum to test
  8635. * @param strategy defines the strategy to use for the culling (default is BABYLON.Scene.CULLINGSTRATEGY_STANDARD)
  8636. * @returns true if the bounding info is in the frustum planes
  8637. */
  8638. isInFrustum(frustumPlanes: Plane[], strategy?: number): boolean;
  8639. /**
  8640. * Gets the world distance between the min and max points of the bounding box
  8641. */
  8642. readonly diagonalLength: number;
  8643. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  8644. /** @hidden */
  8645. intersectsPoint(point: Vector3): boolean;
  8646. intersects(boundingInfo: BoundingInfo, precise: boolean): boolean;
  8647. }
  8648. }
  8649. declare module BABYLON {
  8650. class BoundingSphere {
  8651. center: Vector3;
  8652. radius: number;
  8653. centerWorld: Vector3;
  8654. radiusWorld: number;
  8655. minimum: Vector3;
  8656. maximum: Vector3;
  8657. /**
  8658. * Creates a new bounding sphere
  8659. * @param min defines the minimum vector (in local space)
  8660. * @param max defines the maximum vector (in local space)
  8661. */
  8662. constructor(min: Vector3, max: Vector3);
  8663. /**
  8664. * Recreates the entire bounding sphere from scratch
  8665. * @param min defines the new minimum vector (in local space)
  8666. * @param max defines the new maximum vector (in local space)
  8667. */
  8668. reConstruct(min: Vector3, max: Vector3): void;
  8669. /**
  8670. * Scale the current bounding sphere by applying a scale factor
  8671. * @param factor defines the scale factor to apply
  8672. * @returns the current bounding box
  8673. */
  8674. scale(factor: number): BoundingSphere;
  8675. /** @hidden */
  8676. isInFrustum(frustumPlanes: Plane[]): boolean;
  8677. intersectsPoint(point: Vector3): boolean;
  8678. static Intersects(sphere0: BoundingSphere, sphere1: BoundingSphere): boolean;
  8679. }
  8680. }
  8681. declare module BABYLON {
  8682. class Ray {
  8683. origin: Vector3;
  8684. direction: Vector3;
  8685. length: number;
  8686. private _edge1;
  8687. private _edge2;
  8688. private _pvec;
  8689. private _tvec;
  8690. private _qvec;
  8691. private _tmpRay;
  8692. constructor(origin: Vector3, direction: Vector3, length?: number);
  8693. intersectsBoxMinMax(minimum: Vector3, maximum: Vector3): boolean;
  8694. intersectsBox(box: BoundingBox): boolean;
  8695. intersectsSphere(sphere: BoundingSphere): boolean;
  8696. intersectsTriangle(vertex0: Vector3, vertex1: Vector3, vertex2: Vector3): Nullable<IntersectionInfo>;
  8697. intersectsPlane(plane: Plane): Nullable<number>;
  8698. intersectsMesh(mesh: AbstractMesh, fastCheck?: boolean): PickingInfo;
  8699. intersectsMeshes(meshes: Array<AbstractMesh>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  8700. private _comparePickingInfo;
  8701. private static smallnum;
  8702. private static rayl;
  8703. /**
  8704. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  8705. * @param sega the first point of the segment to test the intersection against
  8706. * @param segb the second point of the segment to test the intersection against
  8707. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  8708. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  8709. */
  8710. intersectionSegment(sega: Vector3, segb: Vector3, threshold: number): number;
  8711. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Ray;
  8712. static Zero(): Ray;
  8713. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Ray;
  8714. /**
  8715. * 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
  8716. * transformed to the given world matrix.
  8717. * @param origin The origin point
  8718. * @param end The end point
  8719. * @param world a matrix to transform the ray to. Default is the identity matrix.
  8720. */
  8721. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: Matrix): Ray;
  8722. static Transform(ray: Ray, matrix: Matrix): Ray;
  8723. static TransformToRef(ray: Ray, matrix: Matrix, result: Ray): void;
  8724. }
  8725. }
  8726. /**
  8727. * Module Debug contains the (visual) components to debug a scene correctly
  8728. */
  8729. declare module BABYLON.Debug {
  8730. /**
  8731. * The Axes viewer will show 3 axes in a specific point in space
  8732. */
  8733. class AxesViewer {
  8734. private _xline;
  8735. private _yline;
  8736. private _zline;
  8737. private _xmesh;
  8738. private _ymesh;
  8739. private _zmesh;
  8740. /**
  8741. * Gets the hosting scene
  8742. */
  8743. scene: Nullable<Scene>;
  8744. /**
  8745. * Gets or sets a number used to scale line length
  8746. */
  8747. scaleLines: number;
  8748. /**
  8749. * Creates a new AxesViewer
  8750. * @param scene defines the hosting scene
  8751. * @param scaleLines defines a number used to scale line length (1 by default)
  8752. */
  8753. constructor(scene: Scene, scaleLines?: number);
  8754. /**
  8755. * Force the viewer to update
  8756. * @param position defines the position of the viewer
  8757. * @param xaxis defines the x axis of the viewer
  8758. * @param yaxis defines the y axis of the viewer
  8759. * @param zaxis defines the z axis of the viewer
  8760. */
  8761. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  8762. /** Releases resources */
  8763. dispose(): void;
  8764. }
  8765. }
  8766. declare module BABYLON.Debug {
  8767. /**
  8768. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  8769. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  8770. */
  8771. class BoneAxesViewer extends AxesViewer {
  8772. /**
  8773. * Gets or sets the target mesh where to display the axes viewer
  8774. */
  8775. mesh: Nullable<Mesh>;
  8776. /**
  8777. * Gets or sets the target bone where to display the axes viewer
  8778. */
  8779. bone: Nullable<Bone>;
  8780. /** Gets current position */
  8781. pos: Vector3;
  8782. /** Gets direction of X axis */
  8783. xaxis: Vector3;
  8784. /** Gets direction of Y axis */
  8785. yaxis: Vector3;
  8786. /** Gets direction of Z axis */
  8787. zaxis: Vector3;
  8788. /**
  8789. * Creates a new BoneAxesViewer
  8790. * @param scene defines the hosting scene
  8791. * @param bone defines the target bone
  8792. * @param mesh defines the target mesh
  8793. * @param scaleLines defines a scaling factor for line length (1 by default)
  8794. */
  8795. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  8796. /**
  8797. * Force the viewer to update
  8798. */
  8799. update(): void;
  8800. /** Releases resources */
  8801. dispose(): void;
  8802. }
  8803. }
  8804. declare module BABYLON {
  8805. interface Scene {
  8806. /**
  8807. * @hidden
  8808. * Backing field
  8809. */
  8810. /**
  8811. * Gets the debug layer (aka Inspector) associated with the scene
  8812. * @see http://doc.babylonjs.com/features/playground_debuglayer
  8813. */
  8814. debugLayer: DebugLayer;
  8815. }
  8816. /**
  8817. * The debug layer (aka Inspector) is the go to tool in order to better understand
  8818. * what is happening in your scene
  8819. * @see http://doc.babylonjs.com/features/playground_debuglayer
  8820. */
  8821. class DebugLayer {
  8822. /**
  8823. * Define the url to get the inspector script from.
  8824. * By default it uses the babylonjs CDN.
  8825. * @ignoreNaming
  8826. */
  8827. static InspectorURL: string;
  8828. private _scene;
  8829. private _inspector;
  8830. private BJSINSPECTOR;
  8831. /**
  8832. * Observable triggered when a property is changed through the inspector.
  8833. */
  8834. onPropertyChangedObservable: Observable<{
  8835. object: any;
  8836. property: string;
  8837. value: any;
  8838. initialValue: any;
  8839. }>;
  8840. /**
  8841. * Instantiates a new debug layer.
  8842. * The debug layer (aka Inspector) is the go to tool in order to better understand
  8843. * what is happening in your scene
  8844. * @see http://doc.babylonjs.com/features/playground_debuglayer
  8845. * @param scene Defines the scene to inspect
  8846. */
  8847. constructor(scene: Scene);
  8848. /** Creates the inspector window. */
  8849. private _createInspector;
  8850. /**
  8851. * Get if the inspector is visible or not.
  8852. * @returns true if visible otherwise, false
  8853. */
  8854. isVisible(): boolean;
  8855. /**
  8856. * Hide the inspector and close its window.
  8857. */
  8858. hide(): void;
  8859. /**
  8860. *
  8861. * Launch the debugLayer.
  8862. *
  8863. * initialTab:
  8864. * | Value | Tab Name |
  8865. * | --- | --- |
  8866. * | 0 | Scene |
  8867. * | 1 | Console |
  8868. * | 2 | Stats |
  8869. * | 3 | Textures |
  8870. * | 4 | Mesh |
  8871. * | 5 | Light |
  8872. * | 6 | Material |
  8873. * | 7 | GLTF |
  8874. * | 8 | GUI |
  8875. * | 9 | Physics |
  8876. * | 10 | Camera |
  8877. * | 11 | Audio |
  8878. *
  8879. * @param config Define the configuration of the inspector
  8880. */
  8881. show(config?: {
  8882. popup?: boolean;
  8883. initialTab?: number | string;
  8884. parentElement?: HTMLElement;
  8885. newColors?: {
  8886. backgroundColor?: string;
  8887. backgroundColorLighter?: string;
  8888. backgroundColorLighter2?: string;
  8889. backgroundColorLighter3?: string;
  8890. color?: string;
  8891. colorTop?: string;
  8892. colorBot?: string;
  8893. };
  8894. }): void;
  8895. /**
  8896. * Gets the active tab
  8897. * @return the index of the active tab or -1 if the inspector is hidden
  8898. */
  8899. getActiveTab(): number;
  8900. }
  8901. }
  8902. declare module BABYLON.Debug {
  8903. /**
  8904. * Used to show the physics impostor around the specific mesh
  8905. */
  8906. class PhysicsViewer {
  8907. /** @hidden */
  8908. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  8909. /** @hidden */
  8910. protected _meshes: Array<Nullable<AbstractMesh>>;
  8911. /** @hidden */
  8912. protected _scene: Nullable<Scene>;
  8913. /** @hidden */
  8914. protected _numMeshes: number;
  8915. /** @hidden */
  8916. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  8917. private _renderFunction;
  8918. private _debugBoxMesh;
  8919. private _debugSphereMesh;
  8920. private _debugMaterial;
  8921. /**
  8922. * Creates a new PhysicsViewer
  8923. * @param scene defines the hosting scene
  8924. */
  8925. constructor(scene: Scene);
  8926. /** @hidden */
  8927. protected _updateDebugMeshes(): void;
  8928. /**
  8929. * Renders a specified physic impostor
  8930. * @param impostor defines the impostor to render
  8931. */
  8932. showImpostor(impostor: PhysicsImpostor): void;
  8933. /**
  8934. * Hides a specified physic impostor
  8935. * @param impostor defines the impostor to hide
  8936. */
  8937. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  8938. private _getDebugMaterial;
  8939. private _getDebugBoxMesh;
  8940. private _getDebugSphereMesh;
  8941. private _getDebugMesh;
  8942. /** Releases all resources */
  8943. dispose(): void;
  8944. }
  8945. }
  8946. declare module BABYLON {
  8947. /**
  8948. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  8949. * in order to better appreciate the issue one might have.
  8950. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  8951. */
  8952. class RayHelper {
  8953. /**
  8954. * Defines the ray we are currently tryin to visualize.
  8955. */
  8956. ray: Nullable<Ray>;
  8957. private _renderPoints;
  8958. private _renderLine;
  8959. private _renderFunction;
  8960. private _scene;
  8961. private _updateToMeshFunction;
  8962. private _attachedToMesh;
  8963. private _meshSpaceDirection;
  8964. private _meshSpaceOrigin;
  8965. /**
  8966. * Helper function to create a colored helper in a scene in one line.
  8967. * @param ray Defines the ray we are currently tryin to visualize
  8968. * @param scene Defines the scene the ray is used in
  8969. * @param color Defines the color we want to see the ray in
  8970. * @returns The newly created ray helper.
  8971. */
  8972. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  8973. /**
  8974. * Instantiate a new ray helper.
  8975. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  8976. * in order to better appreciate the issue one might have.
  8977. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  8978. * @param ray Defines the ray we are currently tryin to visualize
  8979. */
  8980. constructor(ray: Ray);
  8981. /**
  8982. * Shows the ray we are willing to debug.
  8983. * @param scene Defines the scene the ray needs to be rendered in
  8984. * @param color Defines the color the ray needs to be rendered in
  8985. */
  8986. show(scene: Scene, color?: Color3): void;
  8987. /**
  8988. * Hides the ray we are debugging.
  8989. */
  8990. hide(): void;
  8991. private _render;
  8992. /**
  8993. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  8994. * @param mesh Defines the mesh we want the helper attached to
  8995. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  8996. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  8997. * @param length Defines the length of the ray
  8998. */
  8999. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  9000. /**
  9001. * Detach the ray helper from the mesh it has previously been attached to.
  9002. */
  9003. detachFromMesh(): void;
  9004. private _updateToMesh;
  9005. /**
  9006. * Dispose the helper and release its associated resources.
  9007. */
  9008. dispose(): void;
  9009. }
  9010. }
  9011. declare module BABYLON.Debug {
  9012. /**
  9013. * Class used to render a debug view of a given skeleton
  9014. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  9015. */
  9016. class SkeletonViewer {
  9017. /** defines the skeleton to render */
  9018. skeleton: Skeleton;
  9019. /** defines the mesh attached to the skeleton */
  9020. mesh: AbstractMesh;
  9021. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  9022. autoUpdateBonesMatrices: boolean;
  9023. /** defines the rendering group id to use with the viewer */
  9024. renderingGroupId: number;
  9025. /** Gets or sets the color used to render the skeleton */
  9026. color: Color3;
  9027. private _scene;
  9028. private _debugLines;
  9029. private _debugMesh;
  9030. private _isEnabled;
  9031. private _renderFunction;
  9032. /**
  9033. * Creates a new SkeletonViewer
  9034. * @param skeleton defines the skeleton to render
  9035. * @param mesh defines the mesh attached to the skeleton
  9036. * @param scene defines the hosting scene
  9037. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  9038. * @param renderingGroupId defines the rendering group id to use with the viewer
  9039. */
  9040. constructor(
  9041. /** defines the skeleton to render */
  9042. skeleton: Skeleton,
  9043. /** defines the mesh attached to the skeleton */
  9044. mesh: AbstractMesh, scene: Scene,
  9045. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  9046. autoUpdateBonesMatrices?: boolean,
  9047. /** defines the rendering group id to use with the viewer */
  9048. renderingGroupId?: number);
  9049. /** Gets or sets a boolean indicating if the viewer is enabled */
  9050. isEnabled: boolean;
  9051. private _getBonePosition;
  9052. private _getLinesForBonesWithLength;
  9053. private _getLinesForBonesNoLength;
  9054. /** Update the viewer to sync with current skeleton state */
  9055. update(): void;
  9056. /** Release associated resources */
  9057. dispose(): void;
  9058. }
  9059. }
  9060. declare module BABYLON {
  9061. /**
  9062. * Interface for attribute information associated with buffer instanciation
  9063. */
  9064. class InstancingAttributeInfo {
  9065. /**
  9066. * Index/offset of the attribute in the vertex shader
  9067. */
  9068. index: number;
  9069. /**
  9070. * size of the attribute, 1, 2, 3 or 4
  9071. */
  9072. attributeSize: number;
  9073. /**
  9074. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  9075. * default is FLOAT
  9076. */
  9077. attribyteType: number;
  9078. /**
  9079. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  9080. */
  9081. normalized: boolean;
  9082. /**
  9083. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  9084. */
  9085. offset: number;
  9086. /**
  9087. * Name of the GLSL attribute, for debugging purpose only
  9088. */
  9089. attributeName: string;
  9090. }
  9091. /**
  9092. * Define options used to create a render target texture
  9093. */
  9094. class RenderTargetCreationOptions {
  9095. /**
  9096. * Specifies is mipmaps must be generated
  9097. */
  9098. generateMipMaps?: boolean;
  9099. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  9100. generateDepthBuffer?: boolean;
  9101. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  9102. generateStencilBuffer?: boolean;
  9103. /** Defines texture type (int by default) */
  9104. type?: number;
  9105. /** Defines sampling mode (trilinear by default) */
  9106. samplingMode?: number;
  9107. /** Defines format (RGBA by default) */
  9108. format?: number;
  9109. }
  9110. /**
  9111. * Define options used to create a depth texture
  9112. */
  9113. class DepthTextureCreationOptions {
  9114. /** Specifies whether or not a stencil should be allocated in the texture */
  9115. generateStencil?: boolean;
  9116. /** Specifies whether or not bilinear filtering is enable on the texture */
  9117. bilinearFiltering?: boolean;
  9118. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  9119. comparisonFunction?: number;
  9120. /** Specifies if the created texture is a cube texture */
  9121. isCube?: boolean;
  9122. }
  9123. /**
  9124. * Class used to describe the capabilities of the engine relatively to the current browser
  9125. */
  9126. class EngineCapabilities {
  9127. /** Maximum textures units per fragment shader */
  9128. maxTexturesImageUnits: number;
  9129. /** Maximum texture units per vertex shader */
  9130. maxVertexTextureImageUnits: number;
  9131. /** Maximum textures units in the entire pipeline */
  9132. maxCombinedTexturesImageUnits: number;
  9133. /** Maximum texture size */
  9134. maxTextureSize: number;
  9135. /** Maximum cube texture size */
  9136. maxCubemapTextureSize: number;
  9137. /** Maximum render texture size */
  9138. maxRenderTextureSize: number;
  9139. /** Maximum number of vertex attributes */
  9140. maxVertexAttribs: number;
  9141. /** Maximum number of varyings */
  9142. maxVaryingVectors: number;
  9143. /** Maximum number of uniforms per vertex shader */
  9144. maxVertexUniformVectors: number;
  9145. /** Maximum number of uniforms per fragment shader */
  9146. maxFragmentUniformVectors: number;
  9147. /** Defines if standard derivates (dx/dy) are supported */
  9148. standardDerivatives: boolean;
  9149. /** Defines if s3tc texture compression is supported */
  9150. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  9151. /** Defines if pvrtc texture compression is supported */
  9152. pvrtc: any;
  9153. /** Defines if etc1 texture compression is supported */
  9154. etc1: any;
  9155. /** Defines if etc2 texture compression is supported */
  9156. etc2: any;
  9157. /** Defines if astc texture compression is supported */
  9158. astc: any;
  9159. /** Defines if float textures are supported */
  9160. textureFloat: boolean;
  9161. /** Defines if vertex array objects are supported */
  9162. vertexArrayObject: boolean;
  9163. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  9164. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  9165. /** Gets the maximum level of anisotropy supported */
  9166. maxAnisotropy: number;
  9167. /** Defines if instancing is supported */
  9168. instancedArrays: boolean;
  9169. /** Defines if 32 bits indices are supported */
  9170. uintIndices: boolean;
  9171. /** Defines if high precision shaders are supported */
  9172. highPrecisionShaderSupported: boolean;
  9173. /** Defines if depth reading in the fragment shader is supported */
  9174. fragmentDepthSupported: boolean;
  9175. /** Defines if float texture linear filtering is supported*/
  9176. textureFloatLinearFiltering: boolean;
  9177. /** Defines if rendering to float textures is supported */
  9178. textureFloatRender: boolean;
  9179. /** Defines if half float textures are supported*/
  9180. textureHalfFloat: boolean;
  9181. /** Defines if half float texture linear filtering is supported*/
  9182. textureHalfFloatLinearFiltering: boolean;
  9183. /** Defines if rendering to half float textures is supported */
  9184. textureHalfFloatRender: boolean;
  9185. /** Defines if textureLOD shader command is supported */
  9186. textureLOD: boolean;
  9187. /** Defines if draw buffers extension is supported */
  9188. drawBuffersExtension: boolean;
  9189. /** Defines if depth textures are supported */
  9190. depthTextureExtension: boolean;
  9191. /** Defines if float color buffer are supported */
  9192. colorBufferFloat: boolean;
  9193. /** Gets disjoint timer query extension (null if not supported) */
  9194. timerQuery: EXT_disjoint_timer_query;
  9195. /** Defines if timestamp can be used with timer query */
  9196. canUseTimestampForTimerQuery: boolean;
  9197. }
  9198. /** Interface defining initialization parameters for Engine class */
  9199. interface EngineOptions extends WebGLContextAttributes {
  9200. /**
  9201. * Defines if the engine should no exceed a specified device ratio
  9202. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  9203. */
  9204. limitDeviceRatio?: number;
  9205. /**
  9206. * Defines if webvr should be enabled automatically
  9207. * @see http://doc.babylonjs.com/how_to/webvr_camera
  9208. */
  9209. autoEnableWebVR?: boolean;
  9210. /**
  9211. * Defines if webgl2 should be turned off even if supported
  9212. * @see http://doc.babylonjs.com/features/webgl2
  9213. */
  9214. disableWebGL2Support?: boolean;
  9215. /**
  9216. * Defines if webaudio should be initialized as well
  9217. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  9218. */
  9219. audioEngine?: boolean;
  9220. /**
  9221. * Defines if animations should run using a deterministic lock step
  9222. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  9223. */
  9224. deterministicLockstep?: boolean;
  9225. /** Defines the maximum steps to use with deterministic lock step mode */
  9226. lockstepMaxSteps?: number;
  9227. /**
  9228. * Defines that engine should ignore context lost events
  9229. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  9230. */
  9231. doNotHandleContextLost?: boolean;
  9232. }
  9233. /**
  9234. * Defines the interface used by display changed events
  9235. */
  9236. interface IDisplayChangedEventArgs {
  9237. /** Gets the vrDisplay object (if any) */
  9238. vrDisplay: Nullable<any>;
  9239. /** Gets a boolean indicating if webVR is supported */
  9240. vrSupported: boolean;
  9241. }
  9242. /**
  9243. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  9244. */
  9245. class Engine {
  9246. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  9247. static ExceptionList: ({
  9248. key: string;
  9249. capture: string;
  9250. captureConstraint: number;
  9251. targets: string[];
  9252. } | {
  9253. key: string;
  9254. capture: null;
  9255. captureConstraint: null;
  9256. targets: string[];
  9257. })[];
  9258. /** Gets the list of created engines */
  9259. static Instances: Engine[];
  9260. /**
  9261. * Gets the latest created engine
  9262. */
  9263. static readonly LastCreatedEngine: Nullable<Engine>;
  9264. /**
  9265. * Gets the latest created scene
  9266. */
  9267. static readonly LastCreatedScene: Nullable<Scene>;
  9268. /**
  9269. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  9270. * @param flag defines which part of the materials must be marked as dirty
  9271. * @param predicate defines a predicate used to filter which materials should be affected
  9272. */
  9273. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  9274. /**
  9275. * Hidden
  9276. */
  9277. private static _TextureLoaders: IInternalTextureLoader[];
  9278. /** Defines that alpha blending is disabled */
  9279. static readonly ALPHA_DISABLE: number;
  9280. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  9281. static readonly ALPHA_ADD: number;
  9282. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  9283. static readonly ALPHA_COMBINE: number;
  9284. /** Defines that alpha blending to DEST - SRC * DEST */
  9285. static readonly ALPHA_SUBTRACT: number;
  9286. /** Defines that alpha blending to SRC * DEST */
  9287. static readonly ALPHA_MULTIPLY: number;
  9288. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  9289. static readonly ALPHA_MAXIMIZED: number;
  9290. /** Defines that alpha blending to SRC + DEST */
  9291. static readonly ALPHA_ONEONE: number;
  9292. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  9293. static readonly ALPHA_PREMULTIPLIED: number;
  9294. /**
  9295. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  9296. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  9297. */
  9298. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  9299. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  9300. static readonly ALPHA_INTERPOLATE: number;
  9301. /**
  9302. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  9303. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  9304. */
  9305. static readonly ALPHA_SCREENMODE: number;
  9306. /** Defines that the ressource is not delayed*/
  9307. static readonly DELAYLOADSTATE_NONE: number;
  9308. /** Defines that the ressource was successfully delay loaded */
  9309. static readonly DELAYLOADSTATE_LOADED: number;
  9310. /** Defines that the ressource is currently delay loading */
  9311. static readonly DELAYLOADSTATE_LOADING: number;
  9312. /** Defines that the ressource is delayed and has not started loading */
  9313. static readonly DELAYLOADSTATE_NOTLOADED: number;
  9314. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  9315. static readonly NEVER: number;
  9316. /** 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 */
  9317. static readonly ALWAYS: number;
  9318. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  9319. static readonly LESS: number;
  9320. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  9321. static readonly EQUAL: number;
  9322. /** 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 */
  9323. static readonly LEQUAL: number;
  9324. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  9325. static readonly GREATER: number;
  9326. /** 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 */
  9327. static readonly GEQUAL: number;
  9328. /** 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 */
  9329. static readonly NOTEQUAL: number;
  9330. /** Passed to stencilOperation to specify that stencil value must be kept */
  9331. static readonly KEEP: number;
  9332. /** Passed to stencilOperation to specify that stencil value must be replaced */
  9333. static readonly REPLACE: number;
  9334. /** Passed to stencilOperation to specify that stencil value must be incremented */
  9335. static readonly INCR: number;
  9336. /** Passed to stencilOperation to specify that stencil value must be decremented */
  9337. static readonly DECR: number;
  9338. /** Passed to stencilOperation to specify that stencil value must be inverted */
  9339. static readonly INVERT: number;
  9340. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  9341. static readonly INCR_WRAP: number;
  9342. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  9343. static readonly DECR_WRAP: number;
  9344. /** Texture is not repeating outside of 0..1 UVs */
  9345. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  9346. /** Texture is repeating outside of 0..1 UVs */
  9347. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  9348. /** Texture is repeating and mirrored */
  9349. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  9350. /** ALPHA */
  9351. static readonly TEXTUREFORMAT_ALPHA: number;
  9352. /** LUMINANCE */
  9353. static readonly TEXTUREFORMAT_LUMINANCE: number;
  9354. /** LUMINANCE_ALPHA */
  9355. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  9356. /** RGB */
  9357. static readonly TEXTUREFORMAT_RGB: number;
  9358. /** RGBA */
  9359. static readonly TEXTUREFORMAT_RGBA: number;
  9360. /** RED */
  9361. static readonly TEXTUREFORMAT_RED: number;
  9362. /** RED (2nd reference) */
  9363. static readonly TEXTUREFORMAT_R: number;
  9364. /** RG */
  9365. static readonly TEXTUREFORMAT_RG: number;
  9366. /** RED_INTEGER */
  9367. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  9368. /** RED_INTEGER (2nd reference) */
  9369. static readonly TEXTUREFORMAT_R_INTEGER: number;
  9370. /** RG_INTEGER */
  9371. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  9372. /** RGB_INTEGER */
  9373. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  9374. /** RGBA_INTEGER */
  9375. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  9376. /** UNSIGNED_BYTE */
  9377. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  9378. /** UNSIGNED_BYTE (2nd reference) */
  9379. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  9380. /** FLOAT */
  9381. static readonly TEXTURETYPE_FLOAT: number;
  9382. /** HALF_FLOAT */
  9383. static readonly TEXTURETYPE_HALF_FLOAT: number;
  9384. /** BYTE */
  9385. static readonly TEXTURETYPE_BYTE: number;
  9386. /** SHORT */
  9387. static readonly TEXTURETYPE_SHORT: number;
  9388. /** UNSIGNED_SHORT */
  9389. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  9390. /** INT */
  9391. static readonly TEXTURETYPE_INT: number;
  9392. /** UNSIGNED_INT */
  9393. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  9394. /** UNSIGNED_SHORT_4_4_4_4 */
  9395. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  9396. /** UNSIGNED_SHORT_5_5_5_1 */
  9397. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  9398. /** UNSIGNED_SHORT_5_6_5 */
  9399. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  9400. /** UNSIGNED_INT_2_10_10_10_REV */
  9401. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  9402. /** UNSIGNED_INT_24_8 */
  9403. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  9404. /** UNSIGNED_INT_10F_11F_11F_REV */
  9405. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  9406. /** UNSIGNED_INT_5_9_9_9_REV */
  9407. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  9408. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  9409. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  9410. /** nearest is mag = nearest and min = nearest and mip = linear */
  9411. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  9412. /** Bilinear is mag = linear and min = linear and mip = nearest */
  9413. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  9414. /** Trilinear is mag = linear and min = linear and mip = linear */
  9415. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  9416. /** nearest is mag = nearest and min = nearest and mip = linear */
  9417. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  9418. /** Bilinear is mag = linear and min = linear and mip = nearest */
  9419. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  9420. /** Trilinear is mag = linear and min = linear and mip = linear */
  9421. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  9422. /** mag = nearest and min = nearest and mip = nearest */
  9423. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  9424. /** mag = nearest and min = linear and mip = nearest */
  9425. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  9426. /** mag = nearest and min = linear and mip = linear */
  9427. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  9428. /** mag = nearest and min = linear and mip = none */
  9429. static readonly TEXTURE_NEAREST_LINEAR: number;
  9430. /** mag = nearest and min = nearest and mip = none */
  9431. static readonly TEXTURE_NEAREST_NEAREST: number;
  9432. /** mag = linear and min = nearest and mip = nearest */
  9433. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  9434. /** mag = linear and min = nearest and mip = linear */
  9435. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  9436. /** mag = linear and min = linear and mip = none */
  9437. static readonly TEXTURE_LINEAR_LINEAR: number;
  9438. /** mag = linear and min = nearest and mip = none */
  9439. static readonly TEXTURE_LINEAR_NEAREST: number;
  9440. /** Explicit coordinates mode */
  9441. static readonly TEXTURE_EXPLICIT_MODE: number;
  9442. /** Spherical coordinates mode */
  9443. static readonly TEXTURE_SPHERICAL_MODE: number;
  9444. /** Planar coordinates mode */
  9445. static readonly TEXTURE_PLANAR_MODE: number;
  9446. /** Cubic coordinates mode */
  9447. static readonly TEXTURE_CUBIC_MODE: number;
  9448. /** Projection coordinates mode */
  9449. static readonly TEXTURE_PROJECTION_MODE: number;
  9450. /** Skybox coordinates mode */
  9451. static readonly TEXTURE_SKYBOX_MODE: number;
  9452. /** Inverse Cubic coordinates mode */
  9453. static readonly TEXTURE_INVCUBIC_MODE: number;
  9454. /** Equirectangular coordinates mode */
  9455. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  9456. /** Equirectangular Fixed coordinates mode */
  9457. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  9458. /** Equirectangular Fixed Mirrored coordinates mode */
  9459. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  9460. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  9461. static readonly SCALEMODE_FLOOR: number;
  9462. /** Defines that texture rescaling will look for the nearest power of 2 size */
  9463. static readonly SCALEMODE_NEAREST: number;
  9464. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  9465. static readonly SCALEMODE_CEILING: number;
  9466. /**
  9467. * Returns the current version of the framework
  9468. */
  9469. static readonly Version: string;
  9470. /**
  9471. * Gets or sets the epsilon value used by collision engine
  9472. */
  9473. static CollisionsEpsilon: number;
  9474. /**
  9475. * Gets or sets the relative url used to load code if using the engine in non-minified mode
  9476. */
  9477. static CodeRepository: string;
  9478. /**
  9479. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  9480. */
  9481. static ShadersRepository: string;
  9482. /**
  9483. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  9484. */
  9485. forcePOTTextures: boolean;
  9486. /**
  9487. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  9488. */
  9489. isFullscreen: boolean;
  9490. /**
  9491. * Gets a boolean indicating if the pointer is currently locked
  9492. */
  9493. isPointerLock: boolean;
  9494. /**
  9495. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  9496. */
  9497. cullBackFaces: boolean;
  9498. /**
  9499. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  9500. */
  9501. renderEvenInBackground: boolean;
  9502. /**
  9503. * Gets or sets a boolean indicating that cache can be kept between frames
  9504. */
  9505. preventCacheWipeBetweenFrames: boolean;
  9506. /**
  9507. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  9508. **/
  9509. enableOfflineSupport: boolean;
  9510. /**
  9511. * Gets or sets a boolean to enable/disable checking manifest if IndexedDB support is enabled (Babylon.js will always consider the database is up to date)
  9512. **/
  9513. disableManifestCheck: boolean;
  9514. /**
  9515. * Gets the list of created scenes
  9516. */
  9517. scenes: Scene[];
  9518. /**
  9519. * Gets the list of created postprocesses
  9520. */
  9521. postProcesses: PostProcess[];
  9522. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  9523. validateShaderPrograms: boolean;
  9524. /**
  9525. * Observable event triggered each time the rendering canvas is resized
  9526. */
  9527. onResizeObservable: Observable<Engine>;
  9528. /**
  9529. * Observable event triggered each time the canvas loses focus
  9530. */
  9531. onCanvasBlurObservable: Observable<Engine>;
  9532. /**
  9533. * Observable event triggered each time the canvas gains focus
  9534. */
  9535. onCanvasFocusObservable: Observable<Engine>;
  9536. /**
  9537. * Observable event triggered each time the canvas receives pointerout event
  9538. */
  9539. onCanvasPointerOutObservable: Observable<PointerEvent>;
  9540. /**
  9541. * Observable event triggered before each texture is initialized
  9542. */
  9543. onBeforeTextureInitObservable: Observable<Texture>;
  9544. private _vrDisplay;
  9545. private _vrSupported;
  9546. private _oldSize;
  9547. private _oldHardwareScaleFactor;
  9548. private _vrExclusivePointerMode;
  9549. private _webVRInitPromise;
  9550. /**
  9551. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  9552. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  9553. */
  9554. readonly isInVRExclusivePointerMode: boolean;
  9555. /**
  9556. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  9557. */
  9558. disableUniformBuffers: boolean;
  9559. /** @hidden */
  9560. /**
  9561. * Gets a boolean indicating that the engine supports uniform buffers
  9562. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  9563. */
  9564. readonly supportsUniformBuffers: boolean;
  9565. /**
  9566. * Observable raised when the engine begins a new frame
  9567. */
  9568. onBeginFrameObservable: Observable<Engine>;
  9569. /**
  9570. * Observable raised when the engine ends the current frame
  9571. */
  9572. onEndFrameObservable: Observable<Engine>;
  9573. /**
  9574. * Observable raised when the engine is about to compile a shader
  9575. */
  9576. onBeforeShaderCompilationObservable: Observable<Engine>;
  9577. /**
  9578. * Observable raised when the engine has jsut compiled a shader
  9579. */
  9580. onAfterShaderCompilationObservable: Observable<Engine>;
  9581. /** @hidden */
  9582. private _renderingCanvas;
  9583. private _windowIsBackground;
  9584. private _webGLVersion;
  9585. /**
  9586. * Gets a boolean indicating that only power of 2 textures are supported
  9587. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  9588. */
  9589. readonly needPOTTextures: boolean;
  9590. /** @hidden */
  9591. /** @hidden */
  9592. /**
  9593. * Gets or sets a value indicating if we want to disable texture binding optmization.
  9594. * This could be required on some buggy drivers which wants to have textures bound in a progressive order.
  9595. * By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is
  9596. */
  9597. disableTextureBindingOptimization: boolean;
  9598. /**
  9599. * Gets the audio engine
  9600. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  9601. * @ignorenaming
  9602. */
  9603. static audioEngine: IAudioEngine;
  9604. /**
  9605. * Default AudioEngine Factory responsible of creating the Audio Engine.
  9606. * By default, this will create a BabylonJS Audio Engine if the workload
  9607. * has been embedded.
  9608. */
  9609. static AudioEngineFactory: (engine: Engine) => IAudioEngine;
  9610. private _onFocus;
  9611. private _onBlur;
  9612. private _onCanvasPointerOut;
  9613. private _onCanvasBlur;
  9614. private _onCanvasFocus;
  9615. private _onFullscreenChange;
  9616. private _onPointerLockChange;
  9617. private _onVRDisplayPointerRestricted;
  9618. private _onVRDisplayPointerUnrestricted;
  9619. private _onVrDisplayConnect;
  9620. private _onVrDisplayDisconnect;
  9621. private _onVrDisplayPresentChange;
  9622. /**
  9623. * Observable signaled when VR display mode changes
  9624. */
  9625. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  9626. /**
  9627. * Observable signaled when VR request present is complete
  9628. */
  9629. onVRRequestPresentComplete: Observable<boolean>;
  9630. /**
  9631. * Observable signaled when VR request present starts
  9632. */
  9633. onVRRequestPresentStart: Observable<Engine>;
  9634. private _hardwareScalingLevel;
  9635. /** @hidden */
  9636. protected _caps: EngineCapabilities;
  9637. private _pointerLockRequested;
  9638. private _isStencilEnable;
  9639. private _colorWrite;
  9640. private _loadingScreen;
  9641. /** @hidden */
  9642. /** @hidden */
  9643. private _glVersion;
  9644. private _glRenderer;
  9645. private _glVendor;
  9646. private _videoTextureSupported;
  9647. private _renderingQueueLaunched;
  9648. private _activeRenderLoops;
  9649. private _deterministicLockstep;
  9650. private _lockstepMaxSteps;
  9651. /**
  9652. * Observable signaled when a context lost event is raised
  9653. */
  9654. onContextLostObservable: Observable<Engine>;
  9655. /**
  9656. * Observable signaled when a context restored event is raised
  9657. */
  9658. onContextRestoredObservable: Observable<Engine>;
  9659. private _onContextLost;
  9660. private _onContextRestored;
  9661. private _contextWasLost;
  9662. private _doNotHandleContextLost;
  9663. /**
  9664. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  9665. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  9666. */
  9667. doNotHandleContextLost: boolean;
  9668. private _performanceMonitor;
  9669. private _fps;
  9670. private _deltaTime;
  9671. /**
  9672. * Turn this value on if you want to pause FPS computation when in background
  9673. */
  9674. disablePerformanceMonitorInBackground: boolean;
  9675. /**
  9676. * Gets the performance monitor attached to this engine
  9677. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  9678. */
  9679. readonly performanceMonitor: PerformanceMonitor;
  9680. /** @hidden */
  9681. protected _depthCullingState: _DepthCullingState;
  9682. /** @hidden */
  9683. protected _stencilState: _StencilState;
  9684. /** @hidden */
  9685. protected _alphaState: _AlphaState;
  9686. /** @hidden */
  9687. protected _alphaMode: number;
  9688. protected _internalTexturesCache: InternalTexture[];
  9689. /** @hidden */
  9690. protected _activeChannel: number;
  9691. private _currentTextureChannel;
  9692. /** @hidden */
  9693. protected _boundTexturesCache: {
  9694. [key: string]: Nullable<InternalTexture>;
  9695. };
  9696. /** @hidden */
  9697. protected _currentEffect: Nullable<Effect>;
  9698. /** @hidden */
  9699. protected _currentProgram: Nullable<WebGLProgram>;
  9700. private _compiledEffects;
  9701. private _vertexAttribArraysEnabled;
  9702. /** @hidden */
  9703. protected _cachedViewport: Nullable<Viewport>;
  9704. private _cachedVertexArrayObject;
  9705. /** @hidden */
  9706. protected _cachedVertexBuffers: any;
  9707. /** @hidden */
  9708. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  9709. /** @hidden */
  9710. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  9711. /** @hidden */
  9712. protected _currentRenderTarget: Nullable<InternalTexture>;
  9713. private _uintIndicesCurrentlySet;
  9714. private _currentBoundBuffer;
  9715. /** @hidden */
  9716. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  9717. private _currentBufferPointers;
  9718. private _currentInstanceLocations;
  9719. private _currentInstanceBuffers;
  9720. private _textureUnits;
  9721. private _firstBoundInternalTextureTracker;
  9722. private _lastBoundInternalTextureTracker;
  9723. private _workingCanvas;
  9724. private _workingContext;
  9725. private _rescalePostProcess;
  9726. private _dummyFramebuffer;
  9727. private _externalData;
  9728. private _bindedRenderFunction;
  9729. private _vaoRecordInProgress;
  9730. private _mustWipeVertexAttributes;
  9731. private _emptyTexture;
  9732. private _emptyCubeTexture;
  9733. private _emptyTexture3D;
  9734. private _frameHandler;
  9735. private _nextFreeTextureSlots;
  9736. private _maxSimultaneousTextures;
  9737. private _activeRequests;
  9738. private _texturesSupported;
  9739. private _textureFormatInUse;
  9740. /**
  9741. * Gets the list of texture formats supported
  9742. */
  9743. readonly texturesSupported: Array<string>;
  9744. /**
  9745. * Gets the list of texture formats in use
  9746. */
  9747. readonly textureFormatInUse: Nullable<string>;
  9748. /**
  9749. * Gets the current viewport
  9750. */
  9751. readonly currentViewport: Nullable<Viewport>;
  9752. /**
  9753. * Gets the default empty texture
  9754. */
  9755. readonly emptyTexture: InternalTexture;
  9756. /**
  9757. * Gets the default empty 3D texture
  9758. */
  9759. readonly emptyTexture3D: InternalTexture;
  9760. /**
  9761. * Gets the default empty cube texture
  9762. */
  9763. readonly emptyCubeTexture: InternalTexture;
  9764. /**
  9765. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  9766. */
  9767. readonly premultipliedAlpha: boolean;
  9768. /**
  9769. * Creates a new engine
  9770. * @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
  9771. * @param antialias defines enable antialiasing (default: false)
  9772. * @param options defines further options to be sent to the getContext() function
  9773. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  9774. */
  9775. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  9776. private _rebuildInternalTextures;
  9777. private _rebuildEffects;
  9778. private _rebuildBuffers;
  9779. private _initGLContext;
  9780. /**
  9781. * Gets version of the current webGL context
  9782. */
  9783. readonly webGLVersion: number;
  9784. /**
  9785. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  9786. */
  9787. readonly isStencilEnable: boolean;
  9788. private _prepareWorkingCanvas;
  9789. /**
  9790. * Reset the texture cache to empty state
  9791. */
  9792. resetTextureCache(): void;
  9793. /**
  9794. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  9795. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  9796. * @returns true if engine is in deterministic lock step mode
  9797. */
  9798. isDeterministicLockStep(): boolean;
  9799. /**
  9800. * Gets the max steps when engine is running in deterministic lock step
  9801. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  9802. * @returns the max steps
  9803. */
  9804. getLockstepMaxSteps(): number;
  9805. /**
  9806. * Gets an object containing information about the current webGL context
  9807. * @returns an object containing the vender, the renderer and the version of the current webGL context
  9808. */
  9809. getGlInfo(): {
  9810. vendor: string;
  9811. renderer: string;
  9812. version: string;
  9813. };
  9814. /**
  9815. * Gets current aspect ratio
  9816. * @param camera defines the camera to use to get the aspect ratio
  9817. * @param useScreen defines if screen size must be used (or the current render target if any)
  9818. * @returns a number defining the aspect ratio
  9819. */
  9820. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  9821. /**
  9822. * Gets current screen aspect ratio
  9823. * @returns a number defining the aspect ratio
  9824. */
  9825. getScreenAspectRatio(): number;
  9826. /**
  9827. * Gets the current render width
  9828. * @param useScreen defines if screen size must be used (or the current render target if any)
  9829. * @returns a number defining the current render width
  9830. */
  9831. getRenderWidth(useScreen?: boolean): number;
  9832. /**
  9833. * Gets the current render height
  9834. * @param useScreen defines if screen size must be used (or the current render target if any)
  9835. * @returns a number defining the current render height
  9836. */
  9837. getRenderHeight(useScreen?: boolean): number;
  9838. /**
  9839. * Gets the HTML canvas attached with the current webGL context
  9840. * @returns a HTML canvas
  9841. */
  9842. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  9843. /**
  9844. * Gets the client rect of the HTML canvas attached with the current webGL context
  9845. * @returns a client rectanglee
  9846. */
  9847. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  9848. /**
  9849. * Defines the hardware scaling level.
  9850. * By default the hardware scaling level is computed from the window device ratio.
  9851. * 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.
  9852. * @param level defines the level to use
  9853. */
  9854. setHardwareScalingLevel(level: number): void;
  9855. /**
  9856. * Gets the current hardware scaling level.
  9857. * By default the hardware scaling level is computed from the window device ratio.
  9858. * 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.
  9859. * @returns a number indicating the current hardware scaling level
  9860. */
  9861. getHardwareScalingLevel(): number;
  9862. /**
  9863. * Gets the list of loaded textures
  9864. * @returns an array containing all loaded textures
  9865. */
  9866. getLoadedTexturesCache(): InternalTexture[];
  9867. /**
  9868. * Gets the object containing all engine capabilities
  9869. * @returns the EngineCapabilities object
  9870. */
  9871. getCaps(): EngineCapabilities;
  9872. /** @hidden */
  9873. readonly drawCalls: number;
  9874. /** @hidden */
  9875. readonly drawCallsPerfCounter: Nullable<PerfCounter>;
  9876. /**
  9877. * Gets the current depth function
  9878. * @returns a number defining the depth function
  9879. */
  9880. getDepthFunction(): Nullable<number>;
  9881. /**
  9882. * Sets the current depth function
  9883. * @param depthFunc defines the function to use
  9884. */
  9885. setDepthFunction(depthFunc: number): void;
  9886. /**
  9887. * Sets the current depth function to GREATER
  9888. */
  9889. setDepthFunctionToGreater(): void;
  9890. /**
  9891. * Sets the current depth function to GEQUAL
  9892. */
  9893. setDepthFunctionToGreaterOrEqual(): void;
  9894. /**
  9895. * Sets the current depth function to LESS
  9896. */
  9897. setDepthFunctionToLess(): void;
  9898. /**
  9899. * Sets the current depth function to LEQUAL
  9900. */
  9901. setDepthFunctionToLessOrEqual(): void;
  9902. /**
  9903. * Gets a boolean indicating if stencil buffer is enabled
  9904. * @returns the current stencil buffer state
  9905. */
  9906. getStencilBuffer(): boolean;
  9907. /**
  9908. * Enable or disable the stencil buffer
  9909. * @param enable defines if the stencil buffer must be enabled or disabled
  9910. */
  9911. setStencilBuffer(enable: boolean): void;
  9912. /**
  9913. * Gets the current stencil mask
  9914. * @returns a number defining the new stencil mask to use
  9915. */
  9916. getStencilMask(): number;
  9917. /**
  9918. * Sets the current stencil mask
  9919. * @param mask defines the new stencil mask to use
  9920. */
  9921. setStencilMask(mask: number): void;
  9922. /**
  9923. * Gets the current stencil function
  9924. * @returns a number defining the stencil function to use
  9925. */
  9926. getStencilFunction(): number;
  9927. /**
  9928. * Gets the current stencil reference value
  9929. * @returns a number defining the stencil reference value to use
  9930. */
  9931. getStencilFunctionReference(): number;
  9932. /**
  9933. * Gets the current stencil mask
  9934. * @returns a number defining the stencil mask to use
  9935. */
  9936. getStencilFunctionMask(): number;
  9937. /**
  9938. * Sets the current stencil function
  9939. * @param stencilFunc defines the new stencil function to use
  9940. */
  9941. setStencilFunction(stencilFunc: number): void;
  9942. /**
  9943. * Sets the current stencil reference
  9944. * @param reference defines the new stencil reference to use
  9945. */
  9946. setStencilFunctionReference(reference: number): void;
  9947. /**
  9948. * Sets the current stencil mask
  9949. * @param mask defines the new stencil mask to use
  9950. */
  9951. setStencilFunctionMask(mask: number): void;
  9952. /**
  9953. * Gets the current stencil operation when stencil fails
  9954. * @returns a number defining stencil operation to use when stencil fails
  9955. */
  9956. getStencilOperationFail(): number;
  9957. /**
  9958. * Gets the current stencil operation when depth fails
  9959. * @returns a number defining stencil operation to use when depth fails
  9960. */
  9961. getStencilOperationDepthFail(): number;
  9962. /**
  9963. * Gets the current stencil operation when stencil passes
  9964. * @returns a number defining stencil operation to use when stencil passes
  9965. */
  9966. getStencilOperationPass(): number;
  9967. /**
  9968. * Sets the stencil operation to use when stencil fails
  9969. * @param operation defines the stencil operation to use when stencil fails
  9970. */
  9971. setStencilOperationFail(operation: number): void;
  9972. /**
  9973. * Sets the stencil operation to use when depth fails
  9974. * @param operation defines the stencil operation to use when depth fails
  9975. */
  9976. setStencilOperationDepthFail(operation: number): void;
  9977. /**
  9978. * Sets the stencil operation to use when stencil passes
  9979. * @param operation defines the stencil operation to use when stencil passes
  9980. */
  9981. setStencilOperationPass(operation: number): void;
  9982. /**
  9983. * Sets a boolean indicating if the dithering state is enabled or disabled
  9984. * @param value defines the dithering state
  9985. */
  9986. setDitheringState(value: boolean): void;
  9987. /**
  9988. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  9989. * @param value defines the rasterizer state
  9990. */
  9991. setRasterizerState(value: boolean): void;
  9992. /**
  9993. * stop executing a render loop function and remove it from the execution array
  9994. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  9995. */
  9996. stopRenderLoop(renderFunction?: () => void): void;
  9997. /** @hidden */
  9998. /**
  9999. * Register and execute a render loop. The engine can have more than one render function
  10000. * @param renderFunction defines the function to continuously execute
  10001. */
  10002. runRenderLoop(renderFunction: () => void): void;
  10003. /**
  10004. * Toggle full screen mode
  10005. * @param requestPointerLock defines if a pointer lock should be requested from the user
  10006. * @param options defines an option object to be sent to the requestFullscreen function
  10007. */
  10008. switchFullscreen(requestPointerLock: boolean): void;
  10009. /**
  10010. * Clear the current render buffer or the current render target (if any is set up)
  10011. * @param color defines the color to use
  10012. * @param backBuffer defines if the back buffer must be cleared
  10013. * @param depth defines if the depth buffer must be cleared
  10014. * @param stencil defines if the stencil buffer must be cleared
  10015. */
  10016. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  10017. /**
  10018. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  10019. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  10020. * @param y defines the y-coordinate of the corner of the clear rectangle
  10021. * @param width defines the width of the clear rectangle
  10022. * @param height defines the height of the clear rectangle
  10023. * @param clearColor defines the clear color
  10024. */
  10025. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  10026. private _viewportCached;
  10027. /** @hidden */
  10028. /**
  10029. * Set the WebGL's viewport
  10030. * @param viewport defines the viewport element to be used
  10031. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  10032. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  10033. */
  10034. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  10035. /**
  10036. * Directly set the WebGL Viewport
  10037. * @param x defines the x coordinate of the viewport (in screen space)
  10038. * @param y defines the y coordinate of the viewport (in screen space)
  10039. * @param width defines the width of the viewport (in screen space)
  10040. * @param height defines the height of the viewport (in screen space)
  10041. * @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
  10042. */
  10043. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  10044. /**
  10045. * Begin a new frame
  10046. */
  10047. beginFrame(): void;
  10048. /**
  10049. * Enf the current frame
  10050. */
  10051. endFrame(): void;
  10052. /**
  10053. * Resize the view according to the canvas' size
  10054. */
  10055. resize(): void;
  10056. /**
  10057. * Force a specific size of the canvas
  10058. * @param width defines the new canvas' width
  10059. * @param height defines the new canvas' height
  10060. */
  10061. setSize(width: number, height: number): void;
  10062. /**
  10063. * Gets a boolean indicating if a webVR device was detected
  10064. * @returns true if a webVR device was detected
  10065. */
  10066. isVRDevicePresent(): boolean;
  10067. /**
  10068. * Gets the current webVR device
  10069. * @returns the current webVR device (or null)
  10070. */
  10071. getVRDevice(): any;
  10072. /**
  10073. * Initializes a webVR display and starts listening to display change events
  10074. * The onVRDisplayChangedObservable will be notified upon these changes
  10075. * @returns The onVRDisplayChangedObservable
  10076. */
  10077. initWebVR(): Observable<IDisplayChangedEventArgs>;
  10078. /**
  10079. * Initializes a webVR display and starts listening to display change events
  10080. * The onVRDisplayChangedObservable will be notified upon these changes
  10081. * @returns A promise containing a VRDisplay and if vr is supported
  10082. */
  10083. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  10084. /**
  10085. * Call this function to switch to webVR mode
  10086. * Will do nothing if webVR is not supported or if there is no webVR device
  10087. * @see http://doc.babylonjs.com/how_to/webvr_camera
  10088. */
  10089. enableVR(): void;
  10090. /**
  10091. * Call this function to leave webVR mode
  10092. * Will do nothing if webVR is not supported or if there is no webVR device
  10093. * @see http://doc.babylonjs.com/how_to/webvr_camera
  10094. */
  10095. disableVR(): void;
  10096. private _onVRFullScreenTriggered;
  10097. private _getVRDisplaysAsync;
  10098. /**
  10099. * Binds the frame buffer to the specified texture.
  10100. * @param texture The texture to render to or null for the default canvas
  10101. * @param faceIndex The face of the texture to render to in case of cube texture
  10102. * @param requiredWidth The width of the target to render to
  10103. * @param requiredHeight The height of the target to render to
  10104. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  10105. * @param depthStencilTexture The depth stencil texture to use to render
  10106. * @param lodLevel defines le lod level to bind to the frame buffer
  10107. */
  10108. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  10109. private bindUnboundFramebuffer;
  10110. /**
  10111. * Unbind the current render target texture from the webGL context
  10112. * @param texture defines the render target texture to unbind
  10113. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  10114. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  10115. */
  10116. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  10117. /**
  10118. * Unbind a list of render target textures from the webGL context
  10119. * This is used only when drawBuffer extension or webGL2 are active
  10120. * @param textures defines the render target textures to unbind
  10121. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  10122. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  10123. */
  10124. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  10125. /**
  10126. * Force the mipmap generation for the given render target texture
  10127. * @param texture defines the render target texture to use
  10128. */
  10129. generateMipMapsForCubemap(texture: InternalTexture): void;
  10130. /**
  10131. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  10132. */
  10133. flushFramebuffer(): void;
  10134. /**
  10135. * Unbind the current render target and bind the default framebuffer
  10136. */
  10137. restoreDefaultFramebuffer(): void;
  10138. /**
  10139. * Create an uniform buffer
  10140. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  10141. * @param elements defines the content of the uniform buffer
  10142. * @returns the webGL uniform buffer
  10143. */
  10144. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  10145. /**
  10146. * Create a dynamic uniform buffer
  10147. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  10148. * @param elements defines the content of the uniform buffer
  10149. * @returns the webGL uniform buffer
  10150. */
  10151. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  10152. /**
  10153. * Update an existing uniform buffer
  10154. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  10155. * @param uniformBuffer defines the target uniform buffer
  10156. * @param elements defines the content to update
  10157. * @param offset defines the offset in the uniform buffer where update should start
  10158. * @param count defines the size of the data to update
  10159. */
  10160. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  10161. private _resetVertexBufferBinding;
  10162. /**
  10163. * Creates a vertex buffer
  10164. * @param data the data for the vertex buffer
  10165. * @returns the new WebGL static buffer
  10166. */
  10167. createVertexBuffer(data: DataArray): WebGLBuffer;
  10168. /**
  10169. * Creates a dynamic vertex buffer
  10170. * @param data the data for the dynamic vertex buffer
  10171. * @returns the new WebGL dynamic buffer
  10172. */
  10173. createDynamicVertexBuffer(data: DataArray): WebGLBuffer;
  10174. /**
  10175. * Update a dynamic index buffer
  10176. * @param indexBuffer defines the target index buffer
  10177. * @param indices defines the data to update
  10178. * @param offset defines the offset in the target index buffer where update should start
  10179. */
  10180. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  10181. /**
  10182. * Updates a dynamic vertex buffer.
  10183. * @param vertexBuffer the vertex buffer to update
  10184. * @param data the data used to update the vertex buffer
  10185. * @param byteOffset the byte offset of the data
  10186. * @param byteLength the byte length of the data
  10187. */
  10188. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  10189. private _resetIndexBufferBinding;
  10190. /**
  10191. * Creates a new index buffer
  10192. * @param indices defines the content of the index buffer
  10193. * @param updatable defines if the index buffer must be updatable
  10194. * @returns a new webGL buffer
  10195. */
  10196. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  10197. /**
  10198. * Bind a webGL buffer to the webGL context
  10199. * @param buffer defines the buffer to bind
  10200. */
  10201. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  10202. /**
  10203. * Bind an uniform buffer to the current webGL context
  10204. * @param buffer defines the buffer to bind
  10205. */
  10206. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  10207. /**
  10208. * Bind a buffer to the current webGL context at a given location
  10209. * @param buffer defines the buffer to bind
  10210. * @param location defines the index where to bind the buffer
  10211. */
  10212. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  10213. /**
  10214. * Bind a specific block at a given index in a specific shader program
  10215. * @param shaderProgram defines the shader program
  10216. * @param blockName defines the block name
  10217. * @param index defines the index where to bind the block
  10218. */
  10219. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  10220. private bindIndexBuffer;
  10221. private bindBuffer;
  10222. /**
  10223. * update the bound buffer with the given data
  10224. * @param data defines the data to update
  10225. */
  10226. updateArrayBuffer(data: Float32Array): void;
  10227. private _vertexAttribPointer;
  10228. private _bindIndexBufferWithCache;
  10229. private _bindVertexBuffersAttributes;
  10230. /**
  10231. * Records a vertex array object
  10232. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  10233. * @param vertexBuffers defines the list of vertex buffers to store
  10234. * @param indexBuffer defines the index buffer to store
  10235. * @param effect defines the effect to store
  10236. * @returns the new vertex array object
  10237. */
  10238. recordVertexArrayObject(vertexBuffers: {
  10239. [key: string]: VertexBuffer;
  10240. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  10241. /**
  10242. * Bind a specific vertex array object
  10243. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  10244. * @param vertexArrayObject defines the vertex array object to bind
  10245. * @param indexBuffer defines the index buffer to bind
  10246. */
  10247. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  10248. /**
  10249. * Bind webGl buffers directly to the webGL context
  10250. * @param vertexBuffer defines the vertex buffer to bind
  10251. * @param indexBuffer defines the index buffer to bind
  10252. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  10253. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  10254. * @param effect defines the effect associated with the vertex buffer
  10255. */
  10256. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  10257. private _unbindVertexArrayObject;
  10258. /**
  10259. * Bind a list of vertex buffers to the webGL context
  10260. * @param vertexBuffers defines the list of vertex buffers to bind
  10261. * @param indexBuffer defines the index buffer to bind
  10262. * @param effect defines the effect associated with the vertex buffers
  10263. */
  10264. bindBuffers(vertexBuffers: {
  10265. [key: string]: Nullable<VertexBuffer>;
  10266. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  10267. /**
  10268. * Unbind all instance attributes
  10269. */
  10270. unbindInstanceAttributes(): void;
  10271. /**
  10272. * Release and free the memory of a vertex array object
  10273. * @param vao defines the vertex array object to delete
  10274. */
  10275. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  10276. /** @hidden */
  10277. /**
  10278. * Creates a webGL buffer to use with instanciation
  10279. * @param capacity defines the size of the buffer
  10280. * @returns the webGL buffer
  10281. */
  10282. createInstancesBuffer(capacity: number): WebGLBuffer;
  10283. /**
  10284. * Delete a webGL buffer used with instanciation
  10285. * @param buffer defines the webGL buffer to delete
  10286. */
  10287. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  10288. /**
  10289. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  10290. * @param instancesBuffer defines the webGL buffer to update and bind
  10291. * @param data defines the data to store in the buffer
  10292. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  10293. */
  10294. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  10295. /**
  10296. * Apply all cached states (depth, culling, stencil and alpha)
  10297. */
  10298. applyStates(): void;
  10299. /**
  10300. * Send a draw order
  10301. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  10302. * @param indexStart defines the starting index
  10303. * @param indexCount defines the number of index to draw
  10304. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  10305. */
  10306. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  10307. /**
  10308. * Draw a list of points
  10309. * @param verticesStart defines the index of first vertex to draw
  10310. * @param verticesCount defines the count of vertices to draw
  10311. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  10312. */
  10313. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  10314. /**
  10315. * Draw a list of unindexed primitives
  10316. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  10317. * @param verticesStart defines the index of first vertex to draw
  10318. * @param verticesCount defines the count of vertices to draw
  10319. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  10320. */
  10321. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  10322. /**
  10323. * Draw a list of indexed primitives
  10324. * @param fillMode defines the primitive to use
  10325. * @param indexStart defines the starting index
  10326. * @param indexCount defines the number of index to draw
  10327. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  10328. */
  10329. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  10330. /**
  10331. * Draw a list of unindexed primitives
  10332. * @param fillMode defines the primitive to use
  10333. * @param verticesStart defines the index of first vertex to draw
  10334. * @param verticesCount defines the count of vertices to draw
  10335. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  10336. */
  10337. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  10338. private _drawMode;
  10339. /** @hidden */
  10340. /** @hidden */
  10341. /**
  10342. * Create a new effect (used to store vertex/fragment shaders)
  10343. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  10344. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  10345. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  10346. * @param samplers defines an array of string used to represent textures
  10347. * @param defines defines the string containing the defines to use to compile the shaders
  10348. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  10349. * @param onCompiled defines a function to call when the effect creation is successful
  10350. * @param onError defines a function to call when the effect creation has failed
  10351. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  10352. * @returns the new Effect
  10353. */
  10354. createEffect(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, indexParameters?: any): Effect;
  10355. private _compileShader;
  10356. private _compileRawShader;
  10357. /**
  10358. * Directly creates a webGL program
  10359. * @param vertexCode defines the vertex shader code to use
  10360. * @param fragmentCode defines the fragment shader code to use
  10361. * @param context defines the webGL context to use (if not set, the current one will be used)
  10362. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  10363. * @returns the new webGL program
  10364. */
  10365. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  10366. /**
  10367. * Creates a webGL program
  10368. * @param vertexCode defines the vertex shader code to use
  10369. * @param fragmentCode defines the fragment shader code to use
  10370. * @param defines defines the string containing the defines to use to compile the shaders
  10371. * @param context defines the webGL context to use (if not set, the current one will be used)
  10372. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  10373. * @returns the new webGL program
  10374. */
  10375. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  10376. private _createShaderProgram;
  10377. /**
  10378. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  10379. * @param shaderProgram defines the webGL program to use
  10380. * @param uniformsNames defines the list of uniform names
  10381. * @returns an array of webGL uniform locations
  10382. */
  10383. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  10384. /**
  10385. * Gets the lsit of active attributes for a given webGL program
  10386. * @param shaderProgram defines the webGL program to use
  10387. * @param attributesNames defines the list of attribute names to get
  10388. * @returns an array of indices indicating the offset of each attribute
  10389. */
  10390. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  10391. /**
  10392. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  10393. * @param effect defines the effect to activate
  10394. */
  10395. enableEffect(effect: Nullable<Effect>): void;
  10396. /**
  10397. * Set the value of an uniform to an array of int32
  10398. * @param uniform defines the webGL uniform location where to store the value
  10399. * @param array defines the array of int32 to store
  10400. */
  10401. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  10402. /**
  10403. * Set the value of an uniform to an array of int32 (stored as vec2)
  10404. * @param uniform defines the webGL uniform location where to store the value
  10405. * @param array defines the array of int32 to store
  10406. */
  10407. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  10408. /**
  10409. * Set the value of an uniform to an array of int32 (stored as vec3)
  10410. * @param uniform defines the webGL uniform location where to store the value
  10411. * @param array defines the array of int32 to store
  10412. */
  10413. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  10414. /**
  10415. * Set the value of an uniform to an array of int32 (stored as vec4)
  10416. * @param uniform defines the webGL uniform location where to store the value
  10417. * @param array defines the array of int32 to store
  10418. */
  10419. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  10420. /**
  10421. * Set the value of an uniform to an array of float32
  10422. * @param uniform defines the webGL uniform location where to store the value
  10423. * @param array defines the array of float32 to store
  10424. */
  10425. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  10426. /**
  10427. * Set the value of an uniform to an array of float32 (stored as vec2)
  10428. * @param uniform defines the webGL uniform location where to store the value
  10429. * @param array defines the array of float32 to store
  10430. */
  10431. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  10432. /**
  10433. * Set the value of an uniform to an array of float32 (stored as vec3)
  10434. * @param uniform defines the webGL uniform location where to store the value
  10435. * @param array defines the array of float32 to store
  10436. */
  10437. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  10438. /**
  10439. * Set the value of an uniform to an array of float32 (stored as vec4)
  10440. * @param uniform defines the webGL uniform location where to store the value
  10441. * @param array defines the array of float32 to store
  10442. */
  10443. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  10444. /**
  10445. * Set the value of an uniform to an array of number
  10446. * @param uniform defines the webGL uniform location where to store the value
  10447. * @param array defines the array of number to store
  10448. */
  10449. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  10450. /**
  10451. * Set the value of an uniform to an array of number (stored as vec2)
  10452. * @param uniform defines the webGL uniform location where to store the value
  10453. * @param array defines the array of number to store
  10454. */
  10455. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  10456. /**
  10457. * Set the value of an uniform to an array of number (stored as vec3)
  10458. * @param uniform defines the webGL uniform location where to store the value
  10459. * @param array defines the array of number to store
  10460. */
  10461. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  10462. /**
  10463. * Set the value of an uniform to an array of number (stored as vec4)
  10464. * @param uniform defines the webGL uniform location where to store the value
  10465. * @param array defines the array of number to store
  10466. */
  10467. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  10468. /**
  10469. * Set the value of an uniform to an array of float32 (stored as matrices)
  10470. * @param uniform defines the webGL uniform location where to store the value
  10471. * @param matrices defines the array of float32 to store
  10472. */
  10473. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  10474. /**
  10475. * Set the value of an uniform to a matrix
  10476. * @param uniform defines the webGL uniform location where to store the value
  10477. * @param matrix defines the matrix to store
  10478. */
  10479. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  10480. /**
  10481. * Set the value of an uniform to a matrix (3x3)
  10482. * @param uniform defines the webGL uniform location where to store the value
  10483. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  10484. */
  10485. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  10486. /**
  10487. * Set the value of an uniform to a matrix (2x2)
  10488. * @param uniform defines the webGL uniform location where to store the value
  10489. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  10490. */
  10491. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  10492. /**
  10493. * Set the value of an uniform to a number (int)
  10494. * @param uniform defines the webGL uniform location where to store the value
  10495. * @param value defines the int number to store
  10496. */
  10497. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  10498. /**
  10499. * Set the value of an uniform to a number (float)
  10500. * @param uniform defines the webGL uniform location where to store the value
  10501. * @param value defines the float number to store
  10502. */
  10503. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  10504. /**
  10505. * Set the value of an uniform to a vec2
  10506. * @param uniform defines the webGL uniform location where to store the value
  10507. * @param x defines the 1st component of the value
  10508. * @param y defines the 2nd component of the value
  10509. */
  10510. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  10511. /**
  10512. * Set the value of an uniform to a vec3
  10513. * @param uniform defines the webGL uniform location where to store the value
  10514. * @param x defines the 1st component of the value
  10515. * @param y defines the 2nd component of the value
  10516. * @param z defines the 3rd component of the value
  10517. */
  10518. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  10519. /**
  10520. * Set the value of an uniform to a boolean
  10521. * @param uniform defines the webGL uniform location where to store the value
  10522. * @param bool defines the boolean to store
  10523. */
  10524. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  10525. /**
  10526. * Set the value of an uniform to a vec4
  10527. * @param uniform defines the webGL uniform location where to store the value
  10528. * @param x defines the 1st component of the value
  10529. * @param y defines the 2nd component of the value
  10530. * @param z defines the 3rd component of the value
  10531. * @param w defines the 4th component of the value
  10532. */
  10533. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  10534. /**
  10535. * Set the value of an uniform to a Color3
  10536. * @param uniform defines the webGL uniform location where to store the value
  10537. * @param color3 defines the color to store
  10538. */
  10539. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  10540. /**
  10541. * Set the value of an uniform to a Color3 and an alpha value
  10542. * @param uniform defines the webGL uniform location where to store the value
  10543. * @param color3 defines the color to store
  10544. * @param alpha defines the alpha component to store
  10545. */
  10546. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  10547. /**
  10548. * Sets a Color4 on a uniform variable
  10549. * @param uniform defines the uniform location
  10550. * @param color4 defines the value to be set
  10551. */
  10552. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  10553. /**
  10554. * Set various states to the webGL context
  10555. * @param culling defines backface culling state
  10556. * @param zOffset defines the value to apply to zOffset (0 by default)
  10557. * @param force defines if states must be applied even if cache is up to date
  10558. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  10559. */
  10560. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  10561. /**
  10562. * Set the z offset to apply to current rendering
  10563. * @param value defines the offset to apply
  10564. */
  10565. setZOffset(value: number): void;
  10566. /**
  10567. * Gets the current value of the zOffset
  10568. * @returns the current zOffset state
  10569. */
  10570. getZOffset(): number;
  10571. /**
  10572. * Enable or disable depth buffering
  10573. * @param enable defines the state to set
  10574. */
  10575. setDepthBuffer(enable: boolean): void;
  10576. /**
  10577. * Gets a boolean indicating if depth writing is enabled
  10578. * @returns the current depth writing state
  10579. */
  10580. getDepthWrite(): boolean;
  10581. /**
  10582. * Enable or disable depth writing
  10583. * @param enable defines the state to set
  10584. */
  10585. setDepthWrite(enable: boolean): void;
  10586. /**
  10587. * Enable or disable color writing
  10588. * @param enable defines the state to set
  10589. */
  10590. setColorWrite(enable: boolean): void;
  10591. /**
  10592. * Gets a boolean indicating if color writing is enabled
  10593. * @returns the current color writing state
  10594. */
  10595. getColorWrite(): boolean;
  10596. /**
  10597. * Sets alpha constants used by some alpha blending modes
  10598. * @param r defines the red component
  10599. * @param g defines the green component
  10600. * @param b defines the blue component
  10601. * @param a defines the alpha component
  10602. */
  10603. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  10604. /**
  10605. * Sets the current alpha mode
  10606. * @param mode defines the mode to use (one of the BABYLON.Engine.ALPHA_XXX)
  10607. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  10608. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  10609. */
  10610. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  10611. /**
  10612. * Gets the current alpha mode
  10613. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  10614. * @returns the current alpha mode
  10615. */
  10616. getAlphaMode(): number;
  10617. /**
  10618. * Clears the list of texture accessible through engine.
  10619. * This can help preventing texture load conflict due to name collision.
  10620. */
  10621. clearInternalTexturesCache(): void;
  10622. /**
  10623. * Force the entire cache to be cleared
  10624. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  10625. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  10626. */
  10627. wipeCaches(bruteForce?: boolean): void;
  10628. /**
  10629. * Set the compressed texture format to use, based on the formats you have, and the formats
  10630. * supported by the hardware / browser.
  10631. *
  10632. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  10633. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  10634. * to API arguments needed to compressed textures. This puts the burden on the container
  10635. * generator to house the arcane code for determining these for current & future formats.
  10636. *
  10637. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  10638. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  10639. *
  10640. * Note: The result of this call is not taken into account when a texture is base64.
  10641. *
  10642. * @param formatsAvailable defines the list of those format families you have created
  10643. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  10644. *
  10645. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  10646. * @returns The extension selected.
  10647. */
  10648. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  10649. private _getSamplingParameters;
  10650. private _partialLoadImg;
  10651. private _cascadeLoadImgs;
  10652. /** @hidden */
  10653. /**
  10654. * Usually called from BABYLON.Texture.ts.
  10655. * Passed information to create a WebGLTexture
  10656. * @param urlArg defines a value which contains one of the following:
  10657. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  10658. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  10659. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  10660. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  10661. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  10662. * @param scene needed for loading to the correct scene
  10663. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  10664. * @param onLoad optional callback to be called upon successful completion
  10665. * @param onError optional callback to be called upon failure
  10666. * @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
  10667. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  10668. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  10669. * @param forcedExtension defines the extension to use to pick the right loader
  10670. * @returns a InternalTexture for assignment back into BABYLON.Texture
  10671. */
  10672. 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>): InternalTexture;
  10673. private _rescaleTexture;
  10674. /**
  10675. * Update a raw texture
  10676. * @param texture defines the texture to update
  10677. * @param data defines the data to store in the texture
  10678. * @param format defines the format of the data
  10679. * @param invertY defines if data must be stored with Y axis inverted
  10680. * @param compression defines the compression used (null by default)
  10681. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10682. */
  10683. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  10684. /**
  10685. * Creates a raw texture
  10686. * @param data defines the data to store in the texture
  10687. * @param width defines the width of the texture
  10688. * @param height defines the height of the texture
  10689. * @param format defines the format of the data
  10690. * @param generateMipMaps defines if the engine should generate the mip levels
  10691. * @param invertY defines if data must be stored with Y axis inverted
  10692. * @param samplingMode defines the required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  10693. * @param compression defines the compression used (null by default)
  10694. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10695. * @returns the raw texture inside an InternalTexture
  10696. */
  10697. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  10698. private _unpackFlipYCached;
  10699. /**
  10700. * In case you are sharing the context with other applications, it might
  10701. * be interested to not cache the unpack flip y state to ensure a consistent
  10702. * value would be set.
  10703. */
  10704. enableUnpackFlipYCached: boolean;
  10705. /** @hidden */
  10706. /** @hidden */
  10707. /**
  10708. * Creates a dynamic texture
  10709. * @param width defines the width of the texture
  10710. * @param height defines the height of the texture
  10711. * @param generateMipMaps defines if the engine should generate the mip levels
  10712. * @param samplingMode defines the required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  10713. * @returns the dynamic texture inside an InternalTexture
  10714. */
  10715. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  10716. /**
  10717. * Update the sampling mode of a given texture
  10718. * @param samplingMode defines the required sampling mode
  10719. * @param texture defines the texture to update
  10720. */
  10721. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  10722. /**
  10723. * Update the content of a dynamic texture
  10724. * @param texture defines the texture to update
  10725. * @param canvas defines the canvas containing the source
  10726. * @param invertY defines if data must be stored with Y axis inverted
  10727. * @param premulAlpha defines if alpha is stored as premultiplied
  10728. * @param format defines the format of the data
  10729. */
  10730. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  10731. /**
  10732. * Update a video texture
  10733. * @param texture defines the texture to update
  10734. * @param video defines the video element to use
  10735. * @param invertY defines if data must be stored with Y axis inverted
  10736. */
  10737. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  10738. /**
  10739. * Updates a depth texture Comparison Mode and Function.
  10740. * If the comparison Function is equal to 0, the mode will be set to none.
  10741. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  10742. * @param texture The texture to set the comparison function for
  10743. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  10744. */
  10745. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  10746. private _setupDepthStencilTexture;
  10747. /**
  10748. * Creates a depth stencil texture.
  10749. * This is only available in WebGL 2 or with the depth texture extension available.
  10750. * @param size The size of face edge in the texture.
  10751. * @param options The options defining the texture.
  10752. * @returns The texture
  10753. */
  10754. createDepthStencilTexture(size: number | {
  10755. width: number;
  10756. height: number;
  10757. }, options: DepthTextureCreationOptions): InternalTexture;
  10758. /**
  10759. * Creates a depth stencil texture.
  10760. * This is only available in WebGL 2 or with the depth texture extension available.
  10761. * @param size The size of face edge in the texture.
  10762. * @param options The options defining the texture.
  10763. * @returns The texture
  10764. */
  10765. private _createDepthStencilTexture;
  10766. /**
  10767. * Creates a depth stencil cube texture.
  10768. * This is only available in WebGL 2.
  10769. * @param size The size of face edge in the cube texture.
  10770. * @param options The options defining the cube texture.
  10771. * @returns The cube texture
  10772. */
  10773. private _createDepthStencilCubeTexture;
  10774. /**
  10775. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  10776. * @param renderTarget The render target to set the frame buffer for
  10777. */
  10778. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  10779. /**
  10780. * Creates a new render target texture
  10781. * @param size defines the size of the texture
  10782. * @param options defines the options used to create the texture
  10783. * @returns a new render target texture stored in an InternalTexture
  10784. */
  10785. createRenderTargetTexture(size: number | {
  10786. width: number;
  10787. height: number;
  10788. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  10789. /**
  10790. * Create a multi render target texture
  10791. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  10792. * @param size defines the size of the texture
  10793. * @param options defines the creation options
  10794. * @returns the cube texture as an InternalTexture
  10795. */
  10796. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  10797. private _setupFramebufferDepthAttachments;
  10798. /**
  10799. * Updates the sample count of a render target texture
  10800. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  10801. * @param texture defines the texture to update
  10802. * @param samples defines the sample count to set
  10803. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  10804. */
  10805. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  10806. /**
  10807. * Update the sample count for a given multiple render target texture
  10808. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  10809. * @param textures defines the textures to update
  10810. * @param samples defines the sample count to set
  10811. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  10812. */
  10813. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  10814. /** @hidden */
  10815. /** @hidden */
  10816. /** @hidden */
  10817. /** @hidden */
  10818. /**
  10819. * Creates a new render target cube texture
  10820. * @param size defines the size of the texture
  10821. * @param options defines the options used to create the texture
  10822. * @returns a new render target cube texture stored in an InternalTexture
  10823. */
  10824. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  10825. /**
  10826. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  10827. * @param rootUrl defines the url where the file to load is located
  10828. * @param scene defines the current scene
  10829. * @param lodScale defines scale to apply to the mip map selection
  10830. * @param lodOffset defines offset to apply to the mip map selection
  10831. * @param onLoad defines an optional callback raised when the texture is loaded
  10832. * @param onError defines an optional callback raised if there is an issue to load the texture
  10833. * @param format defines the format of the data
  10834. * @param forcedExtension defines the extension to use to pick the right loader
  10835. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  10836. * @returns the cube texture as an InternalTexture
  10837. */
  10838. 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;
  10839. /**
  10840. * Creates a cube texture
  10841. * @param rootUrl defines the url where the files to load is located
  10842. * @param scene defines the current scene
  10843. * @param files defines the list of files to load (1 per face)
  10844. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  10845. * @param onLoad defines an optional callback raised when the texture is loaded
  10846. * @param onError defines an optional callback raised if there is an issue to load the texture
  10847. * @param format defines the format of the data
  10848. * @param forcedExtension defines the extension to use to pick the right loader
  10849. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  10850. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  10851. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  10852. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  10853. * @returns the cube texture as an InternalTexture
  10854. */
  10855. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap?: boolean, onLoad?: Nullable<(data?: any) => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number, fallback?: Nullable<InternalTexture>): InternalTexture;
  10856. /**
  10857. * @hidden
  10858. */
  10859. /**
  10860. * Update a raw cube texture
  10861. * @param texture defines the texture to udpdate
  10862. * @param data defines the data to store
  10863. * @param format defines the data format
  10864. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10865. * @param invertY defines if data must be stored with Y axis inverted
  10866. * @param compression defines the compression used (null by default)
  10867. * @param level defines which level of the texture to update
  10868. */
  10869. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  10870. /**
  10871. * Creates a new raw cube texture
  10872. * @param data defines the array of data to use to create each face
  10873. * @param size defines the size of the textures
  10874. * @param format defines the format of the data
  10875. * @param type defines the type of the data (like BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT)
  10876. * @param generateMipMaps defines if the engine should generate the mip levels
  10877. * @param invertY defines if data must be stored with Y axis inverted
  10878. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  10879. * @param compression defines the compression used (null by default)
  10880. * @returns the cube texture as an InternalTexture
  10881. */
  10882. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  10883. /**
  10884. * Creates a new raw cube texture from a specified url
  10885. * @param url defines the url where the data is located
  10886. * @param scene defines the current scene
  10887. * @param size defines the size of the textures
  10888. * @param format defines the format of the data
  10889. * @param type defines the type fo the data (like BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT)
  10890. * @param noMipmap defines if the engine should avoid generating the mip levels
  10891. * @param callback defines a callback used to extract texture data from loaded data
  10892. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  10893. * @param onLoad defines a callback called when texture is loaded
  10894. * @param onError defines a callback called if there is an error
  10895. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  10896. * @param invertY defines if data must be stored with Y axis inverted
  10897. * @returns the cube texture as an InternalTexture
  10898. */
  10899. 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;
  10900. /**
  10901. * Update a raw 3D texture
  10902. * @param texture defines the texture to update
  10903. * @param data defines the data to store
  10904. * @param format defines the data format
  10905. * @param invertY defines if data must be stored with Y axis inverted
  10906. * @param compression defines the used compression (can be null)
  10907. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  10908. */
  10909. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  10910. /**
  10911. * Creates a new raw 3D texture
  10912. * @param data defines the data used to create the texture
  10913. * @param width defines the width of the texture
  10914. * @param height defines the height of the texture
  10915. * @param depth defines the depth of the texture
  10916. * @param format defines the format of the texture
  10917. * @param generateMipMaps defines if the engine must generate mip levels
  10918. * @param invertY defines if data must be stored with Y axis inverted
  10919. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  10920. * @param compression defines the compressed used (can be null)
  10921. * @param textureType defines the compressed used (can be null)
  10922. * @returns a new raw 3D texture (stored in an InternalTexture)
  10923. */
  10924. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  10925. private _prepareWebGLTextureContinuation;
  10926. private _prepareWebGLTexture;
  10927. private _convertRGBtoRGBATextureData;
  10928. /** @hidden */
  10929. /** @hidden */
  10930. private setProgram;
  10931. private _boundUniforms;
  10932. /**
  10933. * Binds an effect to the webGL context
  10934. * @param effect defines the effect to bind
  10935. */
  10936. bindSamplers(effect: Effect): void;
  10937. private _moveBoundTextureOnTop;
  10938. private _getCorrectTextureChannel;
  10939. private _linkTrackers;
  10940. private _removeDesignatedSlot;
  10941. private _activateCurrentTexture;
  10942. /** @hidden */
  10943. protected _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  10944. /** @hidden */
  10945. /**
  10946. * Sets a texture to the webGL context from a postprocess
  10947. * @param channel defines the channel to use
  10948. * @param postProcess defines the source postprocess
  10949. */
  10950. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  10951. /**
  10952. * Binds the output of the passed in post process to the texture channel specified
  10953. * @param channel The channel the texture should be bound to
  10954. * @param postProcess The post process which's output should be bound
  10955. */
  10956. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  10957. /**
  10958. * Unbind all textures from the webGL context
  10959. */
  10960. unbindAllTextures(): void;
  10961. /**
  10962. * Sets a texture to the according uniform.
  10963. * @param channel The texture channel
  10964. * @param uniform The uniform to set
  10965. * @param texture The texture to apply
  10966. */
  10967. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  10968. /**
  10969. * Sets a depth stencil texture from a render target to the according uniform.
  10970. * @param channel The texture channel
  10971. * @param uniform The uniform to set
  10972. * @param texture The render target texture containing the depth stencil texture to apply
  10973. */
  10974. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  10975. private _bindSamplerUniformToChannel;
  10976. private _getTextureWrapMode;
  10977. private _setTexture;
  10978. /**
  10979. * Sets an array of texture to the webGL context
  10980. * @param channel defines the channel where the texture array must be set
  10981. * @param uniform defines the associated uniform location
  10982. * @param textures defines the array of textures to bind
  10983. */
  10984. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  10985. /** @hidden */
  10986. private _setTextureParameterFloat;
  10987. private _setTextureParameterInteger;
  10988. /**
  10989. * Reads pixels from the current frame buffer. Please note that this function can be slow
  10990. * @param x defines the x coordinate of the rectangle where pixels must be read
  10991. * @param y defines the y coordinate of the rectangle where pixels must be read
  10992. * @param width defines the width of the rectangle where pixels must be read
  10993. * @param height defines the height of the rectangle where pixels must be read
  10994. * @returns a Uint8Array containing RGBA colors
  10995. */
  10996. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  10997. /**
  10998. * Add an externaly attached data from its key.
  10999. * This method call will fail and return false, if such key already exists.
  11000. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  11001. * @param key the unique key that identifies the data
  11002. * @param data the data object to associate to the key for this Engine instance
  11003. * @return true if no such key were already present and the data was added successfully, false otherwise
  11004. */
  11005. addExternalData<T>(key: string, data: T): boolean;
  11006. /**
  11007. * Get an externaly attached data from its key
  11008. * @param key the unique key that identifies the data
  11009. * @return the associated data, if present (can be null), or undefined if not present
  11010. */
  11011. getExternalData<T>(key: string): T;
  11012. /**
  11013. * Get an externaly attached data from its key, create it using a factory if it's not already present
  11014. * @param key the unique key that identifies the data
  11015. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  11016. * @return the associated data, can be null if the factory returned null.
  11017. */
  11018. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  11019. /**
  11020. * Remove an externaly attached data from the Engine instance
  11021. * @param key the unique key that identifies the data
  11022. * @return true if the data was successfully removed, false if it doesn't exist
  11023. */
  11024. removeExternalData(key: string): boolean;
  11025. /**
  11026. * Unbind all vertex attributes from the webGL context
  11027. */
  11028. unbindAllAttributes(): void;
  11029. /**
  11030. * 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
  11031. */
  11032. releaseEffects(): void;
  11033. /**
  11034. * Dispose and release all associated resources
  11035. */
  11036. dispose(): void;
  11037. /**
  11038. * Display the loading screen
  11039. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  11040. */
  11041. displayLoadingUI(): void;
  11042. /**
  11043. * Hide the loading screen
  11044. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  11045. */
  11046. hideLoadingUI(): void;
  11047. /**
  11048. * Gets the current loading screen object
  11049. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  11050. */
  11051. /**
  11052. * Sets the current loading screen object
  11053. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  11054. */
  11055. loadingScreen: ILoadingScreen;
  11056. /**
  11057. * Sets the current loading screen text
  11058. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  11059. */
  11060. loadingUIText: string;
  11061. /**
  11062. * Sets the current loading screen background color
  11063. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  11064. */
  11065. loadingUIBackgroundColor: string;
  11066. /**
  11067. * Attach a new callback raised when context lost event is fired
  11068. * @param callback defines the callback to call
  11069. */
  11070. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  11071. /**
  11072. * Attach a new callback raised when context restored event is fired
  11073. * @param callback defines the callback to call
  11074. */
  11075. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  11076. /**
  11077. * Gets the source code of the vertex shader associated with a specific webGL program
  11078. * @param program defines the program to use
  11079. * @returns a string containing the source code of the vertex shader associated with the program
  11080. */
  11081. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  11082. /**
  11083. * Gets the source code of the fragment shader associated with a specific webGL program
  11084. * @param program defines the program to use
  11085. * @returns a string containing the source code of the fragment shader associated with the program
  11086. */
  11087. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  11088. /**
  11089. * Get the current error code of the webGL context
  11090. * @returns the error code
  11091. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  11092. */
  11093. getError(): number;
  11094. /**
  11095. * Gets the current framerate
  11096. * @returns a number representing the framerate
  11097. */
  11098. getFps(): number;
  11099. /**
  11100. * Gets the time spent between current and previous frame
  11101. * @returns a number representing the delta time in ms
  11102. */
  11103. getDeltaTime(): number;
  11104. private _measureFps;
  11105. /** @hidden */
  11106. private _canRenderToFloatFramebuffer;
  11107. private _canRenderToHalfFloatFramebuffer;
  11108. private _canRenderToFramebuffer;
  11109. /** @hidden */
  11110. private _getInternalFormat;
  11111. /** @hidden */
  11112. /** @hidden */
  11113. /** @hidden */
  11114. /** @hidden */
  11115. private _partialLoadFile;
  11116. private _cascadeLoadFiles;
  11117. /**
  11118. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  11119. * @returns true if the engine can be created
  11120. * @ignorenaming
  11121. */
  11122. static isSupported(): boolean;
  11123. }
  11124. }
  11125. declare module BABYLON {
  11126. class NullEngineOptions {
  11127. renderWidth: number;
  11128. renderHeight: number;
  11129. textureSize: number;
  11130. deterministicLockstep: boolean;
  11131. lockstepMaxSteps: number;
  11132. }
  11133. /**
  11134. * The null engine class provides support for headless version of babylon.js.
  11135. * This can be used in server side scenario or for testing purposes
  11136. */
  11137. class NullEngine extends Engine {
  11138. private _options;
  11139. isDeterministicLockStep(): boolean;
  11140. getLockstepMaxSteps(): number;
  11141. getHardwareScalingLevel(): number;
  11142. constructor(options?: NullEngineOptions);
  11143. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  11144. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  11145. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  11146. getRenderWidth(useScreen?: boolean): number;
  11147. getRenderHeight(useScreen?: boolean): number;
  11148. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  11149. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  11150. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  11151. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  11152. bindSamplers(effect: Effect): void;
  11153. enableEffect(effect: Effect): void;
  11154. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  11155. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  11156. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  11157. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  11158. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  11159. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  11160. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  11161. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  11162. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  11163. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  11164. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  11165. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  11166. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  11167. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  11168. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  11169. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  11170. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  11171. setFloat(uniform: WebGLUniformLocation, value: number): void;
  11172. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  11173. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  11174. setBool(uniform: WebGLUniformLocation, bool: number): void;
  11175. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  11176. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  11177. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  11178. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  11179. bindBuffers(vertexBuffers: {
  11180. [key: string]: VertexBuffer;
  11181. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  11182. wipeCaches(bruteForce?: boolean): void;
  11183. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  11184. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  11185. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  11186. /** @hidden */
  11187. /** @hidden */
  11188. 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;
  11189. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  11190. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  11191. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  11192. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  11193. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  11194. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  11195. /**
  11196. * @hidden
  11197. * Get the current error code of the webGL context
  11198. * @returns the error code
  11199. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  11200. */
  11201. getError(): number;
  11202. /** @hidden */
  11203. /** @hidden */
  11204. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  11205. /**
  11206. * Updates a dynamic vertex buffer.
  11207. * @param vertexBuffer the vertex buffer to update
  11208. * @param data the data used to update the vertex buffer
  11209. * @param byteOffset the byte offset of the data (optional)
  11210. * @param byteLength the byte length of the data (optional)
  11211. */
  11212. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  11213. protected _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  11214. /** @hidden */
  11215. /** @hidden */
  11216. releaseEffects(): void;
  11217. displayLoadingUI(): void;
  11218. hideLoadingUI(): void;
  11219. /** @hidden */
  11220. /** @hidden */
  11221. /** @hidden */
  11222. /** @hidden */
  11223. }
  11224. }
  11225. interface WebGLRenderingContext {
  11226. readonly RASTERIZER_DISCARD: number;
  11227. readonly DEPTH_COMPONENT24: number;
  11228. readonly TEXTURE_3D: number;
  11229. readonly TEXTURE_2D_ARRAY: number;
  11230. readonly TEXTURE_COMPARE_FUNC: number;
  11231. readonly TEXTURE_COMPARE_MODE: number;
  11232. readonly COMPARE_REF_TO_TEXTURE: number;
  11233. readonly TEXTURE_WRAP_R: number;
  11234. readonly HALF_FLOAT: number;
  11235. readonly RGB8: number;
  11236. readonly RED_INTEGER: number;
  11237. readonly RG_INTEGER: number;
  11238. readonly RGB_INTEGER: number;
  11239. readonly RGBA_INTEGER: number;
  11240. readonly R8_SNORM: number;
  11241. readonly RG8_SNORM: number;
  11242. readonly RGB8_SNORM: number;
  11243. readonly RGBA8_SNORM: number;
  11244. readonly R8I: number;
  11245. readonly RG8I: number;
  11246. readonly RGB8I: number;
  11247. readonly RGBA8I: number;
  11248. readonly R8UI: number;
  11249. readonly RG8UI: number;
  11250. readonly RGB8UI: number;
  11251. readonly RGBA8UI: number;
  11252. readonly R16I: number;
  11253. readonly RG16I: number;
  11254. readonly RGB16I: number;
  11255. readonly RGBA16I: number;
  11256. readonly R16UI: number;
  11257. readonly RG16UI: number;
  11258. readonly RGB16UI: number;
  11259. readonly RGBA16UI: number;
  11260. readonly R32I: number;
  11261. readonly RG32I: number;
  11262. readonly RGB32I: number;
  11263. readonly RGBA32I: number;
  11264. readonly R32UI: number;
  11265. readonly RG32UI: number;
  11266. readonly RGB32UI: number;
  11267. readonly RGBA32UI: number;
  11268. readonly RGB10_A2UI: number;
  11269. readonly R11F_G11F_B10F: number;
  11270. readonly RGB9_E5: number;
  11271. readonly RGB10_A2: number;
  11272. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  11273. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  11274. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  11275. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  11276. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  11277. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  11278. 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;
  11279. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  11280. readonly TRANSFORM_FEEDBACK: number;
  11281. readonly INTERLEAVED_ATTRIBS: number;
  11282. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  11283. createTransformFeedback(): WebGLTransformFeedback;
  11284. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  11285. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  11286. beginTransformFeedback(primitiveMode: number): void;
  11287. endTransformFeedback(): void;
  11288. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  11289. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  11290. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  11291. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  11292. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  11293. }
  11294. interface ImageBitmap {
  11295. readonly width: number;
  11296. readonly height: number;
  11297. close(): void;
  11298. }
  11299. interface WebGLQuery extends WebGLObject {
  11300. }
  11301. declare var WebGLQuery: {
  11302. prototype: WebGLQuery;
  11303. new (): WebGLQuery;
  11304. };
  11305. interface WebGLSampler extends WebGLObject {
  11306. }
  11307. declare var WebGLSampler: {
  11308. prototype: WebGLSampler;
  11309. new (): WebGLSampler;
  11310. };
  11311. interface WebGLSync extends WebGLObject {
  11312. }
  11313. declare var WebGLSync: {
  11314. prototype: WebGLSync;
  11315. new (): WebGLSync;
  11316. };
  11317. interface WebGLTransformFeedback extends WebGLObject {
  11318. }
  11319. declare var WebGLTransformFeedback: {
  11320. prototype: WebGLTransformFeedback;
  11321. new (): WebGLTransformFeedback;
  11322. };
  11323. interface WebGLVertexArrayObject extends WebGLObject {
  11324. }
  11325. declare var WebGLVertexArrayObject: {
  11326. prototype: WebGLVertexArrayObject;
  11327. new (): WebGLVertexArrayObject;
  11328. };
  11329. declare module BABYLON {
  11330. /**
  11331. * Gather the list of keyboard event types as constants.
  11332. */
  11333. class KeyboardEventTypes {
  11334. /**
  11335. * The keydown event is fired when a key becomes active (pressed).
  11336. */
  11337. static readonly KEYDOWN: number;
  11338. /**
  11339. * The keyup event is fired when a key has been released.
  11340. */
  11341. static readonly KEYUP: number;
  11342. }
  11343. /**
  11344. * This class is used to store keyboard related info for the onKeyboardObservable event.
  11345. */
  11346. class KeyboardInfo {
  11347. /**
  11348. * Defines the type of event (BABYLON.KeyboardEventTypes)
  11349. */
  11350. type: number;
  11351. /**
  11352. * Defines the related dom event
  11353. */
  11354. event: KeyboardEvent;
  11355. /**
  11356. * Instantiates a new keyboard info.
  11357. * This class is used to store keyboard related info for the onKeyboardObservable event.
  11358. * @param type Defines the type of event (BABYLON.KeyboardEventTypes)
  11359. * @param event Defines the related dom event
  11360. */
  11361. constructor(
  11362. /**
  11363. * Defines the type of event (BABYLON.KeyboardEventTypes)
  11364. */
  11365. type: number,
  11366. /**
  11367. * Defines the related dom event
  11368. */
  11369. event: KeyboardEvent);
  11370. }
  11371. /**
  11372. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  11373. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  11374. */
  11375. class KeyboardInfoPre extends KeyboardInfo {
  11376. /**
  11377. * Defines the type of event (BABYLON.KeyboardEventTypes)
  11378. */
  11379. type: number;
  11380. /**
  11381. * Defines the related dom event
  11382. */
  11383. event: KeyboardEvent;
  11384. /**
  11385. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  11386. */
  11387. skipOnPointerObservable: boolean;
  11388. /**
  11389. * Instantiates a new keyboard pre info.
  11390. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  11391. * @param type Defines the type of event (BABYLON.KeyboardEventTypes)
  11392. * @param event Defines the related dom event
  11393. */
  11394. constructor(
  11395. /**
  11396. * Defines the type of event (BABYLON.KeyboardEventTypes)
  11397. */
  11398. type: number,
  11399. /**
  11400. * Defines the related dom event
  11401. */
  11402. event: KeyboardEvent);
  11403. }
  11404. }
  11405. declare module BABYLON {
  11406. /**
  11407. * Gather the list of pointer event types as constants.
  11408. */
  11409. class PointerEventTypes {
  11410. /**
  11411. * 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.
  11412. */
  11413. static readonly POINTERDOWN: number;
  11414. /**
  11415. * The pointerup event is fired when a pointer is no longer active.
  11416. */
  11417. static readonly POINTERUP: number;
  11418. /**
  11419. * The pointermove event is fired when a pointer changes coordinates.
  11420. */
  11421. static readonly POINTERMOVE: number;
  11422. /**
  11423. * The pointerwheel event is fired when a mouse wheel has been rotated.
  11424. */
  11425. static readonly POINTERWHEEL: number;
  11426. /**
  11427. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  11428. */
  11429. static readonly POINTERPICK: number;
  11430. /**
  11431. * The pointertap event is fired when a the object has been touched and released without drag.
  11432. */
  11433. static readonly POINTERTAP: number;
  11434. /**
  11435. * The pointertap event is fired when a the object has been touched and released twice without drag.
  11436. */
  11437. static readonly POINTERDOUBLETAP: number;
  11438. }
  11439. /**
  11440. * Base class of pointer info types.
  11441. */
  11442. class PointerInfoBase {
  11443. /**
  11444. * Defines the type of event (BABYLON.PointerEventTypes)
  11445. */
  11446. type: number;
  11447. /**
  11448. * Defines the related dom event
  11449. */
  11450. event: PointerEvent | MouseWheelEvent;
  11451. /**
  11452. * Instantiates the base class of pointers info.
  11453. * @param type Defines the type of event (BABYLON.PointerEventTypes)
  11454. * @param event Defines the related dom event
  11455. */
  11456. constructor(
  11457. /**
  11458. * Defines the type of event (BABYLON.PointerEventTypes)
  11459. */
  11460. type: number,
  11461. /**
  11462. * Defines the related dom event
  11463. */
  11464. event: PointerEvent | MouseWheelEvent);
  11465. }
  11466. /**
  11467. * This class is used to store pointer related info for the onPrePointerObservable event.
  11468. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  11469. */
  11470. class PointerInfoPre extends PointerInfoBase {
  11471. /**
  11472. * Ray from a pointer if availible (eg. 6dof controller)
  11473. */
  11474. ray: Nullable<Ray>;
  11475. /**
  11476. * Defines the local position of the pointer on the canvas.
  11477. */
  11478. localPosition: Vector2;
  11479. /**
  11480. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  11481. */
  11482. skipOnPointerObservable: boolean;
  11483. /**
  11484. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  11485. * @param type Defines the type of event (BABYLON.PointerEventTypes)
  11486. * @param event Defines the related dom event
  11487. * @param localX Defines the local x coordinates of the pointer when the event occured
  11488. * @param localY Defines the local y coordinates of the pointer when the event occured
  11489. */
  11490. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  11491. }
  11492. /**
  11493. * This type contains all the data related to a pointer event in Babylon.js.
  11494. * 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.
  11495. */
  11496. class PointerInfo extends PointerInfoBase {
  11497. /**
  11498. * Defines the picking info associated to the info (if any)\
  11499. */
  11500. pickInfo: Nullable<PickingInfo>;
  11501. /**
  11502. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  11503. * @param type Defines the type of event (BABYLON.PointerEventTypes)
  11504. * @param event Defines the related dom event
  11505. * @param pickInfo Defines the picking info associated to the info (if any)\
  11506. */
  11507. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  11508. /**
  11509. * Defines the picking info associated to the info (if any)\
  11510. */
  11511. pickInfo: Nullable<PickingInfo>);
  11512. }
  11513. }
  11514. declare module BABYLON {
  11515. /**
  11516. * Single axis drag gizmo
  11517. */
  11518. class AxisDragGizmo extends Gizmo {
  11519. /**
  11520. * Drag behavior responsible for the gizmos dragging interactions
  11521. */
  11522. dragBehavior: PointerDragBehavior;
  11523. private _pointerObserver;
  11524. /**
  11525. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  11526. */
  11527. snapDistance: number;
  11528. /**
  11529. * Event that fires each time the gizmo snaps to a new location.
  11530. * * snapDistance is the the change in distance
  11531. */
  11532. onSnapObservable: Observable<{
  11533. snapDistance: number;
  11534. }>;
  11535. /**
  11536. * Creates an AxisDragGizmo
  11537. * @param gizmoLayer The utility layer the gizmo will be added to
  11538. * @param dragAxis The axis which the gizmo will be able to drag on
  11539. * @param color The color of the gizmo
  11540. */
  11541. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  11542. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  11543. /**
  11544. * Disposes of the gizmo
  11545. */
  11546. dispose(): void;
  11547. }
  11548. }
  11549. declare module BABYLON {
  11550. /**
  11551. * Single axis scale gizmo
  11552. */
  11553. class AxisScaleGizmo extends Gizmo {
  11554. private _coloredMaterial;
  11555. /**
  11556. * Drag behavior responsible for the gizmos dragging interactions
  11557. */
  11558. dragBehavior: PointerDragBehavior;
  11559. private _pointerObserver;
  11560. /**
  11561. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  11562. */
  11563. snapDistance: number;
  11564. /**
  11565. * Event that fires each time the gizmo snaps to a new location.
  11566. * * snapDistance is the the change in distance
  11567. */
  11568. onSnapObservable: Observable<{
  11569. snapDistance: number;
  11570. }>;
  11571. /**
  11572. * If the scaling operation should be done on all axis (default: false)
  11573. */
  11574. uniformScaling: boolean;
  11575. /**
  11576. * Creates an AxisScaleGizmo
  11577. * @param gizmoLayer The utility layer the gizmo will be added to
  11578. * @param dragAxis The axis which the gizmo will be able to scale on
  11579. * @param color The color of the gizmo
  11580. */
  11581. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  11582. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  11583. /**
  11584. * Disposes of the gizmo
  11585. */
  11586. dispose(): void;
  11587. /**
  11588. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  11589. * @param mesh The mesh to replace the default mesh of the gizmo
  11590. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  11591. */
  11592. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  11593. }
  11594. }
  11595. declare module BABYLON {
  11596. /**
  11597. * Bounding box gizmo
  11598. */
  11599. class BoundingBoxGizmo extends Gizmo {
  11600. private _lineBoundingBox;
  11601. private _rotateSpheresParent;
  11602. private _scaleBoxesParent;
  11603. private _boundingDimensions;
  11604. private _renderObserver;
  11605. private _pointerObserver;
  11606. private _scaleDragSpeed;
  11607. private _tmpQuaternion;
  11608. private _tmpVector;
  11609. private _tmpRotationMatrix;
  11610. /**
  11611. * 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)
  11612. */
  11613. ignoreChildren: boolean;
  11614. /**
  11615. * 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)
  11616. */
  11617. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  11618. /**
  11619. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  11620. */
  11621. rotationSphereSize: number;
  11622. /**
  11623. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  11624. */
  11625. scaleBoxSize: number;
  11626. /**
  11627. * 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)
  11628. */
  11629. fixedDragMeshScreenSize: boolean;
  11630. /**
  11631. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  11632. */
  11633. fixedDragMeshScreenSizeDistanceFactor: number;
  11634. /**
  11635. * Fired when a rotation sphere or scale box is dragged
  11636. */
  11637. onDragStartObservable: Observable<{}>;
  11638. /**
  11639. * Fired when a scale box is dragged
  11640. */
  11641. onScaleBoxDragObservable: Observable<{}>;
  11642. /**
  11643. * Fired when a scale box drag is ended
  11644. */
  11645. onScaleBoxDragEndObservable: Observable<{}>;
  11646. /**
  11647. * Fired when a rotation sphere is dragged
  11648. */
  11649. onRotationSphereDragObservable: Observable<{}>;
  11650. /**
  11651. * Fired when a rotation sphere drag is ended
  11652. */
  11653. onRotationSphereDragEndObservable: Observable<{}>;
  11654. /**
  11655. * 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)
  11656. */
  11657. scalePivot: Nullable<Vector3>;
  11658. private _anchorMesh;
  11659. private _existingMeshScale;
  11660. private static _PivotCached;
  11661. private static _OldPivotPoint;
  11662. private static _PivotTranslation;
  11663. private static _PivotTmpVector;
  11664. /** @hidden */
  11665. private static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  11666. /** @hidden */
  11667. private static _RestorePivotPoint(mesh: AbstractMesh): void;
  11668. /**
  11669. * Creates an BoundingBoxGizmo
  11670. * @param gizmoLayer The utility layer the gizmo will be added to
  11671. * @param color The color of the gizmo
  11672. */
  11673. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  11674. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  11675. private _selectNode;
  11676. /**
  11677. * Updates the bounding box information for the Gizmo
  11678. */
  11679. updateBoundingBox(): void;
  11680. /**
  11681. * Enables rotation on the specified axis and disables rotation on the others
  11682. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  11683. */
  11684. setEnabledRotationAxis(axis: string): void;
  11685. /**
  11686. * Disposes of the gizmo
  11687. */
  11688. dispose(): void;
  11689. /**
  11690. * 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)
  11691. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  11692. * @returns the bounding box mesh with the passed in mesh as a child
  11693. */
  11694. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  11695. /**
  11696. * CustomMeshes are not supported by this gizmo
  11697. * @param mesh The mesh to replace the default mesh of the gizmo
  11698. */
  11699. setCustomMesh(mesh: Mesh): void;
  11700. }
  11701. }
  11702. declare module BABYLON {
  11703. /**
  11704. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  11705. */
  11706. class Gizmo implements IDisposable {
  11707. /** The utility layer the gizmo will be added to */
  11708. gizmoLayer: UtilityLayerRenderer;
  11709. /**
  11710. * The root mesh of the gizmo
  11711. */
  11712. protected _rootMesh: Mesh;
  11713. private _attachedMesh;
  11714. /**
  11715. * Ratio for the scale of the gizmo (Default: 1)
  11716. */
  11717. scaleRatio: number;
  11718. private _tmpMatrix;
  11719. /**
  11720. * If a custom mesh has been set (Default: false)
  11721. */
  11722. protected _customMeshSet: boolean;
  11723. /**
  11724. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  11725. * * When set, interactions will be enabled
  11726. */
  11727. attachedMesh: Nullable<AbstractMesh>;
  11728. /**
  11729. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  11730. * @param mesh The mesh to replace the default mesh of the gizmo
  11731. */
  11732. setCustomMesh(mesh: Mesh): void;
  11733. /**
  11734. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  11735. */
  11736. updateGizmoRotationToMatchAttachedMesh: boolean;
  11737. /**
  11738. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  11739. */
  11740. updateGizmoPositionToMatchAttachedMesh: boolean;
  11741. /**
  11742. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  11743. */
  11744. protected _updateScale: boolean;
  11745. protected _interactionsEnabled: boolean;
  11746. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  11747. private _beforeRenderObserver;
  11748. /**
  11749. * Creates a gizmo
  11750. * @param gizmoLayer The utility layer the gizmo will be added to
  11751. */
  11752. constructor(
  11753. /** The utility layer the gizmo will be added to */
  11754. gizmoLayer?: UtilityLayerRenderer);
  11755. private _tempVector;
  11756. /**
  11757. * @hidden
  11758. * Updates the gizmo to match the attached mesh's position/rotation
  11759. */
  11760. protected _update(): void;
  11761. /**
  11762. * Disposes of the gizmo
  11763. */
  11764. dispose(): void;
  11765. }
  11766. }
  11767. declare module BABYLON {
  11768. /**
  11769. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  11770. */
  11771. class GizmoManager implements IDisposable {
  11772. private scene;
  11773. /**
  11774. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  11775. */
  11776. gizmos: {
  11777. positionGizmo: Nullable<PositionGizmo>;
  11778. rotationGizmo: Nullable<RotationGizmo>;
  11779. scaleGizmo: Nullable<ScaleGizmo>;
  11780. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  11781. };
  11782. private _gizmosEnabled;
  11783. private _pointerObserver;
  11784. private _attachedMesh;
  11785. private _boundingBoxColor;
  11786. /**
  11787. * When bounding box gizmo is enabled, this can be used to track drag/end events
  11788. */
  11789. boundingBoxDragBehavior: SixDofDragBehavior;
  11790. /**
  11791. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  11792. */
  11793. attachableMeshes: Nullable<Array<AbstractMesh>>;
  11794. /**
  11795. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  11796. */
  11797. usePointerToAttachGizmos: boolean;
  11798. /**
  11799. * Instatiates a gizmo manager
  11800. * @param scene the scene to overlay the gizmos on top of
  11801. */
  11802. constructor(scene: Scene);
  11803. /**
  11804. * Attaches a set of gizmos to the specified mesh
  11805. * @param mesh The mesh the gizmo's should be attached to
  11806. */
  11807. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  11808. /**
  11809. * If the position gizmo is enabled
  11810. */
  11811. positionGizmoEnabled: boolean;
  11812. /**
  11813. * If the rotation gizmo is enabled
  11814. */
  11815. rotationGizmoEnabled: boolean;
  11816. /**
  11817. * If the scale gizmo is enabled
  11818. */
  11819. scaleGizmoEnabled: boolean;
  11820. /**
  11821. * If the boundingBox gizmo is enabled
  11822. */
  11823. boundingBoxGizmoEnabled: boolean;
  11824. /**
  11825. * Disposes of the gizmo manager
  11826. */
  11827. dispose(): void;
  11828. }
  11829. }
  11830. declare module BABYLON {
  11831. /**
  11832. * Single plane rotation gizmo
  11833. */
  11834. class PlaneRotationGizmo extends Gizmo {
  11835. /**
  11836. * Drag behavior responsible for the gizmos dragging interactions
  11837. */
  11838. dragBehavior: PointerDragBehavior;
  11839. private _pointerObserver;
  11840. /**
  11841. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  11842. */
  11843. snapDistance: number;
  11844. /**
  11845. * Event that fires each time the gizmo snaps to a new location.
  11846. * * snapDistance is the the change in distance
  11847. */
  11848. onSnapObservable: Observable<{
  11849. snapDistance: number;
  11850. }>;
  11851. /**
  11852. * Creates a PlaneRotationGizmo
  11853. * @param gizmoLayer The utility layer the gizmo will be added to
  11854. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  11855. * @param color The color of the gizmo
  11856. */
  11857. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  11858. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  11859. /**
  11860. * Disposes of the gizmo
  11861. */
  11862. dispose(): void;
  11863. }
  11864. }
  11865. declare module BABYLON {
  11866. /**
  11867. * Gizmo that enables dragging a mesh along 3 axis
  11868. */
  11869. class PositionGizmo extends Gizmo {
  11870. /**
  11871. * Internal gizmo used for interactions on the x axis
  11872. */
  11873. xGizmo: AxisDragGizmo;
  11874. /**
  11875. * Internal gizmo used for interactions on the y axis
  11876. */
  11877. yGizmo: AxisDragGizmo;
  11878. /**
  11879. * Internal gizmo used for interactions on the z axis
  11880. */
  11881. zGizmo: AxisDragGizmo;
  11882. attachedMesh: Nullable<AbstractMesh>;
  11883. /**
  11884. * Creates a PositionGizmo
  11885. * @param gizmoLayer The utility layer the gizmo will be added to
  11886. */
  11887. constructor(gizmoLayer?: UtilityLayerRenderer);
  11888. updateGizmoRotationToMatchAttachedMesh: boolean;
  11889. /**
  11890. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  11891. */
  11892. snapDistance: number;
  11893. /**
  11894. * Ratio for the scale of the gizmo (Default: 1)
  11895. */
  11896. scaleRatio: number;
  11897. /**
  11898. * Disposes of the gizmo
  11899. */
  11900. dispose(): void;
  11901. /**
  11902. * CustomMeshes are not supported by this gizmo
  11903. * @param mesh The mesh to replace the default mesh of the gizmo
  11904. */
  11905. setCustomMesh(mesh: Mesh): void;
  11906. }
  11907. }
  11908. declare module BABYLON {
  11909. /**
  11910. * Gizmo that enables rotating a mesh along 3 axis
  11911. */
  11912. class RotationGizmo extends Gizmo {
  11913. /**
  11914. * Internal gizmo used for interactions on the x axis
  11915. */
  11916. xGizmo: PlaneRotationGizmo;
  11917. /**
  11918. * Internal gizmo used for interactions on the y axis
  11919. */
  11920. yGizmo: PlaneRotationGizmo;
  11921. /**
  11922. * Internal gizmo used for interactions on the z axis
  11923. */
  11924. zGizmo: PlaneRotationGizmo;
  11925. attachedMesh: Nullable<AbstractMesh>;
  11926. /**
  11927. * Creates a RotationGizmo
  11928. * @param gizmoLayer The utility layer the gizmo will be added to
  11929. */
  11930. constructor(gizmoLayer?: UtilityLayerRenderer);
  11931. updateGizmoRotationToMatchAttachedMesh: boolean;
  11932. /**
  11933. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  11934. */
  11935. snapDistance: number;
  11936. /**
  11937. * Ratio for the scale of the gizmo (Default: 1)
  11938. */
  11939. scaleRatio: number;
  11940. /**
  11941. * Disposes of the gizmo
  11942. */
  11943. dispose(): void;
  11944. /**
  11945. * CustomMeshes are not supported by this gizmo
  11946. * @param mesh The mesh to replace the default mesh of the gizmo
  11947. */
  11948. setCustomMesh(mesh: Mesh): void;
  11949. }
  11950. }
  11951. declare module BABYLON {
  11952. /**
  11953. * Gizmo that enables scaling a mesh along 3 axis
  11954. */
  11955. class ScaleGizmo extends Gizmo {
  11956. /**
  11957. * Internal gizmo used for interactions on the x axis
  11958. */
  11959. xGizmo: AxisScaleGizmo;
  11960. /**
  11961. * Internal gizmo used for interactions on the y axis
  11962. */
  11963. yGizmo: AxisScaleGizmo;
  11964. /**
  11965. * Internal gizmo used for interactions on the z axis
  11966. */
  11967. zGizmo: AxisScaleGizmo;
  11968. /**
  11969. * Internal gizmo used to scale all axis equally
  11970. */
  11971. uniformScaleGizmo: AxisScaleGizmo;
  11972. attachedMesh: Nullable<AbstractMesh>;
  11973. /**
  11974. * Creates a ScaleGizmo
  11975. * @param gizmoLayer The utility layer the gizmo will be added to
  11976. */
  11977. constructor(gizmoLayer?: UtilityLayerRenderer);
  11978. updateGizmoRotationToMatchAttachedMesh: boolean;
  11979. /**
  11980. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  11981. */
  11982. snapDistance: number;
  11983. /**
  11984. * Ratio for the scale of the gizmo (Default: 1)
  11985. */
  11986. scaleRatio: number;
  11987. /**
  11988. * Disposes of the gizmo
  11989. */
  11990. dispose(): void;
  11991. }
  11992. }
  11993. declare module BABYLON {
  11994. /**
  11995. * Represents a gamepad control stick position
  11996. */
  11997. class StickValues {
  11998. /**
  11999. * The x component of the control stick
  12000. */
  12001. x: number;
  12002. /**
  12003. * The y component of the control stick
  12004. */
  12005. y: number;
  12006. /**
  12007. * Initializes the gamepad x and y control stick values
  12008. * @param x The x component of the gamepad control stick value
  12009. * @param y The y component of the gamepad control stick value
  12010. */
  12011. constructor(
  12012. /**
  12013. * The x component of the control stick
  12014. */
  12015. x: number,
  12016. /**
  12017. * The y component of the control stick
  12018. */
  12019. y: number);
  12020. }
  12021. /**
  12022. * An interface which manages callbacks for gamepad button changes
  12023. */
  12024. interface GamepadButtonChanges {
  12025. /**
  12026. * Called when a gamepad has been changed
  12027. */
  12028. changed: boolean;
  12029. /**
  12030. * Called when a gamepad press event has been triggered
  12031. */
  12032. pressChanged: boolean;
  12033. /**
  12034. * Called when a touch event has been triggered
  12035. */
  12036. touchChanged: boolean;
  12037. /**
  12038. * Called when a value has changed
  12039. */
  12040. valueChanged: boolean;
  12041. }
  12042. /**
  12043. * Represents a gamepad
  12044. */
  12045. class Gamepad {
  12046. /**
  12047. * The id of the gamepad
  12048. */
  12049. id: string;
  12050. /**
  12051. * The index of the gamepad
  12052. */
  12053. index: number;
  12054. /**
  12055. * The browser gamepad
  12056. */
  12057. browserGamepad: any;
  12058. /**
  12059. * Specifies what type of gamepad this represents
  12060. */
  12061. type: number;
  12062. private _leftStick;
  12063. private _rightStick;
  12064. /** @hidden */
  12065. private _leftStickAxisX;
  12066. private _leftStickAxisY;
  12067. private _rightStickAxisX;
  12068. private _rightStickAxisY;
  12069. /**
  12070. * Triggered when the left control stick has been changed
  12071. */
  12072. private _onleftstickchanged;
  12073. /**
  12074. * Triggered when the right control stick has been changed
  12075. */
  12076. private _onrightstickchanged;
  12077. /**
  12078. * Represents a gamepad controller
  12079. */
  12080. static GAMEPAD: number;
  12081. /**
  12082. * Represents a generic controller
  12083. */
  12084. static GENERIC: number;
  12085. /**
  12086. * Represents an XBox controller
  12087. */
  12088. static XBOX: number;
  12089. /**
  12090. * Represents a pose-enabled controller
  12091. */
  12092. static POSE_ENABLED: number;
  12093. /**
  12094. * Specifies whether the left control stick should be Y-inverted
  12095. */
  12096. protected _invertLeftStickY: boolean;
  12097. /**
  12098. * Specifies if the gamepad has been connected
  12099. */
  12100. readonly isConnected: boolean;
  12101. /**
  12102. * Initializes the gamepad
  12103. * @param id The id of the gamepad
  12104. * @param index The index of the gamepad
  12105. * @param browserGamepad The browser gamepad
  12106. * @param leftStickX The x component of the left joystick
  12107. * @param leftStickY The y component of the left joystick
  12108. * @param rightStickX The x component of the right joystick
  12109. * @param rightStickY The y component of the right joystick
  12110. */
  12111. constructor(
  12112. /**
  12113. * The id of the gamepad
  12114. */
  12115. id: string,
  12116. /**
  12117. * The index of the gamepad
  12118. */
  12119. index: number,
  12120. /**
  12121. * The browser gamepad
  12122. */
  12123. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12124. /**
  12125. * Callback triggered when the left joystick has changed
  12126. * @param callback
  12127. */
  12128. onleftstickchanged(callback: (values: StickValues) => void): void;
  12129. /**
  12130. * Callback triggered when the right joystick has changed
  12131. * @param callback
  12132. */
  12133. onrightstickchanged(callback: (values: StickValues) => void): void;
  12134. /**
  12135. * Gets the left joystick
  12136. */
  12137. /**
  12138. * Sets the left joystick values
  12139. */
  12140. leftStick: StickValues;
  12141. /**
  12142. * Gets the right joystick
  12143. */
  12144. /**
  12145. * Sets the right joystick value
  12146. */
  12147. rightStick: StickValues;
  12148. /**
  12149. * Updates the gamepad joystick positions
  12150. */
  12151. update(): void;
  12152. /**
  12153. * Disposes the gamepad
  12154. */
  12155. dispose(): void;
  12156. }
  12157. /**
  12158. * Represents a generic gamepad
  12159. */
  12160. class GenericPad extends Gamepad {
  12161. private _buttons;
  12162. private _onbuttondown;
  12163. private _onbuttonup;
  12164. /**
  12165. * Observable triggered when a button has been pressed
  12166. */
  12167. onButtonDownObservable: Observable<number>;
  12168. /**
  12169. * Observable triggered when a button has been released
  12170. */
  12171. onButtonUpObservable: Observable<number>;
  12172. /**
  12173. * Callback triggered when a button has been pressed
  12174. * @param callback Called when a button has been pressed
  12175. */
  12176. onbuttondown(callback: (buttonPressed: number) => void): void;
  12177. /**
  12178. * Callback triggered when a button has been released
  12179. * @param callback Called when a button has been released
  12180. */
  12181. onbuttonup(callback: (buttonReleased: number) => void): void;
  12182. /**
  12183. * Initializes the generic gamepad
  12184. * @param id The id of the generic gamepad
  12185. * @param index The index of the generic gamepad
  12186. * @param browserGamepad The browser gamepad
  12187. */
  12188. constructor(id: string, index: number, browserGamepad: any);
  12189. private _setButtonValue;
  12190. /**
  12191. * Updates the generic gamepad
  12192. */
  12193. update(): void;
  12194. /**
  12195. * Disposes the generic gamepad
  12196. */
  12197. dispose(): void;
  12198. }
  12199. }
  12200. declare module BABYLON {
  12201. /**
  12202. * Manager for handling gamepads
  12203. */
  12204. class GamepadManager {
  12205. private _scene?;
  12206. private _babylonGamepads;
  12207. private _oneGamepadConnected;
  12208. /** @hidden */
  12209. private _gamepadEventSupported;
  12210. private _gamepadSupport;
  12211. /**
  12212. * observable to be triggered when the gamepad controller has been connected
  12213. */
  12214. onGamepadConnectedObservable: Observable<Gamepad>;
  12215. /**
  12216. * observable to be triggered when the gamepad controller has been disconnected
  12217. */
  12218. onGamepadDisconnectedObservable: Observable<Gamepad>;
  12219. private _onGamepadConnectedEvent;
  12220. private _onGamepadDisconnectedEvent;
  12221. /**
  12222. * Initializes the gamepad manager
  12223. * @param _scene BabylonJS scene
  12224. */
  12225. constructor(_scene?: Scene | undefined);
  12226. /**
  12227. * The gamepads in the game pad manager
  12228. */
  12229. readonly gamepads: Gamepad[];
  12230. /**
  12231. * Get the gamepad controllers based on type
  12232. * @param type The type of gamepad controller
  12233. * @returns Nullable gamepad
  12234. */
  12235. getGamepadByType(type?: number): Nullable<Gamepad>;
  12236. /**
  12237. * Disposes the gamepad manager
  12238. */
  12239. dispose(): void;
  12240. private _addNewGamepad;
  12241. private _startMonitoringGamepads;
  12242. private _stopMonitoringGamepads;
  12243. /** @hidden */
  12244. private _updateGamepadObjects;
  12245. }
  12246. }
  12247. declare module BABYLON {
  12248. interface Scene {
  12249. /** @hidden */
  12250. /**
  12251. * Gets the gamepad manager associated with the scene
  12252. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  12253. */
  12254. gamepadManager: GamepadManager;
  12255. }
  12256. /**
  12257. * Interface representing a free camera inputs manager
  12258. */
  12259. interface FreeCameraInputsManager {
  12260. addGamepad(): FreeCameraInputsManager;
  12261. }
  12262. /**
  12263. * Interface representing an arc rotate camera inputs manager
  12264. */
  12265. interface ArcRotateCameraInputsManager {
  12266. /**
  12267. * Adds gamepad input support to the ArcRotateCamera InputManager.
  12268. * @returns the camera inputs manager
  12269. */
  12270. addGamepad(): ArcRotateCameraInputsManager;
  12271. }
  12272. /**
  12273. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  12274. */
  12275. class GamepadSystemSceneComponent implements ISceneComponent {
  12276. /**
  12277. * The component name helpfull to identify the component in the list of scene components.
  12278. */
  12279. readonly name: string;
  12280. /**
  12281. * The scene the component belongs to.
  12282. */
  12283. scene: Scene;
  12284. /**
  12285. * Creates a new instance of the component for the given scene
  12286. * @param scene Defines the scene to register the component in
  12287. */
  12288. constructor(scene: Scene);
  12289. /**
  12290. * Registers the component in a given scene
  12291. */
  12292. register(): void;
  12293. /**
  12294. * Rebuilds the elements related to this component in case of
  12295. * context lost for instance.
  12296. */
  12297. rebuild(): void;
  12298. /**
  12299. * Disposes the component and the associated ressources
  12300. */
  12301. dispose(): void;
  12302. private _beforeCameraUpdate;
  12303. }
  12304. }
  12305. declare module BABYLON {
  12306. /**
  12307. * Defines supported buttons for XBox360 compatible gamepads
  12308. */
  12309. enum Xbox360Button {
  12310. /** A */
  12311. A = 0,
  12312. /** B */
  12313. B = 1,
  12314. /** X */
  12315. X = 2,
  12316. /** Y */
  12317. Y = 3,
  12318. /** Start */
  12319. Start = 4,
  12320. /** Back */
  12321. Back = 5,
  12322. /** Left button */
  12323. LB = 6,
  12324. /** Right button */
  12325. RB = 7,
  12326. /** Left stick */
  12327. LeftStick = 8,
  12328. /** Right stick */
  12329. RightStick = 9
  12330. }
  12331. /** Defines values for XBox360 DPad */
  12332. enum Xbox360Dpad {
  12333. /** Up */
  12334. Up = 0,
  12335. /** Down */
  12336. Down = 1,
  12337. /** Left */
  12338. Left = 2,
  12339. /** Right */
  12340. Right = 3
  12341. }
  12342. /**
  12343. * Defines a XBox360 gamepad
  12344. */
  12345. class Xbox360Pad extends Gamepad {
  12346. private _leftTrigger;
  12347. private _rightTrigger;
  12348. private _onlefttriggerchanged;
  12349. private _onrighttriggerchanged;
  12350. private _onbuttondown;
  12351. private _onbuttonup;
  12352. private _ondpaddown;
  12353. private _ondpadup;
  12354. /** Observable raised when a button is pressed */
  12355. onButtonDownObservable: Observable<Xbox360Button>;
  12356. /** Observable raised when a button is released */
  12357. onButtonUpObservable: Observable<Xbox360Button>;
  12358. /** Observable raised when a pad is pressed */
  12359. onPadDownObservable: Observable<Xbox360Dpad>;
  12360. /** Observable raised when a pad is released */
  12361. onPadUpObservable: Observable<Xbox360Dpad>;
  12362. private _buttonA;
  12363. private _buttonB;
  12364. private _buttonX;
  12365. private _buttonY;
  12366. private _buttonBack;
  12367. private _buttonStart;
  12368. private _buttonLB;
  12369. private _buttonRB;
  12370. private _buttonLeftStick;
  12371. private _buttonRightStick;
  12372. private _dPadUp;
  12373. private _dPadDown;
  12374. private _dPadLeft;
  12375. private _dPadRight;
  12376. private _isXboxOnePad;
  12377. /**
  12378. * Creates a new XBox360 gamepad object
  12379. * @param id defines the id of this gamepad
  12380. * @param index defines its index
  12381. * @param gamepad defines the internal HTML gamepad object
  12382. * @param xboxOne defines if it is a XBox One gamepad
  12383. */
  12384. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  12385. /**
  12386. * Defines the callback to call when left trigger is pressed
  12387. * @param callback defines the callback to use
  12388. */
  12389. onlefttriggerchanged(callback: (value: number) => void): void;
  12390. /**
  12391. * Defines the callback to call when right trigger is pressed
  12392. * @param callback defines the callback to use
  12393. */
  12394. onrighttriggerchanged(callback: (value: number) => void): void;
  12395. /**
  12396. * Gets the left trigger value
  12397. */
  12398. /**
  12399. * Sets the left trigger value
  12400. */
  12401. leftTrigger: number;
  12402. /**
  12403. * Gets the right trigger value
  12404. */
  12405. /**
  12406. * Sets the right trigger value
  12407. */
  12408. rightTrigger: number;
  12409. /**
  12410. * Defines the callback to call when a button is pressed
  12411. * @param callback defines the callback to use
  12412. */
  12413. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  12414. /**
  12415. * Defines the callback to call when a button is released
  12416. * @param callback defines the callback to use
  12417. */
  12418. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  12419. /**
  12420. * Defines the callback to call when a pad is pressed
  12421. * @param callback defines the callback to use
  12422. */
  12423. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  12424. /**
  12425. * Defines the callback to call when a pad is released
  12426. * @param callback defines the callback to use
  12427. */
  12428. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  12429. private _setButtonValue;
  12430. private _setDPadValue;
  12431. /**
  12432. * Gets the value of the `A` button
  12433. */
  12434. /**
  12435. * Sets the value of the `A` button
  12436. */
  12437. buttonA: number;
  12438. /**
  12439. * Gets the value of the `B` button
  12440. */
  12441. /**
  12442. * Sets the value of the `B` button
  12443. */
  12444. buttonB: number;
  12445. /**
  12446. * Gets the value of the `X` button
  12447. */
  12448. /**
  12449. * Sets the value of the `X` button
  12450. */
  12451. buttonX: number;
  12452. /**
  12453. * Gets the value of the `Y` button
  12454. */
  12455. /**
  12456. * Sets the value of the `Y` button
  12457. */
  12458. buttonY: number;
  12459. /**
  12460. * Gets the value of the `Start` button
  12461. */
  12462. /**
  12463. * Sets the value of the `Start` button
  12464. */
  12465. buttonStart: number;
  12466. /**
  12467. * Gets the value of the `Back` button
  12468. */
  12469. /**
  12470. * Sets the value of the `Back` button
  12471. */
  12472. buttonBack: number;
  12473. /**
  12474. * Gets the value of the `Left` button
  12475. */
  12476. /**
  12477. * Sets the value of the `Left` button
  12478. */
  12479. buttonLB: number;
  12480. /**
  12481. * Gets the value of the `Right` button
  12482. */
  12483. /**
  12484. * Sets the value of the `Right` button
  12485. */
  12486. buttonRB: number;
  12487. /**
  12488. * Gets the value of the Left joystick
  12489. */
  12490. /**
  12491. * Sets the value of the Left joystick
  12492. */
  12493. buttonLeftStick: number;
  12494. /**
  12495. * Gets the value of the Right joystick
  12496. */
  12497. /**
  12498. * Sets the value of the Right joystick
  12499. */
  12500. buttonRightStick: number;
  12501. /**
  12502. * Gets the value of D-pad up
  12503. */
  12504. /**
  12505. * Sets the value of D-pad up
  12506. */
  12507. dPadUp: number;
  12508. /**
  12509. * Gets the value of D-pad down
  12510. */
  12511. /**
  12512. * Sets the value of D-pad down
  12513. */
  12514. dPadDown: number;
  12515. /**
  12516. * Gets the value of D-pad left
  12517. */
  12518. /**
  12519. * Sets the value of D-pad left
  12520. */
  12521. dPadLeft: number;
  12522. /**
  12523. * Gets the value of D-pad right
  12524. */
  12525. /**
  12526. * Sets the value of D-pad right
  12527. */
  12528. dPadRight: number;
  12529. /**
  12530. * Force the gamepad to synchronize with device values
  12531. */
  12532. update(): void;
  12533. /**
  12534. * Disposes the gamepad
  12535. */
  12536. dispose(): void;
  12537. }
  12538. }
  12539. declare module BABYLON {
  12540. /**
  12541. * Represents the different options available during the creation of
  12542. * a Environment helper.
  12543. *
  12544. * This can control the default ground, skybox and image processing setup of your scene.
  12545. */
  12546. interface IEnvironmentHelperOptions {
  12547. /**
  12548. * Specifies wether or not to create a ground.
  12549. * True by default.
  12550. */
  12551. createGround: boolean;
  12552. /**
  12553. * Specifies the ground size.
  12554. * 15 by default.
  12555. */
  12556. groundSize: number;
  12557. /**
  12558. * The texture used on the ground for the main color.
  12559. * Comes from the BabylonJS CDN by default.
  12560. *
  12561. * Remarks: Can be either a texture or a url.
  12562. */
  12563. groundTexture: string | BaseTexture;
  12564. /**
  12565. * The color mixed in the ground texture by default.
  12566. * BabylonJS clearColor by default.
  12567. */
  12568. groundColor: Color3;
  12569. /**
  12570. * Specifies the ground opacity.
  12571. * 1 by default.
  12572. */
  12573. groundOpacity: number;
  12574. /**
  12575. * Enables the ground to receive shadows.
  12576. * True by default.
  12577. */
  12578. enableGroundShadow: boolean;
  12579. /**
  12580. * Helps preventing the shadow to be fully black on the ground.
  12581. * 0.5 by default.
  12582. */
  12583. groundShadowLevel: number;
  12584. /**
  12585. * Creates a mirror texture attach to the ground.
  12586. * false by default.
  12587. */
  12588. enableGroundMirror: boolean;
  12589. /**
  12590. * Specifies the ground mirror size ratio.
  12591. * 0.3 by default as the default kernel is 64.
  12592. */
  12593. groundMirrorSizeRatio: number;
  12594. /**
  12595. * Specifies the ground mirror blur kernel size.
  12596. * 64 by default.
  12597. */
  12598. groundMirrorBlurKernel: number;
  12599. /**
  12600. * Specifies the ground mirror visibility amount.
  12601. * 1 by default
  12602. */
  12603. groundMirrorAmount: number;
  12604. /**
  12605. * Specifies the ground mirror reflectance weight.
  12606. * This uses the standard weight of the background material to setup the fresnel effect
  12607. * of the mirror.
  12608. * 1 by default.
  12609. */
  12610. groundMirrorFresnelWeight: number;
  12611. /**
  12612. * Specifies the ground mirror Falloff distance.
  12613. * This can helps reducing the size of the reflection.
  12614. * 0 by Default.
  12615. */
  12616. groundMirrorFallOffDistance: number;
  12617. /**
  12618. * Specifies the ground mirror texture type.
  12619. * Unsigned Int by Default.
  12620. */
  12621. groundMirrorTextureType: number;
  12622. /**
  12623. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  12624. * the shown objects.
  12625. */
  12626. groundYBias: number;
  12627. /**
  12628. * Specifies wether or not to create a skybox.
  12629. * True by default.
  12630. */
  12631. createSkybox: boolean;
  12632. /**
  12633. * Specifies the skybox size.
  12634. * 20 by default.
  12635. */
  12636. skyboxSize: number;
  12637. /**
  12638. * The texture used on the skybox for the main color.
  12639. * Comes from the BabylonJS CDN by default.
  12640. *
  12641. * Remarks: Can be either a texture or a url.
  12642. */
  12643. skyboxTexture: string | BaseTexture;
  12644. /**
  12645. * The color mixed in the skybox texture by default.
  12646. * BabylonJS clearColor by default.
  12647. */
  12648. skyboxColor: Color3;
  12649. /**
  12650. * The background rotation around the Y axis of the scene.
  12651. * This helps aligning the key lights of your scene with the background.
  12652. * 0 by default.
  12653. */
  12654. backgroundYRotation: number;
  12655. /**
  12656. * Compute automatically the size of the elements to best fit with the scene.
  12657. */
  12658. sizeAuto: boolean;
  12659. /**
  12660. * Default position of the rootMesh if autoSize is not true.
  12661. */
  12662. rootPosition: Vector3;
  12663. /**
  12664. * Sets up the image processing in the scene.
  12665. * true by default.
  12666. */
  12667. setupImageProcessing: boolean;
  12668. /**
  12669. * The texture used as your environment texture in the scene.
  12670. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  12671. *
  12672. * Remarks: Can be either a texture or a url.
  12673. */
  12674. environmentTexture: string | BaseTexture;
  12675. /**
  12676. * The value of the exposure to apply to the scene.
  12677. * 0.6 by default if setupImageProcessing is true.
  12678. */
  12679. cameraExposure: number;
  12680. /**
  12681. * The value of the contrast to apply to the scene.
  12682. * 1.6 by default if setupImageProcessing is true.
  12683. */
  12684. cameraContrast: number;
  12685. /**
  12686. * Specifies wether or not tonemapping should be enabled in the scene.
  12687. * true by default if setupImageProcessing is true.
  12688. */
  12689. toneMappingEnabled: boolean;
  12690. }
  12691. /**
  12692. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  12693. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  12694. * It also helps with the default setup of your imageProcessing configuration.
  12695. */
  12696. class EnvironmentHelper {
  12697. /**
  12698. * Default ground texture URL.
  12699. */
  12700. private static _groundTextureCDNUrl;
  12701. /**
  12702. * Default skybox texture URL.
  12703. */
  12704. private static _skyboxTextureCDNUrl;
  12705. /**
  12706. * Default environment texture URL.
  12707. */
  12708. private static _environmentTextureCDNUrl;
  12709. /**
  12710. * Creates the default options for the helper.
  12711. */
  12712. private static _getDefaultOptions;
  12713. private _rootMesh;
  12714. /**
  12715. * Gets the root mesh created by the helper.
  12716. */
  12717. readonly rootMesh: Mesh;
  12718. private _skybox;
  12719. /**
  12720. * Gets the skybox created by the helper.
  12721. */
  12722. readonly skybox: Nullable<Mesh>;
  12723. private _skyboxTexture;
  12724. /**
  12725. * Gets the skybox texture created by the helper.
  12726. */
  12727. readonly skyboxTexture: Nullable<BaseTexture>;
  12728. private _skyboxMaterial;
  12729. /**
  12730. * Gets the skybox material created by the helper.
  12731. */
  12732. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  12733. private _ground;
  12734. /**
  12735. * Gets the ground mesh created by the helper.
  12736. */
  12737. readonly ground: Nullable<Mesh>;
  12738. private _groundTexture;
  12739. /**
  12740. * Gets the ground texture created by the helper.
  12741. */
  12742. readonly groundTexture: Nullable<BaseTexture>;
  12743. private _groundMirror;
  12744. /**
  12745. * Gets the ground mirror created by the helper.
  12746. */
  12747. readonly groundMirror: Nullable<MirrorTexture>;
  12748. /**
  12749. * Gets the ground mirror render list to helps pushing the meshes
  12750. * you wish in the ground reflection.
  12751. */
  12752. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  12753. private _groundMaterial;
  12754. /**
  12755. * Gets the ground material created by the helper.
  12756. */
  12757. readonly groundMaterial: Nullable<BackgroundMaterial>;
  12758. /**
  12759. * Stores the creation options.
  12760. */
  12761. private readonly _scene;
  12762. private _options;
  12763. /**
  12764. * This observable will be notified with any error during the creation of the environment,
  12765. * mainly texture creation errors.
  12766. */
  12767. onErrorObservable: Observable<{
  12768. message?: string;
  12769. exception?: any;
  12770. }>;
  12771. /**
  12772. * constructor
  12773. * @param options
  12774. * @param scene The scene to add the material to
  12775. */
  12776. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  12777. /**
  12778. * Updates the background according to the new options
  12779. * @param options
  12780. */
  12781. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  12782. /**
  12783. * Sets the primary color of all the available elements.
  12784. * @param color the main color to affect to the ground and the background
  12785. */
  12786. setMainColor(color: Color3): void;
  12787. /**
  12788. * Setup the image processing according to the specified options.
  12789. */
  12790. private _setupImageProcessing;
  12791. /**
  12792. * Setup the environment texture according to the specified options.
  12793. */
  12794. private _setupEnvironmentTexture;
  12795. /**
  12796. * Setup the background according to the specified options.
  12797. */
  12798. private _setupBackground;
  12799. /**
  12800. * Get the scene sizes according to the setup.
  12801. */
  12802. private _getSceneSize;
  12803. /**
  12804. * Setup the ground according to the specified options.
  12805. */
  12806. private _setupGround;
  12807. /**
  12808. * Setup the ground material according to the specified options.
  12809. */
  12810. private _setupGroundMaterial;
  12811. /**
  12812. * Setup the ground diffuse texture according to the specified options.
  12813. */
  12814. private _setupGroundDiffuseTexture;
  12815. /**
  12816. * Setup the ground mirror texture according to the specified options.
  12817. */
  12818. private _setupGroundMirrorTexture;
  12819. /**
  12820. * Setup the ground to receive the mirror texture.
  12821. */
  12822. private _setupMirrorInGroundMaterial;
  12823. /**
  12824. * Setup the skybox according to the specified options.
  12825. */
  12826. private _setupSkybox;
  12827. /**
  12828. * Setup the skybox material according to the specified options.
  12829. */
  12830. private _setupSkyboxMaterial;
  12831. /**
  12832. * Setup the skybox reflection texture according to the specified options.
  12833. */
  12834. private _setupSkyboxReflectionTexture;
  12835. private _errorHandler;
  12836. /**
  12837. * Dispose all the elements created by the Helper.
  12838. */
  12839. dispose(): void;
  12840. }
  12841. }
  12842. declare module BABYLON {
  12843. /**
  12844. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  12845. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  12846. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  12847. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  12848. */
  12849. class PhotoDome extends TransformNode {
  12850. private _useDirectMapping;
  12851. /**
  12852. * The texture being displayed on the sphere
  12853. */
  12854. protected _photoTexture: Texture;
  12855. /**
  12856. * Gets or sets the texture being displayed on the sphere
  12857. */
  12858. photoTexture: Texture;
  12859. /**
  12860. * Observable raised when an error occured while loading the 360 image
  12861. */
  12862. onLoadErrorObservable: Observable<string>;
  12863. /**
  12864. * The skybox material
  12865. */
  12866. protected _material: BackgroundMaterial;
  12867. /**
  12868. * The surface used for the skybox
  12869. */
  12870. protected _mesh: Mesh;
  12871. /**
  12872. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  12873. * Also see the options.resolution property.
  12874. */
  12875. fovMultiplier: number;
  12876. /**
  12877. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  12878. * @param name Element's name, child elements will append suffixes for their own names.
  12879. * @param urlsOfPhoto defines the url of the photo to display
  12880. * @param options defines an object containing optional or exposed sub element properties
  12881. * @param onError defines a callback called when an error occured while loading the texture
  12882. */
  12883. constructor(name: string, urlOfPhoto: string, options: {
  12884. resolution?: number;
  12885. size?: number;
  12886. useDirectMapping?: boolean;
  12887. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  12888. /**
  12889. * Releases resources associated with this node.
  12890. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  12891. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  12892. */
  12893. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  12894. }
  12895. }
  12896. declare module BABYLON {
  12897. interface Scene {
  12898. /**
  12899. * Creates a default light for the scene.
  12900. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  12901. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  12902. */
  12903. createDefaultLight(replace?: boolean): void;
  12904. /**
  12905. * Creates a default camera for the scene.
  12906. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  12907. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  12908. * @param replace has default false, when true replaces the active camera in the scene
  12909. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  12910. */
  12911. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  12912. /**
  12913. * Creates a default camera and a default light.
  12914. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  12915. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  12916. * @param replace has the default false, when true replaces the active camera/light in the scene
  12917. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  12918. */
  12919. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  12920. /**
  12921. * Creates a new sky box
  12922. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  12923. * @param environmentTexture defines the texture to use as environment texture
  12924. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  12925. * @param scale defines the overall scale of the skybox
  12926. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  12927. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  12928. * @returns a new mesh holding the sky box
  12929. */
  12930. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  12931. /**
  12932. * Creates a new environment
  12933. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  12934. * @param options defines the options you can use to configure the environment
  12935. * @returns the new EnvironmentHelper
  12936. */
  12937. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  12938. /**
  12939. * Creates a new VREXperienceHelper
  12940. * @see http://doc.babylonjs.com/how_to/webvr_helper
  12941. * @param webVROptions defines the options used to create the new VREXperienceHelper
  12942. * @returns a new VREXperienceHelper
  12943. */
  12944. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  12945. }
  12946. }
  12947. declare module BABYLON {
  12948. /**
  12949. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  12950. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  12951. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  12952. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  12953. */
  12954. class VideoDome extends TransformNode {
  12955. private _useDirectMapping;
  12956. /**
  12957. * The video texture being displayed on the sphere
  12958. */
  12959. protected _videoTexture: VideoTexture;
  12960. /**
  12961. * Gets the video texture being displayed on the sphere
  12962. */
  12963. readonly videoTexture: VideoTexture;
  12964. /**
  12965. * The skybox material
  12966. */
  12967. protected _material: BackgroundMaterial;
  12968. /**
  12969. * The surface used for the skybox
  12970. */
  12971. protected _mesh: Mesh;
  12972. /**
  12973. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  12974. * Also see the options.resolution property.
  12975. */
  12976. fovMultiplier: number;
  12977. /**
  12978. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  12979. * @param name Element's name, child elements will append suffixes for their own names.
  12980. * @param urlsOrVideo defines the url(s) or the video element to use
  12981. * @param options An object containing optional or exposed sub element properties
  12982. */
  12983. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  12984. resolution?: number;
  12985. clickToPlay?: boolean;
  12986. autoPlay?: boolean;
  12987. loop?: boolean;
  12988. size?: number;
  12989. poster?: string;
  12990. useDirectMapping?: boolean;
  12991. }, scene: Scene);
  12992. /**
  12993. * Releases resources associated with this node.
  12994. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  12995. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  12996. */
  12997. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  12998. }
  12999. }
  13000. declare module BABYLON {
  13001. /**
  13002. * This class can be used to get instrumentation data from a Babylon engine
  13003. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  13004. */
  13005. class EngineInstrumentation implements IDisposable {
  13006. /**
  13007. * Define the instrumented engine.
  13008. */
  13009. engine: Engine;
  13010. private _captureGPUFrameTime;
  13011. private _gpuFrameTimeToken;
  13012. private _gpuFrameTime;
  13013. private _captureShaderCompilationTime;
  13014. private _shaderCompilationTime;
  13015. private _onBeginFrameObserver;
  13016. private _onEndFrameObserver;
  13017. private _onBeforeShaderCompilationObserver;
  13018. private _onAfterShaderCompilationObserver;
  13019. /**
  13020. * Gets the perf counter used for GPU frame time
  13021. */
  13022. readonly gpuFrameTimeCounter: PerfCounter;
  13023. /**
  13024. * Gets the GPU frame time capture status
  13025. */
  13026. /**
  13027. * Enable or disable the GPU frame time capture
  13028. */
  13029. captureGPUFrameTime: boolean;
  13030. /**
  13031. * Gets the perf counter used for shader compilation time
  13032. */
  13033. readonly shaderCompilationTimeCounter: PerfCounter;
  13034. /**
  13035. * Gets the shader compilation time capture status
  13036. */
  13037. /**
  13038. * Enable or disable the shader compilation time capture
  13039. */
  13040. captureShaderCompilationTime: boolean;
  13041. /**
  13042. * Instantiates a new engine instrumentation.
  13043. * This class can be used to get instrumentation data from a Babylon engine
  13044. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  13045. * @param engine Defines the engine to instrument
  13046. */
  13047. constructor(
  13048. /**
  13049. * Define the instrumented engine.
  13050. */
  13051. engine: Engine);
  13052. /**
  13053. * Dispose and release associated resources.
  13054. */
  13055. dispose(): void;
  13056. }
  13057. }
  13058. declare module BABYLON {
  13059. /**
  13060. * This class can be used to get instrumentation data from a Babylon engine
  13061. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  13062. */
  13063. class SceneInstrumentation implements IDisposable {
  13064. /**
  13065. * Defines the scene to instrument
  13066. */
  13067. scene: Scene;
  13068. private _captureActiveMeshesEvaluationTime;
  13069. private _activeMeshesEvaluationTime;
  13070. private _captureRenderTargetsRenderTime;
  13071. private _renderTargetsRenderTime;
  13072. private _captureFrameTime;
  13073. private _frameTime;
  13074. private _captureRenderTime;
  13075. private _renderTime;
  13076. private _captureInterFrameTime;
  13077. private _interFrameTime;
  13078. private _captureParticlesRenderTime;
  13079. private _particlesRenderTime;
  13080. private _captureSpritesRenderTime;
  13081. private _spritesRenderTime;
  13082. private _capturePhysicsTime;
  13083. private _physicsTime;
  13084. private _captureAnimationsTime;
  13085. private _animationsTime;
  13086. private _captureCameraRenderTime;
  13087. private _cameraRenderTime;
  13088. private _onBeforeActiveMeshesEvaluationObserver;
  13089. private _onAfterActiveMeshesEvaluationObserver;
  13090. private _onBeforeRenderTargetsRenderObserver;
  13091. private _onAfterRenderTargetsRenderObserver;
  13092. private _onAfterRenderObserver;
  13093. private _onBeforeDrawPhaseObserver;
  13094. private _onAfterDrawPhaseObserver;
  13095. private _onBeforeAnimationsObserver;
  13096. private _onBeforeParticlesRenderingObserver;
  13097. private _onAfterParticlesRenderingObserver;
  13098. private _onBeforeSpritesRenderingObserver;
  13099. private _onAfterSpritesRenderingObserver;
  13100. private _onBeforePhysicsObserver;
  13101. private _onAfterPhysicsObserver;
  13102. private _onAfterAnimationsObserver;
  13103. private _onBeforeCameraRenderObserver;
  13104. private _onAfterCameraRenderObserver;
  13105. /**
  13106. * Gets the perf counter used for active meshes evaluation time
  13107. */
  13108. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  13109. /**
  13110. * Gets the active meshes evaluation time capture status
  13111. */
  13112. /**
  13113. * Enable or disable the active meshes evaluation time capture
  13114. */
  13115. captureActiveMeshesEvaluationTime: boolean;
  13116. /**
  13117. * Gets the perf counter used for render targets render time
  13118. */
  13119. readonly renderTargetsRenderTimeCounter: PerfCounter;
  13120. /**
  13121. * Gets the render targets render time capture status
  13122. */
  13123. /**
  13124. * Enable or disable the render targets render time capture
  13125. */
  13126. captureRenderTargetsRenderTime: boolean;
  13127. /**
  13128. * Gets the perf counter used for particles render time
  13129. */
  13130. readonly particlesRenderTimeCounter: PerfCounter;
  13131. /**
  13132. * Gets the particles render time capture status
  13133. */
  13134. /**
  13135. * Enable or disable the particles render time capture
  13136. */
  13137. captureParticlesRenderTime: boolean;
  13138. /**
  13139. * Gets the perf counter used for sprites render time
  13140. */
  13141. readonly spritesRenderTimeCounter: PerfCounter;
  13142. /**
  13143. * Gets the sprites render time capture status
  13144. */
  13145. /**
  13146. * Enable or disable the sprites render time capture
  13147. */
  13148. captureSpritesRenderTime: boolean;
  13149. /**
  13150. * Gets the perf counter used for physics time
  13151. */
  13152. readonly physicsTimeCounter: PerfCounter;
  13153. /**
  13154. * Gets the physics time capture status
  13155. */
  13156. /**
  13157. * Enable or disable the physics time capture
  13158. */
  13159. capturePhysicsTime: boolean;
  13160. /**
  13161. * Gets the perf counter used for animations time
  13162. */
  13163. readonly animationsTimeCounter: PerfCounter;
  13164. /**
  13165. * Gets the animations time capture status
  13166. */
  13167. /**
  13168. * Enable or disable the animations time capture
  13169. */
  13170. captureAnimationsTime: boolean;
  13171. /**
  13172. * Gets the perf counter used for frame time capture
  13173. */
  13174. readonly frameTimeCounter: PerfCounter;
  13175. /**
  13176. * Gets the frame time capture status
  13177. */
  13178. /**
  13179. * Enable or disable the frame time capture
  13180. */
  13181. captureFrameTime: boolean;
  13182. /**
  13183. * Gets the perf counter used for inter-frames time capture
  13184. */
  13185. readonly interFrameTimeCounter: PerfCounter;
  13186. /**
  13187. * Gets the inter-frames time capture status
  13188. */
  13189. /**
  13190. * Enable or disable the inter-frames time capture
  13191. */
  13192. captureInterFrameTime: boolean;
  13193. /**
  13194. * Gets the perf counter used for render time capture
  13195. */
  13196. readonly renderTimeCounter: PerfCounter;
  13197. /**
  13198. * Gets the render time capture status
  13199. */
  13200. /**
  13201. * Enable or disable the render time capture
  13202. */
  13203. captureRenderTime: boolean;
  13204. /**
  13205. * Gets the perf counter used for camera render time capture
  13206. */
  13207. readonly cameraRenderTimeCounter: PerfCounter;
  13208. /**
  13209. * Gets the camera render time capture status
  13210. */
  13211. /**
  13212. * Enable or disable the camera render time capture
  13213. */
  13214. captureCameraRenderTime: boolean;
  13215. /**
  13216. * Gets the perf counter used for draw calls
  13217. */
  13218. readonly drawCallsCounter: PerfCounter;
  13219. /**
  13220. * Gets the perf counter used for texture collisions
  13221. */
  13222. readonly textureCollisionsCounter: PerfCounter;
  13223. /**
  13224. * Instantiates a new scene instrumentation.
  13225. * This class can be used to get instrumentation data from a Babylon engine
  13226. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  13227. * @param scene Defines the scene to instrument
  13228. */
  13229. constructor(
  13230. /**
  13231. * Defines the scene to instrument
  13232. */
  13233. scene: Scene);
  13234. /**
  13235. * Dispose and release associated resources.
  13236. */
  13237. dispose(): void;
  13238. }
  13239. }
  13240. declare module BABYLON {
  13241. /**
  13242. * @hidden
  13243. **/
  13244. class _TimeToken {
  13245. }
  13246. }
  13247. declare module BABYLON {
  13248. /**
  13249. * Effect layer options. This helps customizing the behaviour
  13250. * of the effect layer.
  13251. */
  13252. interface IEffectLayerOptions {
  13253. /**
  13254. * Multiplication factor apply to the canvas size to compute the render target size
  13255. * used to generated the objects (the smaller the faster).
  13256. */
  13257. mainTextureRatio: number;
  13258. /**
  13259. * Enforces a fixed size texture to ensure effect stability across devices.
  13260. */
  13261. mainTextureFixedSize?: number;
  13262. /**
  13263. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  13264. */
  13265. alphaBlendingMode: number;
  13266. /**
  13267. * The camera attached to the layer.
  13268. */
  13269. camera: Nullable<Camera>;
  13270. /**
  13271. * The rendering group to draw the layer in.
  13272. */
  13273. renderingGroupId: number;
  13274. }
  13275. /**
  13276. * The effect layer Helps adding post process effect blended with the main pass.
  13277. *
  13278. * This can be for instance use to generate glow or higlight effects on the scene.
  13279. *
  13280. * The effect layer class can not be used directly and is intented to inherited from to be
  13281. * customized per effects.
  13282. */
  13283. abstract class EffectLayer {
  13284. private _vertexBuffers;
  13285. private _indexBuffer;
  13286. private _cachedDefines;
  13287. private _effectLayerMapGenerationEffect;
  13288. private _effectLayerOptions;
  13289. private _mergeEffect;
  13290. protected _scene: Scene;
  13291. protected _engine: Engine;
  13292. protected _maxSize: number;
  13293. protected _mainTextureDesiredSize: ISize;
  13294. protected _mainTexture: RenderTargetTexture;
  13295. protected _shouldRender: boolean;
  13296. protected _postProcesses: PostProcess[];
  13297. protected _textures: BaseTexture[];
  13298. protected _emissiveTextureAndColor: {
  13299. texture: Nullable<BaseTexture>;
  13300. color: Color4;
  13301. };
  13302. /**
  13303. * The name of the layer
  13304. */
  13305. name: string;
  13306. /**
  13307. * The clear color of the texture used to generate the glow map.
  13308. */
  13309. neutralColor: Color4;
  13310. /**
  13311. * Specifies wether the highlight layer is enabled or not.
  13312. */
  13313. isEnabled: boolean;
  13314. /**
  13315. * Gets the camera attached to the layer.
  13316. */
  13317. readonly camera: Nullable<Camera>;
  13318. /**
  13319. * Gets the rendering group id the layer should render in.
  13320. */
  13321. readonly renderingGroupId: number;
  13322. /**
  13323. * An event triggered when the effect layer has been disposed.
  13324. */
  13325. onDisposeObservable: Observable<EffectLayer>;
  13326. /**
  13327. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  13328. */
  13329. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  13330. /**
  13331. * An event triggered when the generated texture is being merged in the scene.
  13332. */
  13333. onBeforeComposeObservable: Observable<EffectLayer>;
  13334. /**
  13335. * An event triggered when the generated texture has been merged in the scene.
  13336. */
  13337. onAfterComposeObservable: Observable<EffectLayer>;
  13338. /**
  13339. * An event triggered when the efffect layer changes its size.
  13340. */
  13341. onSizeChangedObservable: Observable<EffectLayer>;
  13342. /**
  13343. * Instantiates a new effect Layer and references it in the scene.
  13344. * @param name The name of the layer
  13345. * @param scene The scene to use the layer in
  13346. */
  13347. constructor(
  13348. /** The Friendly of the effect in the scene */
  13349. name: string, scene: Scene);
  13350. /**
  13351. * Get the effect name of the layer.
  13352. * @return The effect name
  13353. */
  13354. abstract getEffectName(): string;
  13355. /**
  13356. * Checks for the readiness of the element composing the layer.
  13357. * @param subMesh the mesh to check for
  13358. * @param useInstances specify wether or not to use instances to render the mesh
  13359. * @return true if ready otherwise, false
  13360. */
  13361. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  13362. /**
  13363. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  13364. * @returns true if the effect requires stencil during the main canvas render pass.
  13365. */
  13366. abstract needStencil(): boolean;
  13367. /**
  13368. * Create the merge effect. This is the shader use to blit the information back
  13369. * to the main canvas at the end of the scene rendering.
  13370. * @returns The effect containing the shader used to merge the effect on the main canvas
  13371. */
  13372. protected abstract _createMergeEffect(): Effect;
  13373. /**
  13374. * Creates the render target textures and post processes used in the effect layer.
  13375. */
  13376. protected abstract _createTextureAndPostProcesses(): void;
  13377. /**
  13378. * Implementation specific of rendering the generating effect on the main canvas.
  13379. * @param effect The effect used to render through
  13380. */
  13381. protected abstract _internalRender(effect: Effect): void;
  13382. /**
  13383. * Sets the required values for both the emissive texture and and the main color.
  13384. */
  13385. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  13386. /**
  13387. * Free any resources and references associated to a mesh.
  13388. * Internal use
  13389. * @param mesh The mesh to free.
  13390. */
  13391. disposeMesh(mesh: Mesh): void;
  13392. /**
  13393. * Serializes this layer (Glow or Highlight for example)
  13394. * @returns a serialized layer object
  13395. */
  13396. abstract serialize?(): any;
  13397. /**
  13398. * Initializes the effect layer with the required options.
  13399. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  13400. */
  13401. protected _init(options: Partial<IEffectLayerOptions>): void;
  13402. /**
  13403. * Generates the index buffer of the full screen quad blending to the main canvas.
  13404. */
  13405. private _generateIndexBuffer;
  13406. /**
  13407. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  13408. */
  13409. private _genrateVertexBuffer;
  13410. /**
  13411. * Sets the main texture desired size which is the closest power of two
  13412. * of the engine canvas size.
  13413. */
  13414. private _setMainTextureSize;
  13415. /**
  13416. * Creates the main texture for the effect layer.
  13417. */
  13418. protected _createMainTexture(): void;
  13419. /**
  13420. * Checks for the readiness of the element composing the layer.
  13421. * @param subMesh the mesh to check for
  13422. * @param useInstances specify wether or not to use instances to render the mesh
  13423. * @param emissiveTexture the associated emissive texture used to generate the glow
  13424. * @return true if ready otherwise, false
  13425. */
  13426. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  13427. /**
  13428. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  13429. */
  13430. render(): void;
  13431. /**
  13432. * Determine if a given mesh will be used in the current effect.
  13433. * @param mesh mesh to test
  13434. * @returns true if the mesh will be used
  13435. */
  13436. hasMesh(mesh: AbstractMesh): boolean;
  13437. /**
  13438. * Returns true if the layer contains information to display, otherwise false.
  13439. * @returns true if the glow layer should be rendered
  13440. */
  13441. shouldRender(): boolean;
  13442. /**
  13443. * Returns true if the mesh should render, otherwise false.
  13444. * @param mesh The mesh to render
  13445. * @returns true if it should render otherwise false
  13446. */
  13447. protected _shouldRenderMesh(mesh: Mesh): boolean;
  13448. /**
  13449. * Returns true if the mesh should render, otherwise false.
  13450. * @param mesh The mesh to render
  13451. * @returns true if it should render otherwise false
  13452. */
  13453. protected _shouldRenderEmissiveTextureForMesh(mesh: Mesh): boolean;
  13454. /**
  13455. * Renders the submesh passed in parameter to the generation map.
  13456. */
  13457. protected _renderSubMesh(subMesh: SubMesh): void;
  13458. /**
  13459. * Rebuild the required buffers.
  13460. * @hidden Internal use only.
  13461. */
  13462. /**
  13463. * Dispose only the render target textures and post process.
  13464. */
  13465. private _disposeTextureAndPostProcesses;
  13466. /**
  13467. * Dispose the highlight layer and free resources.
  13468. */
  13469. dispose(): void;
  13470. /**
  13471. * Gets the class name of the effect layer
  13472. * @returns the string with the class name of the effect layer
  13473. */
  13474. getClassName(): string;
  13475. /**
  13476. * Creates an effect layer from parsed effect layer data
  13477. * @param parsedEffectLayer defines effect layer data
  13478. * @param scene defines the current scene
  13479. * @param rootUrl defines the root URL containing the effect layer information
  13480. * @returns a parsed effect Layer
  13481. */
  13482. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  13483. }
  13484. }
  13485. declare module BABYLON {
  13486. interface AbstractScene {
  13487. /**
  13488. * The list of effect layers (highlights/glow) added to the scene
  13489. * @see http://doc.babylonjs.com/how_to/highlight_layer
  13490. * @see http://doc.babylonjs.com/how_to/glow_layer
  13491. */
  13492. effectLayers: Array<EffectLayer>;
  13493. /**
  13494. * Removes the given effect layer from this scene.
  13495. * @param toRemove defines the effect layer to remove
  13496. * @returns the index of the removed effect layer
  13497. */
  13498. removeEffectLayer(toRemove: EffectLayer): number;
  13499. /**
  13500. * Adds the given effect layer to this scene
  13501. * @param newEffectLayer defines the effect layer to add
  13502. */
  13503. addEffectLayer(newEffectLayer: EffectLayer): void;
  13504. }
  13505. /**
  13506. * Defines the layer scene component responsible to manage any effect layers
  13507. * in a given scene.
  13508. */
  13509. class EffectLayerSceneComponent implements ISceneSerializableComponent {
  13510. /**
  13511. * The component name helpfull to identify the component in the list of scene components.
  13512. */
  13513. readonly name: string;
  13514. /**
  13515. * The scene the component belongs to.
  13516. */
  13517. scene: Scene;
  13518. private _engine;
  13519. private _renderEffects;
  13520. private _needStencil;
  13521. private _previousStencilState;
  13522. /**
  13523. * Creates a new instance of the component for the given scene
  13524. * @param scene Defines the scene to register the component in
  13525. */
  13526. constructor(scene: Scene);
  13527. /**
  13528. * Registers the component in a given scene
  13529. */
  13530. register(): void;
  13531. /**
  13532. * Rebuilds the elements related to this component in case of
  13533. * context lost for instance.
  13534. */
  13535. rebuild(): void;
  13536. /**
  13537. * Serializes the component data to the specified json object
  13538. * @param serializationObject The object to serialize to
  13539. */
  13540. serialize(serializationObject: any): void;
  13541. /**
  13542. * Adds all the element from the container to the scene
  13543. * @param container the container holding the elements
  13544. */
  13545. addFromContainer(container: AbstractScene): void;
  13546. /**
  13547. * Removes all the elements in the container from the scene
  13548. * @param container contains the elements to remove
  13549. */
  13550. removeFromContainer(container: AbstractScene): void;
  13551. /**
  13552. * Disposes the component and the associated ressources.
  13553. */
  13554. dispose(): void;
  13555. private _isReadyForMesh;
  13556. private _renderMainTexture;
  13557. private _setStencil;
  13558. private _setStencilBack;
  13559. private _draw;
  13560. private _drawCamera;
  13561. private _drawRenderingGroup;
  13562. }
  13563. }
  13564. declare module BABYLON {
  13565. interface AbstractScene {
  13566. /**
  13567. * Return a the first highlight layer of the scene with a given name.
  13568. * @param name The name of the highlight layer to look for.
  13569. * @return The highlight layer if found otherwise null.
  13570. */
  13571. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  13572. }
  13573. /**
  13574. * Glow layer options. This helps customizing the behaviour
  13575. * of the glow layer.
  13576. */
  13577. interface IGlowLayerOptions {
  13578. /**
  13579. * Multiplication factor apply to the canvas size to compute the render target size
  13580. * used to generated the glowing objects (the smaller the faster).
  13581. */
  13582. mainTextureRatio: number;
  13583. /**
  13584. * Enforces a fixed size texture to ensure resize independant blur.
  13585. */
  13586. mainTextureFixedSize?: number;
  13587. /**
  13588. * How big is the kernel of the blur texture.
  13589. */
  13590. blurKernelSize: number;
  13591. /**
  13592. * The camera attached to the layer.
  13593. */
  13594. camera: Nullable<Camera>;
  13595. /**
  13596. * Enable MSAA by chosing the number of samples.
  13597. */
  13598. mainTextureSamples?: number;
  13599. /**
  13600. * The rendering group to draw the layer in.
  13601. */
  13602. renderingGroupId: number;
  13603. }
  13604. /**
  13605. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  13606. *
  13607. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  13608. * glowy meshes to your scene.
  13609. *
  13610. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  13611. */
  13612. class GlowLayer extends EffectLayer {
  13613. /**
  13614. * Effect Name of the layer.
  13615. */
  13616. static readonly EffectName: string;
  13617. /**
  13618. * The default blur kernel size used for the glow.
  13619. */
  13620. static DefaultBlurKernelSize: number;
  13621. /**
  13622. * The default texture size ratio used for the glow.
  13623. */
  13624. static DefaultTextureRatio: number;
  13625. /**
  13626. * Sets the kernel size of the blur.
  13627. */
  13628. /**
  13629. * Gets the kernel size of the blur.
  13630. */
  13631. blurKernelSize: number;
  13632. /**
  13633. * Sets the glow intensity.
  13634. */
  13635. /**
  13636. * Gets the glow intensity.
  13637. */
  13638. intensity: number;
  13639. private _options;
  13640. private _intensity;
  13641. private _horizontalBlurPostprocess1;
  13642. private _verticalBlurPostprocess1;
  13643. private _horizontalBlurPostprocess2;
  13644. private _verticalBlurPostprocess2;
  13645. private _blurTexture1;
  13646. private _blurTexture2;
  13647. private _postProcesses1;
  13648. private _postProcesses2;
  13649. private _includedOnlyMeshes;
  13650. private _excludedMeshes;
  13651. /**
  13652. * Callback used to let the user override the color selection on a per mesh basis
  13653. */
  13654. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  13655. /**
  13656. * Callback used to let the user override the texture selection on a per mesh basis
  13657. */
  13658. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  13659. /**
  13660. * Instantiates a new glow Layer and references it to the scene.
  13661. * @param name The name of the layer
  13662. * @param scene The scene to use the layer in
  13663. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  13664. */
  13665. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  13666. /**
  13667. * Get the effect name of the layer.
  13668. * @return The effect name
  13669. */
  13670. getEffectName(): string;
  13671. /**
  13672. * Create the merge effect. This is the shader use to blit the information back
  13673. * to the main canvas at the end of the scene rendering.
  13674. */
  13675. protected _createMergeEffect(): Effect;
  13676. /**
  13677. * Creates the render target textures and post processes used in the glow layer.
  13678. */
  13679. protected _createTextureAndPostProcesses(): void;
  13680. /**
  13681. * Checks for the readiness of the element composing the layer.
  13682. * @param subMesh the mesh to check for
  13683. * @param useInstances specify wether or not to use instances to render the mesh
  13684. * @param emissiveTexture the associated emissive texture used to generate the glow
  13685. * @return true if ready otherwise, false
  13686. */
  13687. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  13688. /**
  13689. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  13690. */
  13691. needStencil(): boolean;
  13692. /**
  13693. * Implementation specific of rendering the generating effect on the main canvas.
  13694. * @param effect The effect used to render through
  13695. */
  13696. protected _internalRender(effect: Effect): void;
  13697. /**
  13698. * Sets the required values for both the emissive texture and and the main color.
  13699. */
  13700. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  13701. /**
  13702. * Returns true if the mesh should render, otherwise false.
  13703. * @param mesh The mesh to render
  13704. * @returns true if it should render otherwise false
  13705. */
  13706. protected _shouldRenderMesh(mesh: Mesh): boolean;
  13707. /**
  13708. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  13709. * @param mesh The mesh to exclude from the glow layer
  13710. */
  13711. addExcludedMesh(mesh: Mesh): void;
  13712. /**
  13713. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  13714. * @param mesh The mesh to remove
  13715. */
  13716. removeExcludedMesh(mesh: Mesh): void;
  13717. /**
  13718. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  13719. * @param mesh The mesh to include in the glow layer
  13720. */
  13721. addIncludedOnlyMesh(mesh: Mesh): void;
  13722. /**
  13723. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  13724. * @param mesh The mesh to remove
  13725. */
  13726. removeIncludedOnlyMesh(mesh: Mesh): void;
  13727. /**
  13728. * Determine if a given mesh will be used in the glow layer
  13729. * @param mesh The mesh to test
  13730. * @returns true if the mesh will be highlighted by the current glow layer
  13731. */
  13732. hasMesh(mesh: AbstractMesh): boolean;
  13733. /**
  13734. * Free any resources and references associated to a mesh.
  13735. * Internal use
  13736. * @param mesh The mesh to free.
  13737. * @hidden
  13738. */
  13739. /**
  13740. * Gets the class name of the effect layer
  13741. * @returns the string with the class name of the effect layer
  13742. */
  13743. getClassName(): string;
  13744. /**
  13745. * Serializes this glow layer
  13746. * @returns a serialized glow layer object
  13747. */
  13748. serialize(): any;
  13749. /**
  13750. * Creates a Glow Layer from parsed glow layer data
  13751. * @param parsedGlowLayer defines glow layer data
  13752. * @param scene defines the current scene
  13753. * @param rootUrl defines the root URL containing the glow layer information
  13754. * @returns a parsed Glow Layer
  13755. */
  13756. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  13757. }
  13758. }
  13759. declare module BABYLON {
  13760. interface AbstractScene {
  13761. /**
  13762. * Return a the first highlight layer of the scene with a given name.
  13763. * @param name The name of the highlight layer to look for.
  13764. * @return The highlight layer if found otherwise null.
  13765. */
  13766. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  13767. }
  13768. /**
  13769. * Highlight layer options. This helps customizing the behaviour
  13770. * of the highlight layer.
  13771. */
  13772. interface IHighlightLayerOptions {
  13773. /**
  13774. * Multiplication factor apply to the canvas size to compute the render target size
  13775. * used to generated the glowing objects (the smaller the faster).
  13776. */
  13777. mainTextureRatio: number;
  13778. /**
  13779. * Enforces a fixed size texture to ensure resize independant blur.
  13780. */
  13781. mainTextureFixedSize?: number;
  13782. /**
  13783. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  13784. * of the picture to blur (the smaller the faster).
  13785. */
  13786. blurTextureSizeRatio: number;
  13787. /**
  13788. * How big in texel of the blur texture is the vertical blur.
  13789. */
  13790. blurVerticalSize: number;
  13791. /**
  13792. * How big in texel of the blur texture is the horizontal blur.
  13793. */
  13794. blurHorizontalSize: number;
  13795. /**
  13796. * Alpha blending mode used to apply the blur. Default is combine.
  13797. */
  13798. alphaBlendingMode: number;
  13799. /**
  13800. * The camera attached to the layer.
  13801. */
  13802. camera: Nullable<Camera>;
  13803. /**
  13804. * Should we display highlight as a solid stroke?
  13805. */
  13806. isStroke?: boolean;
  13807. /**
  13808. * The rendering group to draw the layer in.
  13809. */
  13810. renderingGroupId: number;
  13811. }
  13812. /**
  13813. * The highlight layer Helps adding a glow effect around a mesh.
  13814. *
  13815. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  13816. * glowy meshes to your scene.
  13817. *
  13818. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  13819. */
  13820. class HighlightLayer extends EffectLayer {
  13821. name: string;
  13822. /**
  13823. * Effect Name of the highlight layer.
  13824. */
  13825. static readonly EffectName: string;
  13826. /**
  13827. * The neutral color used during the preparation of the glow effect.
  13828. * This is black by default as the blend operation is a blend operation.
  13829. */
  13830. static NeutralColor: Color4;
  13831. /**
  13832. * Stencil value used for glowing meshes.
  13833. */
  13834. static GlowingMeshStencilReference: number;
  13835. /**
  13836. * Stencil value used for the other meshes in the scene.
  13837. */
  13838. static NormalMeshStencilReference: number;
  13839. /**
  13840. * Specifies whether or not the inner glow is ACTIVE in the layer.
  13841. */
  13842. innerGlow: boolean;
  13843. /**
  13844. * Specifies whether or not the outer glow is ACTIVE in the layer.
  13845. */
  13846. outerGlow: boolean;
  13847. /**
  13848. * Specifies the horizontal size of the blur.
  13849. */
  13850. /**
  13851. * Gets the horizontal size of the blur.
  13852. */
  13853. blurHorizontalSize: number;
  13854. /**
  13855. * Specifies the vertical size of the blur.
  13856. */
  13857. /**
  13858. * Gets the vertical size of the blur.
  13859. */
  13860. blurVerticalSize: number;
  13861. /**
  13862. * An event triggered when the highlight layer is being blurred.
  13863. */
  13864. onBeforeBlurObservable: Observable<HighlightLayer>;
  13865. /**
  13866. * An event triggered when the highlight layer has been blurred.
  13867. */
  13868. onAfterBlurObservable: Observable<HighlightLayer>;
  13869. private _instanceGlowingMeshStencilReference;
  13870. private _options;
  13871. private _downSamplePostprocess;
  13872. private _horizontalBlurPostprocess;
  13873. private _verticalBlurPostprocess;
  13874. private _blurTexture;
  13875. private _meshes;
  13876. private _excludedMeshes;
  13877. /**
  13878. * Instantiates a new highlight Layer and references it to the scene..
  13879. * @param name The name of the layer
  13880. * @param scene The scene to use the layer in
  13881. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  13882. */
  13883. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  13884. /**
  13885. * Get the effect name of the layer.
  13886. * @return The effect name
  13887. */
  13888. getEffectName(): string;
  13889. /**
  13890. * Create the merge effect. This is the shader use to blit the information back
  13891. * to the main canvas at the end of the scene rendering.
  13892. */
  13893. protected _createMergeEffect(): Effect;
  13894. /**
  13895. * Creates the render target textures and post processes used in the highlight layer.
  13896. */
  13897. protected _createTextureAndPostProcesses(): void;
  13898. /**
  13899. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  13900. */
  13901. needStencil(): boolean;
  13902. /**
  13903. * Checks for the readiness of the element composing the layer.
  13904. * @param subMesh the mesh to check for
  13905. * @param useInstances specify wether or not to use instances to render the mesh
  13906. * @param emissiveTexture the associated emissive texture used to generate the glow
  13907. * @return true if ready otherwise, false
  13908. */
  13909. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  13910. /**
  13911. * Implementation specific of rendering the generating effect on the main canvas.
  13912. * @param effect The effect used to render through
  13913. */
  13914. protected _internalRender(effect: Effect): void;
  13915. /**
  13916. * Returns true if the layer contains information to display, otherwise false.
  13917. */
  13918. shouldRender(): boolean;
  13919. /**
  13920. * Returns true if the mesh should render, otherwise false.
  13921. * @param mesh The mesh to render
  13922. * @returns true if it should render otherwise false
  13923. */
  13924. protected _shouldRenderMesh(mesh: Mesh): boolean;
  13925. /**
  13926. * Sets the required values for both the emissive texture and and the main color.
  13927. */
  13928. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  13929. /**
  13930. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  13931. * @param mesh The mesh to exclude from the highlight layer
  13932. */
  13933. addExcludedMesh(mesh: Mesh): void;
  13934. /**
  13935. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  13936. * @param mesh The mesh to highlight
  13937. */
  13938. removeExcludedMesh(mesh: Mesh): void;
  13939. /**
  13940. * Determine if a given mesh will be highlighted by the current HighlightLayer
  13941. * @param mesh mesh to test
  13942. * @returns true if the mesh will be highlighted by the current HighlightLayer
  13943. */
  13944. hasMesh(mesh: AbstractMesh): boolean;
  13945. /**
  13946. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  13947. * @param mesh The mesh to highlight
  13948. * @param color The color of the highlight
  13949. * @param glowEmissiveOnly Extract the glow from the emissive texture
  13950. */
  13951. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  13952. /**
  13953. * Remove a mesh from the highlight layer in order to make it stop glowing.
  13954. * @param mesh The mesh to highlight
  13955. */
  13956. removeMesh(mesh: Mesh): void;
  13957. /**
  13958. * Force the stencil to the normal expected value for none glowing parts
  13959. */
  13960. private _defaultStencilReference;
  13961. /**
  13962. * Free any resources and references associated to a mesh.
  13963. * Internal use
  13964. * @param mesh The mesh to free.
  13965. * @hidden
  13966. */
  13967. /**
  13968. * Dispose the highlight layer and free resources.
  13969. */
  13970. dispose(): void;
  13971. /**
  13972. * Gets the class name of the effect layer
  13973. * @returns the string with the class name of the effect layer
  13974. */
  13975. getClassName(): string;
  13976. /**
  13977. * Serializes this Highlight layer
  13978. * @returns a serialized Highlight layer object
  13979. */
  13980. serialize(): any;
  13981. /**
  13982. * Creates a Highlight layer from parsed Highlight layer data
  13983. * @param parsedHightlightLayer defines the Highlight layer data
  13984. * @param scene defines the current scene
  13985. * @param rootUrl defines the root URL containing the Highlight layer information
  13986. * @returns a parsed Highlight layer
  13987. */
  13988. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  13989. }
  13990. }
  13991. declare module BABYLON {
  13992. /**
  13993. * This represents a full screen 2d layer.
  13994. * This can be usefull to display a picture in the background of your scene for instance.
  13995. * @see https://www.babylonjs-playground.com/#08A2BS#1
  13996. */
  13997. class Layer {
  13998. /**
  13999. * Define the name of the layer.
  14000. */
  14001. name: string;
  14002. /**
  14003. * Define the texture the layer should display.
  14004. */
  14005. texture: Nullable<Texture>;
  14006. /**
  14007. * Is the layer in background or foreground.
  14008. */
  14009. isBackground: boolean;
  14010. /**
  14011. * Define the color of the layer (instead of texture).
  14012. */
  14013. color: Color4;
  14014. /**
  14015. * Define the scale of the layer in order to zoom in out of the texture.
  14016. */
  14017. scale: Vector2;
  14018. /**
  14019. * Define an offset for the layer in order to shift the texture.
  14020. */
  14021. offset: Vector2;
  14022. /**
  14023. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  14024. */
  14025. alphaBlendingMode: number;
  14026. /**
  14027. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  14028. * Alpha test will not mix with the background color in case of transparency.
  14029. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  14030. */
  14031. alphaTest: boolean;
  14032. /**
  14033. * Define a mask to restrict the layer to only some of the scene cameras.
  14034. */
  14035. layerMask: number;
  14036. private _scene;
  14037. private _vertexBuffers;
  14038. private _indexBuffer;
  14039. private _effect;
  14040. private _alphaTestEffect;
  14041. /**
  14042. * An event triggered when the layer is disposed.
  14043. */
  14044. onDisposeObservable: Observable<Layer>;
  14045. private _onDisposeObserver;
  14046. /**
  14047. * Back compatibility with callback before the onDisposeObservable existed.
  14048. * The set callback will be triggered when the layer has been disposed.
  14049. */
  14050. onDispose: () => void;
  14051. /**
  14052. * An event triggered before rendering the scene
  14053. */
  14054. onBeforeRenderObservable: Observable<Layer>;
  14055. private _onBeforeRenderObserver;
  14056. /**
  14057. * Back compatibility with callback before the onBeforeRenderObservable existed.
  14058. * The set callback will be triggered just before rendering the layer.
  14059. */
  14060. onBeforeRender: () => void;
  14061. /**
  14062. * An event triggered after rendering the scene
  14063. */
  14064. onAfterRenderObservable: Observable<Layer>;
  14065. private _onAfterRenderObserver;
  14066. /**
  14067. * Back compatibility with callback before the onAfterRenderObservable existed.
  14068. * The set callback will be triggered just after rendering the layer.
  14069. */
  14070. onAfterRender: () => void;
  14071. /**
  14072. * Instantiates a new layer.
  14073. * This represents a full screen 2d layer.
  14074. * This can be usefull to display a picture in the background of your scene for instance.
  14075. * @see https://www.babylonjs-playground.com/#08A2BS#1
  14076. * @param name Define the name of the layer in the scene
  14077. * @param imgUrl Define the url of the texture to display in the layer
  14078. * @param scene Define the scene the layer belongs to
  14079. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  14080. * @param color Defines a color for the layer
  14081. */
  14082. constructor(
  14083. /**
  14084. * Define the name of the layer.
  14085. */
  14086. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  14087. private _createIndexBuffer;
  14088. /** @hidden */
  14089. /**
  14090. * Renders the layer in the scene.
  14091. */
  14092. render(): void;
  14093. /**
  14094. * Disposes and releases the associated ressources.
  14095. */
  14096. dispose(): void;
  14097. }
  14098. }
  14099. declare module BABYLON {
  14100. interface AbstractScene {
  14101. /**
  14102. * The list of layers (background and foreground) of the scene
  14103. */
  14104. layers: Array<Layer>;
  14105. }
  14106. /**
  14107. * Defines the layer scene component responsible to manage any layers
  14108. * in a given scene.
  14109. */
  14110. class LayerSceneComponent implements ISceneComponent {
  14111. /**
  14112. * The component name helpfull to identify the component in the list of scene components.
  14113. */
  14114. readonly name: string;
  14115. /**
  14116. * The scene the component belongs to.
  14117. */
  14118. scene: Scene;
  14119. private _engine;
  14120. /**
  14121. * Creates a new instance of the component for the given scene
  14122. * @param scene Defines the scene to register the component in
  14123. */
  14124. constructor(scene: Scene);
  14125. /**
  14126. * Registers the component in a given scene
  14127. */
  14128. register(): void;
  14129. /**
  14130. * Rebuilds the elements related to this component in case of
  14131. * context lost for instance.
  14132. */
  14133. rebuild(): void;
  14134. /**
  14135. * Disposes the component and the associated ressources.
  14136. */
  14137. dispose(): void;
  14138. private _draw;
  14139. private _drawBackground;
  14140. private _drawForeground;
  14141. }
  14142. }
  14143. declare module BABYLON {
  14144. /**
  14145. * This represents one of the lens effect in a `BABYLON.lensFlareSystem`.
  14146. * It controls one of the indiviual texture used in the effect.
  14147. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  14148. */
  14149. class LensFlare {
  14150. /**
  14151. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  14152. */
  14153. size: number;
  14154. /**
  14155. * 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.
  14156. */
  14157. position: number;
  14158. /**
  14159. * Define the lens color.
  14160. */
  14161. color: Color3;
  14162. /**
  14163. * Define the lens texture.
  14164. */
  14165. texture: Nullable<Texture>;
  14166. /**
  14167. * Define the alpha mode to render this particular lens.
  14168. */
  14169. alphaMode: number;
  14170. private _system;
  14171. /**
  14172. * Creates a new Lens Flare.
  14173. * This represents one of the lens effect in a `BABYLON.lensFlareSystem`.
  14174. * It controls one of the indiviual texture used in the effect.
  14175. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  14176. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  14177. * @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.
  14178. * @param color Define the lens color
  14179. * @param imgUrl Define the lens texture url
  14180. * @param system Define the `lensFlareSystem` this flare is part of
  14181. * @returns The newly created Lens Flare
  14182. */
  14183. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  14184. /**
  14185. * Instantiates a new Lens Flare.
  14186. * This represents one of the lens effect in a `BABYLON.lensFlareSystem`.
  14187. * It controls one of the indiviual texture used in the effect.
  14188. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  14189. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  14190. * @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.
  14191. * @param color Define the lens color
  14192. * @param imgUrl Define the lens texture url
  14193. * @param system Define the `lensFlareSystem` this flare is part of
  14194. */
  14195. constructor(
  14196. /**
  14197. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  14198. */
  14199. size: number,
  14200. /**
  14201. * 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.
  14202. */
  14203. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  14204. /**
  14205. * Dispose and release the lens flare with its associated resources.
  14206. */
  14207. dispose(): void;
  14208. }
  14209. }
  14210. declare module BABYLON {
  14211. /**
  14212. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  14213. * It is usually composed of several `BABYLON.lensFlare`.
  14214. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  14215. */
  14216. class LensFlareSystem {
  14217. /**
  14218. * Define the name of the lens flare system
  14219. */
  14220. name: string;
  14221. /**
  14222. * List of lens flares used in this system.
  14223. */
  14224. lensFlares: LensFlare[];
  14225. /**
  14226. * Define a limit from the border the lens flare can be visible.
  14227. */
  14228. borderLimit: number;
  14229. /**
  14230. * Define a viewport border we do not want to see the lens flare in.
  14231. */
  14232. viewportBorder: number;
  14233. /**
  14234. * Define a predicate which could limit the list of meshes able to occlude the effect.
  14235. */
  14236. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  14237. /**
  14238. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  14239. */
  14240. layerMask: number;
  14241. /**
  14242. * Define the id of the lens flare system in the scene.
  14243. * (equal to name by default)
  14244. */
  14245. id: string;
  14246. private _scene;
  14247. private _emitter;
  14248. private _vertexBuffers;
  14249. private _indexBuffer;
  14250. private _effect;
  14251. private _positionX;
  14252. private _positionY;
  14253. private _isEnabled;
  14254. /**
  14255. * Instantiates a lens flare system.
  14256. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  14257. * It is usually composed of several `BABYLON.lensFlare`.
  14258. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  14259. * @param name Define the name of the lens flare system in the scene
  14260. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  14261. * @param scene Define the scene the lens flare system belongs to
  14262. */
  14263. constructor(
  14264. /**
  14265. * Define the name of the lens flare system
  14266. */
  14267. name: string, emitter: any, scene: Scene);
  14268. /**
  14269. * Define if the lens flare system is enabled.
  14270. */
  14271. isEnabled: boolean;
  14272. /**
  14273. * Get the scene the effects belongs to.
  14274. * @returns the scene holding the lens flare system
  14275. */
  14276. getScene(): Scene;
  14277. /**
  14278. * Get the emitter of the lens flare system.
  14279. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  14280. * @returns the emitter of the lens flare system
  14281. */
  14282. getEmitter(): any;
  14283. /**
  14284. * Set the emitter of the lens flare system.
  14285. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  14286. * @param newEmitter Define the new emitter of the system
  14287. */
  14288. setEmitter(newEmitter: any): void;
  14289. /**
  14290. * Get the lens flare system emitter position.
  14291. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  14292. * @returns the position
  14293. */
  14294. getEmitterPosition(): Vector3;
  14295. /**
  14296. * @hidden
  14297. */
  14298. computeEffectivePosition(globalViewport: Viewport): boolean;
  14299. /** @hidden */
  14300. /**
  14301. * @hidden
  14302. */
  14303. render(): boolean;
  14304. /**
  14305. * Dispose and release the lens flare with its associated resources.
  14306. */
  14307. dispose(): void;
  14308. /**
  14309. * Parse a lens flare system from a JSON repressentation
  14310. * @param parsedLensFlareSystem Define the JSON to parse
  14311. * @param scene Define the scene the parsed system should be instantiated in
  14312. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  14313. * @returns the parsed system
  14314. */
  14315. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  14316. /**
  14317. * Serialize the current Lens Flare System into a JSON representation.
  14318. * @returns the serialized JSON
  14319. */
  14320. serialize(): any;
  14321. }
  14322. }
  14323. declare module BABYLON {
  14324. interface AbstractScene {
  14325. /**
  14326. * The list of lens flare system added to the scene
  14327. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  14328. */
  14329. lensFlareSystems: Array<LensFlareSystem>;
  14330. /**
  14331. * Removes the given lens flare system from this scene.
  14332. * @param toRemove The lens flare system to remove
  14333. * @returns The index of the removed lens flare system
  14334. */
  14335. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  14336. /**
  14337. * Adds the given lens flare system to this scene
  14338. * @param newLensFlareSystem The lens flare system to add
  14339. */
  14340. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  14341. /**
  14342. * Gets a lens flare system using its name
  14343. * @param name defines the name to look for
  14344. * @returns the lens flare system or null if not found
  14345. */
  14346. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  14347. /**
  14348. * Gets a lens flare system using its id
  14349. * @param id defines the id to look for
  14350. * @returns the lens flare system or null if not found
  14351. */
  14352. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  14353. }
  14354. /**
  14355. * Defines the lens flare scene component responsible to manage any lens flares
  14356. * in a given scene.
  14357. */
  14358. class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  14359. /**
  14360. * The component name helpfull to identify the component in the list of scene components.
  14361. */
  14362. readonly name: string;
  14363. /**
  14364. * The scene the component belongs to.
  14365. */
  14366. scene: Scene;
  14367. /**
  14368. * Creates a new instance of the component for the given scene
  14369. * @param scene Defines the scene to register the component in
  14370. */
  14371. constructor(scene: Scene);
  14372. /**
  14373. * Registers the component in a given scene
  14374. */
  14375. register(): void;
  14376. /**
  14377. * Rebuilds the elements related to this component in case of
  14378. * context lost for instance.
  14379. */
  14380. rebuild(): void;
  14381. /**
  14382. * Adds all the element from the container to the scene
  14383. * @param container the container holding the elements
  14384. */
  14385. addFromContainer(container: AbstractScene): void;
  14386. /**
  14387. * Removes all the elements in the container from the scene
  14388. * @param container contains the elements to remove
  14389. */
  14390. removeFromContainer(container: AbstractScene): void;
  14391. /**
  14392. * Serializes the component data to the specified json object
  14393. * @param serializationObject The object to serialize to
  14394. */
  14395. serialize(serializationObject: any): void;
  14396. /**
  14397. * Disposes the component and the associated ressources.
  14398. */
  14399. dispose(): void;
  14400. private _draw;
  14401. }
  14402. }
  14403. declare module BABYLON {
  14404. /**
  14405. * A directional light is defined by a direction (what a surprise!).
  14406. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  14407. * 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.
  14408. * Documentation: https://doc.babylonjs.com/babylon101/lights
  14409. */
  14410. class DirectionalLight extends ShadowLight {
  14411. private _shadowFrustumSize;
  14412. /**
  14413. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  14414. */
  14415. /**
  14416. * Specifies a fix frustum size for the shadow generation.
  14417. */
  14418. shadowFrustumSize: number;
  14419. private _shadowOrthoScale;
  14420. /**
  14421. * Gets the shadow projection scale against the optimal computed one.
  14422. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  14423. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  14424. */
  14425. /**
  14426. * Sets the shadow projection scale against the optimal computed one.
  14427. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  14428. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  14429. */
  14430. shadowOrthoScale: number;
  14431. /**
  14432. * Automatically compute the projection matrix to best fit (including all the casters)
  14433. * on each frame.
  14434. */
  14435. autoUpdateExtends: boolean;
  14436. private _orthoLeft;
  14437. private _orthoRight;
  14438. private _orthoTop;
  14439. private _orthoBottom;
  14440. /**
  14441. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  14442. * The directional light is emitted from everywhere in the given direction.
  14443. * It can cast shadows.
  14444. * Documentation : http://doc.babylonjs.com/tutorials/lights
  14445. * @param name The friendly name of the light
  14446. * @param direction The direction of the light
  14447. * @param scene The scene the light belongs to
  14448. */
  14449. constructor(name: string, direction: Vector3, scene: Scene);
  14450. /**
  14451. * Returns the string "DirectionalLight".
  14452. * @return The class name
  14453. */
  14454. getClassName(): string;
  14455. /**
  14456. * Returns the integer 1.
  14457. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  14458. */
  14459. getTypeID(): number;
  14460. /**
  14461. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  14462. * Returns the DirectionalLight Shadow projection matrix.
  14463. */
  14464. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  14465. /**
  14466. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  14467. * Returns the DirectionalLight Shadow projection matrix.
  14468. */
  14469. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix): void;
  14470. /**
  14471. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  14472. * Returns the DirectionalLight Shadow projection matrix.
  14473. */
  14474. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  14475. protected _buildUniformLayout(): void;
  14476. /**
  14477. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  14478. * @param effect The effect to update
  14479. * @param lightIndex The index of the light in the effect to update
  14480. * @returns The directional light
  14481. */
  14482. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  14483. /**
  14484. * Gets the minZ used for shadow according to both the scene and the light.
  14485. *
  14486. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  14487. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  14488. * @param activeCamera The camera we are returning the min for
  14489. * @returns the depth min z
  14490. */
  14491. getDepthMinZ(activeCamera: Camera): number;
  14492. /**
  14493. * Gets the maxZ used for shadow according to both the scene and the light.
  14494. *
  14495. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  14496. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  14497. * @param activeCamera The camera we are returning the max for
  14498. * @returns the depth max z
  14499. */
  14500. getDepthMaxZ(activeCamera: Camera): number;
  14501. /**
  14502. * Prepares the list of defines specific to the light type.
  14503. * @param defines the list of defines
  14504. * @param lightIndex defines the index of the light for the effect
  14505. */
  14506. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  14507. }
  14508. }
  14509. declare module BABYLON {
  14510. /**
  14511. * The HemisphericLight simulates the ambient environment light,
  14512. * so the passed direction is the light reflection direction, not the incoming direction.
  14513. */
  14514. class HemisphericLight extends Light {
  14515. /**
  14516. * The groundColor is the light in the opposite direction to the one specified during creation.
  14517. * 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.
  14518. */
  14519. groundColor: Color3;
  14520. /**
  14521. * The light reflection direction, not the incoming direction.
  14522. */
  14523. direction: Vector3;
  14524. /**
  14525. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  14526. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  14527. * The HemisphericLight can't cast shadows.
  14528. * Documentation : http://doc.babylonjs.com/tutorials/lights
  14529. * @param name The friendly name of the light
  14530. * @param direction The direction of the light reflection
  14531. * @param scene The scene the light belongs to
  14532. */
  14533. constructor(name: string, direction: Vector3, scene: Scene);
  14534. protected _buildUniformLayout(): void;
  14535. /**
  14536. * Returns the string "HemisphericLight".
  14537. * @return The class name
  14538. */
  14539. getClassName(): string;
  14540. /**
  14541. * Sets the HemisphericLight direction towards the passed target (Vector3).
  14542. * Returns the updated direction.
  14543. * @param target The target the direction should point to
  14544. * @return The computed direction
  14545. */
  14546. setDirectionToTarget(target: Vector3): Vector3;
  14547. /**
  14548. * Returns the shadow generator associated to the light.
  14549. * @returns Always null for hemispheric lights because it does not support shadows.
  14550. */
  14551. getShadowGenerator(): Nullable<IShadowGenerator>;
  14552. /**
  14553. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  14554. * @param effect The effect to update
  14555. * @param lightIndex The index of the light in the effect to update
  14556. * @returns The hemispheric light
  14557. */
  14558. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  14559. /**
  14560. * Computes the world matrix of the node
  14561. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14562. * @param useWasUpdatedFlag defines a reserved property
  14563. * @returns the world matrix
  14564. */
  14565. computeWorldMatrix(force?: boolean, useWasUpdatedFlag?: boolean): Matrix;
  14566. /**
  14567. * Returns the integer 3.
  14568. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  14569. */
  14570. getTypeID(): number;
  14571. /**
  14572. * Prepares the list of defines specific to the light type.
  14573. * @param defines the list of defines
  14574. * @param lightIndex defines the index of the light for the effect
  14575. */
  14576. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  14577. }
  14578. }
  14579. declare module BABYLON {
  14580. /**
  14581. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  14582. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  14583. * 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.
  14584. */
  14585. abstract class Light extends Node {
  14586. /**
  14587. * Falloff Default: light is falling off following the material specification:
  14588. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  14589. */
  14590. static readonly FALLOFF_DEFAULT: number;
  14591. /**
  14592. * Falloff Physical: light is falling off following the inverse squared distance law.
  14593. */
  14594. static readonly FALLOFF_PHYSICAL: number;
  14595. /**
  14596. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  14597. * to enhance interoperability with other engines.
  14598. */
  14599. static readonly FALLOFF_GLTF: number;
  14600. /**
  14601. * Falloff Standard: light is falling off like in the standard material
  14602. * to enhance interoperability with other materials.
  14603. */
  14604. static readonly FALLOFF_STANDARD: number;
  14605. /**
  14606. * If every light affecting the material is in this lightmapMode,
  14607. * material.lightmapTexture adds or multiplies
  14608. * (depends on material.useLightmapAsShadowmap)
  14609. * after every other light calculations.
  14610. */
  14611. static readonly LIGHTMAP_DEFAULT: number;
  14612. /**
  14613. * material.lightmapTexture as only diffuse lighting from this light
  14614. * adds only specular lighting from this light
  14615. * adds dynamic shadows
  14616. */
  14617. static readonly LIGHTMAP_SPECULAR: number;
  14618. /**
  14619. * material.lightmapTexture as only lighting
  14620. * no light calculation from this light
  14621. * only adds dynamic shadows from this light
  14622. */
  14623. static readonly LIGHTMAP_SHADOWSONLY: number;
  14624. /**
  14625. * Each light type uses the default quantity according to its type:
  14626. * point/spot lights use luminous intensity
  14627. * directional lights use illuminance
  14628. */
  14629. static readonly INTENSITYMODE_AUTOMATIC: number;
  14630. /**
  14631. * lumen (lm)
  14632. */
  14633. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  14634. /**
  14635. * candela (lm/sr)
  14636. */
  14637. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  14638. /**
  14639. * lux (lm/m^2)
  14640. */
  14641. static readonly INTENSITYMODE_ILLUMINANCE: number;
  14642. /**
  14643. * nit (cd/m^2)
  14644. */
  14645. static readonly INTENSITYMODE_LUMINANCE: number;
  14646. /**
  14647. * Light type const id of the point light.
  14648. */
  14649. static readonly LIGHTTYPEID_POINTLIGHT: number;
  14650. /**
  14651. * Light type const id of the directional light.
  14652. */
  14653. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  14654. /**
  14655. * Light type const id of the spot light.
  14656. */
  14657. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  14658. /**
  14659. * Light type const id of the hemispheric light.
  14660. */
  14661. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  14662. /**
  14663. * Diffuse gives the basic color to an object.
  14664. */
  14665. diffuse: Color3;
  14666. /**
  14667. * Specular produces a highlight color on an object.
  14668. * Note: This is note affecting PBR materials.
  14669. */
  14670. specular: Color3;
  14671. /**
  14672. * Defines the falloff type for this light. This lets overrriding how punctual light are
  14673. * falling off base on range or angle.
  14674. * This can be set to any values in Light.FALLOFF_x.
  14675. *
  14676. * Note: This is only usefull for PBR Materials at the moment. This could be extended if required to
  14677. * other types of materials.
  14678. */
  14679. falloffType: number;
  14680. /**
  14681. * Strength of the light.
  14682. * Note: By default it is define in the framework own unit.
  14683. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  14684. */
  14685. intensity: number;
  14686. private _range;
  14687. protected _inverseSquaredRange: number;
  14688. /**
  14689. * Defines how far from the source the light is impacting in scene units.
  14690. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  14691. */
  14692. /**
  14693. * Defines how far from the source the light is impacting in scene units.
  14694. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  14695. */
  14696. range: number;
  14697. /**
  14698. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  14699. * of light.
  14700. */
  14701. private _photometricScale;
  14702. private _intensityMode;
  14703. /**
  14704. * Gets the photometric scale used to interpret the intensity.
  14705. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  14706. */
  14707. /**
  14708. * Sets the photometric scale used to interpret the intensity.
  14709. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  14710. */
  14711. intensityMode: number;
  14712. private _radius;
  14713. /**
  14714. * Gets the light radius used by PBR Materials to simulate soft area lights.
  14715. */
  14716. /**
  14717. * sets the light radius used by PBR Materials to simulate soft area lights.
  14718. */
  14719. radius: number;
  14720. private _renderPriority;
  14721. /**
  14722. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  14723. * exceeding the number allowed of the materials.
  14724. */
  14725. renderPriority: number;
  14726. private _shadowEnabled;
  14727. /**
  14728. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  14729. * the current shadow generator.
  14730. */
  14731. /**
  14732. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  14733. * the current shadow generator.
  14734. */
  14735. shadowEnabled: boolean;
  14736. private _includedOnlyMeshes;
  14737. /**
  14738. * Gets the only meshes impacted by this light.
  14739. */
  14740. /**
  14741. * Sets the only meshes impacted by this light.
  14742. */
  14743. includedOnlyMeshes: AbstractMesh[];
  14744. private _excludedMeshes;
  14745. /**
  14746. * Gets the meshes not impacted by this light.
  14747. */
  14748. /**
  14749. * Sets the meshes not impacted by this light.
  14750. */
  14751. excludedMeshes: AbstractMesh[];
  14752. private _excludeWithLayerMask;
  14753. /**
  14754. * Gets the layer id use to find what meshes are not impacted by the light.
  14755. * Inactive if 0
  14756. */
  14757. /**
  14758. * Sets the layer id use to find what meshes are not impacted by the light.
  14759. * Inactive if 0
  14760. */
  14761. excludeWithLayerMask: number;
  14762. private _includeOnlyWithLayerMask;
  14763. /**
  14764. * Gets the layer id use to find what meshes are impacted by the light.
  14765. * Inactive if 0
  14766. */
  14767. /**
  14768. * Sets the layer id use to find what meshes are impacted by the light.
  14769. * Inactive if 0
  14770. */
  14771. includeOnlyWithLayerMask: number;
  14772. private _lightmapMode;
  14773. /**
  14774. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  14775. */
  14776. /**
  14777. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  14778. */
  14779. lightmapMode: number;
  14780. /**
  14781. * Shadow generator associted to the light.
  14782. * @hidden Internal use only.
  14783. */
  14784. /**
  14785. * @hidden Internal use only.
  14786. */
  14787. /**
  14788. * @hidden Internal use only.
  14789. */
  14790. /**
  14791. * The current light unifom buffer.
  14792. * @hidden Internal use only.
  14793. */
  14794. /**
  14795. * Creates a Light object in the scene.
  14796. * Documentation : http://doc.babylonjs.com/tutorials/lights
  14797. * @param name The firendly name of the light
  14798. * @param scene The scene the light belongs too
  14799. */
  14800. constructor(name: string, scene: Scene);
  14801. protected abstract _buildUniformLayout(): void;
  14802. /**
  14803. * Sets the passed Effect "effect" with the Light information.
  14804. * @param effect The effect to update
  14805. * @param lightIndex The index of the light in the effect to update
  14806. * @returns The light
  14807. */
  14808. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  14809. /**
  14810. * Returns the string "Light".
  14811. * @returns the class name
  14812. */
  14813. getClassName(): string;
  14814. /**
  14815. * Converts the light information to a readable string for debug purpose.
  14816. * @param fullDetails Supports for multiple levels of logging within scene loading
  14817. * @returns the human readable light info
  14818. */
  14819. toString(fullDetails?: boolean): string;
  14820. /** @hidden */
  14821. protected _syncParentEnabledState(): void;
  14822. /**
  14823. * Set the enabled state of this node.
  14824. * @param value - the new enabled state
  14825. */
  14826. setEnabled(value: boolean): void;
  14827. /**
  14828. * Returns the Light associated shadow generator if any.
  14829. * @return the associated shadow generator.
  14830. */
  14831. getShadowGenerator(): Nullable<IShadowGenerator>;
  14832. /**
  14833. * Returns a Vector3, the absolute light position in the World.
  14834. * @returns the world space position of the light
  14835. */
  14836. getAbsolutePosition(): Vector3;
  14837. /**
  14838. * Specifies if the light will affect the passed mesh.
  14839. * @param mesh The mesh to test against the light
  14840. * @return true the mesh is affected otherwise, false.
  14841. */
  14842. canAffectMesh(mesh: AbstractMesh): boolean;
  14843. /**
  14844. * Sort function to order lights for rendering.
  14845. * @param a First Light object to compare to second.
  14846. * @param b Second Light object to compare first.
  14847. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  14848. */
  14849. static CompareLightsPriority(a: Light, b: Light): number;
  14850. /**
  14851. * Releases resources associated with this node.
  14852. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14853. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14854. */
  14855. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14856. /**
  14857. * Returns the light type ID (integer).
  14858. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  14859. */
  14860. getTypeID(): number;
  14861. /**
  14862. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  14863. * @returns the scaled intensity in intensity mode unit
  14864. */
  14865. getScaledIntensity(): number;
  14866. /**
  14867. * Returns a new Light object, named "name", from the current one.
  14868. * @param name The name of the cloned light
  14869. * @returns the new created light
  14870. */
  14871. clone(name: string): Nullable<Light>;
  14872. /**
  14873. * Serializes the current light into a Serialization object.
  14874. * @returns the serialized object.
  14875. */
  14876. serialize(): any;
  14877. /**
  14878. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  14879. * This new light is named "name" and added to the passed scene.
  14880. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  14881. * @param name The friendly name of the light
  14882. * @param scene The scene the new light will belong to
  14883. * @returns the constructor function
  14884. */
  14885. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  14886. /**
  14887. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  14888. * @param parsedLight The JSON representation of the light
  14889. * @param scene The scene to create the parsed light in
  14890. * @returns the created light after parsing
  14891. */
  14892. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  14893. private _hookArrayForExcluded;
  14894. private _hookArrayForIncludedOnly;
  14895. private _resyncMeshes;
  14896. /**
  14897. * Forces the meshes to update their light related information in their rendering used effects
  14898. * @hidden Internal Use Only
  14899. */
  14900. /**
  14901. * Recomputes the cached photometric scale if needed.
  14902. */
  14903. private _computePhotometricScale;
  14904. /**
  14905. * Returns the Photometric Scale according to the light type and intensity mode.
  14906. */
  14907. private _getPhotometricScale;
  14908. /**
  14909. * Reorder the light in the scene according to their defined priority.
  14910. * @hidden Internal Use Only
  14911. */
  14912. /**
  14913. * Prepares the list of defines specific to the light type.
  14914. * @param defines the list of defines
  14915. * @param lightIndex defines the index of the light for the effect
  14916. */
  14917. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  14918. }
  14919. }
  14920. declare module BABYLON {
  14921. /**
  14922. * A point light is a light defined by an unique point in world space.
  14923. * The light is emitted in every direction from this point.
  14924. * A good example of a point light is a standard light bulb.
  14925. * Documentation: https://doc.babylonjs.com/babylon101/lights
  14926. */
  14927. class PointLight extends ShadowLight {
  14928. private _shadowAngle;
  14929. /**
  14930. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  14931. * This specifies what angle the shadow will use to be created.
  14932. *
  14933. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  14934. */
  14935. /**
  14936. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  14937. * This specifies what angle the shadow will use to be created.
  14938. *
  14939. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  14940. */
  14941. shadowAngle: number;
  14942. /**
  14943. * Gets the direction if it has been set.
  14944. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  14945. */
  14946. /**
  14947. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  14948. */
  14949. direction: Vector3;
  14950. /**
  14951. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  14952. * A PointLight emits the light in every direction.
  14953. * It can cast shadows.
  14954. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  14955. * ```javascript
  14956. * var pointLight = new BABYLON.PointLight("pl", camera.position, scene);
  14957. * ```
  14958. * Documentation : http://doc.babylonjs.com/tutorials/lights
  14959. * @param name The light friendly name
  14960. * @param position The position of the point light in the scene
  14961. * @param scene The scene the lights belongs to
  14962. */
  14963. constructor(name: string, position: Vector3, scene: Scene);
  14964. /**
  14965. * Returns the string "PointLight"
  14966. * @returns the class name
  14967. */
  14968. getClassName(): string;
  14969. /**
  14970. * Returns the integer 0.
  14971. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  14972. */
  14973. getTypeID(): number;
  14974. /**
  14975. * Specifies wether or not the shadowmap should be a cube texture.
  14976. * @returns true if the shadowmap needs to be a cube texture.
  14977. */
  14978. needCube(): boolean;
  14979. /**
  14980. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  14981. * @param faceIndex The index of the face we are computed the direction to generate shadow
  14982. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  14983. */
  14984. getShadowDirection(faceIndex?: number): Vector3;
  14985. /**
  14986. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  14987. * - fov = PI / 2
  14988. * - aspect ratio : 1.0
  14989. * - z-near and far equal to the active camera minZ and maxZ.
  14990. * Returns the PointLight.
  14991. */
  14992. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  14993. protected _buildUniformLayout(): void;
  14994. /**
  14995. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  14996. * @param effect The effect to update
  14997. * @param lightIndex The index of the light in the effect to update
  14998. * @returns The point light
  14999. */
  15000. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  15001. /**
  15002. * Prepares the list of defines specific to the light type.
  15003. * @param defines the list of defines
  15004. * @param lightIndex defines the index of the light for the effect
  15005. */
  15006. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  15007. }
  15008. }
  15009. declare module BABYLON {
  15010. /**
  15011. * Interface describing all the common properties and methods a shadow light needs to implement.
  15012. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  15013. * as well as binding the different shadow properties to the effects.
  15014. */
  15015. interface IShadowLight extends Light {
  15016. /**
  15017. * The light id in the scene (used in scene.findLighById for instance)
  15018. */
  15019. id: string;
  15020. /**
  15021. * The position the shdow will be casted from.
  15022. */
  15023. position: Vector3;
  15024. /**
  15025. * In 2d mode (needCube being false), the direction used to cast the shadow.
  15026. */
  15027. direction: Vector3;
  15028. /**
  15029. * The transformed position. Position of the light in world space taking parenting in account.
  15030. */
  15031. transformedPosition: Vector3;
  15032. /**
  15033. * The transformed direction. Direction of the light in world space taking parenting in account.
  15034. */
  15035. transformedDirection: Vector3;
  15036. /**
  15037. * The friendly name of the light in the scene.
  15038. */
  15039. name: string;
  15040. /**
  15041. * Defines the shadow projection clipping minimum z value.
  15042. */
  15043. shadowMinZ: number;
  15044. /**
  15045. * Defines the shadow projection clipping maximum z value.
  15046. */
  15047. shadowMaxZ: number;
  15048. /**
  15049. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  15050. * @returns true if the information has been computed, false if it does not need to (no parenting)
  15051. */
  15052. computeTransformedInformation(): boolean;
  15053. /**
  15054. * Gets the scene the light belongs to.
  15055. * @returns The scene
  15056. */
  15057. getScene(): Scene;
  15058. /**
  15059. * Callback defining a custom Projection Matrix Builder.
  15060. * This can be used to override the default projection matrix computation.
  15061. */
  15062. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  15063. /**
  15064. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  15065. * @param matrix The materix to updated with the projection information
  15066. * @param viewMatrix The transform matrix of the light
  15067. * @param renderList The list of mesh to render in the map
  15068. * @returns The current light
  15069. */
  15070. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  15071. /**
  15072. * Gets the current depth scale used in ESM.
  15073. * @returns The scale
  15074. */
  15075. getDepthScale(): number;
  15076. /**
  15077. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  15078. * @returns true if a cube texture needs to be use
  15079. */
  15080. needCube(): boolean;
  15081. /**
  15082. * Detects if the projection matrix requires to be recomputed this frame.
  15083. * @returns true if it requires to be recomputed otherwise, false.
  15084. */
  15085. needProjectionMatrixCompute(): boolean;
  15086. /**
  15087. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  15088. */
  15089. forceProjectionMatrixCompute(): void;
  15090. /**
  15091. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  15092. * @param faceIndex The index of the face we are computed the direction to generate shadow
  15093. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  15094. */
  15095. getShadowDirection(faceIndex?: number): Vector3;
  15096. /**
  15097. * Gets the minZ used for shadow according to both the scene and the light.
  15098. * @param activeCamera The camera we are returning the min for
  15099. * @returns the depth min z
  15100. */
  15101. getDepthMinZ(activeCamera: Camera): number;
  15102. /**
  15103. * Gets the maxZ used for shadow according to both the scene and the light.
  15104. * @param activeCamera The camera we are returning the max for
  15105. * @returns the depth max z
  15106. */
  15107. getDepthMaxZ(activeCamera: Camera): number;
  15108. }
  15109. /**
  15110. * Base implementation IShadowLight
  15111. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  15112. */
  15113. abstract class ShadowLight extends Light implements IShadowLight {
  15114. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  15115. protected _position: Vector3;
  15116. protected _setPosition(value: Vector3): void;
  15117. /**
  15118. * Sets the position the shadow will be casted from. Also use as the light position for both
  15119. * point and spot lights.
  15120. */
  15121. /**
  15122. * Sets the position the shadow will be casted from. Also use as the light position for both
  15123. * point and spot lights.
  15124. */
  15125. position: Vector3;
  15126. protected _direction: Vector3;
  15127. protected _setDirection(value: Vector3): void;
  15128. /**
  15129. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  15130. * Also use as the light direction on spot and directional lights.
  15131. */
  15132. /**
  15133. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  15134. * Also use as the light direction on spot and directional lights.
  15135. */
  15136. direction: Vector3;
  15137. private _shadowMinZ;
  15138. /**
  15139. * Gets the shadow projection clipping minimum z value.
  15140. */
  15141. /**
  15142. * Sets the shadow projection clipping minimum z value.
  15143. */
  15144. shadowMinZ: number;
  15145. private _shadowMaxZ;
  15146. /**
  15147. * Sets the shadow projection clipping maximum z value.
  15148. */
  15149. /**
  15150. * Gets the shadow projection clipping maximum z value.
  15151. */
  15152. shadowMaxZ: number;
  15153. /**
  15154. * Callback defining a custom Projection Matrix Builder.
  15155. * This can be used to override the default projection matrix computation.
  15156. */
  15157. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  15158. /**
  15159. * The transformed position. Position of the light in world space taking parenting in account.
  15160. */
  15161. transformedPosition: Vector3;
  15162. /**
  15163. * The transformed direction. Direction of the light in world space taking parenting in account.
  15164. */
  15165. transformedDirection: Vector3;
  15166. private _needProjectionMatrixCompute;
  15167. /**
  15168. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  15169. * @returns true if the information has been computed, false if it does not need to (no parenting)
  15170. */
  15171. computeTransformedInformation(): boolean;
  15172. /**
  15173. * Return the depth scale used for the shadow map.
  15174. * @returns the depth scale.
  15175. */
  15176. getDepthScale(): number;
  15177. /**
  15178. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  15179. * @param faceIndex The index of the face we are computed the direction to generate shadow
  15180. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  15181. */
  15182. getShadowDirection(faceIndex?: number): Vector3;
  15183. /**
  15184. * Returns the ShadowLight absolute position in the World.
  15185. * @returns the position vector in world space
  15186. */
  15187. getAbsolutePosition(): Vector3;
  15188. /**
  15189. * Sets the ShadowLight direction toward the passed target.
  15190. * @param target The point tot target in local space
  15191. * @returns the updated ShadowLight direction
  15192. */
  15193. setDirectionToTarget(target: Vector3): Vector3;
  15194. /**
  15195. * Returns the light rotation in euler definition.
  15196. * @returns the x y z rotation in local space.
  15197. */
  15198. getRotation(): Vector3;
  15199. /**
  15200. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  15201. * @returns true if a cube texture needs to be use
  15202. */
  15203. needCube(): boolean;
  15204. /**
  15205. * Detects if the projection matrix requires to be recomputed this frame.
  15206. * @returns true if it requires to be recomputed otherwise, false.
  15207. */
  15208. needProjectionMatrixCompute(): boolean;
  15209. /**
  15210. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  15211. */
  15212. forceProjectionMatrixCompute(): void;
  15213. /** @hidden */
  15214. /** @hidden */
  15215. /**
  15216. * Computes the world matrix of the node
  15217. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  15218. * @returns the world matrix
  15219. */
  15220. computeWorldMatrix(force?: boolean): Matrix;
  15221. /**
  15222. * Gets the minZ used for shadow according to both the scene and the light.
  15223. * @param activeCamera The camera we are returning the min for
  15224. * @returns the depth min z
  15225. */
  15226. getDepthMinZ(activeCamera: Camera): number;
  15227. /**
  15228. * Gets the maxZ used for shadow according to both the scene and the light.
  15229. * @param activeCamera The camera we are returning the max for
  15230. * @returns the depth max z
  15231. */
  15232. getDepthMaxZ(activeCamera: Camera): number;
  15233. /**
  15234. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  15235. * @param matrix The materix to updated with the projection information
  15236. * @param viewMatrix The transform matrix of the light
  15237. * @param renderList The list of mesh to render in the map
  15238. * @returns The current light
  15239. */
  15240. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  15241. }
  15242. }
  15243. declare module BABYLON {
  15244. /**
  15245. * A spot light is defined by a position, a direction, an angle, and an exponent.
  15246. * These values define a cone of light starting from the position, emitting toward the direction.
  15247. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  15248. * and the exponent defines the speed of the decay of the light with distance (reach).
  15249. * Documentation: https://doc.babylonjs.com/babylon101/lights
  15250. */
  15251. class SpotLight extends ShadowLight {
  15252. private _angle;
  15253. private _innerAngle;
  15254. private _cosHalfAngle;
  15255. private _lightAngleScale;
  15256. private _lightAngleOffset;
  15257. /**
  15258. * Gets the cone angle of the spot light in Radians.
  15259. */
  15260. /**
  15261. * Sets the cone angle of the spot light in Radians.
  15262. */
  15263. angle: number;
  15264. /**
  15265. * Only used in gltf falloff mode, this defines the angle where
  15266. * the directional falloff will start before cutting at angle which could be seen
  15267. * as outer angle.
  15268. */
  15269. /**
  15270. * Only used in gltf falloff mode, this defines the angle where
  15271. * the directional falloff will start before cutting at angle which could be seen
  15272. * as outer angle.
  15273. */
  15274. innerAngle: number;
  15275. private _shadowAngleScale;
  15276. /**
  15277. * Allows scaling the angle of the light for shadow generation only.
  15278. */
  15279. /**
  15280. * Allows scaling the angle of the light for shadow generation only.
  15281. */
  15282. shadowAngleScale: number;
  15283. /**
  15284. * The light decay speed with the distance from the emission spot.
  15285. */
  15286. exponent: number;
  15287. private _projectionTextureMatrix;
  15288. /**
  15289. * Allows reading the projecton texture
  15290. */
  15291. readonly projectionTextureMatrix: Matrix;
  15292. protected _projectionTextureLightNear: number;
  15293. /**
  15294. * Gets the near clip of the Spotlight for texture projection.
  15295. */
  15296. /**
  15297. * Sets the near clip of the Spotlight for texture projection.
  15298. */
  15299. projectionTextureLightNear: number;
  15300. protected _projectionTextureLightFar: number;
  15301. /**
  15302. * Gets the far clip of the Spotlight for texture projection.
  15303. */
  15304. /**
  15305. * Sets the far clip of the Spotlight for texture projection.
  15306. */
  15307. projectionTextureLightFar: number;
  15308. protected _projectionTextureUpDirection: Vector3;
  15309. /**
  15310. * Gets the Up vector of the Spotlight for texture projection.
  15311. */
  15312. /**
  15313. * Sets the Up vector of the Spotlight for texture projection.
  15314. */
  15315. projectionTextureUpDirection: Vector3;
  15316. private _projectionTexture;
  15317. /**
  15318. * Gets the projection texture of the light.
  15319. */
  15320. /**
  15321. * Sets the projection texture of the light.
  15322. */
  15323. projectionTexture: Nullable<BaseTexture>;
  15324. private _projectionTextureViewLightDirty;
  15325. private _projectionTextureProjectionLightDirty;
  15326. private _projectionTextureDirty;
  15327. private _projectionTextureViewTargetVector;
  15328. private _projectionTextureViewLightMatrix;
  15329. private _projectionTextureProjectionLightMatrix;
  15330. private _projectionTextureScalingMatrix;
  15331. /**
  15332. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  15333. * It can cast shadows.
  15334. * Documentation : http://doc.babylonjs.com/tutorials/lights
  15335. * @param name The light friendly name
  15336. * @param position The position of the spot light in the scene
  15337. * @param direction The direction of the light in the scene
  15338. * @param angle The cone angle of the light in Radians
  15339. * @param exponent The light decay speed with the distance from the emission spot
  15340. * @param scene The scene the lights belongs to
  15341. */
  15342. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  15343. /**
  15344. * Returns the string "SpotLight".
  15345. * @returns the class name
  15346. */
  15347. getClassName(): string;
  15348. /**
  15349. * Returns the integer 2.
  15350. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  15351. */
  15352. getTypeID(): number;
  15353. /**
  15354. * Overrides the direction setter to recompute the projection texture view light Matrix.
  15355. */
  15356. protected _setDirection(value: Vector3): void;
  15357. /**
  15358. * Overrides the position setter to recompute the projection texture view light Matrix.
  15359. */
  15360. protected _setPosition(value: Vector3): void;
  15361. /**
  15362. * 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.
  15363. * Returns the SpotLight.
  15364. */
  15365. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  15366. protected _computeProjectionTextureViewLightMatrix(): void;
  15367. protected _computeProjectionTextureProjectionLightMatrix(): void;
  15368. /**
  15369. * Main function for light texture projection matrix computing.
  15370. */
  15371. protected _computeProjectionTextureMatrix(): void;
  15372. protected _buildUniformLayout(): void;
  15373. private _computeAngleValues;
  15374. /**
  15375. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  15376. * @param effect The effect to update
  15377. * @param lightIndex The index of the light in the effect to update
  15378. * @returns The spot light
  15379. */
  15380. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  15381. /**
  15382. * Disposes the light and the associated resources.
  15383. */
  15384. dispose(): void;
  15385. /**
  15386. * Prepares the list of defines specific to the light type.
  15387. * @param defines the list of defines
  15388. * @param lightIndex defines the index of the light for the effect
  15389. */
  15390. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  15391. }
  15392. }
  15393. declare module BABYLON {
  15394. interface ILoadingScreen {
  15395. displayLoadingUI: () => void;
  15396. hideLoadingUI: () => void;
  15397. loadingUIBackgroundColor: string;
  15398. loadingUIText: string;
  15399. }
  15400. class DefaultLoadingScreen implements ILoadingScreen {
  15401. private _renderingCanvas;
  15402. private _loadingText;
  15403. private _loadingDivBackgroundColor;
  15404. private _loadingDiv;
  15405. private _loadingTextDiv;
  15406. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  15407. displayLoadingUI(): void;
  15408. hideLoadingUI(): void;
  15409. loadingUIText: string;
  15410. loadingUIBackgroundColor: string;
  15411. private _resizeLoadingUI;
  15412. }
  15413. }
  15414. declare module BABYLON {
  15415. class SceneLoaderProgressEvent {
  15416. readonly lengthComputable: boolean;
  15417. readonly loaded: number;
  15418. readonly total: number;
  15419. constructor(lengthComputable: boolean, loaded: number, total: number);
  15420. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  15421. }
  15422. interface ISceneLoaderPluginExtensions {
  15423. [extension: string]: {
  15424. isBinary: boolean;
  15425. };
  15426. }
  15427. interface ISceneLoaderPluginFactory {
  15428. name: string;
  15429. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  15430. canDirectLoad?: (data: string) => boolean;
  15431. }
  15432. interface ISceneLoaderPlugin {
  15433. /**
  15434. * The friendly name of this plugin.
  15435. */
  15436. name: string;
  15437. /**
  15438. * The file extensions supported by this plugin.
  15439. */
  15440. extensions: string | ISceneLoaderPluginExtensions;
  15441. /**
  15442. * Import meshes into a scene.
  15443. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  15444. * @param scene The scene to import into
  15445. * @param data The data to import
  15446. * @param rootUrl The root url for scene and resources
  15447. * @param meshes The meshes array to import into
  15448. * @param particleSystems The particle systems array to import into
  15449. * @param skeletons The skeletons array to import into
  15450. * @param onError The callback when import fails
  15451. * @returns True if successful or false otherwise
  15452. */
  15453. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  15454. /**
  15455. * Load into a scene.
  15456. * @param scene The scene to load into
  15457. * @param data The data to import
  15458. * @param rootUrl The root url for scene and resources
  15459. * @param onError The callback when import fails
  15460. * @returns true if successful or false otherwise
  15461. */
  15462. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  15463. /**
  15464. * The callback that returns true if the data can be directly loaded.
  15465. */
  15466. canDirectLoad?: (data: string) => boolean;
  15467. /**
  15468. * The callback that allows custom handling of the root url based on the response url.
  15469. */
  15470. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  15471. /**
  15472. * Load into an asset container.
  15473. * @param scene The scene to load into
  15474. * @param data The data to import
  15475. * @param rootUrl The root url for scene and resources
  15476. * @param onError The callback when import fails
  15477. * @returns The loaded asset container
  15478. */
  15479. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  15480. }
  15481. interface ISceneLoaderPluginAsync {
  15482. /**
  15483. * The friendly name of this plugin.
  15484. */
  15485. name: string;
  15486. /**
  15487. * The file extensions supported by this plugin.
  15488. */
  15489. extensions: string | ISceneLoaderPluginExtensions;
  15490. /**
  15491. * Import meshes into a scene.
  15492. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  15493. * @param scene The scene to import into
  15494. * @param data The data to import
  15495. * @param rootUrl The root url for scene and resources
  15496. * @param onProgress The callback when the load progresses
  15497. * @param fileName Defines the name of the file to load
  15498. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  15499. */
  15500. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  15501. meshes: AbstractMesh[];
  15502. particleSystems: IParticleSystem[];
  15503. skeletons: Skeleton[];
  15504. animationGroups: AnimationGroup[];
  15505. }>;
  15506. /**
  15507. * Load into a scene.
  15508. * @param scene The scene to load into
  15509. * @param data The data to import
  15510. * @param rootUrl The root url for scene and resources
  15511. * @param onProgress The callback when the load progresses
  15512. * @param fileName Defines the name of the file to load
  15513. * @returns Nothing
  15514. */
  15515. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  15516. /**
  15517. * The callback that returns true if the data can be directly loaded.
  15518. */
  15519. canDirectLoad?: (data: string) => boolean;
  15520. /**
  15521. * The callback that allows custom handling of the root url based on the response url.
  15522. */
  15523. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  15524. /**
  15525. * Load into an asset container.
  15526. * @param scene The scene to load into
  15527. * @param data The data to import
  15528. * @param rootUrl The root url for scene and resources
  15529. * @param onProgress The callback when the load progresses
  15530. * @param fileName Defines the name of the file to load
  15531. * @returns The loaded asset container
  15532. */
  15533. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  15534. }
  15535. class SceneLoader {
  15536. private static _ForceFullSceneLoadingForIncremental;
  15537. private static _ShowLoadingScreen;
  15538. private static _CleanBoneMatrixWeights;
  15539. static readonly NO_LOGGING: number;
  15540. static readonly MINIMAL_LOGGING: number;
  15541. static readonly SUMMARY_LOGGING: number;
  15542. static readonly DETAILED_LOGGING: number;
  15543. private static _loggingLevel;
  15544. static ForceFullSceneLoadingForIncremental: boolean;
  15545. static ShowLoadingScreen: boolean;
  15546. static loggingLevel: number;
  15547. static CleanBoneMatrixWeights: boolean;
  15548. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  15549. private static _registeredPlugins;
  15550. private static _getDefaultPlugin;
  15551. private static _getPluginForExtension;
  15552. private static _getPluginForDirectLoad;
  15553. private static _getPluginForFilename;
  15554. private static _getDirectLoad;
  15555. private static _loadData;
  15556. private static _getFileInfo;
  15557. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  15558. static IsPluginForExtensionAvailable(extension: string): boolean;
  15559. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  15560. /**
  15561. * Import meshes into a scene
  15562. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  15563. * @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)
  15564. * @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)
  15565. * @param scene the instance of BABYLON.Scene to append to
  15566. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  15567. * @param onProgress a callback with a progress event for each file being loaded
  15568. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  15569. * @param pluginExtension the extension used to determine the plugin
  15570. * @returns The loaded plugin
  15571. */
  15572. static ImportMesh(meshNames: any, rootUrl: string, sceneFilename?: string, 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>;
  15573. /**
  15574. * Import meshes into a scene
  15575. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  15576. * @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)
  15577. * @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)
  15578. * @param scene the instance of BABYLON.Scene to append to
  15579. * @param onProgress a callback with a progress event for each file being loaded
  15580. * @param pluginExtension the extension used to determine the plugin
  15581. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  15582. */
  15583. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  15584. meshes: AbstractMesh[];
  15585. particleSystems: IParticleSystem[];
  15586. skeletons: Skeleton[];
  15587. animationGroups: AnimationGroup[];
  15588. }>;
  15589. /**
  15590. * Load a scene
  15591. * @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)
  15592. * @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)
  15593. * @param engine is the instance of BABYLON.Engine to use to create the scene
  15594. * @param onSuccess a callback with the scene when import succeeds
  15595. * @param onProgress a callback with a progress event for each file being loaded
  15596. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  15597. * @param pluginExtension the extension used to determine the plugin
  15598. * @returns The loaded plugin
  15599. */
  15600. static Load(rootUrl: string, sceneFilename: string, engine: 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>;
  15601. /**
  15602. * Load a scene
  15603. * @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)
  15604. * @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)
  15605. * @param engine is the instance of BABYLON.Engine to use to create the scene
  15606. * @param onProgress a callback with a progress event for each file being loaded
  15607. * @param pluginExtension the extension used to determine the plugin
  15608. * @returns The loaded scene
  15609. */
  15610. static LoadAsync(rootUrl: string, sceneFilename: string, engine: Engine, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  15611. /**
  15612. * Append a scene
  15613. * @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)
  15614. * @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)
  15615. * @param scene is the instance of BABYLON.Scene to append to
  15616. * @param onSuccess a callback with the scene when import succeeds
  15617. * @param onProgress a callback with a progress event for each file being loaded
  15618. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  15619. * @param pluginExtension the extension used to determine the plugin
  15620. * @returns The loaded plugin
  15621. */
  15622. static Append(rootUrl: string, sceneFilename?: string, 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>;
  15623. /**
  15624. * Append a scene
  15625. * @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)
  15626. * @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)
  15627. * @param scene is the instance of BABYLON.Scene to append to
  15628. * @param onProgress a callback with a progress event for each file being loaded
  15629. * @param pluginExtension the extension used to determine the plugin
  15630. * @returns The given scene
  15631. */
  15632. static AppendAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  15633. /**
  15634. * Load a scene into an asset container
  15635. * @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)
  15636. * @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)
  15637. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  15638. * @param onSuccess a callback with the scene when import succeeds
  15639. * @param onProgress a callback with a progress event for each file being loaded
  15640. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  15641. * @param pluginExtension the extension used to determine the plugin
  15642. * @returns The loaded plugin
  15643. */
  15644. static LoadAssetContainer(rootUrl: string, sceneFilename?: string, 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>;
  15645. /**
  15646. * Load a scene into an asset container
  15647. * @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)
  15648. * @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)
  15649. * @param scene is the instance of BABYLON.Scene to append to
  15650. * @param onProgress a callback with a progress event for each file being loaded
  15651. * @param pluginExtension the extension used to determine the plugin
  15652. * @returns The loaded asset container
  15653. */
  15654. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  15655. }
  15656. }
  15657. declare module BABYLON {
  15658. /**
  15659. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  15660. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  15661. * 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;
  15662. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  15663. */
  15664. class ColorCurves {
  15665. private _dirty;
  15666. private _tempColor;
  15667. private _globalCurve;
  15668. private _highlightsCurve;
  15669. private _midtonesCurve;
  15670. private _shadowsCurve;
  15671. private _positiveCurve;
  15672. private _negativeCurve;
  15673. private _globalHue;
  15674. private _globalDensity;
  15675. private _globalSaturation;
  15676. private _globalExposure;
  15677. /**
  15678. * Gets the global Hue value.
  15679. * 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).
  15680. */
  15681. /**
  15682. * Sets the global Hue value.
  15683. * 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).
  15684. */
  15685. globalHue: number;
  15686. /**
  15687. * Gets the global Density value.
  15688. * 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.
  15689. * Values less than zero provide a filter of opposite hue.
  15690. */
  15691. /**
  15692. * Sets the global Density value.
  15693. * 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.
  15694. * Values less than zero provide a filter of opposite hue.
  15695. */
  15696. globalDensity: number;
  15697. /**
  15698. * Gets the global Saturation value.
  15699. * 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.
  15700. */
  15701. /**
  15702. * Sets the global Saturation value.
  15703. * 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.
  15704. */
  15705. globalSaturation: number;
  15706. /**
  15707. * Gets the global Exposure value.
  15708. * 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.
  15709. */
  15710. /**
  15711. * Sets the global Exposure value.
  15712. * 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.
  15713. */
  15714. globalExposure: number;
  15715. private _highlightsHue;
  15716. private _highlightsDensity;
  15717. private _highlightsSaturation;
  15718. private _highlightsExposure;
  15719. /**
  15720. * Gets the highlights Hue value.
  15721. * 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).
  15722. */
  15723. /**
  15724. * Sets the highlights Hue value.
  15725. * 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).
  15726. */
  15727. highlightsHue: number;
  15728. /**
  15729. * Gets the highlights Density value.
  15730. * 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.
  15731. * Values less than zero provide a filter of opposite hue.
  15732. */
  15733. /**
  15734. * Sets the highlights Density value.
  15735. * 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.
  15736. * Values less than zero provide a filter of opposite hue.
  15737. */
  15738. highlightsDensity: number;
  15739. /**
  15740. * Gets the highlights Saturation value.
  15741. * 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.
  15742. */
  15743. /**
  15744. * Sets the highlights Saturation value.
  15745. * 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.
  15746. */
  15747. highlightsSaturation: number;
  15748. /**
  15749. * Gets the highlights Exposure value.
  15750. * 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.
  15751. */
  15752. /**
  15753. * Sets the highlights Exposure value.
  15754. * 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.
  15755. */
  15756. highlightsExposure: number;
  15757. private _midtonesHue;
  15758. private _midtonesDensity;
  15759. private _midtonesSaturation;
  15760. private _midtonesExposure;
  15761. /**
  15762. * Gets the midtones Hue value.
  15763. * 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).
  15764. */
  15765. /**
  15766. * Sets the midtones Hue value.
  15767. * 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).
  15768. */
  15769. midtonesHue: number;
  15770. /**
  15771. * Gets the midtones Density value.
  15772. * 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.
  15773. * Values less than zero provide a filter of opposite hue.
  15774. */
  15775. /**
  15776. * Sets the midtones Density value.
  15777. * 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.
  15778. * Values less than zero provide a filter of opposite hue.
  15779. */
  15780. midtonesDensity: number;
  15781. /**
  15782. * Gets the midtones Saturation value.
  15783. * 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.
  15784. */
  15785. /**
  15786. * Sets the midtones Saturation value.
  15787. * 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.
  15788. */
  15789. midtonesSaturation: number;
  15790. /**
  15791. * Gets the midtones Exposure value.
  15792. * 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.
  15793. */
  15794. /**
  15795. * Sets the midtones Exposure value.
  15796. * 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.
  15797. */
  15798. midtonesExposure: number;
  15799. private _shadowsHue;
  15800. private _shadowsDensity;
  15801. private _shadowsSaturation;
  15802. private _shadowsExposure;
  15803. /**
  15804. * Gets the shadows Hue value.
  15805. * 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).
  15806. */
  15807. /**
  15808. * Sets the shadows Hue value.
  15809. * 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).
  15810. */
  15811. shadowsHue: number;
  15812. /**
  15813. * Gets the shadows Density value.
  15814. * 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.
  15815. * Values less than zero provide a filter of opposite hue.
  15816. */
  15817. /**
  15818. * Sets the shadows Density value.
  15819. * 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.
  15820. * Values less than zero provide a filter of opposite hue.
  15821. */
  15822. shadowsDensity: number;
  15823. /**
  15824. * Gets the shadows Saturation value.
  15825. * 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.
  15826. */
  15827. /**
  15828. * Sets the shadows Saturation value.
  15829. * 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.
  15830. */
  15831. shadowsSaturation: number;
  15832. /**
  15833. * Gets the shadows Exposure value.
  15834. * 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.
  15835. */
  15836. /**
  15837. * Sets the shadows Exposure value.
  15838. * 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.
  15839. */
  15840. shadowsExposure: number;
  15841. getClassName(): string;
  15842. /**
  15843. * Binds the color curves to the shader.
  15844. * @param colorCurves The color curve to bind
  15845. * @param effect The effect to bind to
  15846. */
  15847. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  15848. /**
  15849. * Prepare the list of uniforms associated with the ColorCurves effects.
  15850. * @param uniformsList The list of uniforms used in the effect
  15851. */
  15852. static PrepareUniforms(uniformsList: string[]): void;
  15853. /**
  15854. * Returns color grading data based on a hue, density, saturation and exposure value.
  15855. * @param filterHue The hue of the color filter.
  15856. * @param filterDensity The density of the color filter.
  15857. * @param saturation The saturation.
  15858. * @param exposure The exposure.
  15859. * @param result The result data container.
  15860. */
  15861. private getColorGradingDataToRef;
  15862. /**
  15863. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  15864. * @param value The input slider value in range [-100,100].
  15865. * @returns Adjusted value.
  15866. */
  15867. private static applyColorGradingSliderNonlinear;
  15868. /**
  15869. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  15870. * @param hue The hue (H) input.
  15871. * @param saturation The saturation (S) input.
  15872. * @param brightness The brightness (B) input.
  15873. * @result An RGBA color represented as Vector4.
  15874. */
  15875. private static fromHSBToRef;
  15876. /**
  15877. * Returns a value clamped between min and max
  15878. * @param value The value to clamp
  15879. * @param min The minimum of value
  15880. * @param max The maximum of value
  15881. * @returns The clamped value.
  15882. */
  15883. private static clamp;
  15884. /**
  15885. * Clones the current color curve instance.
  15886. * @return The cloned curves
  15887. */
  15888. clone(): ColorCurves;
  15889. /**
  15890. * Serializes the current color curve instance to a json representation.
  15891. * @return a JSON representation
  15892. */
  15893. serialize(): any;
  15894. /**
  15895. * Parses the color curve from a json representation.
  15896. * @param source the JSON source to parse
  15897. * @return The parsed curves
  15898. */
  15899. static Parse(source: any): ColorCurves;
  15900. }
  15901. }
  15902. declare module BABYLON {
  15903. /**
  15904. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  15905. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  15906. */
  15907. class EffectFallbacks {
  15908. private _defines;
  15909. private _currentRank;
  15910. private _maxRank;
  15911. private _mesh;
  15912. /**
  15913. * Removes the fallback from the bound mesh.
  15914. */
  15915. unBindMesh(): void;
  15916. /**
  15917. * Adds a fallback on the specified property.
  15918. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  15919. * @param define The name of the define in the shader
  15920. */
  15921. addFallback(rank: number, define: string): void;
  15922. /**
  15923. * Sets the mesh to use CPU skinning when needing to fallback.
  15924. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  15925. * @param mesh The mesh to use the fallbacks.
  15926. */
  15927. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  15928. /**
  15929. * Checks to see if more fallbacks are still availible.
  15930. */
  15931. readonly isMoreFallbacks: boolean;
  15932. /**
  15933. * Removes the defines that shoould be removed when falling back.
  15934. * @param currentDefines defines the current define statements for the shader.
  15935. * @param effect defines the current effect we try to compile
  15936. * @returns The resulting defines with defines of the current rank removed.
  15937. */
  15938. reduce(currentDefines: string, effect: Effect): string;
  15939. }
  15940. /**
  15941. * Options to be used when creating an effect.
  15942. */
  15943. class EffectCreationOptions {
  15944. /**
  15945. * Atrributes that will be used in the shader.
  15946. */
  15947. attributes: string[];
  15948. /**
  15949. * Uniform varible names that will be set in the shader.
  15950. */
  15951. uniformsNames: string[];
  15952. /**
  15953. * Uniform buffer varible names that will be set in the shader.
  15954. */
  15955. uniformBuffersNames: string[];
  15956. /**
  15957. * Sampler texture variable names that will be set in the shader.
  15958. */
  15959. samplers: string[];
  15960. /**
  15961. * Define statements that will be set in the shader.
  15962. */
  15963. defines: any;
  15964. /**
  15965. * Possible fallbacks for this effect to improve performance when needed.
  15966. */
  15967. fallbacks: Nullable<EffectFallbacks>;
  15968. /**
  15969. * Callback that will be called when the shader is compiled.
  15970. */
  15971. onCompiled: Nullable<(effect: Effect) => void>;
  15972. /**
  15973. * Callback that will be called if an error occurs during shader compilation.
  15974. */
  15975. onError: Nullable<(effect: Effect, errors: string) => void>;
  15976. /**
  15977. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  15978. */
  15979. indexParameters: any;
  15980. /**
  15981. * Max number of lights that can be used in the shader.
  15982. */
  15983. maxSimultaneousLights: number;
  15984. /**
  15985. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  15986. */
  15987. transformFeedbackVaryings: Nullable<string[]>;
  15988. }
  15989. /**
  15990. * Effect containing vertex and fragment shader that can be executed on an object.
  15991. */
  15992. class Effect {
  15993. /**
  15994. * Name of the effect.
  15995. */
  15996. name: any;
  15997. /**
  15998. * String container all the define statements that should be set on the shader.
  15999. */
  16000. defines: string;
  16001. /**
  16002. * Callback that will be called when the shader is compiled.
  16003. */
  16004. onCompiled: Nullable<(effect: Effect) => void>;
  16005. /**
  16006. * Callback that will be called if an error occurs during shader compilation.
  16007. */
  16008. onError: Nullable<(effect: Effect, errors: string) => void>;
  16009. /**
  16010. * Callback that will be called when effect is bound.
  16011. */
  16012. onBind: Nullable<(effect: Effect) => void>;
  16013. /**
  16014. * Unique ID of the effect.
  16015. */
  16016. uniqueId: number;
  16017. /**
  16018. * Observable that will be called when the shader is compiled.
  16019. */
  16020. onCompileObservable: Observable<Effect>;
  16021. /**
  16022. * Observable that will be called if an error occurs during shader compilation.
  16023. */
  16024. onErrorObservable: Observable<Effect>;
  16025. /** @hidden */
  16026. /**
  16027. * Observable that will be called when effect is bound.
  16028. */
  16029. readonly onBindObservable: Observable<Effect>;
  16030. /** @hidden */
  16031. private static _uniqueIdSeed;
  16032. private _engine;
  16033. private _uniformBuffersNames;
  16034. private _uniformsNames;
  16035. private _samplers;
  16036. private _isReady;
  16037. private _compilationError;
  16038. private _attributesNames;
  16039. private _attributes;
  16040. private _uniforms;
  16041. /**
  16042. * Key for the effect.
  16043. * @hidden
  16044. */
  16045. private _indexParameters;
  16046. private _fallbacks;
  16047. private _vertexSourceCode;
  16048. private _fragmentSourceCode;
  16049. private _vertexSourceCodeOverride;
  16050. private _fragmentSourceCodeOverride;
  16051. private _transformFeedbackVaryings;
  16052. /**
  16053. * Compiled shader to webGL program.
  16054. * @hidden
  16055. */
  16056. private _valueCache;
  16057. private static _baseCache;
  16058. /**
  16059. * Instantiates an effect.
  16060. * An effect can be used to create/manage/execute vertex and fragment shaders.
  16061. * @param baseName Name of the effect.
  16062. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  16063. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  16064. * @param samplers List of sampler variables that will be passed to the shader.
  16065. * @param engine Engine to be used to render the effect
  16066. * @param defines Define statements to be added to the shader.
  16067. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  16068. * @param onCompiled Callback that will be called when the shader is compiled.
  16069. * @param onError Callback that will be called if an error occurs during shader compilation.
  16070. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  16071. */
  16072. 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);
  16073. /**
  16074. * Unique key for this effect
  16075. */
  16076. readonly key: string;
  16077. /**
  16078. * If the effect has been compiled and prepared.
  16079. * @returns if the effect is compiled and prepared.
  16080. */
  16081. isReady(): boolean;
  16082. /**
  16083. * The engine the effect was initialized with.
  16084. * @returns the engine.
  16085. */
  16086. getEngine(): Engine;
  16087. /**
  16088. * The compiled webGL program for the effect
  16089. * @returns the webGL program.
  16090. */
  16091. getProgram(): WebGLProgram;
  16092. /**
  16093. * The set of names of attribute variables for the shader.
  16094. * @returns An array of attribute names.
  16095. */
  16096. getAttributesNames(): string[];
  16097. /**
  16098. * Returns the attribute at the given index.
  16099. * @param index The index of the attribute.
  16100. * @returns The location of the attribute.
  16101. */
  16102. getAttributeLocation(index: number): number;
  16103. /**
  16104. * Returns the attribute based on the name of the variable.
  16105. * @param name of the attribute to look up.
  16106. * @returns the attribute location.
  16107. */
  16108. getAttributeLocationByName(name: string): number;
  16109. /**
  16110. * The number of attributes.
  16111. * @returns the numnber of attributes.
  16112. */
  16113. getAttributesCount(): number;
  16114. /**
  16115. * Gets the index of a uniform variable.
  16116. * @param uniformName of the uniform to look up.
  16117. * @returns the index.
  16118. */
  16119. getUniformIndex(uniformName: string): number;
  16120. /**
  16121. * Returns the attribute based on the name of the variable.
  16122. * @param uniformName of the uniform to look up.
  16123. * @returns the location of the uniform.
  16124. */
  16125. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  16126. /**
  16127. * Returns an array of sampler variable names
  16128. * @returns The array of sampler variable neames.
  16129. */
  16130. getSamplers(): string[];
  16131. /**
  16132. * The error from the last compilation.
  16133. * @returns the error string.
  16134. */
  16135. getCompilationError(): string;
  16136. /**
  16137. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  16138. * @param func The callback to be used.
  16139. */
  16140. executeWhenCompiled(func: (effect: Effect) => void): void;
  16141. /** @hidden */
  16142. /** @hidden */
  16143. /** @hidden */
  16144. private _processShaderConversion;
  16145. private _processIncludes;
  16146. private _processPrecision;
  16147. /**
  16148. * Recompiles the webGL program
  16149. * @param vertexSourceCode The source code for the vertex shader.
  16150. * @param fragmentSourceCode The source code for the fragment shader.
  16151. * @param onCompiled Callback called when completed.
  16152. * @param onError Callback called on error.
  16153. * @hidden
  16154. */
  16155. /**
  16156. * Gets the uniform locations of the the specified variable names
  16157. * @param names THe names of the variables to lookup.
  16158. * @returns Array of locations in the same order as variable names.
  16159. */
  16160. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  16161. /**
  16162. * Prepares the effect
  16163. * @hidden
  16164. */
  16165. /**
  16166. * Checks if the effect is supported. (Must be called after compilation)
  16167. */
  16168. readonly isSupported: boolean;
  16169. /**
  16170. * Binds a texture to the engine to be used as output of the shader.
  16171. * @param channel Name of the output variable.
  16172. * @param texture Texture to bind.
  16173. * @hidden
  16174. */
  16175. /**
  16176. * Sets a texture on the engine to be used in the shader.
  16177. * @param channel Name of the sampler variable.
  16178. * @param texture Texture to set.
  16179. */
  16180. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  16181. /**
  16182. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  16183. * @param channel Name of the sampler variable.
  16184. * @param texture Texture to set.
  16185. */
  16186. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  16187. /**
  16188. * Sets an array of textures on the engine to be used in the shader.
  16189. * @param channel Name of the variable.
  16190. * @param textures Textures to set.
  16191. */
  16192. setTextureArray(channel: string, textures: BaseTexture[]): void;
  16193. /**
  16194. * 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)
  16195. * @param channel Name of the sampler variable.
  16196. * @param postProcess Post process to get the input texture from.
  16197. */
  16198. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  16199. /**
  16200. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  16201. * 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)
  16202. * @param channel Name of the sampler variable.
  16203. * @param postProcess Post process to get the output texture from.
  16204. */
  16205. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  16206. /** @hidden */
  16207. /** @hidden */
  16208. /** @hidden */
  16209. /** @hidden */
  16210. /**
  16211. * Binds a buffer to a uniform.
  16212. * @param buffer Buffer to bind.
  16213. * @param name Name of the uniform variable to bind to.
  16214. */
  16215. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  16216. /**
  16217. * Binds block to a uniform.
  16218. * @param blockName Name of the block to bind.
  16219. * @param index Index to bind.
  16220. */
  16221. bindUniformBlock(blockName: string, index: number): void;
  16222. /**
  16223. * Sets an interger value on a uniform variable.
  16224. * @param uniformName Name of the variable.
  16225. * @param value Value to be set.
  16226. * @returns this effect.
  16227. */
  16228. setInt(uniformName: string, value: number): Effect;
  16229. /**
  16230. * Sets an int array on a uniform variable.
  16231. * @param uniformName Name of the variable.
  16232. * @param array array to be set.
  16233. * @returns this effect.
  16234. */
  16235. setIntArray(uniformName: string, array: Int32Array): Effect;
  16236. /**
  16237. * 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)
  16238. * @param uniformName Name of the variable.
  16239. * @param array array to be set.
  16240. * @returns this effect.
  16241. */
  16242. setIntArray2(uniformName: string, array: Int32Array): Effect;
  16243. /**
  16244. * 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)
  16245. * @param uniformName Name of the variable.
  16246. * @param array array to be set.
  16247. * @returns this effect.
  16248. */
  16249. setIntArray3(uniformName: string, array: Int32Array): Effect;
  16250. /**
  16251. * 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)
  16252. * @param uniformName Name of the variable.
  16253. * @param array array to be set.
  16254. * @returns this effect.
  16255. */
  16256. setIntArray4(uniformName: string, array: Int32Array): Effect;
  16257. /**
  16258. * Sets an float array on a uniform variable.
  16259. * @param uniformName Name of the variable.
  16260. * @param array array to be set.
  16261. * @returns this effect.
  16262. */
  16263. setFloatArray(uniformName: string, array: Float32Array): Effect;
  16264. /**
  16265. * 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)
  16266. * @param uniformName Name of the variable.
  16267. * @param array array to be set.
  16268. * @returns this effect.
  16269. */
  16270. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  16271. /**
  16272. * 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)
  16273. * @param uniformName Name of the variable.
  16274. * @param array array to be set.
  16275. * @returns this effect.
  16276. */
  16277. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  16278. /**
  16279. * 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)
  16280. * @param uniformName Name of the variable.
  16281. * @param array array to be set.
  16282. * @returns this effect.
  16283. */
  16284. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  16285. /**
  16286. * Sets an array on a uniform variable.
  16287. * @param uniformName Name of the variable.
  16288. * @param array array to be set.
  16289. * @returns this effect.
  16290. */
  16291. setArray(uniformName: string, array: number[]): Effect;
  16292. /**
  16293. * 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)
  16294. * @param uniformName Name of the variable.
  16295. * @param array array to be set.
  16296. * @returns this effect.
  16297. */
  16298. setArray2(uniformName: string, array: number[]): Effect;
  16299. /**
  16300. * 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)
  16301. * @param uniformName Name of the variable.
  16302. * @param array array to be set.
  16303. * @returns this effect.
  16304. */
  16305. setArray3(uniformName: string, array: number[]): Effect;
  16306. /**
  16307. * 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)
  16308. * @param uniformName Name of the variable.
  16309. * @param array array to be set.
  16310. * @returns this effect.
  16311. */
  16312. setArray4(uniformName: string, array: number[]): Effect;
  16313. /**
  16314. * Sets matrices on a uniform variable.
  16315. * @param uniformName Name of the variable.
  16316. * @param matrices matrices to be set.
  16317. * @returns this effect.
  16318. */
  16319. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  16320. /**
  16321. * Sets matrix on a uniform variable.
  16322. * @param uniformName Name of the variable.
  16323. * @param matrix matrix to be set.
  16324. * @returns this effect.
  16325. */
  16326. setMatrix(uniformName: string, matrix: Matrix): Effect;
  16327. /**
  16328. * 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)
  16329. * @param uniformName Name of the variable.
  16330. * @param matrix matrix to be set.
  16331. * @returns this effect.
  16332. */
  16333. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  16334. /**
  16335. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  16336. * @param uniformName Name of the variable.
  16337. * @param matrix matrix to be set.
  16338. * @returns this effect.
  16339. */
  16340. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  16341. /**
  16342. * Sets a float on a uniform variable.
  16343. * @param uniformName Name of the variable.
  16344. * @param value value to be set.
  16345. * @returns this effect.
  16346. */
  16347. setFloat(uniformName: string, value: number): Effect;
  16348. /**
  16349. * Sets a boolean on a uniform variable.
  16350. * @param uniformName Name of the variable.
  16351. * @param bool value to be set.
  16352. * @returns this effect.
  16353. */
  16354. setBool(uniformName: string, bool: boolean): Effect;
  16355. /**
  16356. * Sets a Vector2 on a uniform variable.
  16357. * @param uniformName Name of the variable.
  16358. * @param vector2 vector2 to be set.
  16359. * @returns this effect.
  16360. */
  16361. setVector2(uniformName: string, vector2: Vector2): Effect;
  16362. /**
  16363. * Sets a float2 on a uniform variable.
  16364. * @param uniformName Name of the variable.
  16365. * @param x First float in float2.
  16366. * @param y Second float in float2.
  16367. * @returns this effect.
  16368. */
  16369. setFloat2(uniformName: string, x: number, y: number): Effect;
  16370. /**
  16371. * Sets a Vector3 on a uniform variable.
  16372. * @param uniformName Name of the variable.
  16373. * @param vector3 Value to be set.
  16374. * @returns this effect.
  16375. */
  16376. setVector3(uniformName: string, vector3: Vector3): Effect;
  16377. /**
  16378. * Sets a float3 on a uniform variable.
  16379. * @param uniformName Name of the variable.
  16380. * @param x First float in float3.
  16381. * @param y Second float in float3.
  16382. * @param z Third float in float3.
  16383. * @returns this effect.
  16384. */
  16385. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  16386. /**
  16387. * Sets a Vector4 on a uniform variable.
  16388. * @param uniformName Name of the variable.
  16389. * @param vector4 Value to be set.
  16390. * @returns this effect.
  16391. */
  16392. setVector4(uniformName: string, vector4: Vector4): Effect;
  16393. /**
  16394. * Sets a float4 on a uniform variable.
  16395. * @param uniformName Name of the variable.
  16396. * @param x First float in float4.
  16397. * @param y Second float in float4.
  16398. * @param z Third float in float4.
  16399. * @param w Fourth float in float4.
  16400. * @returns this effect.
  16401. */
  16402. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  16403. /**
  16404. * Sets a Color3 on a uniform variable.
  16405. * @param uniformName Name of the variable.
  16406. * @param color3 Value to be set.
  16407. * @returns this effect.
  16408. */
  16409. setColor3(uniformName: string, color3: Color3): Effect;
  16410. /**
  16411. * Sets a Color4 on a uniform variable.
  16412. * @param uniformName Name of the variable.
  16413. * @param color3 Value to be set.
  16414. * @param alpha Alpha value to be set.
  16415. * @returns this effect.
  16416. */
  16417. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  16418. /**
  16419. * Sets a Color4 on a uniform variable
  16420. * @param uniformName defines the name of the variable
  16421. * @param color4 defines the value to be set
  16422. * @returns this effect.
  16423. */
  16424. setDirectColor4(uniformName: string, color4: Color4): Effect;
  16425. /**
  16426. * This function will add a new shader to the shader store
  16427. * @param name the name of the shader
  16428. * @param pixelShader optional pixel shader content
  16429. * @param vertexShader optional vertex shader content
  16430. */
  16431. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  16432. /**
  16433. * Store of each shader (The can be looked up using effect.key)
  16434. */
  16435. static ShadersStore: {
  16436. [key: string]: string;
  16437. };
  16438. /**
  16439. * Store of each included file for a shader (The can be looked up using effect.key)
  16440. */
  16441. static IncludesShadersStore: {
  16442. [key: string]: string;
  16443. };
  16444. /**
  16445. * Resets the cache of effects.
  16446. */
  16447. static ResetCache(): void;
  16448. }
  16449. }
  16450. declare module BABYLON {
  16451. class FresnelParameters {
  16452. private _isEnabled;
  16453. isEnabled: boolean;
  16454. leftColor: Color3;
  16455. rightColor: Color3;
  16456. bias: number;
  16457. power: number;
  16458. clone(): FresnelParameters;
  16459. serialize(): any;
  16460. static Parse(parsedFresnelParameters: any): FresnelParameters;
  16461. }
  16462. }
  16463. declare module BABYLON {
  16464. /**
  16465. * Interface to follow in your material defines to integrate easily the
  16466. * Image proccessing functions.
  16467. * @hidden
  16468. */
  16469. interface IImageProcessingConfigurationDefines {
  16470. IMAGEPROCESSING: boolean;
  16471. VIGNETTE: boolean;
  16472. VIGNETTEBLENDMODEMULTIPLY: boolean;
  16473. VIGNETTEBLENDMODEOPAQUE: boolean;
  16474. TONEMAPPING: boolean;
  16475. TONEMAPPING_ACES: boolean;
  16476. CONTRAST: boolean;
  16477. EXPOSURE: boolean;
  16478. COLORCURVES: boolean;
  16479. COLORGRADING: boolean;
  16480. COLORGRADING3D: boolean;
  16481. SAMPLER3DGREENDEPTH: boolean;
  16482. SAMPLER3DBGRMAP: boolean;
  16483. IMAGEPROCESSINGPOSTPROCESS: boolean;
  16484. }
  16485. /**
  16486. * @hidden
  16487. */
  16488. class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  16489. IMAGEPROCESSING: boolean;
  16490. VIGNETTE: boolean;
  16491. VIGNETTEBLENDMODEMULTIPLY: boolean;
  16492. VIGNETTEBLENDMODEOPAQUE: boolean;
  16493. TONEMAPPING: boolean;
  16494. TONEMAPPING_ACES: boolean;
  16495. CONTRAST: boolean;
  16496. COLORCURVES: boolean;
  16497. COLORGRADING: boolean;
  16498. COLORGRADING3D: boolean;
  16499. SAMPLER3DGREENDEPTH: boolean;
  16500. SAMPLER3DBGRMAP: boolean;
  16501. IMAGEPROCESSINGPOSTPROCESS: boolean;
  16502. EXPOSURE: boolean;
  16503. constructor();
  16504. }
  16505. /**
  16506. * This groups together the common properties used for image processing either in direct forward pass
  16507. * or through post processing effect depending on the use of the image processing pipeline in your scene
  16508. * or not.
  16509. */
  16510. class ImageProcessingConfiguration {
  16511. /**
  16512. * Default tone mapping applied in BabylonJS.
  16513. */
  16514. static readonly TONEMAPPING_STANDARD: number;
  16515. /**
  16516. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  16517. * to other engines rendering to increase portability.
  16518. */
  16519. static readonly TONEMAPPING_ACES: number;
  16520. /**
  16521. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  16522. */
  16523. colorCurves: Nullable<ColorCurves>;
  16524. private _colorCurvesEnabled;
  16525. /**
  16526. * Gets wether the color curves effect is enabled.
  16527. */
  16528. /**
  16529. * Sets wether the color curves effect is enabled.
  16530. */
  16531. colorCurvesEnabled: boolean;
  16532. /**
  16533. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  16534. */
  16535. colorGradingTexture: Nullable<BaseTexture>;
  16536. private _colorGradingEnabled;
  16537. /**
  16538. * Gets wether the color grading effect is enabled.
  16539. */
  16540. /**
  16541. * Sets wether the color grading effect is enabled.
  16542. */
  16543. colorGradingEnabled: boolean;
  16544. private _colorGradingWithGreenDepth;
  16545. /**
  16546. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  16547. */
  16548. /**
  16549. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  16550. */
  16551. colorGradingWithGreenDepth: boolean;
  16552. private _colorGradingBGR;
  16553. /**
  16554. * Gets wether the color grading texture contains BGR values.
  16555. */
  16556. /**
  16557. * Sets wether the color grading texture contains BGR values.
  16558. */
  16559. colorGradingBGR: boolean;
  16560. /** @hidden */
  16561. /**
  16562. * Gets the Exposure used in the effect.
  16563. */
  16564. /**
  16565. * Sets the Exposure used in the effect.
  16566. */
  16567. exposure: number;
  16568. private _toneMappingEnabled;
  16569. /**
  16570. * Gets wether the tone mapping effect is enabled.
  16571. */
  16572. /**
  16573. * Sets wether the tone mapping effect is enabled.
  16574. */
  16575. toneMappingEnabled: boolean;
  16576. private _toneMappingType;
  16577. /**
  16578. * Gets the type of tone mapping effect.
  16579. */
  16580. /**
  16581. * Sets the type of tone mapping effect used in BabylonJS.
  16582. */
  16583. toneMappingType: number;
  16584. protected _contrast: number;
  16585. /**
  16586. * Gets the contrast used in the effect.
  16587. */
  16588. /**
  16589. * Sets the contrast used in the effect.
  16590. */
  16591. contrast: number;
  16592. /**
  16593. * Vignette stretch size.
  16594. */
  16595. vignetteStretch: number;
  16596. /**
  16597. * Vignette centre X Offset.
  16598. */
  16599. vignetteCentreX: number;
  16600. /**
  16601. * Vignette centre Y Offset.
  16602. */
  16603. vignetteCentreY: number;
  16604. /**
  16605. * Vignette weight or intensity of the vignette effect.
  16606. */
  16607. vignetteWeight: number;
  16608. /**
  16609. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  16610. * if vignetteEnabled is set to true.
  16611. */
  16612. vignetteColor: Color4;
  16613. /**
  16614. * Camera field of view used by the Vignette effect.
  16615. */
  16616. vignetteCameraFov: number;
  16617. private _vignetteBlendMode;
  16618. /**
  16619. * Gets the vignette blend mode allowing different kind of effect.
  16620. */
  16621. /**
  16622. * Sets the vignette blend mode allowing different kind of effect.
  16623. */
  16624. vignetteBlendMode: number;
  16625. private _vignetteEnabled;
  16626. /**
  16627. * Gets wether the vignette effect is enabled.
  16628. */
  16629. /**
  16630. * Sets wether the vignette effect is enabled.
  16631. */
  16632. vignetteEnabled: boolean;
  16633. private _applyByPostProcess;
  16634. /**
  16635. * Gets wether the image processing is applied through a post process or not.
  16636. */
  16637. /**
  16638. * Sets wether the image processing is applied through a post process or not.
  16639. */
  16640. applyByPostProcess: boolean;
  16641. private _isEnabled;
  16642. /**
  16643. * Gets wether the image processing is enabled or not.
  16644. */
  16645. /**
  16646. * Sets wether the image processing is enabled or not.
  16647. */
  16648. isEnabled: boolean;
  16649. /**
  16650. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  16651. */
  16652. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  16653. /**
  16654. * Method called each time the image processing information changes requires to recompile the effect.
  16655. */
  16656. protected _updateParameters(): void;
  16657. getClassName(): string;
  16658. /**
  16659. * Prepare the list of uniforms associated with the Image Processing effects.
  16660. * @param uniformsList The list of uniforms used in the effect
  16661. * @param defines the list of defines currently in use
  16662. */
  16663. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  16664. /**
  16665. * Prepare the list of samplers associated with the Image Processing effects.
  16666. * @param uniformsList The list of uniforms used in the effect
  16667. * @param defines the list of defines currently in use
  16668. */
  16669. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  16670. /**
  16671. * Prepare the list of defines associated to the shader.
  16672. * @param defines the list of defines to complete
  16673. */
  16674. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  16675. /**
  16676. * Returns true if all the image processing information are ready.
  16677. */
  16678. isReady(): boolean;
  16679. /**
  16680. * Binds the image processing to the shader.
  16681. * @param effect The effect to bind to
  16682. */
  16683. bind(effect: Effect, aspectRatio?: number): void;
  16684. /**
  16685. * Clones the current image processing instance.
  16686. * @return The cloned image processing
  16687. */
  16688. clone(): ImageProcessingConfiguration;
  16689. /**
  16690. * Serializes the current image processing instance to a json representation.
  16691. * @return a JSON representation
  16692. */
  16693. serialize(): any;
  16694. /**
  16695. * Parses the image processing from a json representation.
  16696. * @param source the JSON source to parse
  16697. * @return The parsed image processing
  16698. */
  16699. static Parse(source: any): ImageProcessingConfiguration;
  16700. private static _VIGNETTEMODE_MULTIPLY;
  16701. private static _VIGNETTEMODE_OPAQUE;
  16702. /**
  16703. * Used to apply the vignette as a mix with the pixel color.
  16704. */
  16705. static readonly VIGNETTEMODE_MULTIPLY: number;
  16706. /**
  16707. * Used to apply the vignette as a replacement of the pixel color.
  16708. */
  16709. static readonly VIGNETTEMODE_OPAQUE: number;
  16710. }
  16711. }
  16712. declare module BABYLON {
  16713. /**
  16714. * Manages the defines for the Material
  16715. */
  16716. class MaterialDefines {
  16717. private _keys;
  16718. private _isDirty;
  16719. /** @hidden */
  16720. /** @hidden */
  16721. /** @hidden */
  16722. /** @hidden */
  16723. /** @hidden */
  16724. /** @hidden */
  16725. /** @hidden */
  16726. /** @hidden */
  16727. /** @hidden */
  16728. /** @hidden */
  16729. /** @hidden */
  16730. /**
  16731. * Specifies if the material needs to be re-calculated
  16732. */
  16733. readonly isDirty: boolean;
  16734. /**
  16735. * Marks the material to indicate that it has been re-calculated
  16736. */
  16737. markAsProcessed(): void;
  16738. /**
  16739. * Marks the material to indicate that it needs to be re-calculated
  16740. */
  16741. markAsUnprocessed(): void;
  16742. /**
  16743. * Marks the material to indicate all of its defines need to be re-calculated
  16744. */
  16745. markAllAsDirty(): void;
  16746. /**
  16747. * Marks the material to indicate that image processing needs to be re-calculated
  16748. */
  16749. markAsImageProcessingDirty(): void;
  16750. /**
  16751. * Marks the material to indicate the lights need to be re-calculated
  16752. */
  16753. markAsLightDirty(): void;
  16754. /**
  16755. * Marks the attribute state as changed
  16756. */
  16757. markAsAttributesDirty(): void;
  16758. /**
  16759. * Marks the texture state as changed
  16760. */
  16761. markAsTexturesDirty(): void;
  16762. /**
  16763. * Marks the fresnel state as changed
  16764. */
  16765. markAsFresnelDirty(): void;
  16766. /**
  16767. * Marks the misc state as changed
  16768. */
  16769. markAsMiscDirty(): void;
  16770. /**
  16771. * Rebuilds the material defines
  16772. */
  16773. rebuild(): void;
  16774. /**
  16775. * Specifies if two material defines are equal
  16776. * @param other - A material define instance to compare to
  16777. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  16778. */
  16779. isEqual(other: MaterialDefines): boolean;
  16780. /**
  16781. * Clones this instance's defines to another instance
  16782. * @param other - material defines to clone values to
  16783. */
  16784. cloneTo(other: MaterialDefines): void;
  16785. /**
  16786. * Resets the material define values
  16787. */
  16788. reset(): void;
  16789. /**
  16790. * Converts the material define values to a string
  16791. * @returns - String of material define information
  16792. */
  16793. toString(): string;
  16794. }
  16795. /**
  16796. * Base class for the main features of a material in Babylon.js
  16797. */
  16798. class Material implements IAnimatable {
  16799. private static _TriangleFillMode;
  16800. private static _WireFrameFillMode;
  16801. private static _PointFillMode;
  16802. private static _PointListDrawMode;
  16803. private static _LineListDrawMode;
  16804. private static _LineLoopDrawMode;
  16805. private static _LineStripDrawMode;
  16806. private static _TriangleStripDrawMode;
  16807. private static _TriangleFanDrawMode;
  16808. /**
  16809. * Returns the triangle fill mode
  16810. */
  16811. static readonly TriangleFillMode: number;
  16812. /**
  16813. * Returns the wireframe mode
  16814. */
  16815. static readonly WireFrameFillMode: number;
  16816. /**
  16817. * Returns the point fill mode
  16818. */
  16819. static readonly PointFillMode: number;
  16820. /**
  16821. * Returns the point list draw mode
  16822. */
  16823. static readonly PointListDrawMode: number;
  16824. /**
  16825. * Returns the line list draw mode
  16826. */
  16827. static readonly LineListDrawMode: number;
  16828. /**
  16829. * Returns the line loop draw mode
  16830. */
  16831. static readonly LineLoopDrawMode: number;
  16832. /**
  16833. * Returns the line strip draw mode
  16834. */
  16835. static readonly LineStripDrawMode: number;
  16836. /**
  16837. * Returns the triangle strip draw mode
  16838. */
  16839. static readonly TriangleStripDrawMode: number;
  16840. /**
  16841. * Returns the triangle fan draw mode
  16842. */
  16843. static readonly TriangleFanDrawMode: number;
  16844. /**
  16845. * Stores the clock-wise side orientation
  16846. */
  16847. private static _ClockWiseSideOrientation;
  16848. /**
  16849. * Stores the counter clock-wise side orientation
  16850. */
  16851. private static _CounterClockWiseSideOrientation;
  16852. /**
  16853. * Returns the clock-wise side orientation
  16854. */
  16855. static readonly ClockWiseSideOrientation: number;
  16856. /**
  16857. * Returns the counter clock-wise side orientation
  16858. */
  16859. static readonly CounterClockWiseSideOrientation: number;
  16860. /**
  16861. * The dirty texture flag value
  16862. */
  16863. static readonly TextureDirtyFlag: number;
  16864. /**
  16865. * The dirty light flag value
  16866. */
  16867. static readonly LightDirtyFlag: number;
  16868. /**
  16869. * The dirty fresnel flag value
  16870. */
  16871. static readonly FresnelDirtyFlag: number;
  16872. /**
  16873. * The dirty attribute flag value
  16874. */
  16875. static readonly AttributesDirtyFlag: number;
  16876. /**
  16877. * The dirty misc flag value
  16878. */
  16879. static readonly MiscDirtyFlag: number;
  16880. /**
  16881. * The all dirty flag value
  16882. */
  16883. static readonly AllDirtyFlag: number;
  16884. /**
  16885. * The ID of the material
  16886. */
  16887. id: string;
  16888. /**
  16889. * Gets or sets the unique id of the material
  16890. */
  16891. uniqueId: number;
  16892. /**
  16893. * The name of the material
  16894. */
  16895. name: string;
  16896. /**
  16897. * Specifies if the ready state should be checked on each call
  16898. */
  16899. checkReadyOnEveryCall: boolean;
  16900. /**
  16901. * Specifies if the ready state should be checked once
  16902. */
  16903. checkReadyOnlyOnce: boolean;
  16904. /**
  16905. * The state of the material
  16906. */
  16907. state: string;
  16908. /**
  16909. * The alpha value of the material
  16910. */
  16911. protected _alpha: number;
  16912. /**
  16913. * Sets the alpha value of the material
  16914. */
  16915. /**
  16916. * Gets the alpha value of the material
  16917. */
  16918. alpha: number;
  16919. /**
  16920. * Specifies if back face culling is enabled
  16921. */
  16922. protected _backFaceCulling: boolean;
  16923. /**
  16924. * Sets the back-face culling state
  16925. */
  16926. /**
  16927. * Gets the back-face culling state
  16928. */
  16929. backFaceCulling: boolean;
  16930. /**
  16931. * Stores the value for side orientation
  16932. */
  16933. sideOrientation: number;
  16934. /**
  16935. * Callback triggered when the material is compiled
  16936. */
  16937. onCompiled: (effect: Effect) => void;
  16938. /**
  16939. * Callback triggered when an error occurs
  16940. */
  16941. onError: (effect: Effect, errors: string) => void;
  16942. /**
  16943. * Callback triggered to get the render target textures
  16944. */
  16945. getRenderTargetTextures: () => SmartArray<RenderTargetTexture>;
  16946. /**
  16947. * Gets a boolean indicating that current material needs to register RTT
  16948. */
  16949. readonly hasRenderTargetTextures: boolean;
  16950. /**
  16951. * Specifies if the material should be serialized
  16952. */
  16953. doNotSerialize: boolean;
  16954. /**
  16955. * Specifies if the effect should be stored on sub meshes
  16956. */
  16957. storeEffectOnSubMeshes: boolean;
  16958. /**
  16959. * Stores the animations for the material
  16960. */
  16961. animations: Array<Animation>;
  16962. /**
  16963. * An event triggered when the material is disposed
  16964. */
  16965. onDisposeObservable: Observable<Material>;
  16966. /**
  16967. * An observer which watches for dispose events
  16968. */
  16969. private _onDisposeObserver;
  16970. private _onUnBindObservable;
  16971. /**
  16972. * Called during a dispose event
  16973. */
  16974. onDispose: () => void;
  16975. private _onBindObservable;
  16976. /**
  16977. * An event triggered when the material is bound
  16978. */
  16979. readonly onBindObservable: Observable<AbstractMesh>;
  16980. /**
  16981. * An observer which watches for bind events
  16982. */
  16983. private _onBindObserver;
  16984. /**
  16985. * Called during a bind event
  16986. */
  16987. onBind: (Mesh: AbstractMesh) => void;
  16988. /**
  16989. * An event triggered when the material is unbound
  16990. */
  16991. readonly onUnBindObservable: Observable<Material>;
  16992. /**
  16993. * Stores the value of the alpha mode
  16994. */
  16995. private _alphaMode;
  16996. /**
  16997. * Sets the value of the alpha mode.
  16998. *
  16999. * | Value | Type | Description |
  17000. * | --- | --- | --- |
  17001. * | 0 | ALPHA_DISABLE | |
  17002. * | 1 | ALPHA_ADD | |
  17003. * | 2 | ALPHA_COMBINE | |
  17004. * | 3 | ALPHA_SUBTRACT | |
  17005. * | 4 | ALPHA_MULTIPLY | |
  17006. * | 5 | ALPHA_MAXIMIZED | |
  17007. * | 6 | ALPHA_ONEONE | |
  17008. * | 7 | ALPHA_PREMULTIPLIED | |
  17009. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  17010. * | 9 | ALPHA_INTERPOLATE | |
  17011. * | 10 | ALPHA_SCREENMODE | |
  17012. *
  17013. */
  17014. /**
  17015. * Gets the value of the alpha mode
  17016. */
  17017. alphaMode: number;
  17018. /**
  17019. * Stores the state of the need depth pre-pass value
  17020. */
  17021. private _needDepthPrePass;
  17022. /**
  17023. * Sets the need depth pre-pass value
  17024. */
  17025. /**
  17026. * Gets the depth pre-pass value
  17027. */
  17028. needDepthPrePass: boolean;
  17029. /**
  17030. * Specifies if depth writing should be disabled
  17031. */
  17032. disableDepthWrite: boolean;
  17033. /**
  17034. * Specifies if depth writing should be forced
  17035. */
  17036. forceDepthWrite: boolean;
  17037. /**
  17038. * Specifies if there should be a separate pass for culling
  17039. */
  17040. separateCullingPass: boolean;
  17041. /**
  17042. * Stores the state specifing if fog should be enabled
  17043. */
  17044. private _fogEnabled;
  17045. /**
  17046. * Sets the state for enabling fog
  17047. */
  17048. /**
  17049. * Gets the value of the fog enabled state
  17050. */
  17051. fogEnabled: boolean;
  17052. /**
  17053. * Stores the size of points
  17054. */
  17055. pointSize: number;
  17056. /**
  17057. * Stores the z offset value
  17058. */
  17059. zOffset: number;
  17060. /**
  17061. * Gets a value specifying if wireframe mode is enabled
  17062. */
  17063. /**
  17064. * Sets the state of wireframe mode
  17065. */
  17066. wireframe: boolean;
  17067. /**
  17068. * Gets the value specifying if point clouds are enabled
  17069. */
  17070. /**
  17071. * Sets the state of point cloud mode
  17072. */
  17073. pointsCloud: boolean;
  17074. /**
  17075. * Gets the material fill mode
  17076. */
  17077. /**
  17078. * Sets the material fill mode
  17079. */
  17080. fillMode: number;
  17081. /**
  17082. * @hidden
  17083. * Stores the effects for the material
  17084. */
  17085. /**
  17086. * @hidden
  17087. * Specifies if the material was previously ready
  17088. */
  17089. /**
  17090. * Specifies if uniform buffers should be used
  17091. */
  17092. private _useUBO;
  17093. /**
  17094. * Stores a reference to the scene
  17095. */
  17096. private _scene;
  17097. /**
  17098. * Stores the fill mode state
  17099. */
  17100. private _fillMode;
  17101. /**
  17102. * Specifies if the depth write state should be cached
  17103. */
  17104. private _cachedDepthWriteState;
  17105. /**
  17106. * Stores the uniform buffer
  17107. */
  17108. protected _uniformBuffer: UniformBuffer;
  17109. /**
  17110. * Creates a material instance
  17111. * @param name defines the name of the material
  17112. * @param scene defines the scene to reference
  17113. * @param doNotAdd specifies if the material should be added to the scene
  17114. */
  17115. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  17116. /**
  17117. * Returns a string representation of the current material
  17118. * @param fullDetails defines a boolean indicating which levels of logging is desired
  17119. * @returns a string with material information
  17120. */
  17121. toString(fullDetails?: boolean): string;
  17122. /**
  17123. * Gets the class name of the material
  17124. * @returns a string with the class name of the material
  17125. */
  17126. getClassName(): string;
  17127. /**
  17128. * Specifies if updates for the material been locked
  17129. */
  17130. readonly isFrozen: boolean;
  17131. /**
  17132. * Locks updates for the material
  17133. */
  17134. freeze(): void;
  17135. /**
  17136. * Unlocks updates for the material
  17137. */
  17138. unfreeze(): void;
  17139. /**
  17140. * Specifies if the material is ready to be used
  17141. * @param mesh defines the mesh to check
  17142. * @param useInstances specifies if instances should be used
  17143. * @returns a boolean indicating if the material is ready to be used
  17144. */
  17145. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  17146. /**
  17147. * Specifies that the submesh is ready to be used
  17148. * @param mesh defines the mesh to check
  17149. * @param subMesh defines which submesh to check
  17150. * @param useInstances specifies that instances should be used
  17151. * @returns a boolean indicating that the submesh is ready or not
  17152. */
  17153. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  17154. /**
  17155. * Returns the material effect
  17156. * @returns the effect associated with the material
  17157. */
  17158. getEffect(): Nullable<Effect>;
  17159. /**
  17160. * Returns the current scene
  17161. * @returns a Scene
  17162. */
  17163. getScene(): Scene;
  17164. /**
  17165. * Specifies if the material will require alpha blending
  17166. * @returns a boolean specifying if alpha blending is needed
  17167. */
  17168. needAlphaBlending(): boolean;
  17169. /**
  17170. * Specifies if the mesh will require alpha blending
  17171. * @param mesh defines the mesh to check
  17172. * @returns a boolean specifying if alpha blending is needed for the mesh
  17173. */
  17174. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  17175. /**
  17176. * Specifies if this material should be rendered in alpha test mode
  17177. * @returns a boolean specifying if an alpha test is needed.
  17178. */
  17179. needAlphaTesting(): boolean;
  17180. /**
  17181. * Gets the texture used for the alpha test
  17182. * @returns the texture to use for alpha testing
  17183. */
  17184. getAlphaTestTexture(): Nullable<BaseTexture>;
  17185. /**
  17186. * Marks the material to indicate that it needs to be re-calculated
  17187. */
  17188. markDirty(): void;
  17189. /** @hidden */
  17190. /**
  17191. * Binds the material to the mesh
  17192. * @param world defines the world transformation matrix
  17193. * @param mesh defines the mesh to bind the material to
  17194. */
  17195. bind(world: Matrix, mesh?: Mesh): void;
  17196. /**
  17197. * Binds the submesh to the material
  17198. * @param world defines the world transformation matrix
  17199. * @param mesh defines the mesh containing the submesh
  17200. * @param subMesh defines the submesh to bind the material to
  17201. */
  17202. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  17203. /**
  17204. * Binds the world matrix to the material
  17205. * @param world defines the world transformation matrix
  17206. */
  17207. bindOnlyWorldMatrix(world: Matrix): void;
  17208. /**
  17209. * Binds the scene's uniform buffer to the effect.
  17210. * @param effect defines the effect to bind to the scene uniform buffer
  17211. * @param sceneUbo defines the uniform buffer storing scene data
  17212. */
  17213. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  17214. /**
  17215. * Binds the view matrix to the effect
  17216. * @param effect defines the effect to bind the view matrix to
  17217. */
  17218. bindView(effect: Effect): void;
  17219. /**
  17220. * Binds the view projection matrix to the effect
  17221. * @param effect defines the effect to bind the view projection matrix to
  17222. */
  17223. bindViewProjection(effect: Effect): void;
  17224. /**
  17225. * Specifies if material alpha testing should be turned on for the mesh
  17226. * @param mesh defines the mesh to check
  17227. */
  17228. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  17229. /**
  17230. * Processes to execute after binding the material to a mesh
  17231. * @param mesh defines the rendered mesh
  17232. */
  17233. protected _afterBind(mesh?: Mesh): void;
  17234. /**
  17235. * Unbinds the material from the mesh
  17236. */
  17237. unbind(): void;
  17238. /**
  17239. * Gets the active textures from the material
  17240. * @returns an array of textures
  17241. */
  17242. getActiveTextures(): BaseTexture[];
  17243. /**
  17244. * Specifies if the material uses a texture
  17245. * @param texture defines the texture to check against the material
  17246. * @returns a boolean specifying if the material uses the texture
  17247. */
  17248. hasTexture(texture: BaseTexture): boolean;
  17249. /**
  17250. * Makes a duplicate of the material, and gives it a new name
  17251. * @param name defines the new name for the duplicated material
  17252. * @returns the cloned material
  17253. */
  17254. clone(name: string): Nullable<Material>;
  17255. /**
  17256. * Gets the meshes bound to the material
  17257. * @returns an array of meshes bound to the material
  17258. */
  17259. getBindedMeshes(): AbstractMesh[];
  17260. /**
  17261. * Force shader compilation
  17262. * @param mesh defines the mesh associated with this material
  17263. * @param onCompiled defines a function to execute once the material is compiled
  17264. * @param options defines the options to configure the compilation
  17265. */
  17266. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  17267. clipPlane: boolean;
  17268. }>): void;
  17269. /**
  17270. * Force shader compilation
  17271. * @param mesh defines the mesh that will use this material
  17272. * @param options defines additional options for compiling the shaders
  17273. * @returns a promise that resolves when the compilation completes
  17274. */
  17275. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  17276. clipPlane: boolean;
  17277. }>): Promise<void>;
  17278. /**
  17279. * Marks a define in the material to indicate that it needs to be re-computed
  17280. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  17281. */
  17282. markAsDirty(flag: number): void;
  17283. /**
  17284. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  17285. * @param func defines a function which checks material defines against the submeshes
  17286. */
  17287. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  17288. /**
  17289. * Indicates that image processing needs to be re-calculated for all submeshes
  17290. */
  17291. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  17292. /**
  17293. * Indicates that textures need to be re-calculated for all submeshes
  17294. */
  17295. protected _markAllSubMeshesAsTexturesDirty(): void;
  17296. /**
  17297. * Indicates that fresnel needs to be re-calculated for all submeshes
  17298. */
  17299. protected _markAllSubMeshesAsFresnelDirty(): void;
  17300. /**
  17301. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  17302. */
  17303. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  17304. /**
  17305. * Indicates that lights need to be re-calculated for all submeshes
  17306. */
  17307. protected _markAllSubMeshesAsLightsDirty(): void;
  17308. /**
  17309. * Indicates that attributes need to be re-calculated for all submeshes
  17310. */
  17311. protected _markAllSubMeshesAsAttributesDirty(): void;
  17312. /**
  17313. * Indicates that misc needs to be re-calculated for all submeshes
  17314. */
  17315. protected _markAllSubMeshesAsMiscDirty(): void;
  17316. /**
  17317. * Indicates that textures and misc need to be re-calculated for all submeshes
  17318. */
  17319. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  17320. /**
  17321. * Disposes the material
  17322. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  17323. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  17324. */
  17325. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  17326. /**
  17327. * Serializes this material
  17328. * @returns the serialized material object
  17329. */
  17330. serialize(): any;
  17331. /**
  17332. * Creates a MultiMaterial from parsed MultiMaterial data.
  17333. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  17334. * @param scene defines the hosting scene
  17335. * @returns a new MultiMaterial
  17336. */
  17337. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  17338. /**
  17339. * Creates a material from parsed material data
  17340. * @param parsedMaterial defines parsed material data
  17341. * @param scene defines the hosting scene
  17342. * @param rootUrl defines the root URL to use to load textures
  17343. * @returns a new material
  17344. */
  17345. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): any;
  17346. }
  17347. }
  17348. declare module BABYLON {
  17349. /**
  17350. * "Static Class" containing the most commonly used helper while dealing with material for
  17351. * rendering purpose.
  17352. *
  17353. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  17354. *
  17355. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  17356. */
  17357. class MaterialHelper {
  17358. /**
  17359. * Bind the current view position to an effect.
  17360. * @param effect The effect to be bound
  17361. * @param scene The scene the eyes position is used from
  17362. */
  17363. static BindEyePosition(effect: Effect, scene: Scene): void;
  17364. /**
  17365. * Helps preparing the defines values about the UVs in used in the effect.
  17366. * UVs are shared as much as we can accross chanels in the shaders.
  17367. * @param texture The texture we are preparing the UVs for
  17368. * @param defines The defines to update
  17369. * @param key The chanel key "diffuse", "specular"... used in the shader
  17370. */
  17371. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  17372. /**
  17373. * Binds a texture matrix value to its corrsponding uniform
  17374. * @param texture The texture to bind the matrix for
  17375. * @param uniformBuffer The uniform buffer receivin the data
  17376. * @param key The chanel key "diffuse", "specular"... used in the shader
  17377. */
  17378. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  17379. /**
  17380. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  17381. * @param mesh defines the current mesh
  17382. * @param scene defines the current scene
  17383. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  17384. * @param pointsCloud defines if point cloud rendering has to be turned on
  17385. * @param fogEnabled defines if fog has to be turned on
  17386. * @param alphaTest defines if alpha testing has to be turned on
  17387. * @param defines defines the current list of defines
  17388. */
  17389. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  17390. /**
  17391. * Helper used to prepare the list of defines associated with frame values for shader compilation
  17392. * @param scene defines the current scene
  17393. * @param engine defines the current engine
  17394. * @param defines specifies the list of active defines
  17395. * @param useInstances defines if instances have to be turned on
  17396. * @param useClipPlane defines if clip plane have to be turned on
  17397. */
  17398. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  17399. /**
  17400. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  17401. * @param mesh The mesh containing the geometry data we will draw
  17402. * @param defines The defines to update
  17403. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  17404. * @param useBones Precise whether bones should be used or not (override mesh info)
  17405. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  17406. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  17407. * @returns false if defines are considered not dirty and have not been checked
  17408. */
  17409. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  17410. /**
  17411. * Prepares the defines related to the light information passed in parameter
  17412. * @param scene The scene we are intending to draw
  17413. * @param mesh The mesh the effect is compiling for
  17414. * @param defines The defines to update
  17415. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  17416. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  17417. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  17418. * @returns true if normals will be required for the rest of the effect
  17419. */
  17420. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  17421. /**
  17422. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  17423. * that won t be acctive due to defines being turned off.
  17424. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  17425. * @param samplersList The samplers list
  17426. * @param defines The defines helping in the list generation
  17427. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  17428. */
  17429. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  17430. /**
  17431. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  17432. * @param defines The defines to update while falling back
  17433. * @param fallbacks The authorized effect fallbacks
  17434. * @param maxSimultaneousLights The maximum number of lights allowed
  17435. * @param rank the current rank of the Effect
  17436. * @returns The newly affected rank
  17437. */
  17438. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  17439. /**
  17440. * Prepares the list of attributes required for morph targets according to the effect defines.
  17441. * @param attribs The current list of supported attribs
  17442. * @param mesh The mesh to prepare the morph targets attributes for
  17443. * @param defines The current Defines of the effect
  17444. */
  17445. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  17446. /**
  17447. * Prepares the list of attributes required for bones according to the effect defines.
  17448. * @param attribs The current list of supported attribs
  17449. * @param mesh The mesh to prepare the bones attributes for
  17450. * @param defines The current Defines of the effect
  17451. * @param fallbacks The current efffect fallback strategy
  17452. */
  17453. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  17454. /**
  17455. * Prepares the list of attributes required for instances according to the effect defines.
  17456. * @param attribs The current list of supported attribs
  17457. * @param defines The current Defines of the effect
  17458. */
  17459. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  17460. /**
  17461. * Binds the light shadow information to the effect for the given mesh.
  17462. * @param light The light containing the generator
  17463. * @param scene The scene the lights belongs to
  17464. * @param mesh The mesh we are binding the information to render
  17465. * @param lightIndex The light index in the effect used to render the mesh
  17466. * @param effect The effect we are binding the data to
  17467. */
  17468. static BindLightShadow(light: Light, scene: Scene, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  17469. /**
  17470. * Binds the light information to the effect.
  17471. * @param light The light containing the generator
  17472. * @param effect The effect we are binding the data to
  17473. * @param lightIndex The light index in the effect used to render
  17474. */
  17475. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  17476. /**
  17477. * Binds the lights information from the scene to the effect for the given mesh.
  17478. * @param scene The scene the lights belongs to
  17479. * @param mesh The mesh we are binding the information to render
  17480. * @param effect The effect we are binding the data to
  17481. * @param defines The generated defines for the effect
  17482. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  17483. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  17484. */
  17485. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  17486. private static _tempFogColor;
  17487. /**
  17488. * Binds the fog information from the scene to the effect for the given mesh.
  17489. * @param scene The scene the lights belongs to
  17490. * @param mesh The mesh we are binding the information to render
  17491. * @param effect The effect we are binding the data to
  17492. * @param linearSpace Defines if the fog effect is applied in linear space
  17493. */
  17494. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  17495. /**
  17496. * Binds the bones information from the mesh to the effect.
  17497. * @param mesh The mesh we are binding the information to render
  17498. * @param effect The effect we are binding the data to
  17499. */
  17500. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  17501. /**
  17502. * Binds the morph targets information from the mesh to the effect.
  17503. * @param abstractMesh The mesh we are binding the information to render
  17504. * @param effect The effect we are binding the data to
  17505. */
  17506. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  17507. /**
  17508. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  17509. * @param defines The generated defines used in the effect
  17510. * @param effect The effect we are binding the data to
  17511. * @param scene The scene we are willing to render with logarithmic scale for
  17512. */
  17513. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  17514. /**
  17515. * Binds the clip plane information from the scene to the effect.
  17516. * @param scene The scene the clip plane information are extracted from
  17517. * @param effect The effect we are binding the data to
  17518. */
  17519. static BindClipPlane(effect: Effect, scene: Scene): void;
  17520. }
  17521. }
  17522. declare module BABYLON {
  17523. class MultiMaterial extends Material {
  17524. private _subMaterials;
  17525. subMaterials: Nullable<Material>[];
  17526. constructor(name: string, scene: Scene);
  17527. private _hookArray;
  17528. getSubMaterial(index: number): Nullable<Material>;
  17529. getActiveTextures(): BaseTexture[];
  17530. getClassName(): string;
  17531. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  17532. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  17533. serialize(): any;
  17534. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  17535. }
  17536. }
  17537. declare module BABYLON {
  17538. class PushMaterial extends Material {
  17539. protected _activeEffect: Effect;
  17540. protected _normalMatrix: Matrix;
  17541. constructor(name: string, scene: Scene);
  17542. getEffect(): Effect;
  17543. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  17544. /**
  17545. * Binds the given world matrix to the active effect
  17546. *
  17547. * @param world the matrix to bind
  17548. */
  17549. bindOnlyWorldMatrix(world: Matrix): void;
  17550. /**
  17551. * Binds the given normal matrix to the active effect
  17552. *
  17553. * @param normalMatrix the matrix to bind
  17554. */
  17555. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  17556. bind(world: Matrix, mesh?: Mesh): void;
  17557. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  17558. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  17559. }
  17560. }
  17561. declare module BABYLON {
  17562. class ShaderMaterial extends Material {
  17563. private _shaderPath;
  17564. private _options;
  17565. private _textures;
  17566. private _textureArrays;
  17567. private _floats;
  17568. private _ints;
  17569. private _floatsArrays;
  17570. private _colors3;
  17571. private _colors3Arrays;
  17572. private _colors4;
  17573. private _vectors2;
  17574. private _vectors3;
  17575. private _vectors4;
  17576. private _matrices;
  17577. private _matrices3x3;
  17578. private _matrices2x2;
  17579. private _vectors2Arrays;
  17580. private _vectors3Arrays;
  17581. private _cachedWorldViewMatrix;
  17582. private _renderId;
  17583. constructor(name: string, scene: Scene, shaderPath: any, options: any);
  17584. getClassName(): string;
  17585. needAlphaBlending(): boolean;
  17586. needAlphaTesting(): boolean;
  17587. private _checkUniform;
  17588. setTexture(name: string, texture: Texture): ShaderMaterial;
  17589. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  17590. setFloat(name: string, value: number): ShaderMaterial;
  17591. setInt(name: string, value: number): ShaderMaterial;
  17592. setFloats(name: string, value: number[]): ShaderMaterial;
  17593. setColor3(name: string, value: Color3): ShaderMaterial;
  17594. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  17595. setColor4(name: string, value: Color4): ShaderMaterial;
  17596. setVector2(name: string, value: Vector2): ShaderMaterial;
  17597. setVector3(name: string, value: Vector3): ShaderMaterial;
  17598. setVector4(name: string, value: Vector4): ShaderMaterial;
  17599. setMatrix(name: string, value: Matrix): ShaderMaterial;
  17600. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  17601. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  17602. setArray2(name: string, value: number[]): ShaderMaterial;
  17603. setArray3(name: string, value: number[]): ShaderMaterial;
  17604. private _checkCache;
  17605. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  17606. bindOnlyWorldMatrix(world: Matrix): void;
  17607. bind(world: Matrix, mesh?: Mesh): void;
  17608. getActiveTextures(): BaseTexture[];
  17609. hasTexture(texture: BaseTexture): boolean;
  17610. clone(name: string): ShaderMaterial;
  17611. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  17612. serialize(): any;
  17613. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  17614. }
  17615. }
  17616. declare module BABYLON {
  17617. /** @hidden */
  17618. class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  17619. MAINUV1: boolean;
  17620. MAINUV2: boolean;
  17621. DIFFUSE: boolean;
  17622. DIFFUSEDIRECTUV: number;
  17623. AMBIENT: boolean;
  17624. AMBIENTDIRECTUV: number;
  17625. OPACITY: boolean;
  17626. OPACITYDIRECTUV: number;
  17627. OPACITYRGB: boolean;
  17628. REFLECTION: boolean;
  17629. EMISSIVE: boolean;
  17630. EMISSIVEDIRECTUV: number;
  17631. SPECULAR: boolean;
  17632. SPECULARDIRECTUV: number;
  17633. BUMP: boolean;
  17634. BUMPDIRECTUV: number;
  17635. PARALLAX: boolean;
  17636. PARALLAXOCCLUSION: boolean;
  17637. SPECULAROVERALPHA: boolean;
  17638. CLIPPLANE: boolean;
  17639. CLIPPLANE2: boolean;
  17640. CLIPPLANE3: boolean;
  17641. CLIPPLANE4: boolean;
  17642. ALPHATEST: boolean;
  17643. DEPTHPREPASS: boolean;
  17644. ALPHAFROMDIFFUSE: boolean;
  17645. POINTSIZE: boolean;
  17646. FOG: boolean;
  17647. SPECULARTERM: boolean;
  17648. DIFFUSEFRESNEL: boolean;
  17649. OPACITYFRESNEL: boolean;
  17650. REFLECTIONFRESNEL: boolean;
  17651. REFRACTIONFRESNEL: boolean;
  17652. EMISSIVEFRESNEL: boolean;
  17653. FRESNEL: boolean;
  17654. NORMAL: boolean;
  17655. UV1: boolean;
  17656. UV2: boolean;
  17657. VERTEXCOLOR: boolean;
  17658. VERTEXALPHA: boolean;
  17659. NUM_BONE_INFLUENCERS: number;
  17660. BonesPerMesh: number;
  17661. INSTANCES: boolean;
  17662. GLOSSINESS: boolean;
  17663. ROUGHNESS: boolean;
  17664. EMISSIVEASILLUMINATION: boolean;
  17665. LINKEMISSIVEWITHDIFFUSE: boolean;
  17666. REFLECTIONFRESNELFROMSPECULAR: boolean;
  17667. LIGHTMAP: boolean;
  17668. LIGHTMAPDIRECTUV: number;
  17669. OBJECTSPACE_NORMALMAP: boolean;
  17670. USELIGHTMAPASSHADOWMAP: boolean;
  17671. REFLECTIONMAP_3D: boolean;
  17672. REFLECTIONMAP_SPHERICAL: boolean;
  17673. REFLECTIONMAP_PLANAR: boolean;
  17674. REFLECTIONMAP_CUBIC: boolean;
  17675. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  17676. REFLECTIONMAP_PROJECTION: boolean;
  17677. REFLECTIONMAP_SKYBOX: boolean;
  17678. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  17679. REFLECTIONMAP_EXPLICIT: boolean;
  17680. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  17681. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  17682. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  17683. INVERTCUBICMAP: boolean;
  17684. LOGARITHMICDEPTH: boolean;
  17685. REFRACTION: boolean;
  17686. REFRACTIONMAP_3D: boolean;
  17687. REFLECTIONOVERALPHA: boolean;
  17688. TWOSIDEDLIGHTING: boolean;
  17689. SHADOWFLOAT: boolean;
  17690. MORPHTARGETS: boolean;
  17691. MORPHTARGETS_NORMAL: boolean;
  17692. MORPHTARGETS_TANGENT: boolean;
  17693. NUM_MORPH_INFLUENCERS: number;
  17694. NONUNIFORMSCALING: boolean;
  17695. PREMULTIPLYALPHA: boolean;
  17696. IMAGEPROCESSING: boolean;
  17697. VIGNETTE: boolean;
  17698. VIGNETTEBLENDMODEMULTIPLY: boolean;
  17699. VIGNETTEBLENDMODEOPAQUE: boolean;
  17700. TONEMAPPING: boolean;
  17701. TONEMAPPING_ACES: boolean;
  17702. CONTRAST: boolean;
  17703. COLORCURVES: boolean;
  17704. COLORGRADING: boolean;
  17705. COLORGRADING3D: boolean;
  17706. SAMPLER3DGREENDEPTH: boolean;
  17707. SAMPLER3DBGRMAP: boolean;
  17708. IMAGEPROCESSINGPOSTPROCESS: boolean;
  17709. /**
  17710. * If the reflection texture on this material is in linear color space
  17711. * @hidden
  17712. */
  17713. IS_REFLECTION_LINEAR: boolean;
  17714. /**
  17715. * If the refraction texture on this material is in linear color space
  17716. * @hidden
  17717. */
  17718. IS_REFRACTION_LINEAR: boolean;
  17719. EXPOSURE: boolean;
  17720. constructor();
  17721. setReflectionMode(modeToEnable: string): void;
  17722. }
  17723. class StandardMaterial extends PushMaterial {
  17724. private _diffuseTexture;
  17725. diffuseTexture: Nullable<BaseTexture>;
  17726. private _ambientTexture;
  17727. ambientTexture: Nullable<BaseTexture>;
  17728. private _opacityTexture;
  17729. opacityTexture: Nullable<BaseTexture>;
  17730. private _reflectionTexture;
  17731. reflectionTexture: Nullable<BaseTexture>;
  17732. private _emissiveTexture;
  17733. emissiveTexture: Nullable<BaseTexture>;
  17734. private _specularTexture;
  17735. specularTexture: Nullable<BaseTexture>;
  17736. private _bumpTexture;
  17737. bumpTexture: Nullable<BaseTexture>;
  17738. private _lightmapTexture;
  17739. lightmapTexture: Nullable<BaseTexture>;
  17740. private _refractionTexture;
  17741. refractionTexture: Nullable<BaseTexture>;
  17742. ambientColor: Color3;
  17743. diffuseColor: Color3;
  17744. specularColor: Color3;
  17745. emissiveColor: Color3;
  17746. specularPower: number;
  17747. private _useAlphaFromDiffuseTexture;
  17748. useAlphaFromDiffuseTexture: boolean;
  17749. private _useEmissiveAsIllumination;
  17750. useEmissiveAsIllumination: boolean;
  17751. private _linkEmissiveWithDiffuse;
  17752. linkEmissiveWithDiffuse: boolean;
  17753. private _useSpecularOverAlpha;
  17754. useSpecularOverAlpha: boolean;
  17755. private _useReflectionOverAlpha;
  17756. useReflectionOverAlpha: boolean;
  17757. private _disableLighting;
  17758. disableLighting: boolean;
  17759. private _useObjectSpaceNormalMap;
  17760. /**
  17761. * Allows using an object space normal map (instead of tangent space).
  17762. */
  17763. useObjectSpaceNormalMap: boolean;
  17764. private _useParallax;
  17765. useParallax: boolean;
  17766. private _useParallaxOcclusion;
  17767. useParallaxOcclusion: boolean;
  17768. parallaxScaleBias: number;
  17769. private _roughness;
  17770. roughness: number;
  17771. indexOfRefraction: number;
  17772. invertRefractionY: boolean;
  17773. /**
  17774. * Defines the alpha limits in alpha test mode
  17775. */
  17776. alphaCutOff: number;
  17777. private _useLightmapAsShadowmap;
  17778. useLightmapAsShadowmap: boolean;
  17779. private _diffuseFresnelParameters;
  17780. diffuseFresnelParameters: FresnelParameters;
  17781. private _opacityFresnelParameters;
  17782. opacityFresnelParameters: FresnelParameters;
  17783. private _reflectionFresnelParameters;
  17784. reflectionFresnelParameters: FresnelParameters;
  17785. private _refractionFresnelParameters;
  17786. refractionFresnelParameters: FresnelParameters;
  17787. private _emissiveFresnelParameters;
  17788. emissiveFresnelParameters: FresnelParameters;
  17789. private _useReflectionFresnelFromSpecular;
  17790. useReflectionFresnelFromSpecular: boolean;
  17791. private _useGlossinessFromSpecularMapAlpha;
  17792. useGlossinessFromSpecularMapAlpha: boolean;
  17793. private _maxSimultaneousLights;
  17794. maxSimultaneousLights: number;
  17795. /**
  17796. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  17797. */
  17798. private _invertNormalMapX;
  17799. invertNormalMapX: boolean;
  17800. /**
  17801. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  17802. */
  17803. private _invertNormalMapY;
  17804. invertNormalMapY: boolean;
  17805. /**
  17806. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  17807. */
  17808. private _twoSidedLighting;
  17809. twoSidedLighting: boolean;
  17810. /**
  17811. * Default configuration related to image processing available in the standard Material.
  17812. */
  17813. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  17814. /**
  17815. * Gets the image processing configuration used either in this material.
  17816. */
  17817. /**
  17818. * Sets the Default image processing configuration used either in the this material.
  17819. *
  17820. * If sets to null, the scene one is in use.
  17821. */
  17822. imageProcessingConfiguration: ImageProcessingConfiguration;
  17823. /**
  17824. * Keep track of the image processing observer to allow dispose and replace.
  17825. */
  17826. private _imageProcessingObserver;
  17827. /**
  17828. * Attaches a new image processing configuration to the Standard Material.
  17829. * @param configuration
  17830. */
  17831. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  17832. /**
  17833. * Gets wether the color curves effect is enabled.
  17834. */
  17835. /**
  17836. * Sets wether the color curves effect is enabled.
  17837. */
  17838. cameraColorCurvesEnabled: boolean;
  17839. /**
  17840. * Gets wether the color grading effect is enabled.
  17841. */
  17842. /**
  17843. * Gets wether the color grading effect is enabled.
  17844. */
  17845. cameraColorGradingEnabled: boolean;
  17846. /**
  17847. * Gets wether tonemapping is enabled or not.
  17848. */
  17849. /**
  17850. * Sets wether tonemapping is enabled or not
  17851. */
  17852. cameraToneMappingEnabled: boolean;
  17853. /**
  17854. * The camera exposure used on this material.
  17855. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  17856. * This corresponds to a photographic exposure.
  17857. */
  17858. /**
  17859. * The camera exposure used on this material.
  17860. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  17861. * This corresponds to a photographic exposure.
  17862. */
  17863. cameraExposure: number;
  17864. /**
  17865. * Gets The camera contrast used on this material.
  17866. */
  17867. /**
  17868. * Sets The camera contrast used on this material.
  17869. */
  17870. cameraContrast: number;
  17871. /**
  17872. * Gets the Color Grading 2D Lookup Texture.
  17873. */
  17874. /**
  17875. * Sets the Color Grading 2D Lookup Texture.
  17876. */
  17877. cameraColorGradingTexture: Nullable<BaseTexture>;
  17878. /**
  17879. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  17880. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  17881. * 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;
  17882. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  17883. */
  17884. /**
  17885. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  17886. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  17887. * 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;
  17888. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  17889. */
  17890. cameraColorCurves: Nullable<ColorCurves>;
  17891. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  17892. protected _renderTargets: SmartArray<RenderTargetTexture>;
  17893. protected _worldViewProjectionMatrix: Matrix;
  17894. protected _globalAmbientColor: Color3;
  17895. protected _useLogarithmicDepth: boolean;
  17896. constructor(name: string, scene: Scene);
  17897. /**
  17898. * Gets a boolean indicating that current material needs to register RTT
  17899. */
  17900. readonly hasRenderTargetTextures: boolean;
  17901. getClassName(): string;
  17902. useLogarithmicDepth: boolean;
  17903. needAlphaBlending(): boolean;
  17904. needAlphaTesting(): boolean;
  17905. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  17906. getAlphaTestTexture(): Nullable<BaseTexture>;
  17907. /**
  17908. * Child classes can use it to update shaders
  17909. */
  17910. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  17911. buildUniformLayout(): void;
  17912. unbind(): void;
  17913. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  17914. getAnimatables(): IAnimatable[];
  17915. getActiveTextures(): BaseTexture[];
  17916. hasTexture(texture: BaseTexture): boolean;
  17917. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  17918. clone(name: string): StandardMaterial;
  17919. serialize(): any;
  17920. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  17921. private static _DiffuseTextureEnabled: boolean;
  17922. static DiffuseTextureEnabled: boolean;
  17923. private static _AmbientTextureEnabled: boolean;
  17924. static AmbientTextureEnabled: boolean;
  17925. private static _OpacityTextureEnabled: boolean;
  17926. static OpacityTextureEnabled: boolean;
  17927. private static _ReflectionTextureEnabled: boolean;
  17928. static ReflectionTextureEnabled: boolean;
  17929. private static _EmissiveTextureEnabled: boolean;
  17930. static EmissiveTextureEnabled: boolean;
  17931. private static _SpecularTextureEnabled: boolean;
  17932. static SpecularTextureEnabled: boolean;
  17933. private static _BumpTextureEnabled: boolean;
  17934. static BumpTextureEnabled: boolean;
  17935. private static _LightmapTextureEnabled: boolean;
  17936. static LightmapTextureEnabled: boolean;
  17937. private static _RefractionTextureEnabled: boolean;
  17938. static RefractionTextureEnabled: boolean;
  17939. private static _ColorGradingTextureEnabled: boolean;
  17940. static ColorGradingTextureEnabled: boolean;
  17941. private static _FresnelEnabled: boolean;
  17942. static FresnelEnabled: boolean;
  17943. }
  17944. }
  17945. declare module BABYLON {
  17946. class UniformBuffer {
  17947. private _engine;
  17948. private _buffer;
  17949. private _data;
  17950. private _bufferData;
  17951. private _dynamic?;
  17952. private _uniformLocations;
  17953. private _uniformSizes;
  17954. private _uniformLocationPointer;
  17955. private _needSync;
  17956. private _noUBO;
  17957. private _currentEffect;
  17958. private static _MAX_UNIFORM_SIZE;
  17959. private static _tempBuffer;
  17960. /**
  17961. * Wrapper for updateUniform.
  17962. * @method updateMatrix3x3
  17963. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  17964. * @param {Float32Array} matrix
  17965. */
  17966. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  17967. /**
  17968. * Wrapper for updateUniform.
  17969. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  17970. * @param {Float32Array} matrix
  17971. */
  17972. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  17973. /**
  17974. * Wrapper for updateUniform.
  17975. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  17976. * @param {number} x
  17977. */
  17978. updateFloat: (name: string, x: number) => void;
  17979. /**
  17980. * Wrapper for updateUniform.
  17981. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  17982. * @param {number} x
  17983. * @param {number} y
  17984. * @param {string} [suffix] Suffix to add to the uniform name.
  17985. */
  17986. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  17987. /**
  17988. * Wrapper for updateUniform.
  17989. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  17990. * @param {number} x
  17991. * @param {number} y
  17992. * @param {number} z
  17993. * @param {string} [suffix] Suffix to add to the uniform name.
  17994. */
  17995. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  17996. /**
  17997. * Wrapper for updateUniform.
  17998. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  17999. * @param {number} x
  18000. * @param {number} y
  18001. * @param {number} z
  18002. * @param {number} w
  18003. * @param {string} [suffix] Suffix to add to the uniform name.
  18004. */
  18005. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  18006. /**
  18007. * Wrapper for updateUniform.
  18008. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  18009. * @param {Matrix} A 4x4 matrix.
  18010. */
  18011. updateMatrix: (name: string, mat: Matrix) => void;
  18012. /**
  18013. * Wrapper for updateUniform.
  18014. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  18015. * @param {Vector3} vector
  18016. */
  18017. updateVector3: (name: string, vector: Vector3) => void;
  18018. /**
  18019. * Wrapper for updateUniform.
  18020. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  18021. * @param {Vector4} vector
  18022. */
  18023. updateVector4: (name: string, vector: Vector4) => void;
  18024. /**
  18025. * Wrapper for updateUniform.
  18026. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  18027. * @param {Color3} color
  18028. * @param {string} [suffix] Suffix to add to the uniform name.
  18029. */
  18030. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  18031. /**
  18032. * Wrapper for updateUniform.
  18033. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  18034. * @param {Color3} color
  18035. * @param {number} alpha
  18036. * @param {string} [suffix] Suffix to add to the uniform name.
  18037. */
  18038. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  18039. /**
  18040. * Uniform buffer objects.
  18041. *
  18042. * Handles blocks of uniform on the GPU.
  18043. *
  18044. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  18045. *
  18046. * For more information, please refer to :
  18047. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  18048. */
  18049. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  18050. /**
  18051. * Indicates if the buffer is using the WebGL2 UBO implementation,
  18052. * or just falling back on setUniformXXX calls.
  18053. */
  18054. readonly useUbo: boolean;
  18055. /**
  18056. * Indicates if the WebGL underlying uniform buffer is in sync
  18057. * with the javascript cache data.
  18058. */
  18059. readonly isSync: boolean;
  18060. /**
  18061. * Indicates if the WebGL underlying uniform buffer is dynamic.
  18062. * Also, a dynamic UniformBuffer will disable cache verification and always
  18063. * update the underlying WebGL uniform buffer to the GPU.
  18064. */
  18065. isDynamic(): boolean;
  18066. /**
  18067. * The data cache on JS side.
  18068. */
  18069. getData(): Float32Array;
  18070. /**
  18071. * The underlying WebGL Uniform buffer.
  18072. */
  18073. getBuffer(): Nullable<WebGLBuffer>;
  18074. /**
  18075. * std140 layout specifies how to align data within an UBO structure.
  18076. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  18077. * for specs.
  18078. */
  18079. private _fillAlignment;
  18080. /**
  18081. * Adds an uniform in the buffer.
  18082. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  18083. * for the layout to be correct !
  18084. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  18085. * @param {number|number[]} size Data size, or data directly.
  18086. */
  18087. addUniform(name: string, size: number | number[]): void;
  18088. /**
  18089. * Wrapper for addUniform.
  18090. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  18091. * @param {Matrix} mat A 4x4 matrix.
  18092. */
  18093. addMatrix(name: string, mat: Matrix): void;
  18094. /**
  18095. * Wrapper for addUniform.
  18096. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  18097. * @param {number} x
  18098. * @param {number} y
  18099. */
  18100. addFloat2(name: string, x: number, y: number): void;
  18101. /**
  18102. * Wrapper for addUniform.
  18103. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  18104. * @param {number} x
  18105. * @param {number} y
  18106. * @param {number} z
  18107. */
  18108. addFloat3(name: string, x: number, y: number, z: number): void;
  18109. /**
  18110. * Wrapper for addUniform.
  18111. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  18112. * @param {Color3} color
  18113. */
  18114. addColor3(name: string, color: Color3): void;
  18115. /**
  18116. * Wrapper for addUniform.
  18117. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  18118. * @param {Color3} color
  18119. * @param {number} alpha
  18120. */
  18121. addColor4(name: string, color: Color3, alpha: number): void;
  18122. /**
  18123. * Wrapper for addUniform.
  18124. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  18125. * @param {Vector3} vector
  18126. */
  18127. addVector3(name: string, vector: Vector3): void;
  18128. /**
  18129. * Wrapper for addUniform.
  18130. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  18131. */
  18132. addMatrix3x3(name: string): void;
  18133. /**
  18134. * Wrapper for addUniform.
  18135. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  18136. */
  18137. addMatrix2x2(name: string): void;
  18138. /**
  18139. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  18140. */
  18141. create(): void;
  18142. /** @hidden */
  18143. /**
  18144. * Updates the WebGL Uniform Buffer on the GPU.
  18145. * If the `dynamic` flag is set to true, no cache comparison is done.
  18146. * Otherwise, the buffer will be updated only if the cache differs.
  18147. */
  18148. update(): void;
  18149. /**
  18150. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  18151. * @param {string} uniformName Name of the uniform, as used in the uniform block in the shader.
  18152. * @param {number[]|Float32Array} data Flattened data
  18153. * @param {number} size Size of the data.
  18154. */
  18155. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  18156. private _updateMatrix3x3ForUniform;
  18157. private _updateMatrix3x3ForEffect;
  18158. private _updateMatrix2x2ForEffect;
  18159. private _updateMatrix2x2ForUniform;
  18160. private _updateFloatForEffect;
  18161. private _updateFloatForUniform;
  18162. private _updateFloat2ForEffect;
  18163. private _updateFloat2ForUniform;
  18164. private _updateFloat3ForEffect;
  18165. private _updateFloat3ForUniform;
  18166. private _updateFloat4ForEffect;
  18167. private _updateFloat4ForUniform;
  18168. private _updateMatrixForEffect;
  18169. private _updateMatrixForUniform;
  18170. private _updateVector3ForEffect;
  18171. private _updateVector3ForUniform;
  18172. private _updateVector4ForEffect;
  18173. private _updateVector4ForUniform;
  18174. private _updateColor3ForEffect;
  18175. private _updateColor3ForUniform;
  18176. private _updateColor4ForEffect;
  18177. private _updateColor4ForUniform;
  18178. /**
  18179. * Sets a sampler uniform on the effect.
  18180. * @param {string} name Name of the sampler.
  18181. * @param {Texture} texture
  18182. */
  18183. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  18184. /**
  18185. * Directly updates the value of the uniform in the cache AND on the GPU.
  18186. * @param {string} uniformName Name of the uniform, as used in the uniform block in the shader.
  18187. * @param {number[]|Float32Array} data Flattened data
  18188. */
  18189. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  18190. /**
  18191. * Binds this uniform buffer to an effect.
  18192. * @param {Effect} effect
  18193. * @param {string} name Name of the uniform block in the shader.
  18194. */
  18195. bindToEffect(effect: Effect, name: string): void;
  18196. /**
  18197. * Disposes the uniform buffer.
  18198. */
  18199. dispose(): void;
  18200. }
  18201. }
  18202. declare module BABYLON {
  18203. class Scalar {
  18204. /**
  18205. * Two pi constants convenient for computation.
  18206. */
  18207. static TwoPi: number;
  18208. /**
  18209. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  18210. */
  18211. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  18212. /**
  18213. * Returns a string : the upper case translation of the number i to hexadecimal.
  18214. */
  18215. static ToHex(i: number): string;
  18216. /**
  18217. * Returns -1 if value is negative and +1 is value is positive.
  18218. * Returns the value itself if it's equal to zero.
  18219. */
  18220. static Sign(value: number): number;
  18221. /**
  18222. * Returns the value itself if it's between min and max.
  18223. * Returns min if the value is lower than min.
  18224. * Returns max if the value is greater than max.
  18225. */
  18226. static Clamp(value: number, min?: number, max?: number): number;
  18227. /**
  18228. * Returns the log2 of value.
  18229. */
  18230. static Log2(value: number): number;
  18231. /**
  18232. * Loops the value, so that it is never larger than length and never smaller than 0.
  18233. *
  18234. * This is similar to the modulo operator but it works with floating point numbers.
  18235. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  18236. * With t = 5 and length = 2.5, the result would be 0.0.
  18237. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  18238. */
  18239. static Repeat(value: number, length: number): number;
  18240. /**
  18241. * Normalize the value between 0.0 and 1.0 using min and max values
  18242. */
  18243. static Normalize(value: number, min: number, max: number): number;
  18244. /**
  18245. * Denormalize the value from 0.0 and 1.0 using min and max values
  18246. */
  18247. static Denormalize(normalized: number, min: number, max: number): number;
  18248. /**
  18249. * Calculates the shortest difference between two given angles given in degrees.
  18250. */
  18251. static DeltaAngle(current: number, target: number): number;
  18252. /**
  18253. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  18254. *
  18255. * The returned value will move back and forth between 0 and length
  18256. */
  18257. static PingPong(tx: number, length: number): number;
  18258. /**
  18259. * Interpolates between min and max with smoothing at the limits.
  18260. *
  18261. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  18262. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  18263. */
  18264. static SmoothStep(from: number, to: number, tx: number): number;
  18265. /**
  18266. * Moves a value current towards target.
  18267. *
  18268. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  18269. * Negative values of maxDelta pushes the value away from target.
  18270. */
  18271. static MoveTowards(current: number, target: number, maxDelta: number): number;
  18272. /**
  18273. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  18274. *
  18275. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  18276. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  18277. */
  18278. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  18279. /**
  18280. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  18281. */
  18282. static Lerp(start: number, end: number, amount: number): number;
  18283. /**
  18284. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  18285. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  18286. */
  18287. static LerpAngle(start: number, end: number, amount: number): number;
  18288. /**
  18289. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  18290. */
  18291. static InverseLerp(a: number, b: number, value: number): number;
  18292. /**
  18293. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  18294. */
  18295. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  18296. /**
  18297. * Returns a random float number between and min and max values
  18298. */
  18299. static RandomRange(min: number, max: number): number;
  18300. /**
  18301. * This function returns percentage of a number in a given range.
  18302. *
  18303. * RangeToPercent(40,20,60) will return 0.5 (50%)
  18304. * RangeToPercent(34,0,100) will return 0.34 (34%)
  18305. */
  18306. static RangeToPercent(number: number, min: number, max: number): number;
  18307. /**
  18308. * This function returns number that corresponds to the percentage in a given range.
  18309. *
  18310. * PercentToRange(0.34,0,100) will return 34.
  18311. */
  18312. static PercentToRange(percent: number, min: number, max: number): number;
  18313. /**
  18314. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  18315. * @param angle The angle to normalize in radian.
  18316. * @return The converted angle.
  18317. */
  18318. static NormalizeRadians(angle: number): number;
  18319. }
  18320. }
  18321. declare module BABYLON {
  18322. /**
  18323. * Constant used to convert a value to gamma space
  18324. * @ignorenaming
  18325. */
  18326. const ToGammaSpace: number;
  18327. /**
  18328. * Constant used to convert a value to linear space
  18329. * @ignorenaming
  18330. */
  18331. const ToLinearSpace = 2.2;
  18332. /**
  18333. * Constant used to define the minimal number value in Babylon.js
  18334. * @ignorenaming
  18335. */
  18336. const Epsilon = 0.001;
  18337. /**
  18338. * Class used to hold a RBG color
  18339. */
  18340. class Color3 {
  18341. /**
  18342. * Defines the red component (between 0 and 1, default is 0)
  18343. */
  18344. r: number;
  18345. /**
  18346. * Defines the green component (between 0 and 1, default is 0)
  18347. */
  18348. g: number;
  18349. /**
  18350. * Defines the blue component (between 0 and 1, default is 0)
  18351. */
  18352. b: number;
  18353. /**
  18354. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  18355. * @param r defines the red component (between 0 and 1, default is 0)
  18356. * @param g defines the green component (between 0 and 1, default is 0)
  18357. * @param b defines the blue component (between 0 and 1, default is 0)
  18358. */
  18359. constructor(
  18360. /**
  18361. * Defines the red component (between 0 and 1, default is 0)
  18362. */
  18363. r?: number,
  18364. /**
  18365. * Defines the green component (between 0 and 1, default is 0)
  18366. */
  18367. g?: number,
  18368. /**
  18369. * Defines the blue component (between 0 and 1, default is 0)
  18370. */
  18371. b?: number);
  18372. /**
  18373. * Creates a string with the Color3 current values
  18374. * @returns the string representation of the Color3 object
  18375. */
  18376. toString(): string;
  18377. /**
  18378. * Returns the string "Color3"
  18379. * @returns "Color3"
  18380. */
  18381. getClassName(): string;
  18382. /**
  18383. * Compute the Color3 hash code
  18384. * @returns an unique number that can be used to hash Color3 objects
  18385. */
  18386. getHashCode(): number;
  18387. /**
  18388. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  18389. * @param array defines the array where to store the r,g,b components
  18390. * @param index defines an optional index in the target array to define where to start storing values
  18391. * @returns the current Color3 object
  18392. */
  18393. toArray(array: FloatArray, index?: number): Color3;
  18394. /**
  18395. * Returns a new {BABYLON.Color4} object from the current Color3 and the given alpha
  18396. * @param alpha defines the alpha component on the new {BABYLON.Color4} object (default is 1)
  18397. * @returns a new {BABYLON.Color4} object
  18398. */
  18399. toColor4(alpha?: number): Color4;
  18400. /**
  18401. * Returns a new array populated with 3 numeric elements : red, green and blue values
  18402. * @returns the new array
  18403. */
  18404. asArray(): number[];
  18405. /**
  18406. * Returns the luminance value
  18407. * @returns a float value
  18408. */
  18409. toLuminance(): number;
  18410. /**
  18411. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  18412. * @param otherColor defines the second operand
  18413. * @returns the new Color3 object
  18414. */
  18415. multiply(otherColor: Color3): Color3;
  18416. /**
  18417. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  18418. * @param otherColor defines the second operand
  18419. * @param result defines the Color3 object where to store the result
  18420. * @returns the current Color3
  18421. */
  18422. multiplyToRef(otherColor: Color3, result: Color3): Color3;
  18423. /**
  18424. * Determines equality between Color3 objects
  18425. * @param otherColor defines the second operand
  18426. * @returns true if the rgb values are equal to the given ones
  18427. */
  18428. equals(otherColor: Color3): boolean;
  18429. /**
  18430. * Determines equality between the current Color3 object and a set of r,b,g values
  18431. * @param r defines the red component to check
  18432. * @param g defines the green component to check
  18433. * @param b defines the blue component to check
  18434. * @returns true if the rgb values are equal to the given ones
  18435. */
  18436. equalsFloats(r: number, g: number, b: number): boolean;
  18437. /**
  18438. * Multiplies in place each rgb value by scale
  18439. * @param scale defines the scaling factor
  18440. * @returns the updated Color3
  18441. */
  18442. scale(scale: number): Color3;
  18443. /**
  18444. * Multiplies the rgb values by scale and stores the result into "result"
  18445. * @param scale defines the scaling factor
  18446. * @param result defines the Color3 object where to store the result
  18447. * @returns the unmodified current Color3
  18448. */
  18449. scaleToRef(scale: number, result: Color3): Color3;
  18450. /**
  18451. * Scale the current Color3 values by a factor and add the result to a given Color3
  18452. * @param scale defines the scale factor
  18453. * @param result defines color to store the result into
  18454. * @returns the unmodified current Color3
  18455. */
  18456. scaleAndAddToRef(scale: number, result: Color3): Color3;
  18457. /**
  18458. * Clamps the rgb values by the min and max values and stores the result into "result"
  18459. * @param min defines minimum clamping value (default is 0)
  18460. * @param max defines maximum clamping value (default is 1)
  18461. * @param result defines color to store the result into
  18462. * @returns the original Color3
  18463. */
  18464. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  18465. /**
  18466. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  18467. * @param otherColor defines the second operand
  18468. * @returns the new Color3
  18469. */
  18470. add(otherColor: Color3): Color3;
  18471. /**
  18472. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  18473. * @param otherColor defines the second operand
  18474. * @param result defines Color3 object to store the result into
  18475. * @returns the unmodified current Color3
  18476. */
  18477. addToRef(otherColor: Color3, result: Color3): Color3;
  18478. /**
  18479. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  18480. * @param otherColor defines the second operand
  18481. * @returns the new Color3
  18482. */
  18483. subtract(otherColor: Color3): Color3;
  18484. /**
  18485. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  18486. * @param otherColor defines the second operand
  18487. * @param result defines Color3 object to store the result into
  18488. * @returns the unmodified current Color3
  18489. */
  18490. subtractToRef(otherColor: Color3, result: Color3): Color3;
  18491. /**
  18492. * Copy the current object
  18493. * @returns a new Color3 copied the current one
  18494. */
  18495. clone(): Color3;
  18496. /**
  18497. * Copies the rgb values from the source in the current Color3
  18498. * @param source defines the source Color3 object
  18499. * @returns the updated Color3 object
  18500. */
  18501. copyFrom(source: Color3): Color3;
  18502. /**
  18503. * Updates the Color3 rgb values from the given floats
  18504. * @param r defines the red component to read from
  18505. * @param g defines the green component to read from
  18506. * @param b defines the blue component to read from
  18507. * @returns the current Color3 object
  18508. */
  18509. copyFromFloats(r: number, g: number, b: number): Color3;
  18510. /**
  18511. * Updates the Color3 rgb values from the given floats
  18512. * @param r defines the red component to read from
  18513. * @param g defines the green component to read from
  18514. * @param b defines the blue component to read from
  18515. * @returns the current Color3 object
  18516. */
  18517. set(r: number, g: number, b: number): Color3;
  18518. /**
  18519. * Compute the Color3 hexadecimal code as a string
  18520. * @returns a string containing the hexadecimal representation of the Color3 object
  18521. */
  18522. toHexString(): string;
  18523. /**
  18524. * Computes a new Color3 converted from the current one to linear space
  18525. * @returns a new Color3 object
  18526. */
  18527. toLinearSpace(): Color3;
  18528. /**
  18529. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  18530. * @param convertedColor defines the Color3 object where to store the linear space version
  18531. * @returns the unmodified Color3
  18532. */
  18533. toLinearSpaceToRef(convertedColor: Color3): Color3;
  18534. /**
  18535. * Computes a new Color3 converted from the current one to gamma space
  18536. * @returns a new Color3 object
  18537. */
  18538. toGammaSpace(): Color3;
  18539. /**
  18540. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  18541. * @param convertedColor defines the Color3 object where to store the gamma space version
  18542. * @returns the unmodified Color3
  18543. */
  18544. toGammaSpaceToRef(convertedColor: Color3): Color3;
  18545. /**
  18546. * Creates a new Color3 from the string containing valid hexadecimal values
  18547. * @param hex defines a string containing valid hexadecimal values
  18548. * @returns a new Color3 object
  18549. */
  18550. static FromHexString(hex: string): Color3;
  18551. /**
  18552. * Creates a new Vector3 from the starting index of the given array
  18553. * @param array defines the source array
  18554. * @param offset defines an offset in the source array
  18555. * @returns a new Color3 object
  18556. */
  18557. static FromArray(array: ArrayLike<number>, offset?: number): Color3;
  18558. /**
  18559. * Creates a new Color3 from integer values (< 256)
  18560. * @param r defines the red component to read from (value between 0 and 255)
  18561. * @param g defines the green component to read from (value between 0 and 255)
  18562. * @param b defines the blue component to read from (value between 0 and 255)
  18563. * @returns a new Color3 object
  18564. */
  18565. static FromInts(r: number, g: number, b: number): Color3;
  18566. /**
  18567. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  18568. * @param start defines the start Color3 value
  18569. * @param end defines the end Color3 value
  18570. * @param amount defines the gradient value between start and end
  18571. * @returns a new Color3 object
  18572. */
  18573. static Lerp(start: Color3, end: Color3, amount: number): Color3;
  18574. /**
  18575. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  18576. * @param left defines the start value
  18577. * @param right defines the end value
  18578. * @param amount defines the gradient factor
  18579. * @param result defines the Color3 object where to store the result
  18580. */
  18581. static LerpToRef(left: Color3, right: Color3, amount: number, result: Color3): void;
  18582. /**
  18583. * Returns a Color3 value containing a red color
  18584. * @returns a new Color3 object
  18585. */
  18586. static Red(): Color3;
  18587. /**
  18588. * Returns a Color3 value containing a green color
  18589. * @returns a new Color3 object
  18590. */
  18591. static Green(): Color3;
  18592. /**
  18593. * Returns a Color3 value containing a blue color
  18594. * @returns a new Color3 object
  18595. */
  18596. static Blue(): Color3;
  18597. /**
  18598. * Returns a Color3 value containing a black color
  18599. * @returns a new Color3 object
  18600. */
  18601. static Black(): Color3;
  18602. /**
  18603. * Returns a Color3 value containing a white color
  18604. * @returns a new Color3 object
  18605. */
  18606. static White(): Color3;
  18607. /**
  18608. * Returns a Color3 value containing a purple color
  18609. * @returns a new Color3 object
  18610. */
  18611. static Purple(): Color3;
  18612. /**
  18613. * Returns a Color3 value containing a magenta color
  18614. * @returns a new Color3 object
  18615. */
  18616. static Magenta(): Color3;
  18617. /**
  18618. * Returns a Color3 value containing a yellow color
  18619. * @returns a new Color3 object
  18620. */
  18621. static Yellow(): Color3;
  18622. /**
  18623. * Returns a Color3 value containing a gray color
  18624. * @returns a new Color3 object
  18625. */
  18626. static Gray(): Color3;
  18627. /**
  18628. * Returns a Color3 value containing a teal color
  18629. * @returns a new Color3 object
  18630. */
  18631. static Teal(): Color3;
  18632. /**
  18633. * Returns a Color3 value containing a random color
  18634. * @returns a new Color3 object
  18635. */
  18636. static Random(): Color3;
  18637. }
  18638. /**
  18639. * Class used to hold a RBGA color
  18640. */
  18641. class Color4 {
  18642. /**
  18643. * Defines the red component (between 0 and 1, default is 0)
  18644. */
  18645. r: number;
  18646. /**
  18647. * Defines the green component (between 0 and 1, default is 0)
  18648. */
  18649. g: number;
  18650. /**
  18651. * Defines the blue component (between 0 and 1, default is 0)
  18652. */
  18653. b: number;
  18654. /**
  18655. * Defines the alpha component (between 0 and 1, default is 1)
  18656. */
  18657. a: number;
  18658. /**
  18659. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  18660. * @param r defines the red component (between 0 and 1, default is 0)
  18661. * @param g defines the green component (between 0 and 1, default is 0)
  18662. * @param b defines the blue component (between 0 and 1, default is 0)
  18663. * @param a defines the alpha component (between 0 and 1, default is 1)
  18664. */
  18665. constructor(
  18666. /**
  18667. * Defines the red component (between 0 and 1, default is 0)
  18668. */
  18669. r?: number,
  18670. /**
  18671. * Defines the green component (between 0 and 1, default is 0)
  18672. */
  18673. g?: number,
  18674. /**
  18675. * Defines the blue component (between 0 and 1, default is 0)
  18676. */
  18677. b?: number,
  18678. /**
  18679. * Defines the alpha component (between 0 and 1, default is 1)
  18680. */
  18681. a?: number);
  18682. /**
  18683. * Adds in place the given Color4 values to the current Color4 object
  18684. * @param right defines the second operand
  18685. * @returns the current updated Color4 object
  18686. */
  18687. addInPlace(right: Color4): Color4;
  18688. /**
  18689. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  18690. * @returns the new array
  18691. */
  18692. asArray(): number[];
  18693. /**
  18694. * Stores from the starting index in the given array the Color4 successive values
  18695. * @param array defines the array where to store the r,g,b components
  18696. * @param index defines an optional index in the target array to define where to start storing values
  18697. * @returns the current Color4 object
  18698. */
  18699. toArray(array: number[], index?: number): Color4;
  18700. /**
  18701. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  18702. * @param right defines the second operand
  18703. * @returns a new Color4 object
  18704. */
  18705. add(right: Color4): Color4;
  18706. /**
  18707. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  18708. * @param right defines the second operand
  18709. * @returns a new Color4 object
  18710. */
  18711. subtract(right: Color4): Color4;
  18712. /**
  18713. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  18714. * @param right defines the second operand
  18715. * @param result defines the Color4 object where to store the result
  18716. * @returns the current Color4 object
  18717. */
  18718. subtractToRef(right: Color4, result: Color4): Color4;
  18719. /**
  18720. * Creates a new Color4 with the current Color4 values multiplied by scale
  18721. * @param scale defines the scaling factor to apply
  18722. * @returns a new Color4 object
  18723. */
  18724. scale(scale: number): Color4;
  18725. /**
  18726. * Multiplies the current Color4 values by scale and stores the result in "result"
  18727. * @param scale defines the scaling factor to apply
  18728. * @param result defines the Color4 object where to store the result
  18729. * @returns the current unmodified Color4
  18730. */
  18731. scaleToRef(scale: number, result: Color4): Color4;
  18732. /**
  18733. * Scale the current Color4 values by a factor and add the result to a given Color4
  18734. * @param scale defines the scale factor
  18735. * @param result defines the Color4 object where to store the result
  18736. * @returns the unmodified current Color4
  18737. */
  18738. scaleAndAddToRef(scale: number, result: Color4): Color4;
  18739. /**
  18740. * Clamps the rgb values by the min and max values and stores the result into "result"
  18741. * @param min defines minimum clamping value (default is 0)
  18742. * @param max defines maximum clamping value (default is 1)
  18743. * @param result defines color to store the result into.
  18744. * @returns the cuurent Color4
  18745. */
  18746. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  18747. /**
  18748. * Multipy an Color4 value by another and return a new Color4 object
  18749. * @param color defines the Color4 value to multiply by
  18750. * @returns a new Color4 object
  18751. */
  18752. multiply(color: Color4): Color4;
  18753. /**
  18754. * Multipy a Color4 value by another and push the result in a reference value
  18755. * @param color defines the Color4 value to multiply by
  18756. * @param result defines the Color4 to fill the result in
  18757. * @returns the result Color4
  18758. */
  18759. multiplyToRef(color: Color4, result: Color4): Color4;
  18760. /**
  18761. * Creates a string with the Color4 current values
  18762. * @returns the string representation of the Color4 object
  18763. */
  18764. toString(): string;
  18765. /**
  18766. * Returns the string "Color4"
  18767. * @returns "Color4"
  18768. */
  18769. getClassName(): string;
  18770. /**
  18771. * Compute the Color4 hash code
  18772. * @returns an unique number that can be used to hash Color4 objects
  18773. */
  18774. getHashCode(): number;
  18775. /**
  18776. * Creates a new Color4 copied from the current one
  18777. * @returns a new Color4 object
  18778. */
  18779. clone(): Color4;
  18780. /**
  18781. * Copies the given Color4 values into the current one
  18782. * @param source defines the source Color4 object
  18783. * @returns the current updated Color4 object
  18784. */
  18785. copyFrom(source: Color4): Color4;
  18786. /**
  18787. * Copies the given float values into the current one
  18788. * @param r defines the red component to read from
  18789. * @param g defines the green component to read from
  18790. * @param b defines the blue component to read from
  18791. * @param a defines the alpha component to read from
  18792. * @returns the current updated Color4 object
  18793. */
  18794. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  18795. /**
  18796. * Copies the given float values into the current one
  18797. * @param r defines the red component to read from
  18798. * @param g defines the green component to read from
  18799. * @param b defines the blue component to read from
  18800. * @param a defines the alpha component to read from
  18801. * @returns the current updated Color4 object
  18802. */
  18803. set(r: number, g: number, b: number, a: number): Color4;
  18804. /**
  18805. * Compute the Color4 hexadecimal code as a string
  18806. * @returns a string containing the hexadecimal representation of the Color4 object
  18807. */
  18808. toHexString(): string;
  18809. /**
  18810. * Computes a new Color4 converted from the current one to linear space
  18811. * @returns a new Color4 object
  18812. */
  18813. toLinearSpace(): Color4;
  18814. /**
  18815. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  18816. * @param convertedColor defines the Color4 object where to store the linear space version
  18817. * @returns the unmodified Color4
  18818. */
  18819. toLinearSpaceToRef(convertedColor: Color4): Color4;
  18820. /**
  18821. * Computes a new Color4 converted from the current one to gamma space
  18822. * @returns a new Color4 object
  18823. */
  18824. toGammaSpace(): Color4;
  18825. /**
  18826. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  18827. * @param convertedColor defines the Color4 object where to store the gamma space version
  18828. * @returns the unmodified Color4
  18829. */
  18830. toGammaSpaceToRef(convertedColor: Color4): Color4;
  18831. /**
  18832. * Creates a new Color4 from the string containing valid hexadecimal values
  18833. * @param hex defines a string containing valid hexadecimal values
  18834. * @returns a new Color4 object
  18835. */
  18836. static FromHexString(hex: string): Color4;
  18837. /**
  18838. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  18839. * @param left defines the start value
  18840. * @param right defines the end value
  18841. * @param amount defines the gradient factor
  18842. * @returns a new Color4 object
  18843. */
  18844. static Lerp(left: Color4, right: Color4, amount: number): Color4;
  18845. /**
  18846. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  18847. * @param left defines the start value
  18848. * @param right defines the end value
  18849. * @param amount defines the gradient factor
  18850. * @param result defines the Color4 object where to store data
  18851. */
  18852. static LerpToRef(left: Color4, right: Color4, amount: number, result: Color4): void;
  18853. /**
  18854. * Creates a new Color4 from a Color3 and an alpha value
  18855. * @param color3 defines the source Color3 to read from
  18856. * @param alpha defines the alpha component (1.0 by default)
  18857. * @returns a new Color4 object
  18858. */
  18859. static FromColor3(color3: Color3, alpha?: number): Color4;
  18860. /**
  18861. * Creates a new Color4 from the starting index element of the given array
  18862. * @param array defines the source array to read from
  18863. * @param offset defines the offset in the source array
  18864. * @returns a new Color4 object
  18865. */
  18866. static FromArray(array: ArrayLike<number>, offset?: number): Color4;
  18867. /**
  18868. * Creates a new Color3 from integer values (< 256)
  18869. * @param r defines the red component to read from (value between 0 and 255)
  18870. * @param g defines the green component to read from (value between 0 and 255)
  18871. * @param b defines the blue component to read from (value between 0 and 255)
  18872. * @param a defines the alpha component to read from (value between 0 and 255)
  18873. * @returns a new Color3 object
  18874. */
  18875. static FromInts(r: number, g: number, b: number, a: number): Color4;
  18876. /**
  18877. * Check the content of a given array and convert it to an array containing RGBA data
  18878. * If the original array was already containing count * 4 values then it is returned directly
  18879. * @param colors defines the array to check
  18880. * @param count defines the number of RGBA data to expect
  18881. * @returns an array containing count * 4 values (RGBA)
  18882. */
  18883. static CheckColors4(colors: number[], count: number): number[];
  18884. }
  18885. /**
  18886. * Class representing a vector containing 2 coordinates
  18887. */
  18888. class Vector2 {
  18889. /** defines the first coordinate */
  18890. x: number;
  18891. /** defines the second coordinate */
  18892. y: number;
  18893. /**
  18894. * Creates a new Vector2 from the given x and y coordinates
  18895. * @param x defines the first coordinate
  18896. * @param y defines the second coordinate
  18897. */
  18898. constructor(
  18899. /** defines the first coordinate */
  18900. x?: number,
  18901. /** defines the second coordinate */
  18902. y?: number);
  18903. /**
  18904. * Gets a string with the Vector2 coordinates
  18905. * @returns a string with the Vector2 coordinates
  18906. */
  18907. toString(): string;
  18908. /**
  18909. * Gets class name
  18910. * @returns the string "Vector2"
  18911. */
  18912. getClassName(): string;
  18913. /**
  18914. * Gets current vector hash code
  18915. * @returns the Vector2 hash code as a number
  18916. */
  18917. getHashCode(): number;
  18918. /**
  18919. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  18920. * @param array defines the source array
  18921. * @param index defines the offset in source array
  18922. * @returns the current Vector2
  18923. */
  18924. toArray(array: FloatArray, index?: number): Vector2;
  18925. /**
  18926. * Copy the current vector to an array
  18927. * @returns a new array with 2 elements: the Vector2 coordinates.
  18928. */
  18929. asArray(): number[];
  18930. /**
  18931. * Sets the Vector2 coordinates with the given Vector2 coordinates
  18932. * @param source defines the source Vector2
  18933. * @returns the current updated Vector2
  18934. */
  18935. copyFrom(source: Vector2): Vector2;
  18936. /**
  18937. * Sets the Vector2 coordinates with the given floats
  18938. * @param x defines the first coordinate
  18939. * @param y defines the second coordinate
  18940. * @returns the current updated Vector2
  18941. */
  18942. copyFromFloats(x: number, y: number): Vector2;
  18943. /**
  18944. * Sets the Vector2 coordinates with the given floats
  18945. * @param x defines the first coordinate
  18946. * @param y defines the second coordinate
  18947. * @returns the current updated Vector2
  18948. */
  18949. set(x: number, y: number): Vector2;
  18950. /**
  18951. * Add another vector with the current one
  18952. * @param otherVector defines the other vector
  18953. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  18954. */
  18955. add(otherVector: Vector2): Vector2;
  18956. /**
  18957. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  18958. * @param otherVector defines the other vector
  18959. * @param result defines the target vector
  18960. * @returns the unmodified current Vector2
  18961. */
  18962. addToRef(otherVector: Vector2, result: Vector2): Vector2;
  18963. /**
  18964. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  18965. * @param otherVector defines the other vector
  18966. * @returns the current updated Vector2
  18967. */
  18968. addInPlace(otherVector: Vector2): Vector2;
  18969. /**
  18970. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  18971. * @param otherVector defines the other vector
  18972. * @returns a new Vector2
  18973. */
  18974. addVector3(otherVector: Vector3): Vector2;
  18975. /**
  18976. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  18977. * @param otherVector defines the other vector
  18978. * @returns a new Vector2
  18979. */
  18980. subtract(otherVector: Vector2): Vector2;
  18981. /**
  18982. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  18983. * @param otherVector defines the other vector
  18984. * @param result defines the target vector
  18985. * @returns the unmodified current Vector2
  18986. */
  18987. subtractToRef(otherVector: Vector2, result: Vector2): Vector2;
  18988. /**
  18989. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  18990. * @param otherVector defines the other vector
  18991. * @returns the current updated Vector2
  18992. */
  18993. subtractInPlace(otherVector: Vector2): Vector2;
  18994. /**
  18995. * Multiplies in place the current Vector2 coordinates by the given ones
  18996. * @param otherVector defines the other vector
  18997. * @returns the current updated Vector2
  18998. */
  18999. multiplyInPlace(otherVector: Vector2): Vector2;
  19000. /**
  19001. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  19002. * @param otherVector defines the other vector
  19003. * @returns a new Vector2
  19004. */
  19005. multiply(otherVector: Vector2): Vector2;
  19006. /**
  19007. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  19008. * @param otherVector defines the other vector
  19009. * @param result defines the target vector
  19010. * @returns the unmodified current Vector2
  19011. */
  19012. multiplyToRef(otherVector: Vector2, result: Vector2): Vector2;
  19013. /**
  19014. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  19015. * @param x defines the first coordinate
  19016. * @param y defines the second coordinate
  19017. * @returns a new Vector2
  19018. */
  19019. multiplyByFloats(x: number, y: number): Vector2;
  19020. /**
  19021. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  19022. * @param otherVector defines the other vector
  19023. * @returns a new Vector2
  19024. */
  19025. divide(otherVector: Vector2): Vector2;
  19026. /**
  19027. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  19028. * @param otherVector defines the other vector
  19029. * @param result defines the target vector
  19030. * @returns the unmodified current Vector2
  19031. */
  19032. divideToRef(otherVector: Vector2, result: Vector2): Vector2;
  19033. /**
  19034. * Divides the current Vector2 coordinates by the given ones
  19035. * @param otherVector defines the other vector
  19036. * @returns the current updated Vector2
  19037. */
  19038. divideInPlace(otherVector: Vector2): Vector2;
  19039. /**
  19040. * Gets a new Vector2 with current Vector2 negated coordinates
  19041. * @returns a new Vector2
  19042. */
  19043. negate(): Vector2;
  19044. /**
  19045. * Multiply the Vector2 coordinates by scale
  19046. * @param scale defines the scaling factor
  19047. * @returns the current updated Vector2
  19048. */
  19049. scaleInPlace(scale: number): Vector2;
  19050. /**
  19051. * Returns a new Vector2 scaled by "scale" from the current Vector2
  19052. * @param scale defines the scaling factor
  19053. * @returns a new Vector2
  19054. */
  19055. scale(scale: number): Vector2;
  19056. /**
  19057. * Scale the current Vector2 values by a factor to a given Vector2
  19058. * @param scale defines the scale factor
  19059. * @param result defines the Vector2 object where to store the result
  19060. * @returns the unmodified current Vector2
  19061. */
  19062. scaleToRef(scale: number, result: Vector2): Vector2;
  19063. /**
  19064. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  19065. * @param scale defines the scale factor
  19066. * @param result defines the Vector2 object where to store the result
  19067. * @returns the unmodified current Vector2
  19068. */
  19069. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  19070. /**
  19071. * Gets a boolean if two vectors are equals
  19072. * @param otherVector defines the other vector
  19073. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  19074. */
  19075. equals(otherVector: Vector2): boolean;
  19076. /**
  19077. * Gets a boolean if two vectors are equals (using an epsilon value)
  19078. * @param otherVector defines the other vector
  19079. * @param epsilon defines the minimal distance to consider equality
  19080. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  19081. */
  19082. equalsWithEpsilon(otherVector: Vector2, epsilon?: number): boolean;
  19083. /**
  19084. * Gets a new Vector2 from current Vector2 floored values
  19085. * @returns a new Vector2
  19086. */
  19087. floor(): Vector2;
  19088. /**
  19089. * Gets a new Vector2 from current Vector2 floored values
  19090. * @returns a new Vector2
  19091. */
  19092. fract(): Vector2;
  19093. /**
  19094. * Gets the length of the vector
  19095. * @returns the vector length (float)
  19096. */
  19097. length(): number;
  19098. /**
  19099. * Gets the vector squared length
  19100. * @returns the vector squared length (float)
  19101. */
  19102. lengthSquared(): number;
  19103. /**
  19104. * Normalize the vector
  19105. * @returns the current updated Vector2
  19106. */
  19107. normalize(): Vector2;
  19108. /**
  19109. * Gets a new Vector2 copied from the Vector2
  19110. * @returns a new Vector2
  19111. */
  19112. clone(): Vector2;
  19113. /**
  19114. * Gets a new Vector2(0, 0)
  19115. * @returns a new Vector2
  19116. */
  19117. static Zero(): Vector2;
  19118. /**
  19119. * Gets a new Vector2(1, 1)
  19120. * @returns a new Vector2
  19121. */
  19122. static One(): Vector2;
  19123. /**
  19124. * Gets a new Vector2 set from the given index element of the given array
  19125. * @param array defines the data source
  19126. * @param offset defines the offset in the data source
  19127. * @returns a new Vector2
  19128. */
  19129. static FromArray(array: ArrayLike<number>, offset?: number): Vector2;
  19130. /**
  19131. * Sets "result" from the given index element of the given array
  19132. * @param array defines the data source
  19133. * @param offset defines the offset in the data source
  19134. * @param result defines the target vector
  19135. */
  19136. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Vector2): void;
  19137. /**
  19138. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  19139. * @param value1 defines 1st point of control
  19140. * @param value2 defines 2nd point of control
  19141. * @param value3 defines 3rd point of control
  19142. * @param value4 defines 4th point of control
  19143. * @param amount defines the interpolation factor
  19144. * @returns a new Vector2
  19145. */
  19146. static CatmullRom(value1: Vector2, value2: Vector2, value3: Vector2, value4: Vector2, amount: number): Vector2;
  19147. /**
  19148. * 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".
  19149. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  19150. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  19151. * @param value defines the value to clamp
  19152. * @param min defines the lower limit
  19153. * @param max defines the upper limit
  19154. * @returns a new Vector2
  19155. */
  19156. static Clamp(value: Vector2, min: Vector2, max: Vector2): Vector2;
  19157. /**
  19158. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  19159. * @param value1 defines the 1st control point
  19160. * @param tangent1 defines the outgoing tangent
  19161. * @param value2 defines the 2nd control point
  19162. * @param tangent2 defines the incoming tangent
  19163. * @param amount defines the interpolation factor
  19164. * @returns a new Vector2
  19165. */
  19166. static Hermite(value1: Vector2, tangent1: Vector2, value2: Vector2, tangent2: Vector2, amount: number): Vector2;
  19167. /**
  19168. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  19169. * @param start defines the start vector
  19170. * @param end defines the end vector
  19171. * @param amount defines the interpolation factor
  19172. * @returns a new Vector2
  19173. */
  19174. static Lerp(start: Vector2, end: Vector2, amount: number): Vector2;
  19175. /**
  19176. * Gets the dot product of the vector "left" and the vector "right"
  19177. * @param left defines first vector
  19178. * @param right defines second vector
  19179. * @returns the dot product (float)
  19180. */
  19181. static Dot(left: Vector2, right: Vector2): number;
  19182. /**
  19183. * Returns a new Vector2 equal to the normalized given vector
  19184. * @param vector defines the vector to normalize
  19185. * @returns a new Vector2
  19186. */
  19187. static Normalize(vector: Vector2): Vector2;
  19188. /**
  19189. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  19190. * @param left defines 1st vector
  19191. * @param right defines 2nd vector
  19192. * @returns a new Vector2
  19193. */
  19194. static Minimize(left: Vector2, right: Vector2): Vector2;
  19195. /**
  19196. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  19197. * @param left defines 1st vector
  19198. * @param right defines 2nd vector
  19199. * @returns a new Vector2
  19200. */
  19201. static Maximize(left: Vector2, right: Vector2): Vector2;
  19202. /**
  19203. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  19204. * @param vector defines the vector to transform
  19205. * @param transformation defines the matrix to apply
  19206. * @returns a new Vector2
  19207. */
  19208. static Transform(vector: Vector2, transformation: Matrix): Vector2;
  19209. /**
  19210. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  19211. * @param vector defines the vector to transform
  19212. * @param transformation defines the matrix to apply
  19213. * @param result defines the target vector
  19214. */
  19215. static TransformToRef(vector: Vector2, transformation: Matrix, result: Vector2): void;
  19216. /**
  19217. * Determines if a given vector is included in a triangle
  19218. * @param p defines the vector to test
  19219. * @param p0 defines 1st triangle point
  19220. * @param p1 defines 2nd triangle point
  19221. * @param p2 defines 3rd triangle point
  19222. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  19223. */
  19224. static PointInTriangle(p: Vector2, p0: Vector2, p1: Vector2, p2: Vector2): boolean;
  19225. /**
  19226. * Gets the distance between the vectors "value1" and "value2"
  19227. * @param value1 defines first vector
  19228. * @param value2 defines second vector
  19229. * @returns the distance between vectors
  19230. */
  19231. static Distance(value1: Vector2, value2: Vector2): number;
  19232. /**
  19233. * Returns the squared distance between the vectors "value1" and "value2"
  19234. * @param value1 defines first vector
  19235. * @param value2 defines second vector
  19236. * @returns the squared distance between vectors
  19237. */
  19238. static DistanceSquared(value1: Vector2, value2: Vector2): number;
  19239. /**
  19240. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  19241. * @param value1 defines first vector
  19242. * @param value2 defines second vector
  19243. * @returns a new Vector2
  19244. */
  19245. static Center(value1: Vector2, value2: Vector2): Vector2;
  19246. /**
  19247. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  19248. * @param p defines the middle point
  19249. * @param segA defines one point of the segment
  19250. * @param segB defines the other point of the segment
  19251. * @returns the shortest distance
  19252. */
  19253. static DistanceOfPointFromSegment(p: Vector2, segA: Vector2, segB: Vector2): number;
  19254. }
  19255. /**
  19256. * Classed used to store (x,y,z) vector representation
  19257. * A Vector3 is the main object used in 3D geometry
  19258. * It can represent etiher the coordinates of a point the space, either a direction
  19259. * Reminder: Babylon.js uses a left handed forward facing system
  19260. */
  19261. class Vector3 {
  19262. /**
  19263. * Defines the first coordinates (on X axis)
  19264. */
  19265. x: number;
  19266. /**
  19267. * Defines the second coordinates (on Y axis)
  19268. */
  19269. y: number;
  19270. /**
  19271. * Defines the third coordinates (on Z axis)
  19272. */
  19273. z: number;
  19274. /**
  19275. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  19276. * @param x defines the first coordinates (on X axis)
  19277. * @param y defines the second coordinates (on Y axis)
  19278. * @param z defines the third coordinates (on Z axis)
  19279. */
  19280. constructor(
  19281. /**
  19282. * Defines the first coordinates (on X axis)
  19283. */
  19284. x?: number,
  19285. /**
  19286. * Defines the second coordinates (on Y axis)
  19287. */
  19288. y?: number,
  19289. /**
  19290. * Defines the third coordinates (on Z axis)
  19291. */
  19292. z?: number);
  19293. /**
  19294. * Creates a string representation of the Vector3
  19295. * @returns a string with the Vector3 coordinates.
  19296. */
  19297. toString(): string;
  19298. /**
  19299. * Gets the class name
  19300. * @returns the string "Vector3"
  19301. */
  19302. getClassName(): string;
  19303. /**
  19304. * Creates the Vector3 hash code
  19305. * @returns a number which tends to be unique between Vector3 instances
  19306. */
  19307. getHashCode(): number;
  19308. /**
  19309. * Creates an array containing three elements : the coordinates of the Vector3
  19310. * @returns a new array of numbers
  19311. */
  19312. asArray(): number[];
  19313. /**
  19314. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  19315. * @param array defines the destination array
  19316. * @param index defines the offset in the destination array
  19317. * @returns the current Vector3
  19318. */
  19319. toArray(array: FloatArray, index?: number): Vector3;
  19320. /**
  19321. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  19322. * @returns a new Quaternion object, computed from the Vector3 coordinates
  19323. */
  19324. toQuaternion(): Quaternion;
  19325. /**
  19326. * Adds the given vector to the current Vector3
  19327. * @param otherVector defines the second operand
  19328. * @returns the current updated Vector3
  19329. */
  19330. addInPlace(otherVector: Vector3): Vector3;
  19331. /**
  19332. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  19333. * @param otherVector defines the second operand
  19334. * @returns the resulting Vector3
  19335. */
  19336. add(otherVector: Vector3): Vector3;
  19337. /**
  19338. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  19339. * @param otherVector defines the second operand
  19340. * @param result defines the Vector3 object where to store the result
  19341. * @returns the current Vector3
  19342. */
  19343. addToRef(otherVector: Vector3, result: Vector3): Vector3;
  19344. /**
  19345. * Subtract the given vector from the current Vector3
  19346. * @param otherVector defines the second operand
  19347. * @returns the current updated Vector3
  19348. */
  19349. subtractInPlace(otherVector: Vector3): Vector3;
  19350. /**
  19351. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  19352. * @param otherVector defines the second operand
  19353. * @returns the resulting Vector3
  19354. */
  19355. subtract(otherVector: Vector3): Vector3;
  19356. /**
  19357. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  19358. * @param otherVector defines the second operand
  19359. * @param result defines the Vector3 object where to store the result
  19360. * @returns the current Vector3
  19361. */
  19362. subtractToRef(otherVector: Vector3, result: Vector3): Vector3;
  19363. /**
  19364. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  19365. * @param x defines the x coordinate of the operand
  19366. * @param y defines the y coordinate of the operand
  19367. * @param z defines the z coordinate of the operand
  19368. * @returns the resulting Vector3
  19369. */
  19370. subtractFromFloats(x: number, y: number, z: number): Vector3;
  19371. /**
  19372. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  19373. * @param x defines the x coordinate of the operand
  19374. * @param y defines the y coordinate of the operand
  19375. * @param z defines the z coordinate of the operand
  19376. * @param result defines the Vector3 object where to store the result
  19377. * @returns the current Vector3
  19378. */
  19379. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  19380. /**
  19381. * Gets a new Vector3 set with the current Vector3 negated coordinates
  19382. * @returns a new Vector3
  19383. */
  19384. negate(): Vector3;
  19385. /**
  19386. * Multiplies the Vector3 coordinates by the float "scale"
  19387. * @param scale defines the multiplier factor
  19388. * @returns the current updated Vector3
  19389. */
  19390. scaleInPlace(scale: number): Vector3;
  19391. /**
  19392. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  19393. * @param scale defines the multiplier factor
  19394. * @returns a new Vector3
  19395. */
  19396. scale(scale: number): Vector3;
  19397. /**
  19398. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  19399. * @param scale defines the multiplier factor
  19400. * @param result defines the Vector3 object where to store the result
  19401. * @returns the current Vector3
  19402. */
  19403. scaleToRef(scale: number, result: Vector3): Vector3;
  19404. /**
  19405. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  19406. * @param scale defines the scale factor
  19407. * @param result defines the Vector3 object where to store the result
  19408. * @returns the unmodified current Vector3
  19409. */
  19410. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  19411. /**
  19412. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  19413. * @param otherVector defines the second operand
  19414. * @returns true if both vectors are equals
  19415. */
  19416. equals(otherVector: Vector3): boolean;
  19417. /**
  19418. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  19419. * @param otherVector defines the second operand
  19420. * @param epsilon defines the minimal distance to define values as equals
  19421. * @returns true if both vectors are distant less than epsilon
  19422. */
  19423. equalsWithEpsilon(otherVector: Vector3, epsilon?: number): boolean;
  19424. /**
  19425. * Returns true if the current Vector3 coordinates equals the given floats
  19426. * @param x defines the x coordinate of the operand
  19427. * @param y defines the y coordinate of the operand
  19428. * @param z defines the z coordinate of the operand
  19429. * @returns true if both vectors are equals
  19430. */
  19431. equalsToFloats(x: number, y: number, z: number): boolean;
  19432. /**
  19433. * Multiplies the current Vector3 coordinates by the given ones
  19434. * @param otherVector defines the second operand
  19435. * @returns the current updated Vector3
  19436. */
  19437. multiplyInPlace(otherVector: Vector3): Vector3;
  19438. /**
  19439. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  19440. * @param otherVector defines the second operand
  19441. * @returns the new Vector3
  19442. */
  19443. multiply(otherVector: Vector3): Vector3;
  19444. /**
  19445. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  19446. * @param otherVector defines the second operand
  19447. * @param result defines the Vector3 object where to store the result
  19448. * @returns the current Vector3
  19449. */
  19450. multiplyToRef(otherVector: Vector3, result: Vector3): Vector3;
  19451. /**
  19452. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  19453. * @param x defines the x coordinate of the operand
  19454. * @param y defines the y coordinate of the operand
  19455. * @param z defines the z coordinate of the operand
  19456. * @returns the new Vector3
  19457. */
  19458. multiplyByFloats(x: number, y: number, z: number): Vector3;
  19459. /**
  19460. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  19461. * @param otherVector defines the second operand
  19462. * @returns the new Vector3
  19463. */
  19464. divide(otherVector: Vector3): Vector3;
  19465. /**
  19466. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  19467. * @param otherVector defines the second operand
  19468. * @param result defines the Vector3 object where to store the result
  19469. * @returns the current Vector3
  19470. */
  19471. divideToRef(otherVector: Vector3, result: Vector3): Vector3;
  19472. /**
  19473. * Divides the current Vector3 coordinates by the given ones.
  19474. * @param otherVector defines the second operand
  19475. * @returns the current updated Vector3
  19476. */
  19477. divideInPlace(otherVector: Vector3): Vector3;
  19478. /**
  19479. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  19480. * @param other defines the second operand
  19481. * @returns the current updated Vector3
  19482. */
  19483. minimizeInPlace(other: Vector3): Vector3;
  19484. /**
  19485. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  19486. * @param other defines the second operand
  19487. * @returns the current updated Vector3
  19488. */
  19489. maximizeInPlace(other: Vector3): Vector3;
  19490. /**
  19491. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  19492. */
  19493. readonly isNonUniform: boolean;
  19494. /**
  19495. * Gets a new Vector3 from current Vector3 floored values
  19496. * @returns a new Vector3
  19497. */
  19498. floor(): Vector3;
  19499. /**
  19500. * Gets a new Vector3 from current Vector3 floored values
  19501. * @returns a new Vector3
  19502. */
  19503. fract(): Vector3;
  19504. /**
  19505. * Gets the length of the Vector3
  19506. * @returns the length of the Vecto3
  19507. */
  19508. length(): number;
  19509. /**
  19510. * Gets the squared length of the Vector3
  19511. * @returns squared length of the Vector3
  19512. */
  19513. lengthSquared(): number;
  19514. /**
  19515. * Normalize the current Vector3.
  19516. * Please note that this is an in place operation.
  19517. * @returns the current updated Vector3
  19518. */
  19519. normalize(): Vector3;
  19520. /**
  19521. * Normalize the current Vector3 to a new vector
  19522. * @returns the new Vector3
  19523. */
  19524. normalizeToNew(): Vector3;
  19525. /**
  19526. * Normalize the current Vector3 to the reference
  19527. * @param reference define the Vector3 to update
  19528. * @returns the updated Vector3
  19529. */
  19530. normalizeToRef(reference: Vector3): Vector3;
  19531. /**
  19532. * Creates a new Vector3 copied from the current Vector3
  19533. * @returns the new Vector3
  19534. */
  19535. clone(): Vector3;
  19536. /**
  19537. * Copies the given vector coordinates to the current Vector3 ones
  19538. * @param source defines the source Vector3
  19539. * @returns the current updated Vector3
  19540. */
  19541. copyFrom(source: Vector3): Vector3;
  19542. /**
  19543. * Copies the given floats to the current Vector3 coordinates
  19544. * @param x defines the x coordinate of the operand
  19545. * @param y defines the y coordinate of the operand
  19546. * @param z defines the z coordinate of the operand
  19547. * @returns the current updated Vector3
  19548. */
  19549. copyFromFloats(x: number, y: number, z: number): Vector3;
  19550. /**
  19551. * Copies the given floats to the current Vector3 coordinates
  19552. * @param x defines the x coordinate of the operand
  19553. * @param y defines the y coordinate of the operand
  19554. * @param z defines the z coordinate of the operand
  19555. * @returns the current updated Vector3
  19556. */
  19557. set(x: number, y: number, z: number): Vector3;
  19558. /**
  19559. * Get the clip factor between two vectors
  19560. * @param vector0 defines the first operand
  19561. * @param vector1 defines the second operand
  19562. * @param axis defines the axis to use
  19563. * @param size defines the size along the axis
  19564. * @returns the clip factor
  19565. */
  19566. static GetClipFactor(vector0: Vector3, vector1: Vector3, axis: Vector3, size: number): number;
  19567. /**
  19568. * Get angle between two vectors
  19569. * @param vector0 angle between vector0 and vector1
  19570. * @param vector1 angle between vector0 and vector1
  19571. * @param normal direction of the normal
  19572. * @return the angle between vector0 and vector1
  19573. */
  19574. static GetAngleBetweenVectors(vector0: Vector3, vector1: Vector3, normal: Vector3): number;
  19575. /**
  19576. * Returns a new Vector3 set from the index "offset" of the given array
  19577. * @param array defines the source array
  19578. * @param offset defines the offset in the source array
  19579. * @returns the new Vector3
  19580. */
  19581. static FromArray(array: ArrayLike<number>, offset?: number): Vector3;
  19582. /**
  19583. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  19584. * This function is deprecated. Use FromArray instead
  19585. * @param array defines the source array
  19586. * @param offset defines the offset in the source array
  19587. * @returns the new Vector3
  19588. */
  19589. static FromFloatArray(array: Float32Array, offset?: number): Vector3;
  19590. /**
  19591. * Sets the given vector "result" with the element values from the index "offset" of the given array
  19592. * @param array defines the source array
  19593. * @param offset defines the offset in the source array
  19594. * @param result defines the Vector3 where to store the result
  19595. */
  19596. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Vector3): void;
  19597. /**
  19598. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  19599. * This function is deprecated. Use FromArrayToRef instead.
  19600. * @param array defines the source array
  19601. * @param offset defines the offset in the source array
  19602. * @param result defines the Vector3 where to store the result
  19603. */
  19604. static FromFloatArrayToRef(array: Float32Array, offset: number, result: Vector3): void;
  19605. /**
  19606. * Sets the given vector "result" with the given floats.
  19607. * @param x defines the x coordinate of the source
  19608. * @param y defines the y coordinate of the source
  19609. * @param z defines the z coordinate of the source
  19610. * @param result defines the Vector3 where to store the result
  19611. */
  19612. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  19613. /**
  19614. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  19615. * @returns a new empty Vector3
  19616. */
  19617. static Zero(): Vector3;
  19618. /**
  19619. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  19620. * @returns a new unit Vector3
  19621. */
  19622. static One(): Vector3;
  19623. /**
  19624. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  19625. * @returns a new up Vector3
  19626. */
  19627. static Up(): Vector3;
  19628. /**
  19629. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  19630. * @returns a new down Vector3
  19631. */
  19632. static Down(): Vector3;
  19633. /**
  19634. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  19635. * @returns a new forward Vector3
  19636. */
  19637. static Forward(): Vector3;
  19638. /**
  19639. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  19640. * @returns a new forward Vector3
  19641. */
  19642. static Backward(): Vector3;
  19643. /**
  19644. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  19645. * @returns a new right Vector3
  19646. */
  19647. static Right(): Vector3;
  19648. /**
  19649. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  19650. * @returns a new left Vector3
  19651. */
  19652. static Left(): Vector3;
  19653. /**
  19654. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  19655. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  19656. * @param vector defines the Vector3 to transform
  19657. * @param transformation defines the transformation matrix
  19658. * @returns the transformed Vector3
  19659. */
  19660. static TransformCoordinates(vector: Vector3, transformation: Matrix): Vector3;
  19661. /**
  19662. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  19663. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  19664. * @param vector defines the Vector3 to transform
  19665. * @param transformation defines the transformation matrix
  19666. * @param result defines the Vector3 where to store the result
  19667. */
  19668. static TransformCoordinatesToRef(vector: Vector3, transformation: Matrix, result: Vector3): void;
  19669. /**
  19670. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  19671. * This method computes tranformed coordinates only, not transformed direction vectors
  19672. * @param x define the x coordinate of the source vector
  19673. * @param y define the y coordinate of the source vector
  19674. * @param z define the z coordinate of the source vector
  19675. * @param transformation defines the transformation matrix
  19676. * @param result defines the Vector3 where to store the result
  19677. */
  19678. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: Matrix, result: Vector3): void;
  19679. /**
  19680. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  19681. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  19682. * @param vector defines the Vector3 to transform
  19683. * @param transformation defines the transformation matrix
  19684. * @returns the new Vector3
  19685. */
  19686. static TransformNormal(vector: Vector3, transformation: Matrix): Vector3;
  19687. /**
  19688. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  19689. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  19690. * @param vector defines the Vector3 to transform
  19691. * @param transformation defines the transformation matrix
  19692. * @param result defines the Vector3 where to store the result
  19693. */
  19694. static TransformNormalToRef(vector: Vector3, transformation: Matrix, result: Vector3): void;
  19695. /**
  19696. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  19697. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  19698. * @param x define the x coordinate of the source vector
  19699. * @param y define the y coordinate of the source vector
  19700. * @param z define the z coordinate of the source vector
  19701. * @param transformation defines the transformation matrix
  19702. * @param result defines the Vector3 where to store the result
  19703. */
  19704. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: Matrix, result: Vector3): void;
  19705. /**
  19706. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  19707. * @param value1 defines the first control point
  19708. * @param value2 defines the second control point
  19709. * @param value3 defines the third control point
  19710. * @param value4 defines the fourth control point
  19711. * @param amount defines the amount on the spline to use
  19712. * @returns the new Vector3
  19713. */
  19714. static CatmullRom(value1: Vector3, value2: Vector3, value3: Vector3, value4: Vector3, amount: number): Vector3;
  19715. /**
  19716. * 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"
  19717. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  19718. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  19719. * @param value defines the current value
  19720. * @param min defines the lower range value
  19721. * @param max defines the upper range value
  19722. * @returns the new Vector3
  19723. */
  19724. static Clamp(value: Vector3, min: Vector3, max: Vector3): Vector3;
  19725. /**
  19726. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  19727. * @param value1 defines the first control point
  19728. * @param tangent1 defines the first tangent vector
  19729. * @param value2 defines the second control point
  19730. * @param tangent2 defines the second tangent vector
  19731. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  19732. * @returns the new Vector3
  19733. */
  19734. static Hermite(value1: Vector3, tangent1: Vector3, value2: Vector3, tangent2: Vector3, amount: number): Vector3;
  19735. /**
  19736. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  19737. * @param start defines the start value
  19738. * @param end defines the end value
  19739. * @param amount max defines amount between both (between 0 and 1)
  19740. * @returns the new Vector3
  19741. */
  19742. static Lerp(start: Vector3, end: Vector3, amount: number): Vector3;
  19743. /**
  19744. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  19745. * @param start defines the start value
  19746. * @param end defines the end value
  19747. * @param amount max defines amount between both (between 0 and 1)
  19748. * @param result defines the Vector3 where to store the result
  19749. */
  19750. static LerpToRef(start: Vector3, end: Vector3, amount: number, result: Vector3): void;
  19751. /**
  19752. * Returns the dot product (float) between the vectors "left" and "right"
  19753. * @param left defines the left operand
  19754. * @param right defines the right operand
  19755. * @returns the dot product
  19756. */
  19757. static Dot(left: Vector3, right: Vector3): number;
  19758. /**
  19759. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  19760. * The cross product is then orthogonal to both "left" and "right"
  19761. * @param left defines the left operand
  19762. * @param right defines the right operand
  19763. * @returns the cross product
  19764. */
  19765. static Cross(left: Vector3, right: Vector3): Vector3;
  19766. /**
  19767. * Sets the given vector "result" with the cross product of "left" and "right"
  19768. * The cross product is then orthogonal to both "left" and "right"
  19769. * @param left defines the left operand
  19770. * @param right defines the right operand
  19771. * @param result defines the Vector3 where to store the result
  19772. */
  19773. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  19774. /**
  19775. * Returns a new Vector3 as the normalization of the given vector
  19776. * @param vector defines the Vector3 to normalize
  19777. * @returns the new Vector3
  19778. */
  19779. static Normalize(vector: Vector3): Vector3;
  19780. /**
  19781. * Sets the given vector "result" with the normalization of the given first vector
  19782. * @param vector defines the Vector3 to normalize
  19783. * @param result defines the Vector3 where to store the result
  19784. */
  19785. static NormalizeToRef(vector: Vector3, result: Vector3): void;
  19786. private static _viewportMatrixCache;
  19787. /**
  19788. * Project a Vector3 onto screen space
  19789. * @param vector defines the Vector3 to project
  19790. * @param world defines the world matrix to use
  19791. * @param transform defines the transform (view x projection) matrix to use
  19792. * @param viewport defines the screen viewport to use
  19793. * @returns the new Vector3
  19794. */
  19795. static Project(vector: Vector3, world: Matrix, transform: Matrix, viewport: Viewport): Vector3;
  19796. /**
  19797. * Unproject from screen space to object space
  19798. * @param source defines the screen space Vector3 to use
  19799. * @param viewportWidth defines the current width of the viewport
  19800. * @param viewportHeight defines the current height of the viewport
  19801. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  19802. * @param transform defines the transform (view x projection) matrix to use
  19803. * @returns the new Vector3
  19804. */
  19805. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, transform: Matrix): Vector3;
  19806. /**
  19807. * Unproject from screen space to object space
  19808. * @param source defines the screen space Vector3 to use
  19809. * @param viewportWidth defines the current width of the viewport
  19810. * @param viewportHeight defines the current height of the viewport
  19811. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  19812. * @param view defines the view matrix to use
  19813. * @param projection defines the projection matrix to use
  19814. * @returns the new Vector3
  19815. */
  19816. static Unproject(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Vector3;
  19817. /**
  19818. * Unproject from screen space to object space
  19819. * @param source defines the screen space Vector3 to use
  19820. * @param viewportWidth defines the current width of the viewport
  19821. * @param viewportHeight defines the current height of the viewport
  19822. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  19823. * @param view defines the view matrix to use
  19824. * @param projection defines the projection matrix to use
  19825. * @param result defines the Vector3 where to store the result
  19826. */
  19827. static UnprojectToRef(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix, result: Vector3): void;
  19828. /**
  19829. * Unproject from screen space to object space
  19830. * @param sourceX defines the screen space x coordinate to use
  19831. * @param sourceY defines the screen space y coordinate to use
  19832. * @param sourceZ defines the screen space z coordinate to use
  19833. * @param viewportWidth defines the current width of the viewport
  19834. * @param viewportHeight defines the current height of the viewport
  19835. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  19836. * @param view defines the view matrix to use
  19837. * @param projection defines the projection matrix to use
  19838. * @param result defines the Vector3 where to store the result
  19839. */
  19840. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix, result: Vector3): void;
  19841. /**
  19842. * Gets the minimal coordinate values between two Vector3
  19843. * @param left defines the first operand
  19844. * @param right defines the second operand
  19845. * @returns the new Vector3
  19846. */
  19847. static Minimize(left: Vector3, right: Vector3): Vector3;
  19848. /**
  19849. * Gets the maximal coordinate values between two Vector3
  19850. * @param left defines the first operand
  19851. * @param right defines the second operand
  19852. * @returns the new Vector3
  19853. */
  19854. static Maximize(left: Vector3, right: Vector3): Vector3;
  19855. /**
  19856. * Returns the distance between the vectors "value1" and "value2"
  19857. * @param value1 defines the first operand
  19858. * @param value2 defines the second operand
  19859. * @returns the distance
  19860. */
  19861. static Distance(value1: Vector3, value2: Vector3): number;
  19862. /**
  19863. * Returns the squared distance between the vectors "value1" and "value2"
  19864. * @param value1 defines the first operand
  19865. * @param value2 defines the second operand
  19866. * @returns the squared distance
  19867. */
  19868. static DistanceSquared(value1: Vector3, value2: Vector3): number;
  19869. /**
  19870. * Returns a new Vector3 located at the center between "value1" and "value2"
  19871. * @param value1 defines the first operand
  19872. * @param value2 defines the second operand
  19873. * @returns the new Vector3
  19874. */
  19875. static Center(value1: Vector3, value2: Vector3): Vector3;
  19876. /**
  19877. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  19878. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  19879. * to something in order to rotate it from its local system to the given target system
  19880. * Note: axis1, axis2 and axis3 are normalized during this operation
  19881. * @param axis1 defines the first axis
  19882. * @param axis2 defines the second axis
  19883. * @param axis3 defines the third axis
  19884. * @returns a new Vector3
  19885. */
  19886. static RotationFromAxis(axis1: Vector3, axis2: Vector3, axis3: Vector3): Vector3;
  19887. /**
  19888. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  19889. * @param axis1 defines the first axis
  19890. * @param axis2 defines the second axis
  19891. * @param axis3 defines the third axis
  19892. * @param ref defines the Vector3 where to store the result
  19893. */
  19894. static RotationFromAxisToRef(axis1: Vector3, axis2: Vector3, axis3: Vector3, ref: Vector3): void;
  19895. }
  19896. class Vector4 {
  19897. x: number;
  19898. y: number;
  19899. z: number;
  19900. w: number;
  19901. /**
  19902. * Creates a Vector4 object from the given floats.
  19903. */
  19904. constructor(x: number, y: number, z: number, w: number);
  19905. /**
  19906. * Returns the string with the Vector4 coordinates.
  19907. */
  19908. toString(): string;
  19909. /**
  19910. * Returns the string "Vector4".
  19911. */
  19912. getClassName(): string;
  19913. /**
  19914. * Returns the Vector4 hash code.
  19915. */
  19916. getHashCode(): number;
  19917. /**
  19918. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  19919. */
  19920. asArray(): number[];
  19921. /**
  19922. * Populates the given array from the given index with the Vector4 coordinates.
  19923. * Returns the Vector4.
  19924. */
  19925. toArray(array: FloatArray, index?: number): Vector4;
  19926. /**
  19927. * Adds the given vector to the current Vector4.
  19928. * Returns the updated Vector4.
  19929. */
  19930. addInPlace(otherVector: Vector4): Vector4;
  19931. /**
  19932. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  19933. */
  19934. add(otherVector: Vector4): Vector4;
  19935. /**
  19936. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  19937. * Returns the current Vector4.
  19938. */
  19939. addToRef(otherVector: Vector4, result: Vector4): Vector4;
  19940. /**
  19941. * Subtract in place the given vector from the current Vector4.
  19942. * Returns the updated Vector4.
  19943. */
  19944. subtractInPlace(otherVector: Vector4): Vector4;
  19945. /**
  19946. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  19947. */
  19948. subtract(otherVector: Vector4): Vector4;
  19949. /**
  19950. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  19951. * Returns the current Vector4.
  19952. */
  19953. subtractToRef(otherVector: Vector4, result: Vector4): Vector4;
  19954. /**
  19955. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  19956. */
  19957. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  19958. /**
  19959. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  19960. * Returns the current Vector4.
  19961. */
  19962. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  19963. /**
  19964. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  19965. */
  19966. negate(): Vector4;
  19967. /**
  19968. * Multiplies the current Vector4 coordinates by scale (float).
  19969. * Returns the updated Vector4.
  19970. */
  19971. scaleInPlace(scale: number): Vector4;
  19972. /**
  19973. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  19974. */
  19975. scale(scale: number): Vector4;
  19976. /**
  19977. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  19978. * Returns the current Vector4.
  19979. */
  19980. scaleToRef(scale: number, result: Vector4): Vector4;
  19981. /**
  19982. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  19983. * @param scale defines the scale factor
  19984. * @param result defines the Vector4 object where to store the result
  19985. * @returns the unmodified current Vector4
  19986. */
  19987. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  19988. /**
  19989. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  19990. */
  19991. equals(otherVector: Vector4): boolean;
  19992. /**
  19993. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  19994. */
  19995. equalsWithEpsilon(otherVector: Vector4, epsilon?: number): boolean;
  19996. /**
  19997. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  19998. */
  19999. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  20000. /**
  20001. * Multiplies in place the current Vector4 by the given one.
  20002. * Returns the updated Vector4.
  20003. */
  20004. multiplyInPlace(otherVector: Vector4): Vector4;
  20005. /**
  20006. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  20007. */
  20008. multiply(otherVector: Vector4): Vector4;
  20009. /**
  20010. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  20011. * Returns the current Vector4.
  20012. */
  20013. multiplyToRef(otherVector: Vector4, result: Vector4): Vector4;
  20014. /**
  20015. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  20016. */
  20017. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  20018. /**
  20019. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  20020. */
  20021. divide(otherVector: Vector4): Vector4;
  20022. /**
  20023. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  20024. * Returns the current Vector4.
  20025. */
  20026. divideToRef(otherVector: Vector4, result: Vector4): Vector4;
  20027. /**
  20028. * Divides the current Vector3 coordinates by the given ones.
  20029. * @returns the updated Vector3.
  20030. */
  20031. divideInPlace(otherVector: Vector4): Vector4;
  20032. /**
  20033. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  20034. * @param other defines the second operand
  20035. * @returns the current updated Vector4
  20036. */
  20037. minimizeInPlace(other: Vector4): Vector4;
  20038. /**
  20039. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  20040. * @param other defines the second operand
  20041. * @returns the current updated Vector4
  20042. */
  20043. maximizeInPlace(other: Vector4): Vector4;
  20044. /**
  20045. * Gets a new Vector4 from current Vector4 floored values
  20046. * @returns a new Vector4
  20047. */
  20048. floor(): Vector4;
  20049. /**
  20050. * Gets a new Vector4 from current Vector3 floored values
  20051. * @returns a new Vector4
  20052. */
  20053. fract(): Vector4;
  20054. /**
  20055. * Returns the Vector4 length (float).
  20056. */
  20057. length(): number;
  20058. /**
  20059. * Returns the Vector4 squared length (float).
  20060. */
  20061. lengthSquared(): number;
  20062. /**
  20063. * Normalizes in place the Vector4.
  20064. * Returns the updated Vector4.
  20065. */
  20066. normalize(): Vector4;
  20067. /**
  20068. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  20069. */
  20070. toVector3(): Vector3;
  20071. /**
  20072. * Returns a new Vector4 copied from the current one.
  20073. */
  20074. clone(): Vector4;
  20075. /**
  20076. * Updates the current Vector4 with the given one coordinates.
  20077. * Returns the updated Vector4.
  20078. */
  20079. copyFrom(source: Vector4): Vector4;
  20080. /**
  20081. * Updates the current Vector4 coordinates with the given floats.
  20082. * Returns the updated Vector4.
  20083. */
  20084. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  20085. /**
  20086. * Updates the current Vector4 coordinates with the given floats.
  20087. * Returns the updated Vector4.
  20088. */
  20089. set(x: number, y: number, z: number, w: number): Vector4;
  20090. /**
  20091. * Returns a new Vector4 set from the starting index of the given array.
  20092. */
  20093. static FromArray(array: ArrayLike<number>, offset?: number): Vector4;
  20094. /**
  20095. * Updates the given vector "result" from the starting index of the given array.
  20096. */
  20097. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Vector4): void;
  20098. /**
  20099. * Updates the given vector "result" from the starting index of the given Float32Array.
  20100. */
  20101. static FromFloatArrayToRef(array: Float32Array, offset: number, result: Vector4): void;
  20102. /**
  20103. * Updates the given vector "result" coordinates from the given floats.
  20104. */
  20105. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  20106. /**
  20107. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  20108. */
  20109. static Zero(): Vector4;
  20110. /**
  20111. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  20112. */
  20113. static One(): Vector4;
  20114. /**
  20115. * Returns a new normalized Vector4 from the given one.
  20116. */
  20117. static Normalize(vector: Vector4): Vector4;
  20118. /**
  20119. * Updates the given vector "result" from the normalization of the given one.
  20120. */
  20121. static NormalizeToRef(vector: Vector4, result: Vector4): void;
  20122. static Minimize(left: Vector4, right: Vector4): Vector4;
  20123. static Maximize(left: Vector4, right: Vector4): Vector4;
  20124. /**
  20125. * Returns the distance (float) between the vectors "value1" and "value2".
  20126. */
  20127. static Distance(value1: Vector4, value2: Vector4): number;
  20128. /**
  20129. * Returns the squared distance (float) between the vectors "value1" and "value2".
  20130. */
  20131. static DistanceSquared(value1: Vector4, value2: Vector4): number;
  20132. /**
  20133. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  20134. */
  20135. static Center(value1: Vector4, value2: Vector4): Vector4;
  20136. /**
  20137. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  20138. * This methods computes transformed normalized direction vectors only.
  20139. */
  20140. static TransformNormal(vector: Vector4, transformation: Matrix): Vector4;
  20141. /**
  20142. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  20143. * This methods computes transformed normalized direction vectors only.
  20144. */
  20145. static TransformNormalToRef(vector: Vector4, transformation: Matrix, result: Vector4): void;
  20146. /**
  20147. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  20148. * This methods computes transformed normalized direction vectors only.
  20149. */
  20150. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: Matrix, result: Vector4): void;
  20151. }
  20152. interface ISize {
  20153. width: number;
  20154. height: number;
  20155. }
  20156. class Size implements ISize {
  20157. width: number;
  20158. height: number;
  20159. /**
  20160. * Creates a Size object from the given width and height (floats).
  20161. */
  20162. constructor(width: number, height: number);
  20163. toString(): string;
  20164. /**
  20165. * Returns the string "Size"
  20166. */
  20167. getClassName(): string;
  20168. /**
  20169. * Returns the Size hash code.
  20170. */
  20171. getHashCode(): number;
  20172. /**
  20173. * Updates the current size from the given one.
  20174. * Returns the updated Size.
  20175. */
  20176. copyFrom(src: Size): void;
  20177. /**
  20178. * Updates in place the current Size from the given floats.
  20179. * Returns the updated Size.
  20180. */
  20181. copyFromFloats(width: number, height: number): Size;
  20182. /**
  20183. * Updates in place the current Size from the given floats.
  20184. * Returns the updated Size.
  20185. */
  20186. set(width: number, height: number): Size;
  20187. /**
  20188. * Returns a new Size set with the multiplication result of the current Size and the given floats.
  20189. */
  20190. multiplyByFloats(w: number, h: number): Size;
  20191. /**
  20192. * Returns a new Size copied from the given one.
  20193. */
  20194. clone(): Size;
  20195. /**
  20196. * Boolean : True if the current Size and the given one width and height are strictly equal.
  20197. */
  20198. equals(other: Size): boolean;
  20199. /**
  20200. * Returns the surface of the Size : width * height (float).
  20201. */
  20202. readonly surface: number;
  20203. /**
  20204. * Returns a new Size set to (0.0, 0.0)
  20205. */
  20206. static Zero(): Size;
  20207. /**
  20208. * Returns a new Size set as the addition result of the current Size and the given one.
  20209. */
  20210. add(otherSize: Size): Size;
  20211. /**
  20212. * Returns a new Size set as the subtraction result of the given one from the current Size.
  20213. */
  20214. subtract(otherSize: Size): Size;
  20215. /**
  20216. * Returns a new Size set at the linear interpolation "amount" between "start" and "end".
  20217. */
  20218. static Lerp(start: Size, end: Size, amount: number): Size;
  20219. }
  20220. /**
  20221. * Class used to store quaternion data
  20222. * @see https://en.wikipedia.org/wiki/Quaternion
  20223. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  20224. */
  20225. class Quaternion {
  20226. /** defines the first component (0 by default) */
  20227. x: number;
  20228. /** defines the second component (0 by default) */
  20229. y: number;
  20230. /** defines the third component (0 by default) */
  20231. z: number;
  20232. /** defines the fourth component (1.0 by default) */
  20233. w: number;
  20234. /**
  20235. * Creates a new Quaternion from the given floats
  20236. * @param x defines the first component (0 by default)
  20237. * @param y defines the second component (0 by default)
  20238. * @param z defines the third component (0 by default)
  20239. * @param w defines the fourth component (1.0 by default)
  20240. */
  20241. constructor(
  20242. /** defines the first component (0 by default) */
  20243. x?: number,
  20244. /** defines the second component (0 by default) */
  20245. y?: number,
  20246. /** defines the third component (0 by default) */
  20247. z?: number,
  20248. /** defines the fourth component (1.0 by default) */
  20249. w?: number);
  20250. /**
  20251. * Gets a string representation for the current quaternion
  20252. * @returns a string with the Quaternion coordinates
  20253. */
  20254. toString(): string;
  20255. /**
  20256. * Gets the class name of the quaternion
  20257. * @returns the string "Quaternion"
  20258. */
  20259. getClassName(): string;
  20260. /**
  20261. * Gets a hash code for this quaternion
  20262. * @returns the quaternion hash code
  20263. */
  20264. getHashCode(): number;
  20265. /**
  20266. * Copy the quaternion to an array
  20267. * @returns a new array populated with 4 elements from the quaternion coordinates
  20268. */
  20269. asArray(): number[];
  20270. /**
  20271. * Check if two quaternions are equals
  20272. * @param otherQuaternion defines the second operand
  20273. * @return true if the current quaternion and the given one coordinates are strictly equals
  20274. */
  20275. equals(otherQuaternion: Quaternion): boolean;
  20276. /**
  20277. * Clone the current quaternion
  20278. * @returns a new quaternion copied from the current one
  20279. */
  20280. clone(): Quaternion;
  20281. /**
  20282. * Copy a quaternion to the current one
  20283. * @param other defines the other quaternion
  20284. * @returns the updated current quaternion
  20285. */
  20286. copyFrom(other: Quaternion): Quaternion;
  20287. /**
  20288. * Updates the current quaternion with the given float coordinates
  20289. * @param x defines the x coordinate
  20290. * @param y defines the y coordinate
  20291. * @param z defines the z coordinate
  20292. * @param w defines the w coordinate
  20293. * @returns the updated current quaternion
  20294. */
  20295. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  20296. /**
  20297. * Updates the current quaternion from the given float coordinates
  20298. * @param x defines the x coordinate
  20299. * @param y defines the y coordinate
  20300. * @param z defines the z coordinate
  20301. * @param w defines the w coordinate
  20302. * @returns the updated current quaternion
  20303. */
  20304. set(x: number, y: number, z: number, w: number): Quaternion;
  20305. /**
  20306. * Adds two quaternions
  20307. * @param other defines the second operand
  20308. * @returns a new quaternion as the addition result of the given one and the current quaternion
  20309. */
  20310. add(other: Quaternion): Quaternion;
  20311. /**
  20312. * Add a quaternion to the current one
  20313. * @param other defines the quaternion to add
  20314. * @returns the current quaternion
  20315. */
  20316. addInPlace(other: Quaternion): Quaternion;
  20317. /**
  20318. * Subtract two quaternions
  20319. * @param other defines the second operand
  20320. * @returns a new quaternion as the subtraction result of the given one from the current one
  20321. */
  20322. subtract(other: Quaternion): Quaternion;
  20323. /**
  20324. * Multiplies the current quaternion by a scale factor
  20325. * @param value defines the scale factor
  20326. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  20327. */
  20328. scale(value: number): Quaternion;
  20329. /**
  20330. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  20331. * @param scale defines the scale factor
  20332. * @param result defines the Quaternion object where to store the result
  20333. * @returns the unmodified current quaternion
  20334. */
  20335. scaleToRef(scale: number, result: Quaternion): Quaternion;
  20336. /**
  20337. * Multiplies in place the current quaternion by a scale factor
  20338. * @param value defines the scale factor
  20339. * @returns the current modified quaternion
  20340. */
  20341. scaleInPlace(value: number): Quaternion;
  20342. /**
  20343. * Scale the current quaternion values by a factor and add the result to a given quaternion
  20344. * @param scale defines the scale factor
  20345. * @param result defines the Quaternion object where to store the result
  20346. * @returns the unmodified current quaternion
  20347. */
  20348. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  20349. /**
  20350. * Multiplies two quaternions
  20351. * @param q1 defines the second operand
  20352. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  20353. */
  20354. multiply(q1: Quaternion): Quaternion;
  20355. /**
  20356. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  20357. * @param q1 defines the second operand
  20358. * @param result defines the target quaternion
  20359. * @returns the current quaternion
  20360. */
  20361. multiplyToRef(q1: Quaternion, result: Quaternion): Quaternion;
  20362. /**
  20363. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  20364. * @param q1 defines the second operand
  20365. * @returns the currentupdated quaternion
  20366. */
  20367. multiplyInPlace(q1: Quaternion): Quaternion;
  20368. /**
  20369. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  20370. * @param ref defines the target quaternion
  20371. * @returns the current quaternion
  20372. */
  20373. conjugateToRef(ref: Quaternion): Quaternion;
  20374. /**
  20375. * Conjugates in place (1-q) the current quaternion
  20376. * @returns the current updated quaternion
  20377. */
  20378. conjugateInPlace(): Quaternion;
  20379. /**
  20380. * Conjugates in place (1-q) the current quaternion
  20381. * @returns a new quaternion
  20382. */
  20383. conjugate(): Quaternion;
  20384. /**
  20385. * Gets length of current quaternion
  20386. * @returns the quaternion length (float)
  20387. */
  20388. length(): number;
  20389. /**
  20390. * Normalize in place the current quaternion
  20391. * @returns the current updated quaternion
  20392. */
  20393. normalize(): Quaternion;
  20394. /**
  20395. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  20396. * @param order is a reserved parameter and is ignore for now
  20397. * @returns a new Vector3 containing the Euler angles
  20398. */
  20399. toEulerAngles(order?: string): Vector3;
  20400. /**
  20401. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  20402. * @param result defines the vector which will be filled with the Euler angles
  20403. * @param order is a reserved parameter and is ignore for now
  20404. * @returns the current unchanged quaternion
  20405. */
  20406. toEulerAnglesToRef(result: Vector3, order?: string): Quaternion;
  20407. /**
  20408. * Updates the given rotation matrix with the current quaternion values
  20409. * @param result defines the target matrix
  20410. * @returns the current unchanged quaternion
  20411. */
  20412. toRotationMatrix(result: Matrix): Quaternion;
  20413. /**
  20414. * Updates the current quaternion from the given rotation matrix values
  20415. * @param matrix defines the source matrix
  20416. * @returns the current updated quaternion
  20417. */
  20418. fromRotationMatrix(matrix: Matrix): Quaternion;
  20419. /**
  20420. * Creates a new quaternion from a rotation matrix
  20421. * @param matrix defines the source matrix
  20422. * @returns a new quaternion created from the given rotation matrix values
  20423. */
  20424. static FromRotationMatrix(matrix: Matrix): Quaternion;
  20425. /**
  20426. * Updates the given quaternion with the given rotation matrix values
  20427. * @param matrix defines the source matrix
  20428. * @param result defines the target quaternion
  20429. */
  20430. static FromRotationMatrixToRef(matrix: Matrix, result: Quaternion): void;
  20431. /**
  20432. * Returns the dot product (float) between the quaternions "left" and "right"
  20433. * @param left defines the left operand
  20434. * @param right defines the right operand
  20435. * @returns the dot product
  20436. */
  20437. static Dot(left: Quaternion, right: Quaternion): number;
  20438. /**
  20439. * Checks if the two quaternions are close to each other
  20440. * @param quat0 defines the first quaternion to check
  20441. * @param quat1 defines the second quaternion to check
  20442. * @returns true if the two quaternions are close to each other
  20443. */
  20444. static AreClose(quat0: Quaternion, quat1: Quaternion): boolean;
  20445. /**
  20446. * Creates an empty quaternion
  20447. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  20448. */
  20449. static Zero(): Quaternion;
  20450. /**
  20451. * Inverse a given quaternion
  20452. * @param q defines the source quaternion
  20453. * @returns a new quaternion as the inverted current quaternion
  20454. */
  20455. static Inverse(q: Quaternion): Quaternion;
  20456. /**
  20457. * Creates an identity quaternion
  20458. * @returns the identity quaternion
  20459. */
  20460. static Identity(): Quaternion;
  20461. /**
  20462. * Gets a boolean indicating if the given quaternion is identity
  20463. * @param quaternion defines the quaternion to check
  20464. * @returns true if the quaternion is identity
  20465. */
  20466. static IsIdentity(quaternion: Quaternion): boolean;
  20467. /**
  20468. * Creates a quaternion from a rotation around an axis
  20469. * @param axis defines the axis to use
  20470. * @param angle defines the angle to use
  20471. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  20472. */
  20473. static RotationAxis(axis: Vector3, angle: number): Quaternion;
  20474. /**
  20475. * Creates a rotation around an axis and stores it into the given quaternion
  20476. * @param axis defines the axis to use
  20477. * @param angle defines the angle to use
  20478. * @param result defines the target quaternion
  20479. * @returns the target quaternion
  20480. */
  20481. static RotationAxisToRef(axis: Vector3, angle: number, result: Quaternion): Quaternion;
  20482. /**
  20483. * Creates a new quaternion from data stored into an array
  20484. * @param array defines the data source
  20485. * @param offset defines the offset in the source array where the data starts
  20486. * @returns a new quaternion
  20487. */
  20488. static FromArray(array: ArrayLike<number>, offset?: number): Quaternion;
  20489. /**
  20490. * Creates a new quaternion from the given Euler float angles (y, x, z)
  20491. * @param yaw defines the rotation around Y axis
  20492. * @param pitch defines the rotation around X axis
  20493. * @param roll defines the rotation around Z axis
  20494. * @returns the new quaternion
  20495. */
  20496. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  20497. /**
  20498. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  20499. * @param yaw defines the rotation around Y axis
  20500. * @param pitch defines the rotation around X axis
  20501. * @param roll defines the rotation around Z axis
  20502. * @param result defines the target quaternion
  20503. */
  20504. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  20505. /**
  20506. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  20507. * @param alpha defines the rotation around first axis
  20508. * @param beta defines the rotation around second axis
  20509. * @param gamma defines the rotation around third axis
  20510. * @returns the new quaternion
  20511. */
  20512. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  20513. /**
  20514. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  20515. * @param alpha defines the rotation around first axis
  20516. * @param beta defines the rotation around second axis
  20517. * @param gamma defines the rotation around third axis
  20518. * @param result defines the target quaternion
  20519. */
  20520. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  20521. /**
  20522. * 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)
  20523. * @param axis1 defines the first axis
  20524. * @param axis2 defines the second axis
  20525. * @param axis3 defines the third axis
  20526. * @returns the new quaternion
  20527. */
  20528. static RotationQuaternionFromAxis(axis1: Vector3, axis2: Vector3, axis3: Vector3): Quaternion;
  20529. /**
  20530. * 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
  20531. * @param axis1 defines the first axis
  20532. * @param axis2 defines the second axis
  20533. * @param axis3 defines the third axis
  20534. * @param ref defines the target quaternion
  20535. */
  20536. static RotationQuaternionFromAxisToRef(axis1: Vector3, axis2: Vector3, axis3: Vector3, ref: Quaternion): void;
  20537. /**
  20538. * Interpolates between two quaternions
  20539. * @param left defines first quaternion
  20540. * @param right defines second quaternion
  20541. * @param amount defines the gradient to use
  20542. * @returns the new interpolated quaternion
  20543. */
  20544. static Slerp(left: Quaternion, right: Quaternion, amount: number): Quaternion;
  20545. /**
  20546. * Interpolates between two quaternions and stores it into a target quaternion
  20547. * @param left defines first quaternion
  20548. * @param right defines second quaternion
  20549. * @param amount defines the gradient to use
  20550. * @param result defines the target quaternion
  20551. */
  20552. static SlerpToRef(left: Quaternion, right: Quaternion, amount: number, result: Quaternion): void;
  20553. /**
  20554. * Interpolate between two quaternions using Hermite interpolation
  20555. * @param value1 defines first quaternion
  20556. * @param tangent1 defines the incoming tangent
  20557. * @param value2 defines second quaternion
  20558. * @param tangent2 defines the outgoing tangent
  20559. * @param amount defines the target quaternion
  20560. * @returns the new interpolated quaternion
  20561. */
  20562. static Hermite(value1: Quaternion, tangent1: Quaternion, value2: Quaternion, tangent2: Quaternion, amount: number): Quaternion;
  20563. }
  20564. /**
  20565. * Class used to store matrix data (4x4)
  20566. */
  20567. class Matrix {
  20568. private static _tempQuaternion;
  20569. private static _xAxis;
  20570. private static _yAxis;
  20571. private static _zAxis;
  20572. private static _updateFlagSeed;
  20573. private static _identityReadOnly;
  20574. private _isIdentity;
  20575. private _isIdentityDirty;
  20576. /**
  20577. * Gets the update flag of the matrix which is an unique number for the matrix.
  20578. * It will be incremented every time the matrix data change.
  20579. * You can use it to speed the comparison between two versions of the same matrix.
  20580. */
  20581. updateFlag: number;
  20582. /**
  20583. * Gets or sets the internal data of the matrix
  20584. */
  20585. m: Float32Array;
  20586. /** @hidden */
  20587. /**
  20588. * Creates an empty matrix (filled with zeros)
  20589. */
  20590. constructor();
  20591. /**
  20592. * Check if the current matrix is indentity
  20593. * @param considerAsTextureMatrix defines if the current matrix must be considered as a texture matrix (3x2)
  20594. * @returns true is the matrix is the identity matrix
  20595. */
  20596. isIdentity(considerAsTextureMatrix?: boolean): boolean;
  20597. /**
  20598. * Gets the determinant of the matrix
  20599. * @returns the matrix determinant
  20600. */
  20601. determinant(): number;
  20602. /**
  20603. * Returns the matrix as a Float32Array
  20604. * @returns the matrix underlying array
  20605. */
  20606. toArray(): Float32Array;
  20607. /**
  20608. * Returns the matrix as a Float32Array
  20609. * @returns the matrix underlying array.
  20610. */
  20611. asArray(): Float32Array;
  20612. /**
  20613. * Inverts the current matrix in place
  20614. * @returns the current inverted matrix
  20615. */
  20616. invert(): Matrix;
  20617. /**
  20618. * Sets all the matrix elements to zero
  20619. * @returns the current matrix
  20620. */
  20621. reset(): Matrix;
  20622. /**
  20623. * Adds the current matrix with a second one
  20624. * @param other defines the matrix to add
  20625. * @returns a new matrix as the addition of the current matrix and the given one
  20626. */
  20627. add(other: Matrix): Matrix;
  20628. /**
  20629. * Sets the given matrix "result" to the addition of the current matrix and the given one
  20630. * @param other defines the matrix to add
  20631. * @param result defines the target matrix
  20632. * @returns the current matrix
  20633. */
  20634. addToRef(other: Matrix, result: Matrix): Matrix;
  20635. /**
  20636. * Adds in place the given matrix to the current matrix
  20637. * @param other defines the second operand
  20638. * @returns the current updated matrix
  20639. */
  20640. addToSelf(other: Matrix): Matrix;
  20641. /**
  20642. * Sets the given matrix to the current inverted Matrix
  20643. * @param other defines the target matrix
  20644. * @returns the unmodified current matrix
  20645. */
  20646. invertToRef(other: Matrix): Matrix;
  20647. /**
  20648. * Inserts the translation vector (using 3 floats) in the current matrix
  20649. * @param x defines the 1st component of the translation
  20650. * @param y defines the 2nd component of the translation
  20651. * @param z defines the 3rd component of the translation
  20652. * @returns the current updated matrix
  20653. */
  20654. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  20655. /**
  20656. * Inserts the translation vector in the current matrix
  20657. * @param vector3 defines the translation to insert
  20658. * @returns the current updated matrix
  20659. */
  20660. setTranslation(vector3: Vector3): Matrix;
  20661. /**
  20662. * Gets the translation value of the current matrix
  20663. * @returns a new Vector3 as the extracted translation from the matrix
  20664. */
  20665. getTranslation(): Vector3;
  20666. /**
  20667. * Fill a Vector3 with the extracted translation from the matrix
  20668. * @param result defines the Vector3 where to store the translation
  20669. * @returns the current matrix
  20670. */
  20671. getTranslationToRef(result: Vector3): Matrix;
  20672. /**
  20673. * Remove rotation and scaling part from the matrix
  20674. * @returns the updated matrix
  20675. */
  20676. removeRotationAndScaling(): Matrix;
  20677. /**
  20678. * Multiply two matrices
  20679. * @param other defines the second operand
  20680. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  20681. */
  20682. multiply(other: Matrix): Matrix;
  20683. /**
  20684. * Copy the current matrix from the given one
  20685. * @param other defines the source matrix
  20686. * @returns the current updated matrix
  20687. */
  20688. copyFrom(other: Matrix): Matrix;
  20689. /**
  20690. * Populates the given array from the starting index with the current matrix values
  20691. * @param array defines the target array
  20692. * @param offset defines the offset in the target array where to start storing values
  20693. * @returns the current matrix
  20694. */
  20695. copyToArray(array: Float32Array, offset?: number): Matrix;
  20696. /**
  20697. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  20698. * @param other defines the second operand
  20699. * @param result defines the matrix where to store the multiplication
  20700. * @returns the current matrix
  20701. */
  20702. multiplyToRef(other: Matrix, result: Matrix): Matrix;
  20703. /**
  20704. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  20705. * @param other defines the second operand
  20706. * @param result defines the array where to store the multiplication
  20707. * @param offset defines the offset in the target array where to start storing values
  20708. * @returns the current matrix
  20709. */
  20710. multiplyToArray(other: Matrix, result: Float32Array, offset: number): Matrix;
  20711. /**
  20712. * Check equality between this matrix and a second one
  20713. * @param value defines the second matrix to compare
  20714. * @returns true is the current matrix and the given one values are strictly equal
  20715. */
  20716. equals(value: Matrix): boolean;
  20717. /**
  20718. * Clone the current matrix
  20719. * @returns a new matrix from the current matrix
  20720. */
  20721. clone(): Matrix;
  20722. /**
  20723. * Returns the name of the current matrix class
  20724. * @returns the string "Matrix"
  20725. */
  20726. getClassName(): string;
  20727. /**
  20728. * Gets the hash code of the current matrix
  20729. * @returns the hash code
  20730. */
  20731. getHashCode(): number;
  20732. /**
  20733. * Decomposes the current Matrix into a translation, rotation and scaling components
  20734. * @param scale defines the scale vector3 given as a reference to update
  20735. * @param rotation defines the rotation quaternion given as a reference to update
  20736. * @param translation defines the translation vector3 given as a reference to update
  20737. * @returns true if operation was successful
  20738. */
  20739. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  20740. /**
  20741. * Gets specific row of the matrix
  20742. * @param index defines the number of the row to get
  20743. * @returns the index-th row of the current matrix as a new Vector4
  20744. */
  20745. getRow(index: number): Nullable<Vector4>;
  20746. /**
  20747. * Sets the index-th row of the current matrix to the vector4 values
  20748. * @param index defines the number of the row to set
  20749. * @param row defines the target vector4
  20750. * @returns the updated current matrix
  20751. */
  20752. setRow(index: number, row: Vector4): Matrix;
  20753. /**
  20754. * Compute the transpose of the matrix
  20755. * @returns the new transposed matrix
  20756. */
  20757. transpose(): Matrix;
  20758. /**
  20759. * Compute the transpose of the matrix and store it in a given matrix
  20760. * @param result defines the target matrix
  20761. * @returns the current matrix
  20762. */
  20763. transposeToRef(result: Matrix): Matrix;
  20764. /**
  20765. * Sets the index-th row of the current matrix with the given 4 x float values
  20766. * @param index defines the row index
  20767. * @param x defines the x component to set
  20768. * @param y defines the y component to set
  20769. * @param z defines the z component to set
  20770. * @param w defines the w component to set
  20771. * @returns the updated current matrix
  20772. */
  20773. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  20774. /**
  20775. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  20776. * @param scale defines the scale factor
  20777. * @returns a new matrix
  20778. */
  20779. scale(scale: number): Matrix;
  20780. /**
  20781. * Scale the current matrix values by a factor to a given result matrix
  20782. * @param scale defines the scale factor
  20783. * @param result defines the matrix to store the result
  20784. * @returns the current matrix
  20785. */
  20786. scaleToRef(scale: number, result: Matrix): Matrix;
  20787. /**
  20788. * Scale the current matrix values by a factor and add the result to a given matrix
  20789. * @param scale defines the scale factor
  20790. * @param result defines the Matrix to store the result
  20791. * @returns the current matrix
  20792. */
  20793. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  20794. /**
  20795. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  20796. * @param ref matrix to store the result
  20797. */
  20798. toNormalMatrix(ref: Matrix): void;
  20799. /**
  20800. * Gets only rotation part of the current matrix
  20801. * @returns a new matrix sets to the extracted rotation matrix from the current one
  20802. */
  20803. getRotationMatrix(): Matrix;
  20804. /**
  20805. * Extracts the rotation matrix from the current one and sets it as the given "result"
  20806. * @param result defines the target matrix to store data to
  20807. * @returns the current matrix
  20808. */
  20809. getRotationMatrixToRef(result: Matrix): Matrix;
  20810. /**
  20811. * Creates a matrix from an array
  20812. * @param array defines the source array
  20813. * @param offset defines an offset in the source array
  20814. * @returns a new Matrix set from the starting index of the given array
  20815. */
  20816. static FromArray(array: ArrayLike<number>, offset?: number): Matrix;
  20817. /**
  20818. * Copy the content of an array into a given matrix
  20819. * @param array defines the source array
  20820. * @param offset defines an offset in the source array
  20821. * @param result defines the target matrix
  20822. */
  20823. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Matrix): void;
  20824. /**
  20825. * Stores an array into a matrix after having multiplied each component by a given factor
  20826. * @param array defines the source array
  20827. * @param offset defines the offset in the source array
  20828. * @param scale defines the scaling factor
  20829. * @param result defines the target matrix
  20830. */
  20831. static FromFloat32ArrayToRefScaled(array: Float32Array, offset: number, scale: number, result: Matrix): void;
  20832. /**
  20833. * Stores a list of values (16) inside a given matrix
  20834. * @param initialM11 defines 1st value of 1st row
  20835. * @param initialM12 defines 2nd value of 1st row
  20836. * @param initialM13 defines 3rd value of 1st row
  20837. * @param initialM14 defines 4th value of 1st row
  20838. * @param initialM21 defines 1st value of 2nd row
  20839. * @param initialM22 defines 2nd value of 2nd row
  20840. * @param initialM23 defines 3rd value of 2nd row
  20841. * @param initialM24 defines 4th value of 2nd row
  20842. * @param initialM31 defines 1st value of 3rd row
  20843. * @param initialM32 defines 2nd value of 3rd row
  20844. * @param initialM33 defines 3rd value of 3rd row
  20845. * @param initialM34 defines 4th value of 3rd row
  20846. * @param initialM41 defines 1st value of 4th row
  20847. * @param initialM42 defines 2nd value of 4th row
  20848. * @param initialM43 defines 3rd value of 4th row
  20849. * @param initialM44 defines 4th value of 4th row
  20850. * @param result defines the target matrix
  20851. */
  20852. 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;
  20853. /**
  20854. * Gets an identity matrix that must not be updated
  20855. */
  20856. static readonly IdentityReadOnly: Matrix;
  20857. /**
  20858. * Creates new matrix from a list of values (16)
  20859. * @param initialM11 defines 1st value of 1st row
  20860. * @param initialM12 defines 2nd value of 1st row
  20861. * @param initialM13 defines 3rd value of 1st row
  20862. * @param initialM14 defines 4th value of 1st row
  20863. * @param initialM21 defines 1st value of 2nd row
  20864. * @param initialM22 defines 2nd value of 2nd row
  20865. * @param initialM23 defines 3rd value of 2nd row
  20866. * @param initialM24 defines 4th value of 2nd row
  20867. * @param initialM31 defines 1st value of 3rd row
  20868. * @param initialM32 defines 2nd value of 3rd row
  20869. * @param initialM33 defines 3rd value of 3rd row
  20870. * @param initialM34 defines 4th value of 3rd row
  20871. * @param initialM41 defines 1st value of 4th row
  20872. * @param initialM42 defines 2nd value of 4th row
  20873. * @param initialM43 defines 3rd value of 4th row
  20874. * @param initialM44 defines 4th value of 4th row
  20875. * @returns the new matrix
  20876. */
  20877. 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;
  20878. /**
  20879. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  20880. * @param scale defines the scale vector3
  20881. * @param rotation defines the rotation quaternion
  20882. * @param translation defines the translation vector3
  20883. * @returns a new matrix
  20884. */
  20885. static Compose(scale: Vector3, rotation: Quaternion, translation: Vector3): Matrix;
  20886. /**
  20887. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  20888. * @param scale defines the scale vector3
  20889. * @param rotation defines the rotation quaternion
  20890. * @param translation defines the translation vector3
  20891. * @param result defines the target matrix
  20892. */
  20893. static ComposeToRef(scale: Vector3, rotation: Quaternion, translation: Vector3, result: Matrix): void;
  20894. /**
  20895. * Creates a new identity matrix
  20896. * @returns a new identity matrix
  20897. */
  20898. static Identity(): Matrix;
  20899. /**
  20900. * Creates a new identity matrix and stores the result in a given matrix
  20901. * @param result defines the target matrix
  20902. */
  20903. static IdentityToRef(result: Matrix): void;
  20904. /**
  20905. * Creates a new zero matrix
  20906. * @returns a new zero matrix
  20907. */
  20908. static Zero(): Matrix;
  20909. /**
  20910. * Creates a new rotation matrix for "angle" radians around the X axis
  20911. * @param angle defines the angle (in radians) to use
  20912. * @return the new matrix
  20913. */
  20914. static RotationX(angle: number): Matrix;
  20915. /**
  20916. * Creates a new matrix as the invert of a given matrix
  20917. * @param source defines the source matrix
  20918. * @returns the new matrix
  20919. */
  20920. static Invert(source: Matrix): Matrix;
  20921. /**
  20922. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  20923. * @param angle defines the angle (in radians) to use
  20924. * @param result defines the target matrix
  20925. */
  20926. static RotationXToRef(angle: number, result: Matrix): void;
  20927. /**
  20928. * Creates a new rotation matrix for "angle" radians around the Y axis
  20929. * @param angle defines the angle (in radians) to use
  20930. * @return the new matrix
  20931. */
  20932. static RotationY(angle: number): Matrix;
  20933. /**
  20934. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  20935. * @param angle defines the angle (in radians) to use
  20936. * @param result defines the target matrix
  20937. */
  20938. static RotationYToRef(angle: number, result: Matrix): void;
  20939. /**
  20940. * Creates a new rotation matrix for "angle" radians around the Z axis
  20941. * @param angle defines the angle (in radians) to use
  20942. * @return the new matrix
  20943. */
  20944. static RotationZ(angle: number): Matrix;
  20945. /**
  20946. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  20947. * @param angle defines the angle (in radians) to use
  20948. * @param result defines the target matrix
  20949. */
  20950. static RotationZToRef(angle: number, result: Matrix): void;
  20951. /**
  20952. * Creates a new rotation matrix for "angle" radians around the given axis
  20953. * @param axis defines the axis to use
  20954. * @param angle defines the angle (in radians) to use
  20955. * @return the new matrix
  20956. */
  20957. static RotationAxis(axis: Vector3, angle: number): Matrix;
  20958. /**
  20959. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  20960. * @param axis defines the axis to use
  20961. * @param angle defines the angle (in radians) to use
  20962. * @param result defines the target matrix
  20963. */
  20964. static RotationAxisToRef(axis: Vector3, angle: number, result: Matrix): void;
  20965. /**
  20966. * Creates a rotation matrix
  20967. * @param yaw defines the yaw angle in radians (Y axis)
  20968. * @param pitch defines the pitch angle in radians (X axis)
  20969. * @param roll defines the roll angle in radians (X axis)
  20970. * @returns the new rotation matrix
  20971. */
  20972. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  20973. /**
  20974. * Creates a rotation matrix and stores it in a given matrix
  20975. * @param yaw defines the yaw angle in radians (Y axis)
  20976. * @param pitch defines the pitch angle in radians (X axis)
  20977. * @param roll defines the roll angle in radians (X axis)
  20978. * @param result defines the target matrix
  20979. */
  20980. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  20981. /**
  20982. * Creates a scaling matrix
  20983. * @param x defines the scale factor on X axis
  20984. * @param y defines the scale factor on Y axis
  20985. * @param z defines the scale factor on Z axis
  20986. * @returns the new matrix
  20987. */
  20988. static Scaling(x: number, y: number, z: number): Matrix;
  20989. /**
  20990. * Creates a scaling matrix and stores it in a given matrix
  20991. * @param x defines the scale factor on X axis
  20992. * @param y defines the scale factor on Y axis
  20993. * @param z defines the scale factor on Z axis
  20994. * @param result defines the target matrix
  20995. */
  20996. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  20997. /**
  20998. * Creates a translation matrix
  20999. * @param x defines the translation on X axis
  21000. * @param y defines the translation on Y axis
  21001. * @param z defines the translationon Z axis
  21002. * @returns the new matrix
  21003. */
  21004. static Translation(x: number, y: number, z: number): Matrix;
  21005. /**
  21006. * Creates a translation matrix and stores it in a given matrix
  21007. * @param x defines the translation on X axis
  21008. * @param y defines the translation on Y axis
  21009. * @param z defines the translationon Z axis
  21010. * @param result defines the target matrix
  21011. */
  21012. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  21013. /**
  21014. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  21015. * @param startValue defines the start value
  21016. * @param endValue defines the end value
  21017. * @param gradient defines the gradient factor
  21018. * @returns the new matrix
  21019. */
  21020. static Lerp(startValue: Matrix, endValue: Matrix, gradient: number): Matrix;
  21021. /**
  21022. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  21023. * @param startValue defines the start value
  21024. * @param endValue defines the end value
  21025. * @param gradient defines the gradient factor
  21026. * @param result defines the Matrix object where to store data
  21027. */
  21028. static LerpToRef(startValue: Matrix, endValue: Matrix, gradient: number, result: Matrix): void;
  21029. /**
  21030. * Builds a new matrix whose values are computed by:
  21031. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  21032. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  21033. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  21034. * @param startValue defines the first matrix
  21035. * @param endValue defines the second matrix
  21036. * @param gradient defines the gradient between the two matrices
  21037. * @returns the new matrix
  21038. */
  21039. static DecomposeLerp(startValue: Matrix, endValue: Matrix, gradient: number): Matrix;
  21040. /**
  21041. * Update a matrix to values which are computed by:
  21042. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  21043. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  21044. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  21045. * @param startValue defines the first matrix
  21046. * @param endValue defines the second matrix
  21047. * @param gradient defines the gradient between the two matrices
  21048. * @param result defines the target matrix
  21049. */
  21050. static DecomposeLerpToRef(startValue: Matrix, endValue: Matrix, gradient: number, result: Matrix): void;
  21051. /**
  21052. * 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"
  21053. * This function works in left handed mode
  21054. * @param eye defines the final position of the entity
  21055. * @param target defines where the entity should look at
  21056. * @param up defines the up vector for the entity
  21057. * @returns the new matrix
  21058. */
  21059. static LookAtLH(eye: Vector3, target: Vector3, up: Vector3): Matrix;
  21060. /**
  21061. * 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".
  21062. * This function works in left handed mode
  21063. * @param eye defines the final position of the entity
  21064. * @param target defines where the entity should look at
  21065. * @param up defines the up vector for the entity
  21066. * @param result defines the target matrix
  21067. */
  21068. static LookAtLHToRef(eye: Vector3, target: Vector3, up: Vector3, result: Matrix): void;
  21069. /**
  21070. * 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"
  21071. * This function works in right handed mode
  21072. * @param eye defines the final position of the entity
  21073. * @param target defines where the entity should look at
  21074. * @param up defines the up vector for the entity
  21075. * @returns the new matrix
  21076. */
  21077. static LookAtRH(eye: Vector3, target: Vector3, up: Vector3): Matrix;
  21078. /**
  21079. * 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".
  21080. * This function works in right handed mode
  21081. * @param eye defines the final position of the entity
  21082. * @param target defines where the entity should look at
  21083. * @param up defines the up vector for the entity
  21084. * @param result defines the target matrix
  21085. */
  21086. static LookAtRHToRef(eye: Vector3, target: Vector3, up: Vector3, result: Matrix): void;
  21087. /**
  21088. * Create a left-handed orthographic projection matrix
  21089. * @param width defines the viewport width
  21090. * @param height defines the viewport height
  21091. * @param znear defines the near clip plane
  21092. * @param zfar defines the far clip plane
  21093. * @returns a new matrix as a left-handed orthographic projection matrix
  21094. */
  21095. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  21096. /**
  21097. * Store a left-handed orthographic projection to a given matrix
  21098. * @param width defines the viewport width
  21099. * @param height defines the viewport height
  21100. * @param znear defines the near clip plane
  21101. * @param zfar defines the far clip plane
  21102. * @param result defines the target matrix
  21103. */
  21104. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  21105. /**
  21106. * Create a left-handed orthographic projection matrix
  21107. * @param left defines the viewport left coordinate
  21108. * @param right defines the viewport right coordinate
  21109. * @param bottom defines the viewport bottom coordinate
  21110. * @param top defines the viewport top coordinate
  21111. * @param znear defines the near clip plane
  21112. * @param zfar defines the far clip plane
  21113. * @returns a new matrix as a left-handed orthographic projection matrix
  21114. */
  21115. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  21116. /**
  21117. * Stores a left-handed orthographic projection into a given matrix
  21118. * @param left defines the viewport left coordinate
  21119. * @param right defines the viewport right coordinate
  21120. * @param bottom defines the viewport bottom coordinate
  21121. * @param top defines the viewport top coordinate
  21122. * @param znear defines the near clip plane
  21123. * @param zfar defines the far clip plane
  21124. * @param result defines the target matrix
  21125. */
  21126. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  21127. /**
  21128. * Creates a right-handed orthographic projection matrix
  21129. * @param left defines the viewport left coordinate
  21130. * @param right defines the viewport right coordinate
  21131. * @param bottom defines the viewport bottom coordinate
  21132. * @param top defines the viewport top coordinate
  21133. * @param znear defines the near clip plane
  21134. * @param zfar defines the far clip plane
  21135. * @returns a new matrix as a right-handed orthographic projection matrix
  21136. */
  21137. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  21138. /**
  21139. * Stores a right-handed orthographic projection into a given matrix
  21140. * @param left defines the viewport left coordinate
  21141. * @param right defines the viewport right coordinate
  21142. * @param bottom defines the viewport bottom coordinate
  21143. * @param top defines the viewport top coordinate
  21144. * @param znear defines the near clip plane
  21145. * @param zfar defines the far clip plane
  21146. * @param result defines the target matrix
  21147. */
  21148. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  21149. /**
  21150. * Creates a left-handed perspective projection matrix
  21151. * @param width defines the viewport width
  21152. * @param height defines the viewport height
  21153. * @param znear defines the near clip plane
  21154. * @param zfar defines the far clip plane
  21155. * @returns a new matrix as a left-handed perspective projection matrix
  21156. */
  21157. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  21158. /**
  21159. * Creates a left-handed perspective projection matrix
  21160. * @param fov defines the horizontal field of view
  21161. * @param aspect defines the aspect ratio
  21162. * @param znear defines the near clip plane
  21163. * @param zfar defines the far clip plane
  21164. * @returns a new matrix as a left-handed perspective projection matrix
  21165. */
  21166. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  21167. /**
  21168. * Stores a left-handed perspective projection into a given matrix
  21169. * @param fov defines the horizontal field of view
  21170. * @param aspect defines the aspect ratio
  21171. * @param znear defines the near clip plane
  21172. * @param zfar defines the far clip plane
  21173. * @param result defines the target matrix
  21174. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  21175. */
  21176. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  21177. /**
  21178. * Creates a right-handed perspective projection matrix
  21179. * @param fov defines the horizontal field of view
  21180. * @param aspect defines the aspect ratio
  21181. * @param znear defines the near clip plane
  21182. * @param zfar defines the far clip plane
  21183. * @returns a new matrix as a right-handed perspective projection matrix
  21184. */
  21185. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  21186. /**
  21187. * Stores a right-handed perspective projection into a given matrix
  21188. * @param fov defines the horizontal field of view
  21189. * @param aspect defines the aspect ratio
  21190. * @param znear defines the near clip plane
  21191. * @param zfar defines the far clip plane
  21192. * @param result defines the target matrix
  21193. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  21194. */
  21195. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  21196. /**
  21197. * Stores a perspective projection for WebVR info a given matrix
  21198. * @param fov defines the field of view
  21199. * @param znear defines the near clip plane
  21200. * @param zfar defines the far clip plane
  21201. * @param result defines the target matrix
  21202. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  21203. */
  21204. static PerspectiveFovWebVRToRef(fov: {
  21205. upDegrees: number;
  21206. downDegrees: number;
  21207. leftDegrees: number;
  21208. rightDegrees: number;
  21209. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  21210. /**
  21211. * Computes a complete transformation matrix
  21212. * @param viewport defines the viewport to use
  21213. * @param world defines the world matrix
  21214. * @param view defines the view matrix
  21215. * @param projection defines the projection matrix
  21216. * @param zmin defines the near clip plane
  21217. * @param zmax defines the far clip plane
  21218. * @returns the transformation matrix
  21219. */
  21220. static GetFinalMatrix(viewport: Viewport, world: Matrix, view: Matrix, projection: Matrix, zmin: number, zmax: number): Matrix;
  21221. /**
  21222. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  21223. * @param matrix defines the matrix to use
  21224. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  21225. */
  21226. static GetAsMatrix2x2(matrix: Matrix): Float32Array;
  21227. /**
  21228. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  21229. * @param matrix defines the matrix to use
  21230. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  21231. */
  21232. static GetAsMatrix3x3(matrix: Matrix): Float32Array;
  21233. /**
  21234. * Compute the transpose of a given matrix
  21235. * @param matrix defines the matrix to transpose
  21236. * @returns the new matrix
  21237. */
  21238. static Transpose(matrix: Matrix): Matrix;
  21239. /**
  21240. * Compute the transpose of a matrix and store it in a target matrix
  21241. * @param matrix defines the matrix to transpose
  21242. * @param result defines the target matrix
  21243. */
  21244. static TransposeToRef(matrix: Matrix, result: Matrix): void;
  21245. /**
  21246. * Computes a reflection matrix from a plane
  21247. * @param plane defines the reflection plane
  21248. * @returns a new matrix
  21249. */
  21250. static Reflection(plane: Plane): Matrix;
  21251. /**
  21252. * Computes a reflection matrix from a plane
  21253. * @param plane defines the reflection plane
  21254. * @param result defines the target matrix
  21255. */
  21256. static ReflectionToRef(plane: Plane, result: Matrix): void;
  21257. /**
  21258. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  21259. * @param xaxis defines the value of the 1st axis
  21260. * @param yaxis defines the value of the 2nd axis
  21261. * @param zaxis defines the value of the 3rd axis
  21262. * @param result defines the target matrix
  21263. */
  21264. static FromXYZAxesToRef(xaxis: Vector3, yaxis: Vector3, zaxis: Vector3, result: Matrix): void;
  21265. /**
  21266. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  21267. * @param quat defines the quaternion to use
  21268. * @param result defines the target matrix
  21269. */
  21270. static FromQuaternionToRef(quat: Quaternion, result: Matrix): void;
  21271. }
  21272. class Plane {
  21273. normal: Vector3;
  21274. d: number;
  21275. /**
  21276. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  21277. */
  21278. constructor(a: number, b: number, c: number, d: number);
  21279. /**
  21280. * Returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  21281. */
  21282. asArray(): number[];
  21283. /**
  21284. * Returns a new plane copied from the current Plane.
  21285. */
  21286. clone(): Plane;
  21287. /**
  21288. * Returns the string "Plane".
  21289. */
  21290. getClassName(): string;
  21291. /**
  21292. * Returns the Plane hash code.
  21293. */
  21294. getHashCode(): number;
  21295. /**
  21296. * Normalize the current Plane in place.
  21297. * Returns the updated Plane.
  21298. */
  21299. normalize(): Plane;
  21300. /**
  21301. * Returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  21302. */
  21303. transform(transformation: Matrix): Plane;
  21304. /**
  21305. * Returns the dot product (float) of the point coordinates and the plane normal.
  21306. */
  21307. dotCoordinate(point: Vector3): number;
  21308. /**
  21309. * Updates the current Plane from the plane defined by the three given points.
  21310. * Returns the updated Plane.
  21311. */
  21312. copyFromPoints(point1: Vector3, point2: Vector3, point3: Vector3): Plane;
  21313. /**
  21314. * Boolean : True is the vector "direction" is the same side than the plane normal.
  21315. */
  21316. isFrontFacingTo(direction: Vector3, epsilon: number): boolean;
  21317. /**
  21318. * Returns the signed distance (float) from the given point to the Plane.
  21319. */
  21320. signedDistanceTo(point: Vector3): number;
  21321. /**
  21322. * Returns a new Plane from the given array.
  21323. */
  21324. static FromArray(array: ArrayLike<number>): Plane;
  21325. /**
  21326. * Returns a new Plane defined by the three given points.
  21327. */
  21328. static FromPoints(point1: Vector3, point2: Vector3, point3: Vector3): Plane;
  21329. /**
  21330. * Returns a new Plane the normal vector to this plane at the given origin point.
  21331. * Note : the vector "normal" is updated because normalized.
  21332. */
  21333. static FromPositionAndNormal(origin: Vector3, normal: Vector3): Plane;
  21334. /**
  21335. * Returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  21336. */
  21337. static SignedDistanceToPlaneFromPositionAndNormal(origin: Vector3, normal: Vector3, point: Vector3): number;
  21338. }
  21339. /**
  21340. * Class used to represent a viewport on screen
  21341. */
  21342. class Viewport {
  21343. /** viewport left coordinate */
  21344. x: number;
  21345. /** viewport top coordinate */
  21346. y: number;
  21347. /**viewport width */
  21348. width: number;
  21349. /** viewport height */
  21350. height: number;
  21351. /**
  21352. * Creates a Viewport object located at (x, y) and sized (width, height)
  21353. * @param x defines viewport left coordinate
  21354. * @param y defines viewport top coordinate
  21355. * @param width defines the viewport width
  21356. * @param height defines the viewport height
  21357. */
  21358. constructor(
  21359. /** viewport left coordinate */
  21360. x: number,
  21361. /** viewport top coordinate */
  21362. y: number,
  21363. /**viewport width */
  21364. width: number,
  21365. /** viewport height */
  21366. height: number);
  21367. /**
  21368. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  21369. * @param renderWidthOrEngine defines either an engine or the rendering width
  21370. * @param renderHeight defines the rendering height
  21371. * @returns a new Viewport
  21372. */
  21373. toGlobal(renderWidthOrEngine: number | Engine, renderHeight: number): Viewport;
  21374. /**
  21375. * Returns a new Viewport copied from the current one
  21376. * @returns a new Viewport
  21377. */
  21378. clone(): Viewport;
  21379. }
  21380. class Frustum {
  21381. /**
  21382. * Returns a new array of 6 Frustum planes computed by the given transformation matrix.
  21383. */
  21384. static GetPlanes(transform: Matrix): Plane[];
  21385. static GetNearPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  21386. static GetFarPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  21387. static GetLeftPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  21388. static GetRightPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  21389. static GetTopPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  21390. static GetBottomPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  21391. /**
  21392. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  21393. */
  21394. static GetPlanesToRef(transform: Matrix, frustumPlanes: Plane[]): void;
  21395. }
  21396. /** Defines supported spaces */
  21397. enum Space {
  21398. /** Local (object) space */
  21399. LOCAL = 0,
  21400. /** World space */
  21401. WORLD = 1,
  21402. /** Bone space */
  21403. BONE = 2
  21404. }
  21405. /** Defines the 3 main axes */
  21406. class Axis {
  21407. /** X axis */
  21408. static X: Vector3;
  21409. /** Y axis */
  21410. static Y: Vector3;
  21411. /** Z axis */
  21412. static Z: Vector3;
  21413. }
  21414. /** Class used to represent a Bezier curve */
  21415. class BezierCurve {
  21416. /**
  21417. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  21418. * @param t defines the time
  21419. * @param x1 defines the left coordinate on X axis
  21420. * @param y1 defines the left coordinate on Y axis
  21421. * @param x2 defines the right coordinate on X axis
  21422. * @param y2 defines the right coordinate on Y axis
  21423. * @returns the interpolated value
  21424. */
  21425. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  21426. }
  21427. /**
  21428. * Defines potential orientation for back face culling
  21429. */
  21430. enum Orientation {
  21431. /**
  21432. * Clockwise
  21433. */
  21434. CW = 0,
  21435. /** Counter clockwise */
  21436. CCW = 1
  21437. }
  21438. /**
  21439. * Defines angle representation
  21440. */
  21441. class Angle {
  21442. private _radians;
  21443. /**
  21444. * Creates an Angle object of "radians" radians (float).
  21445. */
  21446. constructor(radians: number);
  21447. /**
  21448. * Get value in degrees
  21449. * @returns the Angle value in degrees (float)
  21450. */
  21451. degrees(): number;
  21452. /**
  21453. * Get value in radians
  21454. * @returns the Angle value in radians (float)
  21455. */
  21456. radians(): number;
  21457. /**
  21458. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  21459. * @param a defines first vector
  21460. * @param b defines second vector
  21461. * @returns a new Angle
  21462. */
  21463. static BetweenTwoPoints(a: Vector2, b: Vector2): Angle;
  21464. /**
  21465. * Gets a new Angle object from the given float in radians
  21466. * @param radians defines the angle value in radians
  21467. * @returns a new Angle
  21468. */
  21469. static FromRadians(radians: number): Angle;
  21470. /**
  21471. * Gets a new Angle object from the given float in degrees
  21472. * @param degrees defines the angle value in degrees
  21473. * @returns a new Angle
  21474. */
  21475. static FromDegrees(degrees: number): Angle;
  21476. }
  21477. /**
  21478. * This represents an arc in a 2d space.
  21479. */
  21480. class Arc2 {
  21481. /** Defines the start point of the arc */
  21482. startPoint: Vector2;
  21483. /** Defines the mid point of the arc */
  21484. midPoint: Vector2;
  21485. /** Defines the end point of the arc */
  21486. endPoint: Vector2;
  21487. /**
  21488. * Defines the center point of the arc.
  21489. */
  21490. centerPoint: Vector2;
  21491. /**
  21492. * Defines the radius of the arc.
  21493. */
  21494. radius: number;
  21495. /**
  21496. * Defines the angle of the arc (from mid point to end point).
  21497. */
  21498. angle: Angle;
  21499. /**
  21500. * Defines the start angle of the arc (from start point to middle point).
  21501. */
  21502. startAngle: Angle;
  21503. /**
  21504. * Defines the orientation of the arc (clock wise/counter clock wise).
  21505. */
  21506. orientation: Orientation;
  21507. /**
  21508. * Creates an Arc object from the three given points : start, middle and end.
  21509. * @param startPoint Defines the start point of the arc
  21510. * @param midPoint Defines the midlle point of the arc
  21511. * @param endPoint Defines the end point of the arc
  21512. */
  21513. constructor(
  21514. /** Defines the start point of the arc */
  21515. startPoint: Vector2,
  21516. /** Defines the mid point of the arc */
  21517. midPoint: Vector2,
  21518. /** Defines the end point of the arc */
  21519. endPoint: Vector2);
  21520. }
  21521. class Path2 {
  21522. private _points;
  21523. private _length;
  21524. closed: boolean;
  21525. /**
  21526. * Creates a Path2 object from the starting 2D coordinates x and y.
  21527. */
  21528. constructor(x: number, y: number);
  21529. /**
  21530. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  21531. * Returns the updated Path2.
  21532. */
  21533. addLineTo(x: number, y: number): Path2;
  21534. /**
  21535. * 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.
  21536. * Returns the updated Path2.
  21537. */
  21538. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  21539. /**
  21540. * Closes the Path2.
  21541. * Returns the Path2.
  21542. */
  21543. close(): Path2;
  21544. /**
  21545. * Returns the Path2 total length (float).
  21546. */
  21547. length(): number;
  21548. /**
  21549. * Returns the Path2 internal array of points.
  21550. */
  21551. getPoints(): Vector2[];
  21552. /**
  21553. * Returns a new Vector2 located at a percentage of the Path2 total length on this path.
  21554. */
  21555. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  21556. /**
  21557. * Returns a new Path2 starting at the coordinates (x, y).
  21558. */
  21559. static StartingAt(x: number, y: number): Path2;
  21560. }
  21561. class Path3D {
  21562. path: Vector3[];
  21563. private _curve;
  21564. private _distances;
  21565. private _tangents;
  21566. private _normals;
  21567. private _binormals;
  21568. private _raw;
  21569. /**
  21570. * new Path3D(path, normal, raw)
  21571. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  21572. * please read the description in the tutorial : http://doc.babylonjs.com/tutorials/How_to_use_Path3D
  21573. * path : an array of Vector3, the curve axis of the Path3D
  21574. * normal (optional) : Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  21575. * raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  21576. */
  21577. constructor(path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  21578. /**
  21579. * Returns the Path3D array of successive Vector3 designing its curve.
  21580. */
  21581. getCurve(): Vector3[];
  21582. /**
  21583. * Returns an array populated with tangent vectors on each Path3D curve point.
  21584. */
  21585. getTangents(): Vector3[];
  21586. /**
  21587. * Returns an array populated with normal vectors on each Path3D curve point.
  21588. */
  21589. getNormals(): Vector3[];
  21590. /**
  21591. * Returns an array populated with binormal vectors on each Path3D curve point.
  21592. */
  21593. getBinormals(): Vector3[];
  21594. /**
  21595. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  21596. */
  21597. getDistances(): number[];
  21598. /**
  21599. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  21600. * Returns the same object updated.
  21601. */
  21602. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  21603. private _compute;
  21604. private _getFirstNonNullVector;
  21605. private _getLastNonNullVector;
  21606. private _normalVector;
  21607. }
  21608. class Curve3 {
  21609. private _points;
  21610. private _length;
  21611. /**
  21612. * Returns a Curve3 object along a Quadratic Bezier curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#quadratic-bezier-curve
  21613. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  21614. * @param v1 (Vector3) the control point
  21615. * @param v2 (Vector3) the end point of the Quadratic Bezier
  21616. * @param nbPoints (integer) the wanted number of points in the curve
  21617. */
  21618. static CreateQuadraticBezier(v0: Vector3, v1: Vector3, v2: Vector3, nbPoints: number): Curve3;
  21619. /**
  21620. * Returns a Curve3 object along a Cubic Bezier curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#cubic-bezier-curve
  21621. * @param v0 (Vector3) the origin point of the Cubic Bezier
  21622. * @param v1 (Vector3) the first control point
  21623. * @param v2 (Vector3) the second control point
  21624. * @param v3 (Vector3) the end point of the Cubic Bezier
  21625. * @param nbPoints (integer) the wanted number of points in the curve
  21626. */
  21627. static CreateCubicBezier(v0: Vector3, v1: Vector3, v2: Vector3, v3: Vector3, nbPoints: number): Curve3;
  21628. /**
  21629. * Returns a Curve3 object along a Hermite Spline curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#hermite-spline
  21630. * @param p1 (Vector3) the origin point of the Hermite Spline
  21631. * @param t1 (Vector3) the tangent vector at the origin point
  21632. * @param p2 (Vector3) the end point of the Hermite Spline
  21633. * @param t2 (Vector3) the tangent vector at the end point
  21634. * @param nbPoints (integer) the wanted number of points in the curve
  21635. */
  21636. static CreateHermiteSpline(p1: Vector3, t1: Vector3, p2: Vector3, t2: Vector3, nbPoints: number): Curve3;
  21637. /**
  21638. * Returns a Curve3 object along a CatmullRom Spline curve :
  21639. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  21640. * @param nbPoints (integer) the wanted number of points between each curve control points
  21641. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  21642. */
  21643. static CreateCatmullRomSpline(points: Vector3[], nbPoints: number, closed?: boolean): Curve3;
  21644. /**
  21645. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  21646. * A Curve3 is designed from a series of successive Vector3.
  21647. * Tuto : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#curve3-object
  21648. */
  21649. constructor(points: Vector3[]);
  21650. /**
  21651. * Returns the Curve3 stored array of successive Vector3
  21652. */
  21653. getPoints(): Vector3[];
  21654. /**
  21655. * Returns the computed length (float) of the curve.
  21656. */
  21657. length(): number;
  21658. /**
  21659. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  21660. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  21661. * curveA and curveB keep unchanged.
  21662. */
  21663. continue(curve: Curve3): Curve3;
  21664. private _computeLength;
  21665. }
  21666. class PositionNormalVertex {
  21667. position: Vector3;
  21668. normal: Vector3;
  21669. constructor(position?: Vector3, normal?: Vector3);
  21670. clone(): PositionNormalVertex;
  21671. }
  21672. class PositionNormalTextureVertex {
  21673. position: Vector3;
  21674. normal: Vector3;
  21675. uv: Vector2;
  21676. constructor(position?: Vector3, normal?: Vector3, uv?: Vector2);
  21677. clone(): PositionNormalTextureVertex;
  21678. }
  21679. class Tmp {
  21680. static Color3: Color3[];
  21681. static Color4: Color4[];
  21682. static Vector2: Vector2[];
  21683. static Vector3: Vector3[];
  21684. static Vector4: Vector4[];
  21685. static Quaternion: Quaternion[];
  21686. static Matrix: Matrix[];
  21687. }
  21688. }
  21689. declare module BABYLON {
  21690. /**
  21691. * Class representing spherical polynomial coefficients to the 3rd degree
  21692. */
  21693. class SphericalPolynomial {
  21694. /**
  21695. * The x coefficients of the spherical polynomial
  21696. */
  21697. x: Vector3;
  21698. /**
  21699. * The y coefficients of the spherical polynomial
  21700. */
  21701. y: Vector3;
  21702. /**
  21703. * The z coefficients of the spherical polynomial
  21704. */
  21705. z: Vector3;
  21706. /**
  21707. * The xx coefficients of the spherical polynomial
  21708. */
  21709. xx: Vector3;
  21710. /**
  21711. * The yy coefficients of the spherical polynomial
  21712. */
  21713. yy: Vector3;
  21714. /**
  21715. * The zz coefficients of the spherical polynomial
  21716. */
  21717. zz: Vector3;
  21718. /**
  21719. * The xy coefficients of the spherical polynomial
  21720. */
  21721. xy: Vector3;
  21722. /**
  21723. * The yz coefficients of the spherical polynomial
  21724. */
  21725. yz: Vector3;
  21726. /**
  21727. * The zx coefficients of the spherical polynomial
  21728. */
  21729. zx: Vector3;
  21730. /**
  21731. * Adds an ambient color to the spherical polynomial
  21732. * @param color the color to add
  21733. */
  21734. addAmbient(color: Color3): void;
  21735. /**
  21736. * Scales the spherical polynomial by the given amount
  21737. * @param scale the amount to scale
  21738. */
  21739. scale(scale: number): void;
  21740. /**
  21741. * Gets the spherical polynomial from harmonics
  21742. * @param harmonics the spherical harmonics
  21743. * @returns the spherical polynomial
  21744. */
  21745. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  21746. /**
  21747. * Constructs a spherical polynomial from an array.
  21748. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  21749. * @returns the spherical polynomial
  21750. */
  21751. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  21752. }
  21753. /**
  21754. * Class representing spherical harmonics coefficients to the 3rd degree
  21755. */
  21756. class SphericalHarmonics {
  21757. /**
  21758. * The l0,0 coefficients of the spherical harmonics
  21759. */
  21760. l00: Vector3;
  21761. /**
  21762. * The l1,-1 coefficients of the spherical harmonics
  21763. */
  21764. l1_1: Vector3;
  21765. /**
  21766. * The l1,0 coefficients of the spherical harmonics
  21767. */
  21768. l10: Vector3;
  21769. /**
  21770. * The l1,1 coefficients of the spherical harmonics
  21771. */
  21772. l11: Vector3;
  21773. /**
  21774. * The l2,-2 coefficients of the spherical harmonics
  21775. */
  21776. l2_2: Vector3;
  21777. /**
  21778. * The l2,-1 coefficients of the spherical harmonics
  21779. */
  21780. l2_1: Vector3;
  21781. /**
  21782. * The l2,0 coefficients of the spherical harmonics
  21783. */
  21784. l20: Vector3;
  21785. /**
  21786. * The l2,1 coefficients of the spherical harmonics
  21787. */
  21788. l21: Vector3;
  21789. /**
  21790. * The l2,2 coefficients of the spherical harmonics
  21791. */
  21792. lL22: Vector3;
  21793. /**
  21794. * Adds a light to the spherical harmonics
  21795. * @param direction the direction of the light
  21796. * @param color the color of the light
  21797. * @param deltaSolidAngle the delta solid angle of the light
  21798. */
  21799. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  21800. /**
  21801. * Scales the spherical harmonics by the given amount
  21802. * @param scale the amount to scale
  21803. */
  21804. scale(scale: number): void;
  21805. /**
  21806. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  21807. *
  21808. * ```
  21809. * E_lm = A_l * L_lm
  21810. * ```
  21811. *
  21812. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  21813. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  21814. * the scaling factors are given in equation 9.
  21815. */
  21816. convertIncidentRadianceToIrradiance(): void;
  21817. /**
  21818. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  21819. *
  21820. * ```
  21821. * L = (1/pi) * E * rho
  21822. * ```
  21823. *
  21824. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  21825. */
  21826. convertIrradianceToLambertianRadiance(): void;
  21827. /**
  21828. * Gets the spherical harmonics from polynomial
  21829. * @param polynomial the spherical polynomial
  21830. * @returns the spherical harmonics
  21831. */
  21832. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  21833. /**
  21834. * Constructs a spherical harmonics from an array.
  21835. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  21836. * @returns the spherical harmonics
  21837. */
  21838. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  21839. }
  21840. }
  21841. declare module BABYLON {
  21842. /**
  21843. * Defines a target to use with MorphTargetManager
  21844. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  21845. */
  21846. class MorphTarget implements IAnimatable {
  21847. /** defines the name of the target */
  21848. name: string;
  21849. /**
  21850. * Gets or sets the list of animations
  21851. */
  21852. animations: Animation[];
  21853. private _scene;
  21854. private _positions;
  21855. private _normals;
  21856. private _tangents;
  21857. private _influence;
  21858. /**
  21859. * Observable raised when the influence changes
  21860. */
  21861. onInfluenceChanged: Observable<boolean>;
  21862. /**
  21863. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  21864. */
  21865. influence: number;
  21866. private _animationPropertiesOverride;
  21867. /**
  21868. * Gets or sets the animation properties override
  21869. */
  21870. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  21871. /**
  21872. * Creates a new MorphTarget
  21873. * @param name defines the name of the target
  21874. * @param influence defines the influence to use
  21875. */
  21876. constructor(
  21877. /** defines the name of the target */
  21878. name: string, influence?: number, scene?: Nullable<Scene>);
  21879. /**
  21880. * Gets a boolean defining if the target contains position data
  21881. */
  21882. readonly hasPositions: boolean;
  21883. /**
  21884. * Gets a boolean defining if the target contains normal data
  21885. */
  21886. readonly hasNormals: boolean;
  21887. /**
  21888. * Gets a boolean defining if the target contains tangent data
  21889. */
  21890. readonly hasTangents: boolean;
  21891. /**
  21892. * Affects position data to this target
  21893. * @param data defines the position data to use
  21894. */
  21895. setPositions(data: Nullable<FloatArray>): void;
  21896. /**
  21897. * Gets the position data stored in this target
  21898. * @returns a FloatArray containing the position data (or null if not present)
  21899. */
  21900. getPositions(): Nullable<FloatArray>;
  21901. /**
  21902. * Affects normal data to this target
  21903. * @param data defines the normal data to use
  21904. */
  21905. setNormals(data: Nullable<FloatArray>): void;
  21906. /**
  21907. * Gets the normal data stored in this target
  21908. * @returns a FloatArray containing the normal data (or null if not present)
  21909. */
  21910. getNormals(): Nullable<FloatArray>;
  21911. /**
  21912. * Affects tangent data to this target
  21913. * @param data defines the tangent data to use
  21914. */
  21915. setTangents(data: Nullable<FloatArray>): void;
  21916. /**
  21917. * Gets the tangent data stored in this target
  21918. * @returns a FloatArray containing the tangent data (or null if not present)
  21919. */
  21920. getTangents(): Nullable<FloatArray>;
  21921. /**
  21922. * Serializes the current target into a Serialization object
  21923. * @returns the serialized object
  21924. */
  21925. serialize(): any;
  21926. /**
  21927. * Creates a new target from serialized data
  21928. * @param serializationObject defines the serialized data to use
  21929. * @returns a new MorphTarget
  21930. */
  21931. static Parse(serializationObject: any): MorphTarget;
  21932. /**
  21933. * Creates a MorphTarget from mesh data
  21934. * @param mesh defines the source mesh
  21935. * @param name defines the name to use for the new target
  21936. * @param influence defines the influence to attach to the target
  21937. * @returns a new MorphTarget
  21938. */
  21939. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  21940. }
  21941. }
  21942. declare module BABYLON {
  21943. /**
  21944. * This class is used to deform meshes using morphing between different targets
  21945. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  21946. */
  21947. class MorphTargetManager {
  21948. private _targets;
  21949. private _targetObservable;
  21950. private _activeTargets;
  21951. private _scene;
  21952. private _influences;
  21953. private _supportsNormals;
  21954. private _supportsTangents;
  21955. private _vertexCount;
  21956. private _uniqueId;
  21957. private _tempInfluences;
  21958. /**
  21959. * Creates a new MorphTargetManager
  21960. * @param scene defines the current scene
  21961. */
  21962. constructor(scene?: Nullable<Scene>);
  21963. /**
  21964. * Gets the unique ID of this manager
  21965. */
  21966. readonly uniqueId: number;
  21967. /**
  21968. * Gets the number of vertices handled by this manager
  21969. */
  21970. readonly vertexCount: number;
  21971. /**
  21972. * Gets a boolean indicating if this manager supports morphing of normals
  21973. */
  21974. readonly supportsNormals: boolean;
  21975. /**
  21976. * Gets a boolean indicating if this manager supports morphing of tangents
  21977. */
  21978. readonly supportsTangents: boolean;
  21979. /**
  21980. * Gets the number of targets stored in this manager
  21981. */
  21982. readonly numTargets: number;
  21983. /**
  21984. * Gets the number of influencers (ie. the number of targets with influences > 0)
  21985. */
  21986. readonly numInfluencers: number;
  21987. /**
  21988. * Gets the list of influences (one per target)
  21989. */
  21990. readonly influences: Float32Array;
  21991. /**
  21992. * Gets the active target at specified index. An active target is a target with an influence > 0
  21993. * @param index defines the index to check
  21994. * @returns the requested target
  21995. */
  21996. getActiveTarget(index: number): MorphTarget;
  21997. /**
  21998. * Gets the target at specified index
  21999. * @param index defines the index to check
  22000. * @returns the requested target
  22001. */
  22002. getTarget(index: number): MorphTarget;
  22003. /**
  22004. * Add a new target to this manager
  22005. * @param target defines the target to add
  22006. */
  22007. addTarget(target: MorphTarget): void;
  22008. /**
  22009. * Removes a target from the manager
  22010. * @param target defines the target to remove
  22011. */
  22012. removeTarget(target: MorphTarget): void;
  22013. /**
  22014. * Serializes the current manager into a Serialization object
  22015. * @returns the serialized object
  22016. */
  22017. serialize(): any;
  22018. private _syncActiveTargets;
  22019. /**
  22020. * Syncrhonize the targets with all the meshes using this morph target manager
  22021. */
  22022. synchronize(): void;
  22023. /**
  22024. * Creates a new MorphTargetManager from serialized data
  22025. * @param serializationObject defines the serialized data
  22026. * @param scene defines the hosting scene
  22027. * @returns the new MorphTargetManager
  22028. */
  22029. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  22030. }
  22031. }
  22032. declare module BABYLON {
  22033. /**
  22034. * Class used to store all common mesh properties
  22035. */
  22036. class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  22037. /** No occlusion */
  22038. static OCCLUSION_TYPE_NONE: number;
  22039. /** Occlusion set to optimisitic */
  22040. static OCCLUSION_TYPE_OPTIMISTIC: number;
  22041. /** Occlusion set to strict */
  22042. static OCCLUSION_TYPE_STRICT: number;
  22043. /** Use an accurante occlusion algorithm */
  22044. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  22045. /** Use a conservative occlusion algorithm */
  22046. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  22047. /** Default culling strategy with bounding box and bounding sphere and then frustum culling */
  22048. static readonly CULLINGSTRATEGY_STANDARD: number;
  22049. /** Culling strategy with bounding sphere only and then frustum culling */
  22050. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  22051. /**
  22052. * No billboard
  22053. */
  22054. static readonly BILLBOARDMODE_NONE: number;
  22055. /** Billboard on X axis */
  22056. static readonly BILLBOARDMODE_X: number;
  22057. /** Billboard on Y axis */
  22058. static readonly BILLBOARDMODE_Y: number;
  22059. /** Billboard on Z axis */
  22060. static readonly BILLBOARDMODE_Z: number;
  22061. /** Billboard on all axes */
  22062. static readonly BILLBOARDMODE_ALL: number;
  22063. private _facetPositions;
  22064. private _facetNormals;
  22065. private _facetPartitioning;
  22066. private _facetNb;
  22067. private _partitioningSubdivisions;
  22068. private _partitioningBBoxRatio;
  22069. private _facetDataEnabled;
  22070. private _facetParameters;
  22071. private _bbSize;
  22072. private _subDiv;
  22073. private _facetDepthSort;
  22074. private _facetDepthSortEnabled;
  22075. private _depthSortedIndices;
  22076. private _depthSortedFacets;
  22077. private _facetDepthSortFunction;
  22078. private _facetDepthSortFrom;
  22079. private _facetDepthSortOrigin;
  22080. private _invertedMatrix;
  22081. /** Gets ot sets the culling strategy to use to find visible meshes */
  22082. cullingStrategy: number;
  22083. /**
  22084. * Gets the number of facets in the mesh
  22085. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  22086. */
  22087. readonly facetNb: number;
  22088. /**
  22089. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  22090. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  22091. */
  22092. partitioningSubdivisions: number;
  22093. /**
  22094. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  22095. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  22096. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  22097. */
  22098. partitioningBBoxRatio: number;
  22099. /**
  22100. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  22101. * Works only for updatable meshes.
  22102. * Doesn't work with multi-materials
  22103. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  22104. */
  22105. mustDepthSortFacets: boolean;
  22106. /**
  22107. * The location (Vector3) where the facet depth sort must be computed from.
  22108. * By default, the active camera position.
  22109. * Used only when facet depth sort is enabled
  22110. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  22111. */
  22112. facetDepthSortFrom: Vector3;
  22113. /**
  22114. * gets a boolean indicating if facetData is enabled
  22115. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  22116. */
  22117. readonly isFacetDataEnabled: boolean;
  22118. /** @hidden */
  22119. /**
  22120. * An event triggered when this mesh collides with another one
  22121. */
  22122. onCollideObservable: Observable<AbstractMesh>;
  22123. private _onCollideObserver;
  22124. /** Set a function to call when this mesh collides with another one */
  22125. onCollide: () => void;
  22126. /**
  22127. * An event triggered when the collision's position changes
  22128. */
  22129. onCollisionPositionChangeObservable: Observable<Vector3>;
  22130. private _onCollisionPositionChangeObserver;
  22131. /** Set a function to call when the collision's position changes */
  22132. onCollisionPositionChange: () => void;
  22133. /**
  22134. * An event triggered when material is changed
  22135. */
  22136. onMaterialChangedObservable: Observable<AbstractMesh>;
  22137. /**
  22138. * Gets or sets the orientation for POV movement & rotation
  22139. */
  22140. definedFacingForward: boolean;
  22141. /**
  22142. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  22143. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  22144. * * 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.
  22145. * @see http://doc.babylonjs.com/features/occlusionquery
  22146. */
  22147. occlusionQueryAlgorithmType: number;
  22148. /**
  22149. * 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:
  22150. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  22151. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  22152. * * 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.
  22153. * @see http://doc.babylonjs.com/features/occlusionquery
  22154. */
  22155. occlusionType: number;
  22156. /**
  22157. * 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.
  22158. * The default value is -1 which means don't break the query and wait till the result
  22159. * @see http://doc.babylonjs.com/features/occlusionquery
  22160. */
  22161. occlusionRetryCount: number;
  22162. /** @hidden */
  22163. /** @hidden */
  22164. /**
  22165. * 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
  22166. * @see http://doc.babylonjs.com/features/occlusionquery
  22167. */
  22168. isOccluded: boolean;
  22169. /** @hidden */
  22170. /**
  22171. * Flag to check the progress status of the query
  22172. * @see http://doc.babylonjs.com/features/occlusionquery
  22173. */
  22174. readonly isOcclusionQueryInProgress: boolean;
  22175. /** @hidden */
  22176. private _visibility;
  22177. /**
  22178. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  22179. */
  22180. /**
  22181. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  22182. */
  22183. visibility: number;
  22184. /** Gets or sets the alpha index used to sort transparent meshes
  22185. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  22186. */
  22187. alphaIndex: number;
  22188. /**
  22189. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  22190. */
  22191. isVisible: boolean;
  22192. /**
  22193. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  22194. */
  22195. isPickable: boolean;
  22196. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  22197. showSubMeshesBoundingBox: boolean;
  22198. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  22199. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  22200. */
  22201. isBlocker: boolean;
  22202. /**
  22203. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  22204. */
  22205. enablePointerMoveEvents: boolean;
  22206. /**
  22207. * Specifies the rendering group id for this mesh (0 by default)
  22208. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  22209. */
  22210. renderingGroupId: number;
  22211. private _material;
  22212. /** Gets or sets current material */
  22213. material: Nullable<Material>;
  22214. private _receiveShadows;
  22215. /**
  22216. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  22217. * @see http://doc.babylonjs.com/babylon101/shadows
  22218. */
  22219. receiveShadows: boolean;
  22220. /** Defines color to use when rendering outline */
  22221. outlineColor: Color3;
  22222. /** Define width to use when rendering outline */
  22223. outlineWidth: number;
  22224. /** Defines color to use when rendering overlay */
  22225. overlayColor: Color3;
  22226. /** Defines alpha to use when rendering overlay */
  22227. overlayAlpha: number;
  22228. private _hasVertexAlpha;
  22229. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  22230. hasVertexAlpha: boolean;
  22231. private _useVertexColors;
  22232. /** 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) */
  22233. useVertexColors: boolean;
  22234. private _computeBonesUsingShaders;
  22235. /**
  22236. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  22237. */
  22238. computeBonesUsingShaders: boolean;
  22239. private _numBoneInfluencers;
  22240. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  22241. numBoneInfluencers: number;
  22242. private _applyFog;
  22243. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  22244. applyFog: boolean;
  22245. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  22246. useOctreeForRenderingSelection: boolean;
  22247. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  22248. useOctreeForPicking: boolean;
  22249. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  22250. useOctreeForCollisions: boolean;
  22251. private _layerMask;
  22252. /**
  22253. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  22254. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  22255. */
  22256. layerMask: number;
  22257. /**
  22258. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  22259. */
  22260. alwaysSelectAsActiveMesh: boolean;
  22261. /**
  22262. * Gets or sets the current action manager
  22263. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  22264. */
  22265. actionManager: Nullable<ActionManager>;
  22266. private _checkCollisions;
  22267. private _collisionMask;
  22268. private _collisionGroup;
  22269. /**
  22270. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  22271. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  22272. */
  22273. ellipsoid: Vector3;
  22274. /**
  22275. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  22276. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  22277. */
  22278. ellipsoidOffset: Vector3;
  22279. private _collider;
  22280. private _oldPositionForCollisions;
  22281. private _diffPositionForCollisions;
  22282. /**
  22283. * Gets or sets a collision mask used to mask collisions (default is -1).
  22284. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  22285. */
  22286. collisionMask: number;
  22287. /**
  22288. * Gets or sets the current collision group mask (-1 by default).
  22289. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  22290. */
  22291. collisionGroup: number;
  22292. /**
  22293. * Defines edge width used when edgesRenderer is enabled
  22294. * @see https://www.babylonjs-playground.com/#10OJSG#13
  22295. */
  22296. edgesWidth: number;
  22297. /**
  22298. * Defines edge color used when edgesRenderer is enabled
  22299. * @see https://www.babylonjs-playground.com/#10OJSG#13
  22300. */
  22301. edgesColor: Color4;
  22302. /** @hidden */
  22303. private _collisionsTransformMatrix;
  22304. private _collisionsScalingMatrix;
  22305. /** @hidden */
  22306. /** @hidden */
  22307. /** @hidden */
  22308. /**
  22309. * Gets or sets the list of subMeshes
  22310. * @see http://doc.babylonjs.com/how_to/multi_materials
  22311. */
  22312. subMeshes: SubMesh[];
  22313. /** @hidden */
  22314. /** @hidden */
  22315. /** @hidden */
  22316. /** @hidden */
  22317. protected readonly _positions: Nullable<Vector3[]>;
  22318. /** @hidden */
  22319. /** @hidden */
  22320. private _skeleton;
  22321. /** @hidden */
  22322. /**
  22323. * Gets or sets a skeleton to apply skining transformations
  22324. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  22325. */
  22326. skeleton: Nullable<Skeleton>;
  22327. /**
  22328. * An event triggered when the mesh is rebuilt.
  22329. */
  22330. onRebuildObservable: Observable<AbstractMesh>;
  22331. /**
  22332. * Creates a new AbstractMesh
  22333. * @param name defines the name of the mesh
  22334. * @param scene defines the hosting scene
  22335. */
  22336. constructor(name: string, scene?: Nullable<Scene>);
  22337. /**
  22338. * Returns the string "AbstractMesh"
  22339. * @returns "AbstractMesh"
  22340. */
  22341. getClassName(): string;
  22342. /**
  22343. * Gets a string representation of the current mesh
  22344. * @param fullDetails defines a boolean indicating if full details must be included
  22345. * @returns a string representation of the current mesh
  22346. */
  22347. toString(fullDetails?: boolean): string;
  22348. /** @hidden */
  22349. /** @hidden */
  22350. /** @hidden */
  22351. /** @hidden */
  22352. /** @hidden */
  22353. private _markSubMeshesAsDirty;
  22354. /** @hidden */
  22355. /** @hidden */
  22356. /** @hidden */
  22357. /**
  22358. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  22359. */
  22360. scaling: Vector3;
  22361. /**
  22362. * Returns true if the mesh is blocked. Implemented by child classes
  22363. */
  22364. readonly isBlocked: boolean;
  22365. /**
  22366. * Returns the mesh itself by default. Implemented by child classes
  22367. * @param camera defines the camera to use to pick the right LOD level
  22368. * @returns the currentAbstractMesh
  22369. */
  22370. getLOD(camera: Camera): Nullable<AbstractMesh>;
  22371. /**
  22372. * Returns 0 by default. Implemented by child classes
  22373. * @returns an integer
  22374. */
  22375. getTotalVertices(): number;
  22376. /**
  22377. * Returns null by default. Implemented by child classes
  22378. * @returns null
  22379. */
  22380. getIndices(): Nullable<IndicesArray>;
  22381. /**
  22382. * Returns the array of the requested vertex data kind. Implemented by child classes
  22383. * @param kind defines the vertex data kind to use
  22384. * @returns null
  22385. */
  22386. getVerticesData(kind: string): Nullable<FloatArray>;
  22387. /**
  22388. * Sets the vertex data of the mesh geometry for the requested `kind`.
  22389. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  22390. * Note that a new underlying VertexBuffer object is created each call.
  22391. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  22392. * @param kind defines vertex data kind:
  22393. * * BABYLON.VertexBuffer.PositionKind
  22394. * * BABYLON.VertexBuffer.UVKind
  22395. * * BABYLON.VertexBuffer.UV2Kind
  22396. * * BABYLON.VertexBuffer.UV3Kind
  22397. * * BABYLON.VertexBuffer.UV4Kind
  22398. * * BABYLON.VertexBuffer.UV5Kind
  22399. * * BABYLON.VertexBuffer.UV6Kind
  22400. * * BABYLON.VertexBuffer.ColorKind
  22401. * * BABYLON.VertexBuffer.MatricesIndicesKind
  22402. * * BABYLON.VertexBuffer.MatricesIndicesExtraKind
  22403. * * BABYLON.VertexBuffer.MatricesWeightsKind
  22404. * * BABYLON.VertexBuffer.MatricesWeightsExtraKind
  22405. * @param data defines the data source
  22406. * @param updatable defines if the data must be flagged as updatable (or static)
  22407. * @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
  22408. * @returns the current mesh
  22409. */
  22410. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  22411. /**
  22412. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  22413. * If the mesh has no geometry, it is simply returned as it is.
  22414. * @param kind defines vertex data kind:
  22415. * * BABYLON.VertexBuffer.PositionKind
  22416. * * BABYLON.VertexBuffer.UVKind
  22417. * * BABYLON.VertexBuffer.UV2Kind
  22418. * * BABYLON.VertexBuffer.UV3Kind
  22419. * * BABYLON.VertexBuffer.UV4Kind
  22420. * * BABYLON.VertexBuffer.UV5Kind
  22421. * * BABYLON.VertexBuffer.UV6Kind
  22422. * * BABYLON.VertexBuffer.ColorKind
  22423. * * BABYLON.VertexBuffer.MatricesIndicesKind
  22424. * * BABYLON.VertexBuffer.MatricesIndicesExtraKind
  22425. * * BABYLON.VertexBuffer.MatricesWeightsKind
  22426. * * BABYLON.VertexBuffer.MatricesWeightsExtraKind
  22427. * @param data defines the data source
  22428. * @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
  22429. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  22430. * @returns the current mesh
  22431. */
  22432. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  22433. /**
  22434. * Sets the mesh indices,
  22435. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  22436. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  22437. * @param totalVertices Defines the total number of vertices
  22438. * @returns the current mesh
  22439. */
  22440. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  22441. /**
  22442. * Gets a boolean indicating if specific vertex data is present
  22443. * @param kind defines the vertex data kind to use
  22444. * @returns true is data kind is present
  22445. */
  22446. isVerticesDataPresent(kind: string): boolean;
  22447. /**
  22448. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  22449. * @returns a BoundingInfo
  22450. */
  22451. getBoundingInfo(): BoundingInfo;
  22452. /**
  22453. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  22454. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box
  22455. * @returns the current mesh
  22456. */
  22457. normalizeToUnitCube(includeDescendants?: boolean): AbstractMesh;
  22458. /**
  22459. * Overwrite the current bounding info
  22460. * @param boundingInfo defines the new bounding info
  22461. * @returns the current mesh
  22462. */
  22463. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  22464. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  22465. readonly useBones: boolean;
  22466. /** @hidden */
  22467. /** @hidden */
  22468. /** @hidden */
  22469. /**
  22470. * Gets the current world matrix
  22471. * @returns a Matrix
  22472. */
  22473. getWorldMatrix(): Matrix;
  22474. /** @hidden */
  22475. /**
  22476. * Perform relative position change from the point of view of behind the front of the mesh.
  22477. * This is performed taking into account the meshes current rotation, so you do not have to care.
  22478. * Supports definition of mesh facing forward or backward
  22479. * @param amountRight defines the distance on the right axis
  22480. * @param amountUp defines the distance on the up axis
  22481. * @param amountForward defines the distance on the forward axis
  22482. * @returns the current mesh
  22483. */
  22484. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  22485. /**
  22486. * Calculate relative position change from the point of view of behind the front of the mesh.
  22487. * This is performed taking into account the meshes current rotation, so you do not have to care.
  22488. * Supports definition of mesh facing forward or backward
  22489. * @param amountRight defines the distance on the right axis
  22490. * @param amountUp defines the distance on the up axis
  22491. * @param amountForward defines the distance on the forward axis
  22492. * @returns the new displacement vector
  22493. */
  22494. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  22495. /**
  22496. * Perform relative rotation change from the point of view of behind the front of the mesh.
  22497. * Supports definition of mesh facing forward or backward
  22498. * @param flipBack defines the flip
  22499. * @param twirlClockwise defines the twirl
  22500. * @param tiltRight defines the tilt
  22501. * @returns the current mesh
  22502. */
  22503. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  22504. /**
  22505. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  22506. * Supports definition of mesh facing forward or backward.
  22507. * @param flipBack defines the flip
  22508. * @param twirlClockwise defines the twirl
  22509. * @param tiltRight defines the tilt
  22510. * @returns the new rotation vector
  22511. */
  22512. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  22513. /**
  22514. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  22515. * @param includeDescendants Include bounding info from descendants as well (true by default)
  22516. * @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
  22517. * @returns the new bounding vectors
  22518. */
  22519. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  22520. min: Vector3;
  22521. max: Vector3;
  22522. };
  22523. /** @hidden */
  22524. /** @hidden */
  22525. /** @hidden */
  22526. protected _afterComputeWorldMatrix(): void;
  22527. /**
  22528. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  22529. * A mesh is in the frustum if its bounding box intersects the frustum
  22530. * @param frustumPlanes defines the frustum to test
  22531. * @returns true if the mesh is in the frustum planes
  22532. */
  22533. isInFrustum(frustumPlanes: Plane[]): boolean;
  22534. /**
  22535. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  22536. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  22537. * @param frustumPlanes defines the frustum to test
  22538. * @returns true if the mesh is completely in the frustum planes
  22539. */
  22540. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  22541. /**
  22542. * True if the mesh intersects another mesh or a SolidParticle object
  22543. * @param mesh defines a target mesh or SolidParticle to test
  22544. * @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)
  22545. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  22546. * @returns true if there is an intersection
  22547. */
  22548. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  22549. /**
  22550. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  22551. * @param point defines the point to test
  22552. * @returns true if there is an intersection
  22553. */
  22554. intersectsPoint(point: Vector3): boolean;
  22555. /**
  22556. * Gets the position of the current mesh in camera space
  22557. * @param camera defines the camera to use
  22558. * @returns a position
  22559. */
  22560. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  22561. /**
  22562. * Returns the distance from the mesh to the active camera
  22563. * @param camera defines the camera to use
  22564. * @returns the distance
  22565. */
  22566. getDistanceToCamera(camera?: Nullable<Camera>): number;
  22567. /**
  22568. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  22569. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  22570. */
  22571. checkCollisions: boolean;
  22572. /**
  22573. * Gets Collider object used to compute collisions (not physics)
  22574. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  22575. */
  22576. readonly collider: Collider;
  22577. /**
  22578. * Move the mesh using collision engine
  22579. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  22580. * @param displacement defines the requested displacement vector
  22581. * @returns the current mesh
  22582. */
  22583. moveWithCollisions(displacement: Vector3): AbstractMesh;
  22584. private _onCollisionPositionChange;
  22585. /** @hidden */
  22586. /** @hidden */
  22587. /** @hidden */
  22588. /** @hidden */
  22589. /**
  22590. * Checks if the passed Ray intersects with the mesh
  22591. * @param ray defines the ray to use
  22592. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  22593. * @returns the picking info
  22594. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  22595. */
  22596. intersects(ray: Ray, fastCheck?: boolean): PickingInfo;
  22597. /**
  22598. * Clones the current mesh
  22599. * @param name defines the mesh name
  22600. * @param newParent defines the new mesh parent
  22601. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  22602. * @returns the new mesh
  22603. */
  22604. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  22605. /**
  22606. * Disposes all the submeshes of the current meshnp
  22607. * @returns the current mesh
  22608. */
  22609. releaseSubMeshes(): AbstractMesh;
  22610. /**
  22611. * Releases resources associated with this abstract mesh.
  22612. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  22613. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  22614. */
  22615. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  22616. /**
  22617. * Adds the passed mesh as a child to the current mesh
  22618. * @param mesh defines the child mesh
  22619. * @returns the current mesh
  22620. */
  22621. addChild(mesh: AbstractMesh): AbstractMesh;
  22622. /**
  22623. * Removes the passed mesh from the current mesh children list
  22624. * @param mesh defines the child mesh
  22625. * @returns the current mesh
  22626. */
  22627. removeChild(mesh: AbstractMesh): AbstractMesh;
  22628. /** @hidden */
  22629. private _initFacetData;
  22630. /**
  22631. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  22632. * This method can be called within the render loop.
  22633. * 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
  22634. * @returns the current mesh
  22635. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  22636. */
  22637. updateFacetData(): AbstractMesh;
  22638. /**
  22639. * Returns the facetLocalNormals array.
  22640. * The normals are expressed in the mesh local spac
  22641. * @returns an array of Vector3
  22642. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  22643. */
  22644. getFacetLocalNormals(): Vector3[];
  22645. /**
  22646. * Returns the facetLocalPositions array.
  22647. * The facet positions are expressed in the mesh local space
  22648. * @returns an array of Vector3
  22649. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  22650. */
  22651. getFacetLocalPositions(): Vector3[];
  22652. /**
  22653. * Returns the facetLocalPartioning array
  22654. * @returns an array of array of numbers
  22655. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  22656. */
  22657. getFacetLocalPartitioning(): number[][];
  22658. /**
  22659. * Returns the i-th facet position in the world system.
  22660. * This method allocates a new Vector3 per call
  22661. * @param i defines the facet index
  22662. * @returns a new Vector3
  22663. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  22664. */
  22665. getFacetPosition(i: number): Vector3;
  22666. /**
  22667. * Sets the reference Vector3 with the i-th facet position in the world system
  22668. * @param i defines the facet index
  22669. * @param ref defines the target vector
  22670. * @returns the current mesh
  22671. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  22672. */
  22673. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  22674. /**
  22675. * Returns the i-th facet normal in the world system.
  22676. * This method allocates a new Vector3 per call
  22677. * @param i defines the facet index
  22678. * @returns a new Vector3
  22679. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  22680. */
  22681. getFacetNormal(i: number): Vector3;
  22682. /**
  22683. * Sets the reference Vector3 with the i-th facet normal in the world system
  22684. * @param i defines the facet index
  22685. * @param ref defines the target vector
  22686. * @returns the current mesh
  22687. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  22688. */
  22689. getFacetNormalToRef(i: number, ref: Vector3): this;
  22690. /**
  22691. * 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)
  22692. * @param x defines x coordinate
  22693. * @param y defines y coordinate
  22694. * @param z defines z coordinate
  22695. * @returns the array of facet indexes
  22696. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  22697. */
  22698. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  22699. /**
  22700. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  22701. * @param projected sets as the (x,y,z) world projection on the facet
  22702. * @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
  22703. * @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
  22704. * @param x defines x coordinate
  22705. * @param y defines y coordinate
  22706. * @param z defines z coordinate
  22707. * @returns the face index if found (or null instead)
  22708. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  22709. */
  22710. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  22711. /**
  22712. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  22713. * @param projected sets as the (x,y,z) local projection on the facet
  22714. * @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
  22715. * @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
  22716. * @param x defines x coordinate
  22717. * @param y defines y coordinate
  22718. * @param z defines z coordinate
  22719. * @returns the face index if found (or null instead)
  22720. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  22721. */
  22722. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  22723. /**
  22724. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  22725. * @returns the parameters
  22726. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  22727. */
  22728. getFacetDataParameters(): any;
  22729. /**
  22730. * Disables the feature FacetData and frees the related memory
  22731. * @returns the current mesh
  22732. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  22733. */
  22734. disableFacetData(): AbstractMesh;
  22735. /**
  22736. * Updates the AbstractMesh indices array
  22737. * @param indices defines the data source
  22738. * @returns the current mesh
  22739. */
  22740. updateIndices(indices: IndicesArray): AbstractMesh;
  22741. /**
  22742. * Creates new normals data for the mesh
  22743. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  22744. * @returns the current mesh
  22745. */
  22746. createNormals(updatable: boolean): AbstractMesh;
  22747. /**
  22748. * Align the mesh with a normal
  22749. * @param normal defines the normal to use
  22750. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  22751. * @returns the current mesh
  22752. */
  22753. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  22754. /** @hidden */
  22755. }
  22756. }
  22757. declare module BABYLON {
  22758. class Buffer {
  22759. private _engine;
  22760. private _buffer;
  22761. /** @hidden */
  22762. private _updatable;
  22763. private _instanced;
  22764. /**
  22765. * Gets the byte stride.
  22766. */
  22767. readonly byteStride: number;
  22768. /**
  22769. * Constructor
  22770. * @param engine the engine
  22771. * @param data the data to use for this buffer
  22772. * @param updatable whether the data is updatable
  22773. * @param stride the stride (optional)
  22774. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  22775. * @param instanced whether the buffer is instanced (optional)
  22776. * @param useBytes set to true if the stride in in bytes (optional)
  22777. */
  22778. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  22779. /**
  22780. * Create a new {BABYLON.VertexBuffer} based on the current buffer
  22781. * @param kind defines the vertex buffer kind (position, normal, etc.)
  22782. * @param offset defines offset in the buffer (0 by default)
  22783. * @param size defines the size in floats of attributes (position is 3 for instance)
  22784. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  22785. * @param instanced defines if the vertex buffer contains indexed data
  22786. * @param useBytes defines if the offset and stride are in bytes
  22787. * @returns the new vertex buffer
  22788. */
  22789. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  22790. isUpdatable(): boolean;
  22791. getData(): Nullable<DataArray>;
  22792. getBuffer(): Nullable<WebGLBuffer>;
  22793. /**
  22794. * Gets the stride in float32 units (i.e. byte stride / 4).
  22795. * May not be an integer if the byte stride is not divisible by 4.
  22796. * DEPRECATED. Use byteStride instead.
  22797. * @returns the stride in float32 units
  22798. */
  22799. getStrideSize(): number;
  22800. create(data?: Nullable<DataArray>): void;
  22801. /** @hidden */
  22802. update(data: DataArray): void;
  22803. /**
  22804. * Updates the data directly.
  22805. * @param data the new data
  22806. * @param offset the new offset
  22807. * @param vertexCount the vertex count (optional)
  22808. * @param useBytes set to true if the offset is in bytes
  22809. */
  22810. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  22811. dispose(): void;
  22812. }
  22813. }
  22814. declare module BABYLON {
  22815. class CSG {
  22816. private polygons;
  22817. matrix: Matrix;
  22818. position: Vector3;
  22819. rotation: Vector3;
  22820. rotationQuaternion: Nullable<Quaternion>;
  22821. scaling: Vector3;
  22822. static FromMesh(mesh: Mesh): CSG;
  22823. private static FromPolygons;
  22824. clone(): CSG;
  22825. union(csg: CSG): CSG;
  22826. unionInPlace(csg: CSG): void;
  22827. subtract(csg: CSG): CSG;
  22828. subtractInPlace(csg: CSG): void;
  22829. intersect(csg: CSG): CSG;
  22830. intersectInPlace(csg: CSG): void;
  22831. inverse(): CSG;
  22832. inverseInPlace(): void;
  22833. copyTransformAttributes(csg: CSG): CSG;
  22834. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  22835. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  22836. }
  22837. }
  22838. declare module BABYLON {
  22839. /**
  22840. * Class used to store geometry data (vertex buffers + index buffer)
  22841. */
  22842. class Geometry implements IGetSetVerticesData {
  22843. /**
  22844. * Gets or sets the unique ID of the geometry
  22845. */
  22846. id: string;
  22847. /**
  22848. * Gets the delay loading state of the geometry (none by default which means not delayed)
  22849. */
  22850. delayLoadState: number;
  22851. /**
  22852. * Gets the file containing the data to load when running in delay load state
  22853. */
  22854. delayLoadingFile: Nullable<string>;
  22855. /**
  22856. * Callback called when the geometry is updated
  22857. */
  22858. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  22859. private _scene;
  22860. private _engine;
  22861. private _meshes;
  22862. private _totalVertices;
  22863. /** @hidden */
  22864. /** @hidden */
  22865. ;
  22866. private _isDisposed;
  22867. private _extend;
  22868. private _boundingBias;
  22869. /** @hidden */
  22870. private _indexBuffer;
  22871. private _indexBufferIsUpdatable;
  22872. /** @hidden */
  22873. /** @hidden */
  22874. /** @hidden */
  22875. private _vertexArrayObjects;
  22876. private _updatable;
  22877. /** @hidden */
  22878. /**
  22879. * 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
  22880. */
  22881. /**
  22882. * 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
  22883. */
  22884. boundingBias: Vector2;
  22885. /**
  22886. * Static function used to attach a new empty geometry to a mesh
  22887. * @param mesh defines the mesh to attach the geometry to
  22888. * @returns the new {BABYLON.Geometry}
  22889. */
  22890. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  22891. /**
  22892. * Creates a new geometry
  22893. * @param id defines the unique ID
  22894. * @param scene defines the hosting scene
  22895. * @param vertexData defines the {BABYLON.VertexData} used to get geometry data
  22896. * @param updatable defines if geometry must be updatable (false by default)
  22897. * @param mesh defines the mesh that will be associated with the geometry
  22898. */
  22899. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  22900. /**
  22901. * Gets the current extend of the geometry
  22902. */
  22903. readonly extend: {
  22904. minimum: Vector3;
  22905. maximum: Vector3;
  22906. };
  22907. /**
  22908. * Gets the hosting scene
  22909. * @returns the hosting {BABYLON.Scene}
  22910. */
  22911. getScene(): Scene;
  22912. /**
  22913. * Gets the hosting engine
  22914. * @returns the hosting {BABYLON.Engine}
  22915. */
  22916. getEngine(): Engine;
  22917. /**
  22918. * Defines if the geometry is ready to use
  22919. * @returns true if the geometry is ready to be used
  22920. */
  22921. isReady(): boolean;
  22922. /**
  22923. * Gets a value indicating that the geometry should not be serialized
  22924. */
  22925. readonly doNotSerialize: boolean;
  22926. /** @hidden */
  22927. /**
  22928. * Affects all geometry data in one call
  22929. * @param vertexData defines the geometry data
  22930. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  22931. */
  22932. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  22933. /**
  22934. * Set specific vertex data
  22935. * @param kind defines the data kind (Position, normal, etc...)
  22936. * @param data defines the vertex data to use
  22937. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22938. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22939. */
  22940. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  22941. /**
  22942. * Removes a specific vertex data
  22943. * @param kind defines the data kind (Position, normal, etc...)
  22944. */
  22945. removeVerticesData(kind: string): void;
  22946. /**
  22947. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  22948. * @param buffer defines the vertex buffer to use
  22949. * @param totalVertices defines the total number of vertices for position kind (could be null)
  22950. */
  22951. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  22952. /**
  22953. * Update a specific vertex buffer
  22954. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  22955. * It will do nothing if the buffer is not updatable
  22956. * @param kind defines the data kind (Position, normal, etc...)
  22957. * @param data defines the data to use
  22958. * @param offset defines the offset in the target buffer where to store the data
  22959. * @param useBytes set to true if the offset is in bytes
  22960. */
  22961. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  22962. /**
  22963. * Update a specific vertex buffer
  22964. * This function will create a new buffer if the current one is not updatable
  22965. * @param kind defines the data kind (Position, normal, etc...)
  22966. * @param data defines the data to use
  22967. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  22968. */
  22969. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  22970. private _updateBoundingInfo;
  22971. /** @hidden */
  22972. /**
  22973. * Gets total number of vertices
  22974. * @returns the total number of vertices
  22975. */
  22976. getTotalVertices(): number;
  22977. /**
  22978. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22979. * @param kind defines the data kind (Position, normal, etc...)
  22980. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22981. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22982. * @returns a float array containing vertex data
  22983. */
  22984. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22985. /**
  22986. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  22987. * @param kind defines the data kind (Position, normal, etc...)
  22988. * @returns true if the vertex buffer with the specified kind is updatable
  22989. */
  22990. isVertexBufferUpdatable(kind: string): boolean;
  22991. /**
  22992. * Gets a specific vertex buffer
  22993. * @param kind defines the data kind (Position, normal, etc...)
  22994. * @returns a {BABYLON.VertexBuffer}
  22995. */
  22996. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  22997. /**
  22998. * Returns all vertex buffers
  22999. * @return an object holding all vertex buffers indexed by kind
  23000. */
  23001. getVertexBuffers(): Nullable<{
  23002. [key: string]: VertexBuffer;
  23003. }>;
  23004. /**
  23005. * Gets a boolean indicating if specific vertex buffer is present
  23006. * @param kind defines the data kind (Position, normal, etc...)
  23007. * @returns true if data is present
  23008. */
  23009. isVerticesDataPresent(kind: string): boolean;
  23010. /**
  23011. * Gets a list of all attached data kinds (Position, normal, etc...)
  23012. * @returns a list of string containing all kinds
  23013. */
  23014. getVerticesDataKinds(): string[];
  23015. /**
  23016. * Update index buffer
  23017. * @param indices defines the indices to store in the index buffer
  23018. * @param offset defines the offset in the target buffer where to store the data
  23019. */
  23020. updateIndices(indices: IndicesArray, offset?: number): void;
  23021. /**
  23022. * Creates a new index buffer
  23023. * @param indices defines the indices to store in the index buffer
  23024. * @param totalVertices defines the total number of vertices (could be null)
  23025. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  23026. */
  23027. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  23028. /**
  23029. * Return the total number of indices
  23030. * @returns the total number of indices
  23031. */
  23032. getTotalIndices(): number;
  23033. /**
  23034. * Gets the index buffer array
  23035. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23036. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23037. * @returns the index buffer array
  23038. */
  23039. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  23040. /**
  23041. * Gets the index buffer
  23042. * @return the index buffer
  23043. */
  23044. getIndexBuffer(): Nullable<WebGLBuffer>;
  23045. /** @hidden */
  23046. /**
  23047. * Release the associated resources for a specific mesh
  23048. * @param mesh defines the source mesh
  23049. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  23050. */
  23051. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  23052. /**
  23053. * Apply current geometry to a given mesh
  23054. * @param mesh defines the mesh to apply geometry to
  23055. */
  23056. applyToMesh(mesh: Mesh): void;
  23057. private _updateExtend;
  23058. private _applyToMesh;
  23059. private notifyUpdate;
  23060. /**
  23061. * Load the geometry if it was flagged as delay loaded
  23062. * @param scene defines the hosting scene
  23063. * @param onLoaded defines a callback called when the geometry is loaded
  23064. */
  23065. load(scene: Scene, onLoaded?: () => void): void;
  23066. private _queueLoad;
  23067. /**
  23068. * Invert the geometry to move from a right handed system to a left handed one.
  23069. */
  23070. toLeftHanded(): void;
  23071. /** @hidden */
  23072. /** @hidden */
  23073. /**
  23074. * Gets a value indicating if the geometry is disposed
  23075. * @returns true if the geometry was disposed
  23076. */
  23077. isDisposed(): boolean;
  23078. private _disposeVertexArrayObjects;
  23079. /**
  23080. * Free all associated resources
  23081. */
  23082. dispose(): void;
  23083. /**
  23084. * Clone the current geometry into a new geometry
  23085. * @param id defines the unique ID of the new geometry
  23086. * @returns a new geometry object
  23087. */
  23088. copy(id: string): Geometry;
  23089. /**
  23090. * Serialize the current geometry info (and not the vertices data) into a JSON object
  23091. * @return a JSON representation of the current geometry data (without the vertices data)
  23092. */
  23093. serialize(): any;
  23094. private toNumberArray;
  23095. /**
  23096. * Serialize all vertices data into a JSON oject
  23097. * @returns a JSON representation of the current geometry data
  23098. */
  23099. serializeVerticeData(): any;
  23100. /**
  23101. * Extracts a clone of a mesh geometry
  23102. * @param mesh defines the source mesh
  23103. * @param id defines the unique ID of the new geometry object
  23104. * @returns the new geometry object
  23105. */
  23106. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  23107. /**
  23108. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  23109. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  23110. * Be aware Math.random() could cause collisions, but:
  23111. * "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"
  23112. * @returns a string containing a new GUID
  23113. */
  23114. static RandomId(): string;
  23115. /** @hidden */
  23116. private static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  23117. private static _CleanMatricesWeights;
  23118. /**
  23119. * Create a new geometry from persisted data (Using .babylon file format)
  23120. * @param parsedVertexData defines the persisted data
  23121. * @param scene defines the hosting scene
  23122. * @param rootUrl defines the root url to use to load assets (like delayed data)
  23123. * @returns the new geometry object
  23124. */
  23125. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  23126. }
  23127. /**
  23128. * Abstract class used to provide common services for all typed geometries
  23129. * @hidden
  23130. */
  23131. class _PrimitiveGeometry extends Geometry {
  23132. private _canBeRegenerated;
  23133. private _beingRegenerated;
  23134. /**
  23135. * Creates a new typed geometry
  23136. * @param id defines the unique ID of the geometry
  23137. * @param scene defines the hosting scene
  23138. * @param _canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  23139. * @param mesh defines the hosting mesh (can be null)
  23140. */
  23141. constructor(id: string, scene: Scene, _canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  23142. /**
  23143. * Gets a value indicating if the geometry supports being regenerated with new parameters (false by default)
  23144. * @returns true if the geometry can be regenerated
  23145. */
  23146. canBeRegenerated(): boolean;
  23147. /**
  23148. * If the geometry supports regeneration, the function will recreates the geometry with updated parameter values
  23149. */
  23150. regenerate(): void;
  23151. /**
  23152. * Clone the geometry
  23153. * @param id defines the unique ID of the new geometry
  23154. * @returns the new geometry
  23155. */
  23156. asNewGeometry(id: string): Geometry;
  23157. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  23158. setVerticesData(kind: string, data: FloatArray, updatable?: boolean): void;
  23159. /** @hidden */
  23160. copy(id: string): Geometry;
  23161. serialize(): any;
  23162. }
  23163. /**
  23164. * Creates a ribbon geometry
  23165. * @description See http://doc.babylonjs.com/how_to/ribbon_tutorial, http://doc.babylonjs.com/resources/maths_make_ribbons
  23166. */
  23167. class RibbonGeometry extends _PrimitiveGeometry {
  23168. /**
  23169. * Defines the array of paths to use
  23170. */
  23171. pathArray: Vector3[][];
  23172. /**
  23173. * Defines if the last and first points of each path in your pathArray must be joined
  23174. */
  23175. closeArray: boolean;
  23176. /**
  23177. * Defines if the last and first points of each path in your pathArray must be joined
  23178. */
  23179. closePath: boolean;
  23180. /**
  23181. * Defines the offset between points
  23182. */
  23183. offset: number;
  23184. /**
  23185. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  23186. */
  23187. side: number;
  23188. /**
  23189. * Creates a ribbon geometry
  23190. * @param id defines the unique ID of the geometry
  23191. * @param scene defines the hosting scene
  23192. * @param pathArray defines the array of paths to use
  23193. * @param closeArray defines if the last path and the first path must be joined
  23194. * @param closePath defines if the last and first points of each path in your pathArray must be joined
  23195. * @param offset defines the offset between points
  23196. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  23197. * @param mesh defines the hosting mesh (can be null)
  23198. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  23199. */
  23200. constructor(id: string, scene: Scene,
  23201. /**
  23202. * Defines the array of paths to use
  23203. */
  23204. pathArray: Vector3[][],
  23205. /**
  23206. * Defines if the last and first points of each path in your pathArray must be joined
  23207. */
  23208. closeArray: boolean,
  23209. /**
  23210. * Defines if the last and first points of each path in your pathArray must be joined
  23211. */
  23212. closePath: boolean,
  23213. /**
  23214. * Defines the offset between points
  23215. */
  23216. offset: number, canBeRegenerated?: boolean, mesh?: Mesh,
  23217. /**
  23218. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  23219. */
  23220. side?: number);
  23221. /** @hidden */
  23222. copy(id: string): Geometry;
  23223. }
  23224. /**
  23225. * Creates a box geometry
  23226. * @description see http://doc.babylonjs.com/how_to/set_shapes#box
  23227. */
  23228. class BoxGeometry extends _PrimitiveGeometry {
  23229. /**
  23230. * Defines the zise of the box (width, height and depth are the same)
  23231. */
  23232. size: number;
  23233. /**
  23234. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  23235. */
  23236. side: number;
  23237. /**
  23238. * Creates a box geometry
  23239. * @param id defines the unique ID of the geometry
  23240. * @param scene defines the hosting scene
  23241. * @param size defines the zise of the box (width, height and depth are the same)
  23242. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  23243. * @param mesh defines the hosting mesh (can be null)
  23244. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  23245. */
  23246. constructor(id: string, scene: Scene,
  23247. /**
  23248. * Defines the zise of the box (width, height and depth are the same)
  23249. */
  23250. size: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  23251. /**
  23252. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  23253. */
  23254. side?: number);
  23255. /** @hidden */
  23256. copy(id: string): Geometry;
  23257. serialize(): any;
  23258. static Parse(parsedBox: any, scene: Scene): Nullable<BoxGeometry>;
  23259. }
  23260. /**
  23261. * Creates a sphere geometry
  23262. * @description see http://doc.babylonjs.com/how_to/set_shapes#sphere
  23263. */
  23264. class SphereGeometry extends _PrimitiveGeometry {
  23265. /**
  23266. * Defines the number of segments to use to create the sphere
  23267. */
  23268. segments: number;
  23269. /**
  23270. * Defines the diameter of the sphere
  23271. */
  23272. diameter: number;
  23273. /**
  23274. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  23275. */
  23276. side: number;
  23277. /**
  23278. * Create a new sphere geometry
  23279. * @param id defines the unique ID of the geometry
  23280. * @param scene defines the hosting scene
  23281. * @param segments defines the number of segments to use to create the sphere
  23282. * @param diameter defines the diameter of the sphere
  23283. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  23284. * @param mesh defines the hosting mesh (can be null)
  23285. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  23286. */
  23287. constructor(id: string, scene: Scene,
  23288. /**
  23289. * Defines the number of segments to use to create the sphere
  23290. */
  23291. segments: number,
  23292. /**
  23293. * Defines the diameter of the sphere
  23294. */
  23295. diameter: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  23296. /**
  23297. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  23298. */
  23299. side?: number);
  23300. /** @hidden */
  23301. copy(id: string): Geometry;
  23302. serialize(): any;
  23303. static Parse(parsedSphere: any, scene: Scene): Nullable<SphereGeometry>;
  23304. }
  23305. /**
  23306. * Creates a disc geometry
  23307. * @description see http://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  23308. */
  23309. class DiscGeometry extends _PrimitiveGeometry {
  23310. /**
  23311. * Defines the radius of the disc
  23312. */
  23313. radius: number;
  23314. /**
  23315. * Defines the tesselation factor to apply to the disc
  23316. */
  23317. tessellation: number;
  23318. /**
  23319. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  23320. */
  23321. side: number;
  23322. /**
  23323. * Creates a new disc geometry
  23324. * @param id defines the unique ID of the geometry
  23325. * @param scene defines the hosting scene
  23326. * @param radius defines the radius of the disc
  23327. * @param tessellation defines the tesselation factor to apply to the disc
  23328. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  23329. * @param mesh defines the hosting mesh (can be null)
  23330. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  23331. */
  23332. constructor(id: string, scene: Scene,
  23333. /**
  23334. * Defines the radius of the disc
  23335. */
  23336. radius: number,
  23337. /**
  23338. * Defines the tesselation factor to apply to the disc
  23339. */
  23340. tessellation: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  23341. /**
  23342. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  23343. */
  23344. side?: number);
  23345. /** @hidden */
  23346. copy(id: string): Geometry;
  23347. }
  23348. /**
  23349. * Creates a new cylinder geometry
  23350. * @description see http://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  23351. */
  23352. class CylinderGeometry extends _PrimitiveGeometry {
  23353. /**
  23354. * Defines the height of the cylinder
  23355. */
  23356. height: number;
  23357. /**
  23358. * Defines the diameter of the cylinder's top cap
  23359. */
  23360. diameterTop: number;
  23361. /**
  23362. * Defines the diameter of the cylinder's bottom cap
  23363. */
  23364. diameterBottom: number;
  23365. /**
  23366. * Defines the tessellation factor to apply to the cylinder
  23367. */
  23368. tessellation: number;
  23369. /**
  23370. * Defines the number of subdivisions to apply to the cylinder (1 by default)
  23371. */
  23372. subdivisions: number;
  23373. /**
  23374. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  23375. */
  23376. side: number;
  23377. /**
  23378. * Creates a new cylinder geometry
  23379. * @param id defines the unique ID of the geometry
  23380. * @param scene defines the hosting scene
  23381. * @param height defines the height of the cylinder
  23382. * @param diameterTop defines the diameter of the cylinder's top cap
  23383. * @param diameterBottom defines the diameter of the cylinder's bottom cap
  23384. * @param tessellation defines the tessellation factor to apply to the cylinder (number of radial sides)
  23385. * @param subdivisions defines the number of subdivisions to apply to the cylinder (number of rings) (1 by default)
  23386. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  23387. * @param mesh defines the hosting mesh (can be null)
  23388. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  23389. */
  23390. constructor(id: string, scene: Scene,
  23391. /**
  23392. * Defines the height of the cylinder
  23393. */
  23394. height: number,
  23395. /**
  23396. * Defines the diameter of the cylinder's top cap
  23397. */
  23398. diameterTop: number,
  23399. /**
  23400. * Defines the diameter of the cylinder's bottom cap
  23401. */
  23402. diameterBottom: number,
  23403. /**
  23404. * Defines the tessellation factor to apply to the cylinder
  23405. */
  23406. tessellation: number,
  23407. /**
  23408. * Defines the number of subdivisions to apply to the cylinder (1 by default)
  23409. */
  23410. subdivisions?: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  23411. /**
  23412. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  23413. */
  23414. side?: number);
  23415. /** @hidden */
  23416. copy(id: string): Geometry;
  23417. serialize(): any;
  23418. static Parse(parsedCylinder: any, scene: Scene): Nullable<CylinderGeometry>;
  23419. }
  23420. /**
  23421. * Creates a new torus geometry
  23422. * @description see http://doc.babylonjs.com/how_to/set_shapes#torus
  23423. */
  23424. class TorusGeometry extends _PrimitiveGeometry {
  23425. /**
  23426. * Defines the diameter of the torus
  23427. */
  23428. diameter: number;
  23429. /**
  23430. * Defines the thickness of the torus (ie. internal diameter)
  23431. */
  23432. thickness: number;
  23433. /**
  23434. * Defines the tesselation factor to apply to the torus
  23435. */
  23436. tessellation: number;
  23437. /**
  23438. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  23439. */
  23440. side: number;
  23441. /**
  23442. * Creates a new torus geometry
  23443. * @param id defines the unique ID of the geometry
  23444. * @param scene defines the hosting scene
  23445. * @param diameter defines the diameter of the torus
  23446. * @param thickness defines the thickness of the torus (ie. internal diameter)
  23447. * @param tessellation defines the tesselation factor to apply to the torus (number of segments along the circle)
  23448. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  23449. * @param mesh defines the hosting mesh (can be null)
  23450. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  23451. */
  23452. constructor(id: string, scene: Scene,
  23453. /**
  23454. * Defines the diameter of the torus
  23455. */
  23456. diameter: number,
  23457. /**
  23458. * Defines the thickness of the torus (ie. internal diameter)
  23459. */
  23460. thickness: number,
  23461. /**
  23462. * Defines the tesselation factor to apply to the torus
  23463. */
  23464. tessellation: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  23465. /**
  23466. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  23467. */
  23468. side?: number);
  23469. /** @hidden */
  23470. copy(id: string): Geometry;
  23471. serialize(): any;
  23472. static Parse(parsedTorus: any, scene: Scene): Nullable<TorusGeometry>;
  23473. }
  23474. /**
  23475. * Creates a new ground geometry
  23476. * @description see http://doc.babylonjs.com/how_to/set_shapes#ground
  23477. */
  23478. class GroundGeometry extends _PrimitiveGeometry {
  23479. /**
  23480. * Defines the width of the ground
  23481. */
  23482. width: number;
  23483. /**
  23484. * Defines the height of the ground
  23485. */
  23486. height: number;
  23487. /**
  23488. * Defines the subdivisions to apply to the ground
  23489. */
  23490. subdivisions: number;
  23491. /**
  23492. * Creates a new ground geometry
  23493. * @param id defines the unique ID of the geometry
  23494. * @param scene defines the hosting scene
  23495. * @param width defines the width of the ground
  23496. * @param height defines the height of the ground
  23497. * @param subdivisions defines the subdivisions to apply to the ground
  23498. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  23499. * @param mesh defines the hosting mesh (can be null)
  23500. */
  23501. constructor(id: string, scene: Scene,
  23502. /**
  23503. * Defines the width of the ground
  23504. */
  23505. width: number,
  23506. /**
  23507. * Defines the height of the ground
  23508. */
  23509. height: number,
  23510. /**
  23511. * Defines the subdivisions to apply to the ground
  23512. */
  23513. subdivisions: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  23514. /** @hidden */
  23515. copy(id: string): Geometry;
  23516. serialize(): any;
  23517. static Parse(parsedGround: any, scene: Scene): Nullable<GroundGeometry>;
  23518. }
  23519. /**
  23520. * Creates a tiled ground geometry
  23521. * @description see http://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  23522. */
  23523. class TiledGroundGeometry extends _PrimitiveGeometry {
  23524. /**
  23525. * Defines the minimum value on X axis
  23526. */
  23527. xmin: number;
  23528. /**
  23529. * Defines the minimum value on Z axis
  23530. */
  23531. zmin: number;
  23532. /**
  23533. * Defines the maximum value on X axis
  23534. */
  23535. xmax: number;
  23536. /**
  23537. * Defines the maximum value on Z axis
  23538. */
  23539. zmax: number;
  23540. /**
  23541. * Defines the subdivisions to apply to the ground
  23542. */
  23543. subdivisions: {
  23544. w: number;
  23545. h: number;
  23546. };
  23547. /**
  23548. * Defines the precision to use when computing the tiles
  23549. */
  23550. precision: {
  23551. w: number;
  23552. h: number;
  23553. };
  23554. /**
  23555. * Creates a tiled ground geometry
  23556. * @param id defines the unique ID of the geometry
  23557. * @param scene defines the hosting scene
  23558. * @param xmin defines the minimum value on X axis
  23559. * @param zmin defines the minimum value on Z axis
  23560. * @param xmax defines the maximum value on X axis
  23561. * @param zmax defines the maximum value on Z axis
  23562. * @param subdivisions defines the subdivisions to apply to the ground (number of subdivisions (tiles) on the height and the width of the map)
  23563. * @param precision defines the precision to use when computing the tiles
  23564. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  23565. * @param mesh defines the hosting mesh (can be null)
  23566. */
  23567. constructor(id: string, scene: Scene,
  23568. /**
  23569. * Defines the minimum value on X axis
  23570. */
  23571. xmin: number,
  23572. /**
  23573. * Defines the minimum value on Z axis
  23574. */
  23575. zmin: number,
  23576. /**
  23577. * Defines the maximum value on X axis
  23578. */
  23579. xmax: number,
  23580. /**
  23581. * Defines the maximum value on Z axis
  23582. */
  23583. zmax: number,
  23584. /**
  23585. * Defines the subdivisions to apply to the ground
  23586. */
  23587. subdivisions: {
  23588. w: number;
  23589. h: number;
  23590. },
  23591. /**
  23592. * Defines the precision to use when computing the tiles
  23593. */
  23594. precision: {
  23595. w: number;
  23596. h: number;
  23597. }, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  23598. /** @hidden */
  23599. copy(id: string): Geometry;
  23600. }
  23601. /**
  23602. * Creates a plane geometry
  23603. * @description see http://doc.babylonjs.com/how_to/set_shapes#plane
  23604. */
  23605. class PlaneGeometry extends _PrimitiveGeometry {
  23606. /**
  23607. * Defines the size of the plane (width === height)
  23608. */
  23609. size: number;
  23610. /**
  23611. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  23612. */
  23613. side: number;
  23614. /**
  23615. * Creates a plane geometry
  23616. * @param id defines the unique ID of the geometry
  23617. * @param scene defines the hosting scene
  23618. * @param size defines the size of the plane (width === height)
  23619. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  23620. * @param mesh defines the hosting mesh (can be null)
  23621. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  23622. */
  23623. constructor(id: string, scene: Scene,
  23624. /**
  23625. * Defines the size of the plane (width === height)
  23626. */
  23627. size: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  23628. /**
  23629. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  23630. */
  23631. side?: number);
  23632. /** @hidden */
  23633. copy(id: string): Geometry;
  23634. serialize(): any;
  23635. static Parse(parsedPlane: any, scene: Scene): Nullable<PlaneGeometry>;
  23636. }
  23637. /**
  23638. * Creates a torus knot geometry
  23639. * @description see http://doc.babylonjs.com/how_to/set_shapes#torus-knot
  23640. */
  23641. class TorusKnotGeometry extends _PrimitiveGeometry {
  23642. /**
  23643. * Defines the radius of the torus knot
  23644. */
  23645. radius: number;
  23646. /**
  23647. * Defines the thickness of the torus knot tube
  23648. */
  23649. tube: number;
  23650. /**
  23651. * Defines the number of radial segments
  23652. */
  23653. radialSegments: number;
  23654. /**
  23655. * Defines the number of tubular segments
  23656. */
  23657. tubularSegments: number;
  23658. /**
  23659. * Defines the first number of windings
  23660. */
  23661. p: number;
  23662. /**
  23663. * Defines the second number of windings
  23664. */
  23665. q: number;
  23666. /**
  23667. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  23668. */
  23669. side: number;
  23670. /**
  23671. * Creates a torus knot geometry
  23672. * @param id defines the unique ID of the geometry
  23673. * @param scene defines the hosting scene
  23674. * @param radius defines the radius of the torus knot
  23675. * @param tube defines the thickness of the torus knot tube
  23676. * @param radialSegments defines the number of radial segments
  23677. * @param tubularSegments defines the number of tubular segments
  23678. * @param p defines the first number of windings
  23679. * @param q defines the second number of windings
  23680. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  23681. * @param mesh defines the hosting mesh (can be null)
  23682. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  23683. */
  23684. constructor(id: string, scene: Scene,
  23685. /**
  23686. * Defines the radius of the torus knot
  23687. */
  23688. radius: number,
  23689. /**
  23690. * Defines the thickness of the torus knot tube
  23691. */
  23692. tube: number,
  23693. /**
  23694. * Defines the number of radial segments
  23695. */
  23696. radialSegments: number,
  23697. /**
  23698. * Defines the number of tubular segments
  23699. */
  23700. tubularSegments: number,
  23701. /**
  23702. * Defines the first number of windings
  23703. */
  23704. p: number,
  23705. /**
  23706. * Defines the second number of windings
  23707. */
  23708. q: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  23709. /**
  23710. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  23711. */
  23712. side?: number);
  23713. /** @hidden */
  23714. copy(id: string): Geometry;
  23715. serialize(): any;
  23716. static Parse(parsedTorusKnot: any, scene: Scene): Nullable<TorusKnotGeometry>;
  23717. }
  23718. }
  23719. declare module BABYLON {
  23720. class GroundMesh extends Mesh {
  23721. generateOctree: boolean;
  23722. private _heightQuads;
  23723. /** @hidden */
  23724. /** @hidden */
  23725. /** @hidden */
  23726. /** @hidden */
  23727. /** @hidden */
  23728. /** @hidden */
  23729. /** @hidden */
  23730. /** @hidden */
  23731. constructor(name: string, scene: Scene);
  23732. getClassName(): string;
  23733. readonly subdivisions: number;
  23734. readonly subdivisionsX: number;
  23735. readonly subdivisionsY: number;
  23736. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  23737. /**
  23738. * Returns a height (y) value in the Worl system :
  23739. * the ground altitude at the coordinates (x, z) expressed in the World system.
  23740. * Returns the ground y position if (x, z) are outside the ground surface.
  23741. */
  23742. getHeightAtCoordinates(x: number, z: number): number;
  23743. /**
  23744. * Returns a normalized vector (Vector3) orthogonal to the ground
  23745. * at the ground coordinates (x, z) expressed in the World system.
  23746. * Returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  23747. */
  23748. getNormalAtCoordinates(x: number, z: number): Vector3;
  23749. /**
  23750. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  23751. * at the ground coordinates (x, z) expressed in the World system.
  23752. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  23753. * Returns the GroundMesh.
  23754. */
  23755. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  23756. /**
  23757. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  23758. * if the ground has been updated.
  23759. * This can be used in the render loop.
  23760. * Returns the GroundMesh.
  23761. */
  23762. updateCoordinateHeights(): GroundMesh;
  23763. private _getFacetAt;
  23764. private _initHeightQuads;
  23765. private _computeHeightQuads;
  23766. serialize(serializationObject: any): void;
  23767. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  23768. }
  23769. }
  23770. declare module BABYLON {
  23771. /**
  23772. * Creates an instance based on a source mesh.
  23773. */
  23774. class InstancedMesh extends AbstractMesh {
  23775. private _sourceMesh;
  23776. private _currentLOD;
  23777. constructor(name: string, source: Mesh);
  23778. /**
  23779. * Returns the string "InstancedMesh".
  23780. */
  23781. getClassName(): string;
  23782. readonly receiveShadows: boolean;
  23783. readonly material: Nullable<Material>;
  23784. readonly visibility: number;
  23785. readonly skeleton: Nullable<Skeleton>;
  23786. renderingGroupId: number;
  23787. /**
  23788. * Returns the total number of vertices (integer).
  23789. */
  23790. getTotalVertices(): number;
  23791. readonly sourceMesh: Mesh;
  23792. /**
  23793. * Is this node ready to be used/rendered
  23794. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  23795. * @return {boolean} is it ready
  23796. */
  23797. isReady(completeCheck?: boolean): boolean;
  23798. /**
  23799. * Returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  23800. */
  23801. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  23802. /**
  23803. * Sets the vertex data of the mesh geometry for the requested `kind`.
  23804. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  23805. * The `data` are either a numeric array either a Float32Array.
  23806. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  23807. * 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).
  23808. * Note that a new underlying VertexBuffer object is created each call.
  23809. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  23810. *
  23811. * Possible `kind` values :
  23812. * - BABYLON.VertexBuffer.PositionKind
  23813. * - BABYLON.VertexBuffer.UVKind
  23814. * - BABYLON.VertexBuffer.UV2Kind
  23815. * - BABYLON.VertexBuffer.UV3Kind
  23816. * - BABYLON.VertexBuffer.UV4Kind
  23817. * - BABYLON.VertexBuffer.UV5Kind
  23818. * - BABYLON.VertexBuffer.UV6Kind
  23819. * - BABYLON.VertexBuffer.ColorKind
  23820. * - BABYLON.VertexBuffer.MatricesIndicesKind
  23821. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  23822. * - BABYLON.VertexBuffer.MatricesWeightsKind
  23823. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  23824. *
  23825. * Returns the Mesh.
  23826. */
  23827. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  23828. /**
  23829. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  23830. * If the mesh has no geometry, it is simply returned as it is.
  23831. * The `data` are either a numeric array either a Float32Array.
  23832. * No new underlying VertexBuffer object is created.
  23833. * 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.
  23834. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  23835. *
  23836. * Possible `kind` values :
  23837. * - BABYLON.VertexBuffer.PositionKind
  23838. * - BABYLON.VertexBuffer.UVKind
  23839. * - BABYLON.VertexBuffer.UV2Kind
  23840. * - BABYLON.VertexBuffer.UV3Kind
  23841. * - BABYLON.VertexBuffer.UV4Kind
  23842. * - BABYLON.VertexBuffer.UV5Kind
  23843. * - BABYLON.VertexBuffer.UV6Kind
  23844. * - BABYLON.VertexBuffer.ColorKind
  23845. * - BABYLON.VertexBuffer.MatricesIndicesKind
  23846. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  23847. * - BABYLON.VertexBuffer.MatricesWeightsKind
  23848. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  23849. *
  23850. * Returns the Mesh.
  23851. */
  23852. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  23853. /**
  23854. * Sets the mesh indices.
  23855. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  23856. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  23857. * This method creates a new index buffer each call.
  23858. * Returns the Mesh.
  23859. */
  23860. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  23861. /**
  23862. * Boolean : True if the mesh owns the requested kind of data.
  23863. */
  23864. isVerticesDataPresent(kind: string): boolean;
  23865. /**
  23866. * Returns an array of indices (IndicesArray).
  23867. */
  23868. getIndices(): Nullable<IndicesArray>;
  23869. protected readonly _positions: Nullable<Vector3[]>;
  23870. /**
  23871. * Sets a new updated BoundingInfo to the mesh.
  23872. * Returns the mesh.
  23873. */
  23874. refreshBoundingInfo(): InstancedMesh;
  23875. /** @hidden */
  23876. /** @hidden */
  23877. /**
  23878. * Returns the current associated LOD AbstractMesh.
  23879. */
  23880. getLOD(camera: Camera): AbstractMesh;
  23881. /** @hidden */
  23882. /** @hidden */
  23883. /**
  23884. * Creates a new InstancedMesh from the current mesh.
  23885. * - name (string) : the cloned mesh name
  23886. * - newParent (optional Node) : the optional Node to parent the clone to.
  23887. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  23888. *
  23889. * Returns the clone.
  23890. */
  23891. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  23892. /**
  23893. * Disposes the InstancedMesh.
  23894. * Returns nothing.
  23895. */
  23896. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  23897. }
  23898. }
  23899. declare module BABYLON {
  23900. class LinesMesh extends Mesh {
  23901. useVertexColor?: boolean | undefined;
  23902. useVertexAlpha?: boolean | undefined;
  23903. color: Color3;
  23904. alpha: number;
  23905. /**
  23906. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  23907. * This margin is expressed in world space coordinates, so its value may vary.
  23908. * Default value is 0.1
  23909. * @returns the intersection Threshold value.
  23910. */
  23911. /**
  23912. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  23913. * This margin is expressed in world space coordinates, so its value may vary.
  23914. * @param value the new threshold to apply
  23915. */
  23916. intersectionThreshold: number;
  23917. private _intersectionThreshold;
  23918. private _colorShader;
  23919. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean, useVertexColor?: boolean | undefined, useVertexAlpha?: boolean | undefined);
  23920. /**
  23921. * Returns the string "LineMesh"
  23922. */
  23923. getClassName(): string;
  23924. /**
  23925. * @hidden
  23926. */
  23927. /**
  23928. * @hidden
  23929. */
  23930. material: Material;
  23931. /**
  23932. * @hidden
  23933. */
  23934. readonly checkCollisions: boolean;
  23935. createInstance(name: string): InstancedMesh;
  23936. /** @hidden */
  23937. /** @hidden */
  23938. dispose(doNotRecurse?: boolean): void;
  23939. /**
  23940. * Returns a new LineMesh object cloned from the current one.
  23941. */
  23942. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  23943. }
  23944. }
  23945. declare module BABYLON {
  23946. /**
  23947. * @hidden
  23948. **/
  23949. class _InstancesBatch {
  23950. mustReturn: boolean;
  23951. visibleInstances: Nullable<InstancedMesh[]>[];
  23952. renderSelf: boolean[];
  23953. }
  23954. /**
  23955. * Class used to represent renderable models
  23956. */
  23957. class Mesh extends AbstractMesh implements IGetSetVerticesData {
  23958. /**
  23959. * Mesh side orientation : usually the external or front surface
  23960. */
  23961. static readonly FRONTSIDE: number;
  23962. /**
  23963. * Mesh side orientation : usually the internal or back surface
  23964. */
  23965. static readonly BACKSIDE: number;
  23966. /**
  23967. * Mesh side orientation : both internal and external or front and back surfaces
  23968. */
  23969. static readonly DOUBLESIDE: number;
  23970. /**
  23971. * Mesh side orientation : by default, `FRONTSIDE`
  23972. */
  23973. static readonly DEFAULTSIDE: number;
  23974. /**
  23975. * Mesh cap setting : no cap
  23976. */
  23977. static readonly NO_CAP: number;
  23978. /**
  23979. * Mesh cap setting : one cap at the beginning of the mesh
  23980. */
  23981. static readonly CAP_START: number;
  23982. /**
  23983. * Mesh cap setting : one cap at the end of the mesh
  23984. */
  23985. static readonly CAP_END: number;
  23986. /**
  23987. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  23988. */
  23989. static readonly CAP_ALL: number;
  23990. private _onBeforeRenderObservable;
  23991. private _onAfterRenderObservable;
  23992. private _onBeforeDrawObservable;
  23993. /**
  23994. * An event triggered before rendering the mesh
  23995. */
  23996. readonly onBeforeRenderObservable: Observable<Mesh>;
  23997. /**
  23998. * An event triggered after rendering the mesh
  23999. */
  24000. readonly onAfterRenderObservable: Observable<Mesh>;
  24001. /**
  24002. * An event triggered before drawing the mesh
  24003. */
  24004. readonly onBeforeDrawObservable: Observable<Mesh>;
  24005. private _onBeforeDrawObserver;
  24006. /**
  24007. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  24008. */
  24009. onBeforeDraw: () => void;
  24010. /**
  24011. * Gets the delay loading state of the mesh (when delay loading is turned on)
  24012. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  24013. */
  24014. delayLoadState: number;
  24015. /**
  24016. * Gets the list of instances created from this mesh
  24017. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24018. */
  24019. instances: InstancedMesh[];
  24020. /**
  24021. * Gets the file containing delay loading data for this mesh
  24022. */
  24023. delayLoadingFile: string;
  24024. /** @hidden */
  24025. private _LODLevels;
  24026. /**
  24027. * User defined function used to change how LOD level selection is done
  24028. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  24029. */
  24030. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  24031. private _morphTargetManager;
  24032. /**
  24033. * Gets or sets the morph target manager
  24034. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  24035. */
  24036. morphTargetManager: Nullable<MorphTargetManager>;
  24037. /** @hidden */
  24038. /** @hidden */
  24039. /** @hidden */
  24040. /** @hidden */
  24041. private _renderIdForInstances;
  24042. private _batchCache;
  24043. private _instancesBufferSize;
  24044. private _instancesBuffer;
  24045. private _instancesData;
  24046. private _overridenInstanceCount;
  24047. private _effectiveMaterial;
  24048. /** @hidden */
  24049. private _preActivateId;
  24050. /** @hidden */
  24051. /**
  24052. * Use this property to change the original side orientation defined at construction time
  24053. */
  24054. overrideMaterialSideOrientation: Nullable<number>;
  24055. private _areNormalsFrozen;
  24056. private _sourcePositions;
  24057. private _sourceNormals;
  24058. private _source;
  24059. /**
  24060. * Gets the source mesh (the one used to clone this one from)
  24061. */
  24062. readonly source: Nullable<Mesh>;
  24063. /**
  24064. * Gets or sets a boolean indicating that this mesh does not use index buffer
  24065. */
  24066. isUnIndexed: boolean;
  24067. /**
  24068. * @constructor
  24069. * @param name The value used by scene.getMeshByName() to do a lookup.
  24070. * @param scene The scene to add this mesh to.
  24071. * @param parent The parent of this mesh, if it has one
  24072. * @param source An optional Mesh from which geometry is shared, cloned.
  24073. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  24074. * When false, achieved by calling a clone(), also passing False.
  24075. * This will make creation of children, recursive.
  24076. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  24077. */
  24078. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  24079. /**
  24080. * Gets the class name
  24081. * @returns the string "Mesh".
  24082. */
  24083. getClassName(): string;
  24084. /**
  24085. * Returns a description of this mesh
  24086. * @param fullDetails define if full details about this mesh must be used
  24087. * @returns a descriptive string representing this mesh
  24088. */
  24089. toString(fullDetails?: boolean): string;
  24090. /** @hidden */
  24091. /**
  24092. * Gets a boolean indicating if this mesh has LOD
  24093. */
  24094. readonly hasLODLevels: boolean;
  24095. /**
  24096. * Gets the list of MeshLODLevel associated with the current mesh
  24097. * @returns an array of MeshLODLevel
  24098. */
  24099. getLODLevels(): MeshLODLevel[];
  24100. private _sortLODLevels;
  24101. /**
  24102. * Add a mesh as LOD level triggered at the given distance.
  24103. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24104. * @param distance The distance from the center of the object to show this level
  24105. * @param mesh The mesh to be added as LOD level (can be null)
  24106. * @return This mesh (for chaining)
  24107. */
  24108. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  24109. /**
  24110. * Returns the LOD level mesh at the passed distance or null if not found.
  24111. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24112. * @param distance The distance from the center of the object to show this level
  24113. * @returns a Mesh or `null`
  24114. */
  24115. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  24116. /**
  24117. * Remove a mesh from the LOD array
  24118. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24119. * @param mesh defines the mesh to be removed
  24120. * @return This mesh (for chaining)
  24121. */
  24122. removeLODLevel(mesh: Mesh): Mesh;
  24123. /**
  24124. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  24125. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24126. * @param camera defines the camera to use to compute distance
  24127. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  24128. * @return This mesh (for chaining)
  24129. */
  24130. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  24131. /**
  24132. * Gets the mesh internal Geometry object
  24133. */
  24134. readonly geometry: Nullable<Geometry>;
  24135. /**
  24136. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  24137. * @returns the total number of vertices
  24138. */
  24139. getTotalVertices(): number;
  24140. /**
  24141. * Returns the content of an associated vertex buffer
  24142. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24143. * - BABYLON.VertexBuffer.PositionKind
  24144. * - BABYLON.VertexBuffer.UVKind
  24145. * - BABYLON.VertexBuffer.UV2Kind
  24146. * - BABYLON.VertexBuffer.UV3Kind
  24147. * - BABYLON.VertexBuffer.UV4Kind
  24148. * - BABYLON.VertexBuffer.UV5Kind
  24149. * - BABYLON.VertexBuffer.UV6Kind
  24150. * - BABYLON.VertexBuffer.ColorKind
  24151. * - BABYLON.VertexBuffer.MatricesIndicesKind
  24152. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  24153. * - BABYLON.VertexBuffer.MatricesWeightsKind
  24154. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  24155. * @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
  24156. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  24157. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  24158. */
  24159. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24160. /**
  24161. * Returns the mesh VertexBuffer object from the requested `kind`
  24162. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24163. * - BABYLON.VertexBuffer.PositionKind
  24164. * - BABYLON.VertexBuffer.UVKind
  24165. * - BABYLON.VertexBuffer.UV2Kind
  24166. * - BABYLON.VertexBuffer.UV3Kind
  24167. * - BABYLON.VertexBuffer.UV4Kind
  24168. * - BABYLON.VertexBuffer.UV5Kind
  24169. * - BABYLON.VertexBuffer.UV6Kind
  24170. * - BABYLON.VertexBuffer.ColorKind
  24171. * - BABYLON.VertexBuffer.MatricesIndicesKind
  24172. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  24173. * - BABYLON.VertexBuffer.MatricesWeightsKind
  24174. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  24175. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  24176. */
  24177. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  24178. /**
  24179. * Tests if a specific vertex buffer is associated with this mesh
  24180. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24181. * - BABYLON.VertexBuffer.PositionKind
  24182. * - BABYLON.VertexBuffer.UVKind
  24183. * - BABYLON.VertexBuffer.UV2Kind
  24184. * - BABYLON.VertexBuffer.UV3Kind
  24185. * - BABYLON.VertexBuffer.UV4Kind
  24186. * - BABYLON.VertexBuffer.UV5Kind
  24187. * - BABYLON.VertexBuffer.UV6Kind
  24188. * - BABYLON.VertexBuffer.ColorKind
  24189. * - BABYLON.VertexBuffer.MatricesIndicesKind
  24190. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  24191. * - BABYLON.VertexBuffer.MatricesWeightsKind
  24192. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  24193. * @returns a boolean
  24194. */
  24195. isVerticesDataPresent(kind: string): boolean;
  24196. /**
  24197. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  24198. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24199. * - BABYLON.VertexBuffer.PositionKind
  24200. * - BABYLON.VertexBuffer.UVKind
  24201. * - BABYLON.VertexBuffer.UV2Kind
  24202. * - BABYLON.VertexBuffer.UV3Kind
  24203. * - BABYLON.VertexBuffer.UV4Kind
  24204. * - BABYLON.VertexBuffer.UV5Kind
  24205. * - BABYLON.VertexBuffer.UV6Kind
  24206. * - BABYLON.VertexBuffer.ColorKind
  24207. * - BABYLON.VertexBuffer.MatricesIndicesKind
  24208. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  24209. * - BABYLON.VertexBuffer.MatricesWeightsKind
  24210. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  24211. * @returns a boolean
  24212. */
  24213. isVertexBufferUpdatable(kind: string): boolean;
  24214. /**
  24215. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  24216. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24217. * - BABYLON.VertexBuffer.PositionKind
  24218. * - BABYLON.VertexBuffer.UVKind
  24219. * - BABYLON.VertexBuffer.UV2Kind
  24220. * - BABYLON.VertexBuffer.UV3Kind
  24221. * - BABYLON.VertexBuffer.UV4Kind
  24222. * - BABYLON.VertexBuffer.UV5Kind
  24223. * - BABYLON.VertexBuffer.UV6Kind
  24224. * - BABYLON.VertexBuffer.ColorKind
  24225. * - BABYLON.VertexBuffer.MatricesIndicesKind
  24226. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  24227. * - BABYLON.VertexBuffer.MatricesWeightsKind
  24228. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  24229. * @returns an array of strings
  24230. */
  24231. getVerticesDataKinds(): string[];
  24232. /**
  24233. * Returns a positive integer : the total number of indices in this mesh geometry.
  24234. * @returns the numner of indices or zero if the mesh has no geometry.
  24235. */
  24236. getTotalIndices(): number;
  24237. /**
  24238. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  24239. * @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.
  24240. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24241. * @returns the indices array or an empty array if the mesh has no geometry
  24242. */
  24243. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  24244. readonly isBlocked: boolean;
  24245. /**
  24246. * Determine if the current mesh is ready to be rendered
  24247. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  24248. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  24249. * @returns true if all associated assets are ready (material, textures, shaders)
  24250. */
  24251. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  24252. /**
  24253. * 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.
  24254. */
  24255. readonly areNormalsFrozen: boolean;
  24256. /**
  24257. * 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.
  24258. * @returns the current mesh
  24259. */
  24260. freezeNormals(): Mesh;
  24261. /**
  24262. * 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
  24263. * @returns the current mesh
  24264. */
  24265. unfreezeNormals(): Mesh;
  24266. /**
  24267. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  24268. */
  24269. overridenInstanceCount: number;
  24270. /** @hidden */
  24271. /** @hidden */
  24272. /** @hidden */
  24273. /**
  24274. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24275. * This means the mesh underlying bounding box and sphere are recomputed.
  24276. * @returns the current mesh
  24277. */
  24278. refreshBoundingInfo(): Mesh;
  24279. /** @hidden */
  24280. private _getPositionData;
  24281. /** @hidden */
  24282. /**
  24283. * This function will subdivide the mesh into multiple submeshes
  24284. * @param count defines the expected number of submeshes
  24285. */
  24286. subdivide(count: number): void;
  24287. /**
  24288. * Copy a FloatArray into a specific associated vertex buffer
  24289. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24290. * - BABYLON.VertexBuffer.PositionKind
  24291. * - BABYLON.VertexBuffer.UVKind
  24292. * - BABYLON.VertexBuffer.UV2Kind
  24293. * - BABYLON.VertexBuffer.UV3Kind
  24294. * - BABYLON.VertexBuffer.UV4Kind
  24295. * - BABYLON.VertexBuffer.UV5Kind
  24296. * - BABYLON.VertexBuffer.UV6Kind
  24297. * - BABYLON.VertexBuffer.ColorKind
  24298. * - BABYLON.VertexBuffer.MatricesIndicesKind
  24299. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  24300. * - BABYLON.VertexBuffer.MatricesWeightsKind
  24301. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  24302. * @param data defines the data source
  24303. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24304. * @param stride defines the data stride size (can be null)
  24305. * @returns the current mesh
  24306. */
  24307. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  24308. /**
  24309. * Flags an associated vertex buffer as updatable
  24310. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  24311. * - BABYLON.VertexBuffer.PositionKind
  24312. * - BABYLON.VertexBuffer.UVKind
  24313. * - BABYLON.VertexBuffer.UV2Kind
  24314. * - BABYLON.VertexBuffer.UV3Kind
  24315. * - BABYLON.VertexBuffer.UV4Kind
  24316. * - BABYLON.VertexBuffer.UV5Kind
  24317. * - BABYLON.VertexBuffer.UV6Kind
  24318. * - BABYLON.VertexBuffer.ColorKind
  24319. * - BABYLON.VertexBuffer.MatricesIndicesKind
  24320. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  24321. * - BABYLON.VertexBuffer.MatricesWeightsKind
  24322. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  24323. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24324. */
  24325. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  24326. /**
  24327. * Sets the mesh global Vertex Buffer
  24328. * @param buffer defines the buffer to use
  24329. * @returns the current mesh
  24330. */
  24331. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  24332. /**
  24333. * Update a specific associated vertex buffer
  24334. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24335. * - BABYLON.VertexBuffer.PositionKind
  24336. * - BABYLON.VertexBuffer.UVKind
  24337. * - BABYLON.VertexBuffer.UV2Kind
  24338. * - BABYLON.VertexBuffer.UV3Kind
  24339. * - BABYLON.VertexBuffer.UV4Kind
  24340. * - BABYLON.VertexBuffer.UV5Kind
  24341. * - BABYLON.VertexBuffer.UV6Kind
  24342. * - BABYLON.VertexBuffer.ColorKind
  24343. * - BABYLON.VertexBuffer.MatricesIndicesKind
  24344. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  24345. * - BABYLON.VertexBuffer.MatricesWeightsKind
  24346. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  24347. * @param data defines the data source
  24348. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  24349. * @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)
  24350. * @returns the current mesh
  24351. */
  24352. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  24353. /**
  24354. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  24355. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  24356. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  24357. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  24358. * @returns the current mesh
  24359. */
  24360. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  24361. /**
  24362. * Creates a un-shared specific occurence of the geometry for the mesh.
  24363. * @returns the current mesh
  24364. */
  24365. makeGeometryUnique(): Mesh;
  24366. /**
  24367. * Set the index buffer of this mesh
  24368. * @param indices defines the source data
  24369. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  24370. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  24371. * @returns the current mesh
  24372. */
  24373. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  24374. /**
  24375. * Update the current index buffer
  24376. * @param indices defines the source data
  24377. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  24378. * @returns the current mesh
  24379. */
  24380. updateIndices(indices: IndicesArray, offset?: number): Mesh;
  24381. /**
  24382. * Invert the geometry to move from a right handed system to a left handed one.
  24383. * @returns the current mesh
  24384. */
  24385. toLeftHanded(): Mesh;
  24386. /** @hidden */
  24387. /** @hidden */
  24388. /**
  24389. * Registers for this mesh a javascript function called just before the rendering process
  24390. * @param func defines the function to call before rendering this mesh
  24391. * @returns the current mesh
  24392. */
  24393. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24394. /**
  24395. * Disposes a previously registered javascript function called before the rendering
  24396. * @param func defines the function to remove
  24397. * @returns the current mesh
  24398. */
  24399. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24400. /**
  24401. * Registers for this mesh a javascript function called just after the rendering is complete
  24402. * @param func defines the function to call after rendering this mesh
  24403. * @returns the current mesh
  24404. */
  24405. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24406. /**
  24407. * Disposes a previously registered javascript function called after the rendering.
  24408. * @param func defines the function to remove
  24409. * @returns the current mesh
  24410. */
  24411. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24412. /** @hidden */
  24413. /** @hidden */
  24414. /** @hidden */
  24415. /**
  24416. * 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
  24417. * @param subMesh defines the subMesh to render
  24418. * @param enableAlphaMode defines if alpha mode can be changed
  24419. * @returns the current mesh
  24420. */
  24421. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  24422. private _onBeforeDraw;
  24423. /**
  24424. * Normalize matrix weights so that all vertices have a total weight set to 1
  24425. */
  24426. cleanMatrixWeights(): void;
  24427. /** @hidden */
  24428. private _queueLoad;
  24429. /**
  24430. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24431. * A mesh is in the frustum if its bounding box intersects the frustum
  24432. * @param frustumPlanes defines the frustum to test
  24433. * @returns true if the mesh is in the frustum planes
  24434. */
  24435. isInFrustum(frustumPlanes: Plane[]): boolean;
  24436. /**
  24437. * Sets the mesh material by the material or multiMaterial `id` property
  24438. * @param id is a string identifying the material or the multiMaterial
  24439. * @returns the current mesh
  24440. */
  24441. setMaterialByID(id: string): Mesh;
  24442. /**
  24443. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  24444. * @returns an array of IAnimatable
  24445. */
  24446. getAnimatables(): IAnimatable[];
  24447. /**
  24448. * Modifies the mesh geometry according to the passed transformation matrix.
  24449. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  24450. * The mesh normals are modified using the same transformation.
  24451. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24452. * @param transform defines the transform matrix to use
  24453. * @see http://doc.babylonjs.com/resources/baking_transformations
  24454. * @returns the current mesh
  24455. */
  24456. bakeTransformIntoVertices(transform: Matrix): Mesh;
  24457. /**
  24458. * Modifies the mesh geometry according to its own current World Matrix.
  24459. * The mesh World Matrix is then reset.
  24460. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  24461. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24462. * @see http://doc.babylonjs.com/resources/baking_transformations
  24463. * @returns the current mesh
  24464. */
  24465. bakeCurrentTransformIntoVertices(): Mesh;
  24466. /** @hidden */
  24467. protected readonly _positions: Nullable<Vector3[]>;
  24468. /** @hidden */
  24469. /** @hidden */
  24470. /**
  24471. * Returns a new Mesh object generated from the current mesh properties.
  24472. * This method must not get confused with createInstance()
  24473. * @param name is a string, the name given to the new mesh
  24474. * @param newParent can be any Node object (default `null`)
  24475. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  24476. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  24477. * @returns a new mesh
  24478. */
  24479. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  24480. /**
  24481. * Releases resources associated with this mesh.
  24482. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24483. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24484. */
  24485. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24486. /**
  24487. * Modifies the mesh geometry according to a displacement map.
  24488. * 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.
  24489. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24490. * @param url is a string, the URL from the image file is to be downloaded.
  24491. * @param minHeight is the lower limit of the displacement.
  24492. * @param maxHeight is the upper limit of the displacement.
  24493. * @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.
  24494. * @param uvOffset is an optional vector2 used to offset UV.
  24495. * @param uvScale is an optional vector2 used to scale UV.
  24496. * @param forceUpdate defines whether or not to force an update of the generated buffers. This is usefull to apply on a deserialized model for instance.
  24497. * @returns the Mesh.
  24498. */
  24499. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24500. /**
  24501. * Modifies the mesh geometry according to a displacementMap buffer.
  24502. * 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.
  24503. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24504. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  24505. * @param heightMapWidth is the width of the buffer image.
  24506. * @param heightMapHeight is the height of the buffer image.
  24507. * @param minHeight is the lower limit of the displacement.
  24508. * @param maxHeight is the upper limit of the displacement.
  24509. * @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.
  24510. * @param uvOffset is an optional vector2 used to offset UV.
  24511. * @param uvScale is an optional vector2 used to scale UV.
  24512. * @param forceUpdate defines whether or not to force an update of the generated buffers. This is usefull to apply on a deserialized model for instance.
  24513. * @returns the Mesh.
  24514. */
  24515. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24516. /**
  24517. * Modify the mesh to get a flat shading rendering.
  24518. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  24519. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  24520. * @returns current mesh
  24521. */
  24522. convertToFlatShadedMesh(): Mesh;
  24523. /**
  24524. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  24525. * In other words, more vertices, no more indices and a single bigger VBO.
  24526. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  24527. * @returns current mesh
  24528. */
  24529. convertToUnIndexedMesh(): Mesh;
  24530. /**
  24531. * Inverses facet orientations.
  24532. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24533. * @param flipNormals will also inverts the normals
  24534. * @returns current mesh
  24535. */
  24536. flipFaces(flipNormals?: boolean): Mesh;
  24537. /**
  24538. * Creates a new InstancedMesh object from the mesh model.
  24539. * Warning : this method is not supported for Line mesh and LineSystem
  24540. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24541. * @param name defines the name of the new instance
  24542. * @returns a new InstancedMesh
  24543. */
  24544. createInstance(name: string): InstancedMesh;
  24545. /**
  24546. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  24547. * After this call, all the mesh instances have the same submeshes than the current mesh.
  24548. * @returns the current mesh
  24549. */
  24550. synchronizeInstances(): Mesh;
  24551. /**
  24552. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  24553. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  24554. * This should be used together with the simplification to avoid disappearing triangles.
  24555. * @param successCallback an optional success callback to be called after the optimization finished.
  24556. * @returns the current mesh
  24557. */
  24558. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  24559. /**
  24560. * Serialize current mesh
  24561. * @param serializationObject defines the object which will receive the serialization data
  24562. */
  24563. serialize(serializationObject: any): void;
  24564. /** @hidden */
  24565. /**
  24566. * Returns a new Mesh object parsed from the source provided.
  24567. * @param parsedMesh is the source
  24568. * @param scene defines the hosting scene
  24569. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  24570. * @returns a new Mesh
  24571. */
  24572. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  24573. /**
  24574. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  24575. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24576. * @param name defines the name of the mesh to create
  24577. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  24578. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  24579. * @param closePath creates a seam between the first and the last points of each path of the path array
  24580. * @param offset is taken in account only if the `pathArray` is containing a single path
  24581. * @param scene defines the hosting scene
  24582. * @param updatable defines if the mesh must be flagged as updatable
  24583. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24584. * @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)
  24585. * @returns a new Mesh
  24586. */
  24587. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean | undefined, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24588. /**
  24589. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  24590. * @param name defines the name of the mesh to create
  24591. * @param radius sets the radius size (float) of the polygon (default 0.5)
  24592. * @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
  24593. * @param scene defines the hosting scene
  24594. * @param updatable defines if the mesh must be flagged as updatable
  24595. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24596. * @returns a new Mesh
  24597. */
  24598. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24599. /**
  24600. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  24601. * @param name defines the name of the mesh to create
  24602. * @param size sets the size (float) of each box side (default 1)
  24603. * @param scene defines the hosting scene
  24604. * @param updatable defines if the mesh must be flagged as updatable
  24605. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24606. * @returns a new Mesh
  24607. */
  24608. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24609. /**
  24610. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  24611. * @param name defines the name of the mesh to create
  24612. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24613. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24614. * @param scene defines the hosting scene
  24615. * @param updatable defines if the mesh must be flagged as updatable
  24616. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24617. * @returns a new Mesh
  24618. */
  24619. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24620. /**
  24621. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  24622. * @param name defines the name of the mesh to create
  24623. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  24624. * @param diameterTop set the top cap diameter (floats, default 1)
  24625. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  24626. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  24627. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  24628. * @param scene defines the hosting scene
  24629. * @param updatable defines if the mesh must be flagged as updatable
  24630. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24631. * @returns a new Mesh
  24632. */
  24633. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  24634. /**
  24635. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  24636. * @param name defines the name of the mesh to create
  24637. * @param diameter sets the diameter size (float) of the torus (default 1)
  24638. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  24639. * @param tessellation sets the number of torus sides (postive integer, default 16)
  24640. * @param scene defines the hosting scene
  24641. * @param updatable defines if the mesh must be flagged as updatable
  24642. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24643. * @returns a new Mesh
  24644. */
  24645. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24646. /**
  24647. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  24648. * @param name defines the name of the mesh to create
  24649. * @param radius sets the global radius size (float) of the torus knot (default 2)
  24650. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  24651. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  24652. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  24653. * @param p the number of windings on X axis (positive integers, default 2)
  24654. * @param q the number of windings on Y axis (positive integers, default 3)
  24655. * @param scene defines the hosting scene
  24656. * @param updatable defines if the mesh must be flagged as updatable
  24657. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24658. * @returns a new Mesh
  24659. */
  24660. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24661. /**
  24662. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  24663. * @param name defines the name of the mesh to create
  24664. * @param points is an array successive Vector3
  24665. * @param scene defines the hosting scene
  24666. * @param updatable defines if the mesh must be flagged as updatable
  24667. * @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).
  24668. * @returns a new Mesh
  24669. */
  24670. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  24671. /**
  24672. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  24673. * @param name defines the name of the mesh to create
  24674. * @param points is an array successive Vector3
  24675. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  24676. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  24677. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  24678. * @param scene defines the hosting scene
  24679. * @param updatable defines if the mesh must be flagged as updatable
  24680. * @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)
  24681. * @returns a new Mesh
  24682. */
  24683. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  24684. /**
  24685. * Creates a polygon mesh.
  24686. * Please consider using the same method from the MeshBuilder class instead.
  24687. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  24688. * 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.
  24689. * You can set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  24690. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  24691. * Remember you can only change the shape positions, not their number when updating a polygon.
  24692. */
  24693. /**
  24694. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  24695. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  24696. * @param name defines the name of the mesh to create
  24697. * @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
  24698. * @param scene defines the hosting scene
  24699. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  24700. * @param updatable defines if the mesh must be flagged as updatable
  24701. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24702. * @returns a new Mesh
  24703. */
  24704. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number): Mesh;
  24705. /**
  24706. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  24707. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  24708. * @param name defines the name of the mesh to create
  24709. * @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
  24710. * @param depth defines the height of extrusion
  24711. * @param scene defines the hosting scene
  24712. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  24713. * @param updatable defines if the mesh must be flagged as updatable
  24714. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24715. * @returns a new Mesh
  24716. */
  24717. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number): Mesh;
  24718. /**
  24719. * Creates an extruded shape mesh.
  24720. * 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
  24721. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24722. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  24723. * @param name defines the name of the mesh to create
  24724. * @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
  24725. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  24726. * @param scale is the value to scale the shape
  24727. * @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
  24728. * @param 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
  24729. * @param scene defines the hosting scene
  24730. * @param updatable defines if the mesh must be flagged as updatable
  24731. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24732. * @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)
  24733. * @returns a new Mesh
  24734. */
  24735. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24736. /**
  24737. * Creates an custom extruded shape mesh.
  24738. * The custom extrusion is a parametric shape.
  24739. * It has no predefined shape. Its final shape will depend on the input parameters.
  24740. * Please consider using the same method from the MeshBuilder class instead
  24741. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  24742. * @param name defines the name of the mesh to create
  24743. * @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
  24744. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  24745. * @param scaleFunction is a custom Javascript function called on each path point
  24746. * @param rotationFunction is a custom Javascript function called on each path point
  24747. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  24748. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  24749. * @param 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
  24750. * @param scene defines the hosting scene
  24751. * @param updatable defines if the mesh must be flagged as updatable
  24752. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24753. * @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)
  24754. * @returns a new Mesh
  24755. */
  24756. 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;
  24757. /**
  24758. * Creates lathe mesh.
  24759. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  24760. * Please consider using the same method from the MeshBuilder class instead
  24761. * @param name defines the name of the mesh to create
  24762. * @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
  24763. * @param radius is the radius value of the lathe
  24764. * @param tessellation is the side number of the lathe.
  24765. * @param scene defines the hosting scene
  24766. * @param updatable defines if the mesh must be flagged as updatable
  24767. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24768. * @returns a new Mesh
  24769. */
  24770. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24771. /**
  24772. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  24773. * @param name defines the name of the mesh to create
  24774. * @param size sets the size (float) of both sides of the plane at once (default 1)
  24775. * @param scene defines the hosting scene
  24776. * @param updatable defines if the mesh must be flagged as updatable
  24777. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24778. * @returns a new Mesh
  24779. */
  24780. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24781. /**
  24782. * Creates a ground mesh.
  24783. * Please consider using the same method from the MeshBuilder class instead
  24784. * @param name defines the name of the mesh to create
  24785. * @param width set the width of the ground
  24786. * @param height set the height of the ground
  24787. * @param subdivisions sets the number of subdivisions per side
  24788. * @param scene defines the hosting scene
  24789. * @param updatable defines if the mesh must be flagged as updatable
  24790. * @returns a new Mesh
  24791. */
  24792. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  24793. /**
  24794. * Creates a tiled ground mesh.
  24795. * Please consider using the same method from the MeshBuilder class instead
  24796. * @param name defines the name of the mesh to create
  24797. * @param xmin set the ground minimum X coordinate
  24798. * @param zmin set the ground minimum Y coordinate
  24799. * @param xmax set the ground maximum X coordinate
  24800. * @param zmax set the ground maximum Z coordinate
  24801. * @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
  24802. * @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
  24803. * @param scene defines the hosting scene
  24804. * @param updatable defines if the mesh must be flagged as updatable
  24805. * @returns a new Mesh
  24806. */
  24807. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  24808. w: number;
  24809. h: number;
  24810. }, precision: {
  24811. w: number;
  24812. h: number;
  24813. }, scene: Scene, updatable?: boolean): Mesh;
  24814. /**
  24815. * Creates a ground mesh from a height map.
  24816. * Please consider using the same method from the MeshBuilder class instead
  24817. * @see http://doc.babylonjs.com/babylon101/height_map
  24818. * @param name defines the name of the mesh to create
  24819. * @param url sets the URL of the height map image resource
  24820. * @param width set the ground width size
  24821. * @param height set the ground height size
  24822. * @param subdivisions sets the number of subdivision per side
  24823. * @param minHeight is the minimum altitude on the ground
  24824. * @param maxHeight is the maximum altitude on the ground
  24825. * @param scene defines the hosting scene
  24826. * @param updatable defines if the mesh must be flagged as updatable
  24827. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  24828. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  24829. * @returns a new Mesh
  24830. */
  24831. 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;
  24832. /**
  24833. * Creates a tube mesh.
  24834. * The tube is a parametric shape.
  24835. * It has no predefined shape. Its final shape will depend on the input parameters.
  24836. * Please consider using the same method from the MeshBuilder class instead
  24837. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24838. * @param name defines the name of the mesh to create
  24839. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  24840. * @param radius sets the tube radius size
  24841. * @param tessellation is the number of sides on the tubular surface
  24842. * @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
  24843. * @param 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
  24844. * @param scene defines the hosting scene
  24845. * @param updatable defines if the mesh must be flagged as updatable
  24846. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24847. * @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)
  24848. * @returns a new Mesh
  24849. */
  24850. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  24851. (i: number, distance: number): number;
  24852. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24853. /**
  24854. * Creates a polyhedron mesh.
  24855. * Please consider using the same method from the MeshBuilder class instead.
  24856. * * 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
  24857. * * The parameter `size` (positive float, default 1) sets the polygon size
  24858. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  24859. * * 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`
  24860. * * 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
  24861. * * 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)`)
  24862. * * 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 : http://doc.babylonjs.com/tutorials/CreateBox_Per_Face_Textures_And_Colors
  24863. * * 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
  24864. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  24865. * * 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
  24866. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24867. * @param name defines the name of the mesh to create
  24868. * @param options defines the options used to create the mesh
  24869. * @param scene defines the hosting scene
  24870. * @returns a new Mesh
  24871. */
  24872. static CreatePolyhedron(name: string, options: {
  24873. type?: number;
  24874. size?: number;
  24875. sizeX?: number;
  24876. sizeY?: number;
  24877. sizeZ?: number;
  24878. custom?: any;
  24879. faceUV?: Vector4[];
  24880. faceColors?: Color4[];
  24881. updatable?: boolean;
  24882. sideOrientation?: number;
  24883. }, scene: Scene): Mesh;
  24884. /**
  24885. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  24886. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  24887. * * 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`)
  24888. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  24889. * * 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
  24890. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  24891. * * 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
  24892. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24893. * @param name defines the name of the mesh
  24894. * @param options defines the options used to create the mesh
  24895. * @param scene defines the hosting scene
  24896. * @returns a new Mesh
  24897. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  24898. */
  24899. static CreateIcoSphere(name: string, options: {
  24900. radius?: number;
  24901. flat?: boolean;
  24902. subdivisions?: number;
  24903. sideOrientation?: number;
  24904. updatable?: boolean;
  24905. }, scene: Scene): Mesh;
  24906. /**
  24907. * Creates a decal mesh.
  24908. * Please consider using the same method from the MeshBuilder class instead.
  24909. * A decal is a mesh usually applied as a model onto the surface of another mesh
  24910. * @param name defines the name of the mesh
  24911. * @param sourceMesh defines the mesh receiving the decal
  24912. * @param position sets the position of the decal in world coordinates
  24913. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  24914. * @param size sets the decal scaling
  24915. * @param angle sets the angle to rotate the decal
  24916. * @returns a new Mesh
  24917. */
  24918. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  24919. /**
  24920. * Prepare internal position array for software CPU skinning
  24921. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  24922. */
  24923. setPositionsForCPUSkinning(): Float32Array;
  24924. /**
  24925. * Prepare internal normal array for software CPU skinning
  24926. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  24927. */
  24928. setNormalsForCPUSkinning(): Float32Array;
  24929. /**
  24930. * Updates the vertex buffer by applying transformation from the bones
  24931. * @param skeleton defines the skeleton to apply to current mesh
  24932. * @returns the current mesh
  24933. */
  24934. applySkeleton(skeleton: Skeleton): Mesh;
  24935. /**
  24936. * 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
  24937. * @param meshes defines the list of meshes to scan
  24938. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  24939. */
  24940. static MinMax(meshes: AbstractMesh[]): {
  24941. min: Vector3;
  24942. max: Vector3;
  24943. };
  24944. /**
  24945. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  24946. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  24947. * @returns a vector3
  24948. */
  24949. static Center(meshesOrMinMaxVector: {
  24950. min: Vector3;
  24951. max: Vector3;
  24952. } | AbstractMesh[]): Vector3;
  24953. /**
  24954. * Merge the array of meshes into a single mesh for performance reasons.
  24955. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  24956. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  24957. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  24958. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  24959. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  24960. * @returns a new mesh
  24961. */
  24962. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean): Nullable<Mesh>;
  24963. }
  24964. }
  24965. declare module BABYLON {
  24966. /**
  24967. * Define an interface for all classes that will get and set the data on vertices
  24968. */
  24969. interface IGetSetVerticesData {
  24970. isVerticesDataPresent(kind: string): boolean;
  24971. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24972. /**
  24973. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  24974. * @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.
  24975. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24976. * @returns the indices array or an empty array if the mesh has no geometry
  24977. */
  24978. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  24979. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  24980. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  24981. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  24982. }
  24983. /**
  24984. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  24985. */
  24986. class VertexData {
  24987. /**
  24988. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  24989. */
  24990. positions: Nullable<FloatArray>;
  24991. /**
  24992. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  24993. */
  24994. normals: Nullable<FloatArray>;
  24995. /**
  24996. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  24997. */
  24998. tangents: Nullable<FloatArray>;
  24999. /**
  25000. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25001. */
  25002. uvs: Nullable<FloatArray>;
  25003. /**
  25004. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25005. */
  25006. uvs2: Nullable<FloatArray>;
  25007. /**
  25008. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25009. */
  25010. uvs3: Nullable<FloatArray>;
  25011. /**
  25012. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25013. */
  25014. uvs4: Nullable<FloatArray>;
  25015. /**
  25016. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25017. */
  25018. uvs5: Nullable<FloatArray>;
  25019. /**
  25020. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25021. */
  25022. uvs6: Nullable<FloatArray>;
  25023. /**
  25024. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  25025. */
  25026. colors: Nullable<FloatArray>;
  25027. /**
  25028. * 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).
  25029. */
  25030. matricesIndices: Nullable<FloatArray>;
  25031. /**
  25032. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  25033. */
  25034. matricesWeights: Nullable<FloatArray>;
  25035. /**
  25036. * An array extending the number of possible indices
  25037. */
  25038. matricesIndicesExtra: Nullable<FloatArray>;
  25039. /**
  25040. * An array extending the number of possible weights when the number of indices is extended
  25041. */
  25042. matricesWeightsExtra: Nullable<FloatArray>;
  25043. /**
  25044. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  25045. */
  25046. indices: Nullable<IndicesArray>;
  25047. /**
  25048. * Uses the passed data array to set the set the values for the specified kind of data
  25049. * @param data a linear array of floating numbers
  25050. * @param kind the type of data that is being set, eg positions, colors etc
  25051. */
  25052. set(data: FloatArray, kind: string): void;
  25053. /**
  25054. * Associates the vertexData to the passed Mesh.
  25055. * Sets it as updatable or not (default `false`)
  25056. * @param mesh the mesh the vertexData is applied to
  25057. * @param updatable when used and having the value true allows new data to update the vertexData
  25058. * @returns the VertexData
  25059. */
  25060. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  25061. /**
  25062. * Associates the vertexData to the passed Geometry.
  25063. * Sets it as updatable or not (default `false`)
  25064. * @param geometry the geometry the vertexData is applied to
  25065. * @param updatable when used and having the value true allows new data to update the vertexData
  25066. * @returns VertexData
  25067. */
  25068. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  25069. /**
  25070. * Updates the associated mesh
  25071. * @param mesh the mesh to be updated
  25072. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  25073. * @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
  25074. * @returns VertexData
  25075. */
  25076. updateMesh(mesh: Mesh, updateExtends?: boolean, makeItUnique?: boolean): VertexData;
  25077. /**
  25078. * Updates the associated geometry
  25079. * @param geometry the geometry to be updated
  25080. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  25081. * @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
  25082. * @returns VertexData.
  25083. */
  25084. updateGeometry(geometry: Geometry, updateExtends?: boolean, makeItUnique?: boolean): VertexData;
  25085. private _applyTo;
  25086. private _update;
  25087. /**
  25088. * Transforms each position and each normal of the vertexData according to the passed Matrix
  25089. * @param matrix the transforming matrix
  25090. * @returns the VertexData
  25091. */
  25092. transform(matrix: Matrix): VertexData;
  25093. /**
  25094. * Merges the passed VertexData into the current one
  25095. * @param other the VertexData to be merged into the current one
  25096. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  25097. * @returns the modified VertexData
  25098. */
  25099. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  25100. private _mergeElement;
  25101. private _validate;
  25102. /**
  25103. * Serializes the VertexData
  25104. * @returns a serialized object
  25105. */
  25106. serialize(): any;
  25107. /**
  25108. * Extracts the vertexData from a mesh
  25109. * @param mesh the mesh from which to extract the VertexData
  25110. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  25111. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  25112. * @returns the object VertexData associated to the passed mesh
  25113. */
  25114. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  25115. /**
  25116. * Extracts the vertexData from the geometry
  25117. * @param geometry the geometry from which to extract the VertexData
  25118. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  25119. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  25120. * @returns the object VertexData associated to the passed mesh
  25121. */
  25122. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  25123. private static _ExtractFrom;
  25124. /**
  25125. * Creates the VertexData for a Ribbon
  25126. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  25127. * * pathArray array of paths, each of which an array of successive Vector3
  25128. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  25129. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  25130. * * 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
  25131. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  25132. * * 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)
  25133. * * 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)
  25134. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  25135. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  25136. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  25137. * @returns the VertexData of the ribbon
  25138. */
  25139. static CreateRibbon(options: {
  25140. pathArray: Vector3[][];
  25141. closeArray?: boolean;
  25142. closePath?: boolean;
  25143. offset?: number;
  25144. sideOrientation?: number;
  25145. frontUVs?: Vector4;
  25146. backUVs?: Vector4;
  25147. invertUV?: boolean;
  25148. uvs?: Vector2[];
  25149. colors?: Color4[];
  25150. }): VertexData;
  25151. /**
  25152. * Creates the VertexData for a box
  25153. * @param options an object used to set the following optional parameters for the box, required but can be empty
  25154. * * size sets the width, height and depth of the box to the value of size, optional default 1
  25155. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  25156. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  25157. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  25158. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  25159. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  25160. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  25161. * * 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)
  25162. * * 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)
  25163. * @returns the VertexData of the box
  25164. */
  25165. static CreateBox(options: {
  25166. size?: number;
  25167. width?: number;
  25168. height?: number;
  25169. depth?: number;
  25170. faceUV?: Vector4[];
  25171. faceColors?: Color4[];
  25172. sideOrientation?: number;
  25173. frontUVs?: Vector4;
  25174. backUVs?: Vector4;
  25175. }): VertexData;
  25176. /**
  25177. * Creates the VertexData for an ellipsoid, defaults to a sphere
  25178. * @param options an object used to set the following optional parameters for the box, required but can be empty
  25179. * * segments sets the number of horizontal strips optional, default 32
  25180. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  25181. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  25182. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  25183. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  25184. * * 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
  25185. * * 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
  25186. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  25187. * * 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)
  25188. * * 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)
  25189. * @returns the VertexData of the ellipsoid
  25190. */
  25191. static CreateSphere(options: {
  25192. segments?: number;
  25193. diameter?: number;
  25194. diameterX?: number;
  25195. diameterY?: number;
  25196. diameterZ?: number;
  25197. arc?: number;
  25198. slice?: number;
  25199. sideOrientation?: number;
  25200. frontUVs?: Vector4;
  25201. backUVs?: Vector4;
  25202. }): VertexData;
  25203. /**
  25204. * Creates the VertexData for a cylinder, cone or prism
  25205. * @param options an object used to set the following optional parameters for the box, required but can be empty
  25206. * * height sets the height (y direction) of the cylinder, optional, default 2
  25207. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  25208. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  25209. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  25210. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  25211. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  25212. * * 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
  25213. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  25214. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  25215. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  25216. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  25217. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  25218. * * 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)
  25219. * * 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)
  25220. * @returns the VertexData of the cylinder, cone or prism
  25221. */
  25222. static CreateCylinder(options: {
  25223. height?: number;
  25224. diameterTop?: number;
  25225. diameterBottom?: number;
  25226. diameter?: number;
  25227. tessellation?: number;
  25228. subdivisions?: number;
  25229. arc?: number;
  25230. faceColors?: Color4[];
  25231. faceUV?: Vector4[];
  25232. hasRings?: boolean;
  25233. enclose?: boolean;
  25234. sideOrientation?: number;
  25235. frontUVs?: Vector4;
  25236. backUVs?: Vector4;
  25237. }): VertexData;
  25238. /**
  25239. * Creates the VertexData for a torus
  25240. * @param options an object used to set the following optional parameters for the box, required but can be empty
  25241. * * diameter the diameter of the torus, optional default 1
  25242. * * thickness the diameter of the tube forming the torus, optional default 0.5
  25243. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  25244. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  25245. * * 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)
  25246. * * 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)
  25247. * @returns the VertexData of the torus
  25248. */
  25249. static CreateTorus(options: {
  25250. diameter?: number;
  25251. thickness?: number;
  25252. tessellation?: number;
  25253. sideOrientation?: number;
  25254. frontUVs?: Vector4;
  25255. backUVs?: Vector4;
  25256. }): VertexData;
  25257. /**
  25258. * Creates the VertexData of the LineSystem
  25259. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  25260. * - lines an array of lines, each line being an array of successive Vector3
  25261. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  25262. * @returns the VertexData of the LineSystem
  25263. */
  25264. static CreateLineSystem(options: {
  25265. lines: Vector3[][];
  25266. colors?: Nullable<Color4[][]>;
  25267. }): VertexData;
  25268. /**
  25269. * Create the VertexData for a DashedLines
  25270. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  25271. * - points an array successive Vector3
  25272. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  25273. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  25274. * - dashNb the intended total number of dashes, optional, default 200
  25275. * @returns the VertexData for the DashedLines
  25276. */
  25277. static CreateDashedLines(options: {
  25278. points: Vector3[];
  25279. dashSize?: number;
  25280. gapSize?: number;
  25281. dashNb?: number;
  25282. }): VertexData;
  25283. /**
  25284. * Creates the VertexData for a Ground
  25285. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  25286. * - width the width (x direction) of the ground, optional, default 1
  25287. * - height the height (z direction) of the ground, optional, default 1
  25288. * - subdivisions the number of subdivisions per side, optional, default 1
  25289. * @returns the VertexData of the Ground
  25290. */
  25291. static CreateGround(options: {
  25292. width?: number;
  25293. height?: number;
  25294. subdivisions?: number;
  25295. subdivisionsX?: number;
  25296. subdivisionsY?: number;
  25297. }): VertexData;
  25298. /**
  25299. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  25300. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  25301. * * xmin the ground minimum X coordinate, optional, default -1
  25302. * * zmin the ground minimum Z coordinate, optional, default -1
  25303. * * xmax the ground maximum X coordinate, optional, default 1
  25304. * * zmax the ground maximum Z coordinate, optional, default 1
  25305. * * 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}
  25306. * * 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}
  25307. * @returns the VertexData of the TiledGround
  25308. */
  25309. static CreateTiledGround(options: {
  25310. xmin: number;
  25311. zmin: number;
  25312. xmax: number;
  25313. zmax: number;
  25314. subdivisions?: {
  25315. w: number;
  25316. h: number;
  25317. };
  25318. precision?: {
  25319. w: number;
  25320. h: number;
  25321. };
  25322. }): VertexData;
  25323. /**
  25324. * Creates the VertexData of the Ground designed from a heightmap
  25325. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  25326. * * width the width (x direction) of the ground
  25327. * * height the height (z direction) of the ground
  25328. * * subdivisions the number of subdivisions per side
  25329. * * minHeight the minimum altitude on the ground, optional, default 0
  25330. * * maxHeight the maximum altitude on the ground, optional default 1
  25331. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  25332. * * buffer the array holding the image color data
  25333. * * bufferWidth the width of image
  25334. * * bufferHeight the height of image
  25335. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  25336. * @returns the VertexData of the Ground designed from a heightmap
  25337. */
  25338. static CreateGroundFromHeightMap(options: {
  25339. width: number;
  25340. height: number;
  25341. subdivisions: number;
  25342. minHeight: number;
  25343. maxHeight: number;
  25344. colorFilter: Color3;
  25345. buffer: Uint8Array;
  25346. bufferWidth: number;
  25347. bufferHeight: number;
  25348. alphaFilter: number;
  25349. }): VertexData;
  25350. /**
  25351. * Creates the VertexData for a Plane
  25352. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  25353. * * size sets the width and height of the plane to the value of size, optional default 1
  25354. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  25355. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  25356. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  25357. * * 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)
  25358. * * 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)
  25359. * @returns the VertexData of the box
  25360. */
  25361. static CreatePlane(options: {
  25362. size?: number;
  25363. width?: number;
  25364. height?: number;
  25365. sideOrientation?: number;
  25366. frontUVs?: Vector4;
  25367. backUVs?: Vector4;
  25368. }): VertexData;
  25369. /**
  25370. * Creates the VertexData of the Disc or regular Polygon
  25371. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  25372. * * radius the radius of the disc, optional default 0.5
  25373. * * tessellation the number of polygon sides, optional, default 64
  25374. * * 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
  25375. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  25376. * * 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)
  25377. * * 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)
  25378. * @returns the VertexData of the box
  25379. */
  25380. static CreateDisc(options: {
  25381. radius?: number;
  25382. tessellation?: number;
  25383. arc?: number;
  25384. sideOrientation?: number;
  25385. frontUVs?: Vector4;
  25386. backUVs?: Vector4;
  25387. }): VertexData;
  25388. /**
  25389. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  25390. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  25391. * @param polygon a mesh built from polygonTriangulation.build()
  25392. * @param sideOrientation takes the values BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  25393. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  25394. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  25395. * @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)
  25396. * @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)
  25397. * @returns the VertexData of the Polygon
  25398. */
  25399. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  25400. /**
  25401. * Creates the VertexData of the IcoSphere
  25402. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  25403. * * radius the radius of the IcoSphere, optional default 1
  25404. * * radiusX allows stretching in the x direction, optional, default radius
  25405. * * radiusY allows stretching in the y direction, optional, default radius
  25406. * * radiusZ allows stretching in the z direction, optional, default radius
  25407. * * flat when true creates a flat shaded mesh, optional, default true
  25408. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  25409. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  25410. * * 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)
  25411. * * 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)
  25412. * @returns the VertexData of the IcoSphere
  25413. */
  25414. static CreateIcoSphere(options: {
  25415. radius?: number;
  25416. radiusX?: number;
  25417. radiusY?: number;
  25418. radiusZ?: number;
  25419. flat?: boolean;
  25420. subdivisions?: number;
  25421. sideOrientation?: number;
  25422. frontUVs?: Vector4;
  25423. backUVs?: Vector4;
  25424. }): VertexData;
  25425. /**
  25426. * Creates the VertexData for a Polyhedron
  25427. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  25428. * * type provided types are:
  25429. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  25430. * * 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)
  25431. * * size the size of the IcoSphere, optional default 1
  25432. * * sizeX allows stretching in the x direction, optional, default size
  25433. * * sizeY allows stretching in the y direction, optional, default size
  25434. * * sizeZ allows stretching in the z direction, optional, default size
  25435. * * 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
  25436. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  25437. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  25438. * * flat when true creates a flat shaded mesh, optional, default true
  25439. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  25440. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  25441. * * 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)
  25442. * * 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)
  25443. * @returns the VertexData of the Polyhedron
  25444. */
  25445. static CreatePolyhedron(options: {
  25446. type?: number;
  25447. size?: number;
  25448. sizeX?: number;
  25449. sizeY?: number;
  25450. sizeZ?: number;
  25451. custom?: any;
  25452. faceUV?: Vector4[];
  25453. faceColors?: Color4[];
  25454. flat?: boolean;
  25455. sideOrientation?: number;
  25456. frontUVs?: Vector4;
  25457. backUVs?: Vector4;
  25458. }): VertexData;
  25459. /**
  25460. * Creates the VertexData for a TorusKnot
  25461. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  25462. * * radius the radius of the torus knot, optional, default 2
  25463. * * tube the thickness of the tube, optional, default 0.5
  25464. * * radialSegments the number of sides on each tube segments, optional, default 32
  25465. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  25466. * * p the number of windings around the z axis, optional, default 2
  25467. * * q the number of windings around the x axis, optional, default 3
  25468. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  25469. * * 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)
  25470. * * 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)
  25471. * @returns the VertexData of the Torus Knot
  25472. */
  25473. static CreateTorusKnot(options: {
  25474. radius?: number;
  25475. tube?: number;
  25476. radialSegments?: number;
  25477. tubularSegments?: number;
  25478. p?: number;
  25479. q?: number;
  25480. sideOrientation?: number;
  25481. frontUVs?: Vector4;
  25482. backUVs?: Vector4;
  25483. }): VertexData;
  25484. /**
  25485. * Compute normals for given positions and indices
  25486. * @param positions an array of vertex positions, [...., x, y, z, ......]
  25487. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  25488. * @param normals an array of vertex normals, [...., x, y, z, ......]
  25489. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  25490. * * facetNormals : optional array of facet normals (vector3)
  25491. * * facetPositions : optional array of facet positions (vector3)
  25492. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  25493. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  25494. * * bInfo : optional bounding info, required for facetPartitioning computation
  25495. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  25496. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  25497. * * useRightHandedSystem: optional boolean to for right handed system computation
  25498. * * depthSort : optional boolean to enable the facet depth sort computation
  25499. * * distanceTo : optional Vector3 to compute the facet depth from this location
  25500. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  25501. */
  25502. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  25503. facetNormals?: any;
  25504. facetPositions?: any;
  25505. facetPartitioning?: any;
  25506. ratio?: number;
  25507. bInfo?: any;
  25508. bbSize?: Vector3;
  25509. subDiv?: any;
  25510. useRightHandedSystem?: boolean;
  25511. depthSort?: boolean;
  25512. distanceTo?: Vector3;
  25513. depthSortedFacets?: any;
  25514. }): void;
  25515. private static _ComputeSides;
  25516. /**
  25517. * Applies VertexData created from the imported parameters to the geometry
  25518. * @param parsedVertexData the parsed data from an imported file
  25519. * @param geometry the geometry to apply the VertexData to
  25520. */
  25521. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  25522. }
  25523. }
  25524. declare module BABYLON {
  25525. /**
  25526. * Class containing static functions to help procedurally build meshes
  25527. */
  25528. class MeshBuilder {
  25529. private static updateSideOrientation;
  25530. /**
  25531. * Creates a box mesh
  25532. * * The parameter `size` sets the size (float) of each box side (default 1)
  25533. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  25534. * * 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)
  25535. * * Please read this tutorial : http://doc.babylonjs.com/tutorials/CreateBox_Per_Face_Textures_And_Colors
  25536. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  25537. * * 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
  25538. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25539. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#box
  25540. * @param name defines the name of the mesh
  25541. * @param options defines the options used to create the mesh
  25542. * @param scene defines the hosting scene
  25543. * @returns the box mesh
  25544. */
  25545. static CreateBox(name: string, options: {
  25546. size?: number;
  25547. width?: number;
  25548. height?: number;
  25549. depth?: number;
  25550. faceUV?: Vector4[];
  25551. faceColors?: Color4[];
  25552. sideOrientation?: number;
  25553. frontUVs?: Vector4;
  25554. backUVs?: Vector4;
  25555. updatable?: boolean;
  25556. }, scene?: Nullable<Scene>): Mesh;
  25557. /**
  25558. * Creates a sphere mesh
  25559. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  25560. * * 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`)
  25561. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  25562. * * 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
  25563. * * 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)
  25564. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  25565. * * 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
  25566. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25567. * @param name defines the name of the mesh
  25568. * @param options defines the options used to create the mesh
  25569. * @param scene defines the hosting scene
  25570. * @returns the sphere mesh
  25571. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#sphere
  25572. */
  25573. static CreateSphere(name: string, options: {
  25574. segments?: number;
  25575. diameter?: number;
  25576. diameterX?: number;
  25577. diameterY?: number;
  25578. diameterZ?: number;
  25579. arc?: number;
  25580. slice?: number;
  25581. sideOrientation?: number;
  25582. frontUVs?: Vector4;
  25583. backUVs?: Vector4;
  25584. updatable?: boolean;
  25585. }, scene: any): Mesh;
  25586. /**
  25587. * Creates a plane polygonal mesh. By default, this is a disc
  25588. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  25589. * * 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
  25590. * * 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
  25591. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  25592. * * 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
  25593. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25594. * @param name defines the name of the mesh
  25595. * @param options defines the options used to create the mesh
  25596. * @param scene defines the hosting scene
  25597. * @returns the plane polygonal mesh
  25598. * @see http://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  25599. */
  25600. static CreateDisc(name: string, options: {
  25601. radius?: number;
  25602. tessellation?: number;
  25603. arc?: number;
  25604. updatable?: boolean;
  25605. sideOrientation?: number;
  25606. frontUVs?: Vector4;
  25607. backUVs?: Vector4;
  25608. }, scene?: Nullable<Scene>): Mesh;
  25609. /**
  25610. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  25611. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  25612. * * 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`)
  25613. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  25614. * * 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
  25615. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  25616. * * 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
  25617. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25618. * @param name defines the name of the mesh
  25619. * @param options defines the options used to create the mesh
  25620. * @param scene defines the hosting scene
  25621. * @returns the icosahedron mesh
  25622. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  25623. */
  25624. static CreateIcoSphere(name: string, options: {
  25625. radius?: number;
  25626. radiusX?: number;
  25627. radiusY?: number;
  25628. radiusZ?: number;
  25629. flat?: boolean;
  25630. subdivisions?: number;
  25631. sideOrientation?: number;
  25632. frontUVs?: Vector4;
  25633. backUVs?: Vector4;
  25634. updatable?: boolean;
  25635. }, scene: Scene): Mesh;
  25636. /**
  25637. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  25638. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  25639. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  25640. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  25641. * * 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
  25642. * * 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
  25643. * * The optional parameter `instance` is an instance of an existing Ribbon object to be updated with the passed `pathArray` parameter : http://doc.babylonjs.com/tutorials/How_to_dynamically_morph_a_mesh#ribbon
  25644. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  25645. * * 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
  25646. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  25647. * * 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
  25648. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  25649. * * 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
  25650. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  25651. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25652. * @param name defines the name of the mesh
  25653. * @param options defines the options used to create the mesh
  25654. * @param scene defines the hosting scene
  25655. * @returns the ribbon mesh
  25656. * @see http://doc.babylonjs.com/tutorials/Ribbon_Tutorial
  25657. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  25658. */
  25659. static CreateRibbon(name: string, options: {
  25660. pathArray: Vector3[][];
  25661. closeArray?: boolean;
  25662. closePath?: boolean;
  25663. offset?: number;
  25664. updatable?: boolean;
  25665. sideOrientation?: number;
  25666. frontUVs?: Vector4;
  25667. backUVs?: Vector4;
  25668. instance?: Mesh;
  25669. invertUV?: boolean;
  25670. uvs?: Vector2[];
  25671. colors?: Color4[];
  25672. }, scene?: Nullable<Scene>): Mesh;
  25673. /**
  25674. * Creates a cylinder or a cone mesh
  25675. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  25676. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  25677. * * 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.
  25678. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  25679. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  25680. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  25681. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  25682. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  25683. * * 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).
  25684. * * 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
  25685. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  25686. * * 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
  25687. * * 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.
  25688. * * If `enclose` is false, a ring surface is one element.
  25689. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  25690. * * Example how to set colors and textures on a sliced cylinder : http://www.html5gamedevs.com/topic/17945-creating-a-closed-slice-of-a-cylinder/#comment-106379
  25691. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  25692. * * 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
  25693. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  25694. * @param name defines the name of the mesh
  25695. * @param options defines the options used to create the mesh
  25696. * @param scene defines the hosting scene
  25697. * @returns the cylinder mesh
  25698. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#cylinder-or-cone
  25699. */
  25700. static CreateCylinder(name: string, options: {
  25701. height?: number;
  25702. diameterTop?: number;
  25703. diameterBottom?: number;
  25704. diameter?: number;
  25705. tessellation?: number;
  25706. subdivisions?: number;
  25707. arc?: number;
  25708. faceColors?: Color4[];
  25709. faceUV?: Vector4[];
  25710. updatable?: boolean;
  25711. hasRings?: boolean;
  25712. enclose?: boolean;
  25713. sideOrientation?: number;
  25714. frontUVs?: Vector4;
  25715. backUVs?: Vector4;
  25716. }, scene: any): Mesh;
  25717. /**
  25718. * Creates a torus mesh
  25719. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  25720. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  25721. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  25722. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  25723. * * 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
  25724. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  25725. * @param name defines the name of the mesh
  25726. * @param options defines the options used to create the mesh
  25727. * @param scene defines the hosting scene
  25728. * @returns the torus mesh
  25729. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#torus
  25730. */
  25731. static CreateTorus(name: string, options: {
  25732. diameter?: number;
  25733. thickness?: number;
  25734. tessellation?: number;
  25735. updatable?: boolean;
  25736. sideOrientation?: number;
  25737. frontUVs?: Vector4;
  25738. backUVs?: Vector4;
  25739. }, scene: any): Mesh;
  25740. /**
  25741. * Creates a torus knot mesh
  25742. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  25743. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  25744. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  25745. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  25746. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  25747. * * 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
  25748. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  25749. * @param name defines the name of the mesh
  25750. * @param options defines the options used to create the mesh
  25751. * @param scene defines the hosting scene
  25752. * @returns the torus knot mesh
  25753. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#torus-knot
  25754. */
  25755. static CreateTorusKnot(name: string, options: {
  25756. radius?: number;
  25757. tube?: number;
  25758. radialSegments?: number;
  25759. tubularSegments?: number;
  25760. p?: number;
  25761. q?: number;
  25762. updatable?: boolean;
  25763. sideOrientation?: number;
  25764. frontUVs?: Vector4;
  25765. backUVs?: Vector4;
  25766. }, scene: any): Mesh;
  25767. /**
  25768. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  25769. * * 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
  25770. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  25771. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  25772. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  25773. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  25774. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  25775. * * Updating a simple Line mesh, you just need to update every line in the `lines` array : http://doc.babylonjs.com/tutorials/How_to_dynamically_morph_a_mesh#lines-and-dashedlines
  25776. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  25777. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25778. * @see http://doc.babylonjs.com/how_to/parametric_shapes#line-system
  25779. * @param name defines the name of the new line system
  25780. * @param options defines the options used to create the line system
  25781. * @param scene defines the hosting scene
  25782. * @returns a new line system mesh
  25783. */
  25784. static CreateLineSystem(name: string, options: {
  25785. lines: Vector3[][];
  25786. updatable?: boolean;
  25787. instance?: Nullable<LinesMesh>;
  25788. colors?: Nullable<Color4[][]>;
  25789. useVertexAlpha?: boolean;
  25790. }, scene: Nullable<Scene>): LinesMesh;
  25791. /**
  25792. * Creates a line mesh
  25793. * 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
  25794. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  25795. * * The parameter `points` is an array successive Vector3
  25796. * * The optional parameter `instance` is an instance of an existing LineMesh object to be updated with the passed `points` parameter : http://doc.babylonjs.com/tutorials/How_to_dynamically_morph_a_mesh#lines-and-dashedlines
  25797. * * The optional parameter `colors` is an array of successive Color4, one per line point
  25798. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  25799. * * When updating an instance, remember that only point positions can change, not the number of points
  25800. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25801. * @see http://doc.babylonjs.com/how_to/parametric_shapes#lines
  25802. * @param name defines the name of the new line system
  25803. * @param options defines the options used to create the line system
  25804. * @param scene defines the hosting scene
  25805. * @returns a new line mesh
  25806. */
  25807. static CreateLines(name: string, options: {
  25808. points: Vector3[];
  25809. updatable?: boolean;
  25810. instance?: Nullable<LinesMesh>;
  25811. colors?: Color4[];
  25812. useVertexAlpha?: boolean;
  25813. }, scene?: Nullable<Scene>): LinesMesh;
  25814. /**
  25815. * Creates a dashed line mesh
  25816. * * 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
  25817. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  25818. * * The parameter `points` is an array successive Vector3
  25819. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  25820. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  25821. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  25822. * * The optional parameter `instance` is an instance of an existing LineMesh object to be updated with the passed `points` parameter : http://doc.babylonjs.com/tutorials/How_to_dynamically_morph_a_mesh#lines-and-dashedlines
  25823. * * When updating an instance, remember that only point positions can change, not the number of points
  25824. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25825. * @param name defines the name of the mesh
  25826. * @param options defines the options used to create the mesh
  25827. * @param scene defines the hosting scene
  25828. * @returns the dashed line mesh
  25829. * @see http://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  25830. */
  25831. static CreateDashedLines(name: string, options: {
  25832. points: Vector3[];
  25833. dashSize?: number;
  25834. gapSize?: number;
  25835. dashNb?: number;
  25836. updatable?: boolean;
  25837. instance?: LinesMesh;
  25838. }, scene?: Nullable<Scene>): LinesMesh;
  25839. /**
  25840. * 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.
  25841. * * 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.
  25842. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  25843. * * 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.
  25844. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  25845. * * 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
  25846. * * The optional parameter `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/tutorials/How_to_dynamically_morph_a_mesh#extruded-shape
  25847. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  25848. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  25849. * * 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
  25850. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  25851. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  25852. * @param name defines the name of the mesh
  25853. * @param options defines the options used to create the mesh
  25854. * @param scene defines the hosting scene
  25855. * @returns the extruded shape mesh
  25856. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  25857. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25858. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25859. */
  25860. static ExtrudeShape(name: string, options: {
  25861. shape: Vector3[];
  25862. path: Vector3[];
  25863. scale?: number;
  25864. rotation?: number;
  25865. cap?: number;
  25866. updatable?: boolean;
  25867. sideOrientation?: number;
  25868. frontUVs?: Vector4;
  25869. backUVs?: Vector4;
  25870. instance?: Mesh;
  25871. invertUV?: boolean;
  25872. }, scene?: Nullable<Scene>): Mesh;
  25873. /**
  25874. * Creates an custom extruded shape mesh.
  25875. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  25876. * * 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.
  25877. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  25878. * * 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
  25879. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  25880. * * 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
  25881. * * It must returns a float value that will be the scale value applied to the shape on each path point
  25882. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  25883. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  25884. * * 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
  25885. * * The optional parameter `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/tutorials/How_to_dynamically_morph_a_mesh#extruded-shape
  25886. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  25887. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  25888. * * 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
  25889. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  25890. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25891. * @param name defines the name of the mesh
  25892. * @param options defines the options used to create the mesh
  25893. * @param scene defines the hosting scene
  25894. * @returns the custom extruded shape mesh
  25895. * @see http://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  25896. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  25897. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25898. */
  25899. static ExtrudeShapeCustom(name: string, options: {
  25900. shape: Vector3[];
  25901. path: Vector3[];
  25902. scaleFunction?: any;
  25903. rotationFunction?: any;
  25904. ribbonCloseArray?: boolean;
  25905. ribbonClosePath?: boolean;
  25906. cap?: number;
  25907. updatable?: boolean;
  25908. sideOrientation?: number;
  25909. frontUVs?: Vector4;
  25910. backUVs?: Vector4;
  25911. instance?: Mesh;
  25912. invertUV?: boolean;
  25913. }, scene: Scene): Mesh;
  25914. /**
  25915. * Creates lathe mesh.
  25916. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  25917. * * 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
  25918. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  25919. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  25920. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  25921. * * 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
  25922. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  25923. * * 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
  25924. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  25925. * * 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
  25926. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  25927. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25928. * @param name defines the name of the mesh
  25929. * @param options defines the options used to create the mesh
  25930. * @param scene defines the hosting scene
  25931. * @returns the lathe mesh
  25932. * @see http://doc.babylonjs.com/how_to/parametric_shapes#lathe
  25933. */
  25934. static CreateLathe(name: string, options: {
  25935. shape: Vector3[];
  25936. radius?: number;
  25937. tessellation?: number;
  25938. clip?: number;
  25939. arc?: number;
  25940. closed?: boolean;
  25941. updatable?: boolean;
  25942. sideOrientation?: number;
  25943. frontUVs?: Vector4;
  25944. backUVs?: Vector4;
  25945. cap?: number;
  25946. invertUV?: boolean;
  25947. }, scene: Scene): Mesh;
  25948. /**
  25949. * Creates a plane mesh
  25950. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  25951. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  25952. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  25953. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  25954. * * 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
  25955. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25956. * @param name defines the name of the mesh
  25957. * @param options defines the options used to create the mesh
  25958. * @param scene defines the hosting scene
  25959. * @returns the plane mesh
  25960. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#plane
  25961. */
  25962. static CreatePlane(name: string, options: {
  25963. size?: number;
  25964. width?: number;
  25965. height?: number;
  25966. sideOrientation?: number;
  25967. frontUVs?: Vector4;
  25968. backUVs?: Vector4;
  25969. updatable?: boolean;
  25970. sourcePlane?: Plane;
  25971. }, scene: Scene): Mesh;
  25972. /**
  25973. * Creates a ground mesh
  25974. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  25975. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  25976. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25977. * @param name defines the name of the mesh
  25978. * @param options defines the options used to create the mesh
  25979. * @param scene defines the hosting scene
  25980. * @returns the ground mesh
  25981. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#plane
  25982. */
  25983. static CreateGround(name: string, options: {
  25984. width?: number;
  25985. height?: number;
  25986. subdivisions?: number;
  25987. subdivisionsX?: number;
  25988. subdivisionsY?: number;
  25989. updatable?: boolean;
  25990. }, scene: any): Mesh;
  25991. /**
  25992. * Creates a tiled ground mesh
  25993. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  25994. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  25995. * * 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
  25996. * * 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
  25997. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  25998. * @param name defines the name of the mesh
  25999. * @param options defines the options used to create the mesh
  26000. * @param scene defines the hosting scene
  26001. * @returns the tiled ground mesh
  26002. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#tiled-ground
  26003. */
  26004. static CreateTiledGround(name: string, options: {
  26005. xmin: number;
  26006. zmin: number;
  26007. xmax: number;
  26008. zmax: number;
  26009. subdivisions?: {
  26010. w: number;
  26011. h: number;
  26012. };
  26013. precision?: {
  26014. w: number;
  26015. h: number;
  26016. };
  26017. updatable?: boolean;
  26018. }, scene: Scene): Mesh;
  26019. /**
  26020. * Creates a ground mesh from a height map
  26021. * * The parameter `url` sets the URL of the height map image resource.
  26022. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  26023. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  26024. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  26025. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  26026. * * 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.
  26027. * * 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).
  26028. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  26029. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  26030. * @param name defines the name of the mesh
  26031. * @param url defines the url to the height map
  26032. * @param options defines the options used to create the mesh
  26033. * @param scene defines the hosting scene
  26034. * @returns the ground mesh
  26035. * @see http://doc.babylonjs.com/babylon101/height_map
  26036. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#ground-from-a-height-map
  26037. */
  26038. static CreateGroundFromHeightMap(name: string, url: string, options: {
  26039. width?: number;
  26040. height?: number;
  26041. subdivisions?: number;
  26042. minHeight?: number;
  26043. maxHeight?: number;
  26044. colorFilter?: Color3;
  26045. alphaFilter?: number;
  26046. updatable?: boolean;
  26047. onReady?: (mesh: GroundMesh) => void;
  26048. }, scene: Scene): GroundMesh;
  26049. /**
  26050. * Creates a polygon mesh
  26051. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  26052. * * 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
  26053. * * You can set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  26054. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  26055. * * 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)
  26056. * * Remember you can only change the shape positions, not their number when updating a polygon
  26057. * @param name defines the name of the mesh
  26058. * @param options defines the options used to create the mesh
  26059. * @param scene defines the hosting scene
  26060. * @returns the polygon mesh
  26061. */
  26062. static CreatePolygon(name: string, options: {
  26063. shape: Vector3[];
  26064. holes?: Vector3[][];
  26065. depth?: number;
  26066. faceUV?: Vector4[];
  26067. faceColors?: Color4[];
  26068. updatable?: boolean;
  26069. sideOrientation?: number;
  26070. frontUVs?: Vector4;
  26071. backUVs?: Vector4;
  26072. }, scene: Scene): Mesh;
  26073. /**
  26074. * Creates an extruded polygon mesh, with depth in the Y direction.
  26075. * * 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)
  26076. * @see http://doc.babylonjs.com/tutorials/CreateBox_Per_Face_Textures_And_Colors
  26077. * @param name defines the name of the mesh
  26078. * @param options defines the options used to create the mesh
  26079. * @param scene defines the hosting scene
  26080. * @returns the polygon mesh
  26081. */
  26082. static ExtrudePolygon(name: string, options: {
  26083. shape: Vector3[];
  26084. holes?: Vector3[][];
  26085. depth?: number;
  26086. faceUV?: Vector4[];
  26087. faceColors?: Color4[];
  26088. updatable?: boolean;
  26089. sideOrientation?: number;
  26090. frontUVs?: Vector4;
  26091. backUVs?: Vector4;
  26092. }, scene: Scene): Mesh;
  26093. /**
  26094. * Creates a tube mesh.
  26095. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  26096. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  26097. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  26098. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  26099. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  26100. * * 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)
  26101. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  26102. * * 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
  26103. * * The optional parameter `instance` is an instance of an existing Tube object to be updated with the passed `pathArray` parameter : http://doc.babylonjs.com/tutorials/How_to_dynamically_morph_a_mesh#tube
  26104. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  26105. * * 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
  26106. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  26107. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  26108. * @param name defines the name of the mesh
  26109. * @param options defines the options used to create the mesh
  26110. * @param scene defines the hosting scene
  26111. * @returns the tube mesh
  26112. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  26113. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#tube
  26114. */
  26115. static CreateTube(name: string, options: {
  26116. path: Vector3[];
  26117. radius?: number;
  26118. tessellation?: number;
  26119. radiusFunction?: {
  26120. (i: number, distance: number): number;
  26121. };
  26122. cap?: number;
  26123. arc?: number;
  26124. updatable?: boolean;
  26125. sideOrientation?: number;
  26126. frontUVs?: Vector4;
  26127. backUVs?: Vector4;
  26128. instance?: Mesh;
  26129. invertUV?: boolean;
  26130. }, scene: Scene): Mesh;
  26131. /**
  26132. * Creates a polyhedron mesh
  26133. * * 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
  26134. * * The parameter `size` (positive float, default 1) sets the polygon size
  26135. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  26136. * * 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`
  26137. * * 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
  26138. * * 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)`)
  26139. * * 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 : http://doc.babylonjs.com/tutorials/CreateBox_Per_Face_Textures_And_Colors
  26140. * * 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
  26141. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  26142. * * 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
  26143. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  26144. * @param name defines the name of the mesh
  26145. * @param options defines the options used to create the mesh
  26146. * @param scene defines the hosting scene
  26147. * @returns the polyhedron mesh
  26148. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes
  26149. */
  26150. static CreatePolyhedron(name: string, options: {
  26151. type?: number;
  26152. size?: number;
  26153. sizeX?: number;
  26154. sizeY?: number;
  26155. sizeZ?: number;
  26156. custom?: any;
  26157. faceUV?: Vector4[];
  26158. faceColors?: Color4[];
  26159. flat?: boolean;
  26160. updatable?: boolean;
  26161. sideOrientation?: number;
  26162. frontUVs?: Vector4;
  26163. backUVs?: Vector4;
  26164. }, scene: Scene): Mesh;
  26165. /**
  26166. * Creates a decal mesh.
  26167. * 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
  26168. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  26169. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  26170. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  26171. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  26172. * @param name defines the name of the mesh
  26173. * @param sourceMesh defines the mesh where the decal must be applied
  26174. * @param options defines the options used to create the mesh
  26175. * @param scene defines the hosting scene
  26176. * @returns the decal mesh
  26177. * @see http://doc.babylonjs.com/how_to/decals
  26178. */
  26179. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  26180. position?: Vector3;
  26181. normal?: Vector3;
  26182. size?: Vector3;
  26183. angle?: number;
  26184. }): Mesh;
  26185. private static _ExtrudeShapeGeneric;
  26186. }
  26187. }
  26188. declare module BABYLON {
  26189. /**
  26190. * Class used to represent a specific level of detail of a mesh
  26191. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  26192. */
  26193. class MeshLODLevel {
  26194. /** Defines the distance where this level should star being displayed */
  26195. distance: number;
  26196. /** Defines the mesh to use to render this level */
  26197. mesh: Nullable<Mesh>;
  26198. /**
  26199. * Creates a new LOD level
  26200. * @param distance defines the distance where this level should star being displayed
  26201. * @param mesh defines the mesh to use to render this level
  26202. */
  26203. constructor(
  26204. /** Defines the distance where this level should star being displayed */
  26205. distance: number,
  26206. /** Defines the mesh to use to render this level */
  26207. mesh: Nullable<Mesh>);
  26208. }
  26209. }
  26210. declare module BABYLON {
  26211. /**
  26212. * A simplifier interface for future simplification implementations.
  26213. */
  26214. interface ISimplifier {
  26215. /**
  26216. * Simplification of a given mesh according to the given settings.
  26217. * Since this requires computation, it is assumed that the function runs async.
  26218. * @param settings The settings of the simplification, including quality and distance
  26219. * @param successCallback A callback that will be called after the mesh was simplified.
  26220. * @param errorCallback in case of an error, this callback will be called. optional.
  26221. */
  26222. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  26223. }
  26224. /**
  26225. * Expected simplification settings.
  26226. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%);
  26227. */
  26228. interface ISimplificationSettings {
  26229. quality: number;
  26230. distance: number;
  26231. optimizeMesh?: boolean;
  26232. }
  26233. class SimplificationSettings implements ISimplificationSettings {
  26234. quality: number;
  26235. distance: number;
  26236. optimizeMesh?: boolean | undefined;
  26237. constructor(quality: number, distance: number, optimizeMesh?: boolean | undefined);
  26238. }
  26239. interface ISimplificationTask {
  26240. settings: Array<ISimplificationSettings>;
  26241. simplificationType: SimplificationType;
  26242. mesh: Mesh;
  26243. successCallback?: () => void;
  26244. parallelProcessing: boolean;
  26245. }
  26246. class SimplificationQueue {
  26247. private _simplificationArray;
  26248. running: boolean;
  26249. constructor();
  26250. addTask(task: ISimplificationTask): void;
  26251. executeNext(): void;
  26252. runSimplification(task: ISimplificationTask): void;
  26253. private getSimplifier;
  26254. }
  26255. /**
  26256. * The implemented types of simplification
  26257. * At the moment only Quadratic Error Decimation is implemented
  26258. */
  26259. enum SimplificationType {
  26260. /** Quadratic error decimation */
  26261. QUADRATIC = 0
  26262. }
  26263. class DecimationTriangle {
  26264. vertices: Array<DecimationVertex>;
  26265. normal: Vector3;
  26266. error: Array<number>;
  26267. deleted: boolean;
  26268. isDirty: boolean;
  26269. borderFactor: number;
  26270. deletePending: boolean;
  26271. originalOffset: number;
  26272. constructor(vertices: Array<DecimationVertex>);
  26273. }
  26274. class DecimationVertex {
  26275. position: Vector3;
  26276. id: number;
  26277. q: QuadraticMatrix;
  26278. isBorder: boolean;
  26279. triangleStart: number;
  26280. triangleCount: number;
  26281. originalOffsets: Array<number>;
  26282. constructor(position: Vector3, id: number);
  26283. updatePosition(newPosition: Vector3): void;
  26284. }
  26285. class QuadraticMatrix {
  26286. data: Array<number>;
  26287. constructor(data?: Array<number>);
  26288. det(a11: number, a12: number, a13: number, a21: number, a22: number, a23: number, a31: number, a32: number, a33: number): number;
  26289. addInPlace(matrix: QuadraticMatrix): void;
  26290. addArrayInPlace(data: Array<number>): void;
  26291. add(matrix: QuadraticMatrix): QuadraticMatrix;
  26292. static FromData(a: number, b: number, c: number, d: number): QuadraticMatrix;
  26293. static DataFromNumbers(a: number, b: number, c: number, d: number): number[];
  26294. }
  26295. class Reference {
  26296. vertexId: number;
  26297. triangleId: number;
  26298. constructor(vertexId: number, triangleId: number);
  26299. }
  26300. /**
  26301. * An implementation of the Quadratic Error simplification algorithm.
  26302. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  26303. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  26304. * @author RaananW
  26305. */
  26306. class QuadraticErrorSimplification implements ISimplifier {
  26307. private _mesh;
  26308. private triangles;
  26309. private vertices;
  26310. private references;
  26311. private _reconstructedMesh;
  26312. syncIterations: number;
  26313. aggressiveness: number;
  26314. decimationIterations: number;
  26315. boundingBoxEpsilon: number;
  26316. constructor(_mesh: Mesh);
  26317. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  26318. private runDecimation;
  26319. private initWithMesh;
  26320. private init;
  26321. private reconstructMesh;
  26322. private initDecimatedMesh;
  26323. private isFlipped;
  26324. private updateTriangles;
  26325. private identifyBorder;
  26326. private updateMesh;
  26327. private vertexError;
  26328. private calculateError;
  26329. }
  26330. }
  26331. declare module BABYLON {
  26332. interface Scene {
  26333. /** @hidden (Backing field) */
  26334. /**
  26335. * Gets or sets the simplification queue attached to the scene
  26336. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  26337. */
  26338. simplificationQueue: SimplificationQueue;
  26339. }
  26340. interface Mesh {
  26341. /**
  26342. * Simplify the mesh according to the given array of settings.
  26343. * Function will return immediately and will simplify async
  26344. * @param settings a collection of simplification settings
  26345. * @param parallelProcessing should all levels calculate parallel or one after the other
  26346. * @param simplificationType the type of simplification to run
  26347. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  26348. * @returns the current mesh
  26349. */
  26350. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  26351. }
  26352. /**
  26353. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  26354. * created in a scene
  26355. */
  26356. class SimplicationQueueSceneComponent implements ISceneComponent {
  26357. /**
  26358. * The component name helpfull to identify the component in the list of scene components.
  26359. */
  26360. readonly name: string;
  26361. /**
  26362. * The scene the component belongs to.
  26363. */
  26364. scene: Scene;
  26365. /**
  26366. * Creates a new instance of the component for the given scene
  26367. * @param scene Defines the scene to register the component in
  26368. */
  26369. constructor(scene: Scene);
  26370. /**
  26371. * Registers the component in a given scene
  26372. */
  26373. register(): void;
  26374. /**
  26375. * Rebuilds the elements related to this component in case of
  26376. * context lost for instance.
  26377. */
  26378. rebuild(): void;
  26379. /**
  26380. * Disposes the component and the associated ressources
  26381. */
  26382. dispose(): void;
  26383. private _beforeCameraUpdate;
  26384. }
  26385. }
  26386. declare module BABYLON {
  26387. class Polygon {
  26388. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  26389. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  26390. static Parse(input: string): Vector2[];
  26391. static StartingAt(x: number, y: number): Path2;
  26392. }
  26393. class PolygonMeshBuilder {
  26394. private _points;
  26395. private _outlinepoints;
  26396. private _holes;
  26397. private _name;
  26398. private _scene;
  26399. private _epoints;
  26400. private _eholes;
  26401. private _addToepoint;
  26402. constructor(name: string, contours: Path2, scene: Scene);
  26403. constructor(name: string, contours: Vector2[], scene: Scene);
  26404. addHole(hole: Vector2[]): PolygonMeshBuilder;
  26405. build(updatable?: boolean, depth?: number): Mesh;
  26406. private addSide;
  26407. }
  26408. }
  26409. declare module BABYLON {
  26410. class BaseSubMesh {
  26411. /** @hidden */
  26412. /** @hidden */
  26413. readonly effect: Nullable<Effect>;
  26414. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  26415. }
  26416. class SubMesh extends BaseSubMesh implements ICullable {
  26417. materialIndex: number;
  26418. verticesStart: number;
  26419. verticesCount: number;
  26420. indexStart: number;
  26421. indexCount: number;
  26422. linesIndexCount: number;
  26423. private _mesh;
  26424. private _renderingMesh;
  26425. private _boundingInfo;
  26426. private _linesIndexBuffer;
  26427. /** @hidden */
  26428. /** @hidden */
  26429. /** @hidden */
  26430. /** @hidden */
  26431. /** @hidden */
  26432. /** @hidden */
  26433. /** @hidden */
  26434. private _currentMaterial;
  26435. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  26436. constructor(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  26437. readonly IsGlobal: boolean;
  26438. /**
  26439. * Returns the submesh BoudingInfo object.
  26440. */
  26441. getBoundingInfo(): BoundingInfo;
  26442. /**
  26443. * Sets the submesh BoundingInfo.
  26444. * Return the SubMesh.
  26445. */
  26446. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  26447. /**
  26448. * Returns the mesh of the current submesh.
  26449. */
  26450. getMesh(): AbstractMesh;
  26451. /**
  26452. * Returns the rendering mesh of the submesh.
  26453. */
  26454. getRenderingMesh(): Mesh;
  26455. /**
  26456. * Returns the submesh material.
  26457. */
  26458. getMaterial(): Nullable<Material>;
  26459. /**
  26460. * Sets a new updated BoundingInfo object to the submesh.
  26461. * Returns the SubMesh.
  26462. */
  26463. refreshBoundingInfo(): SubMesh;
  26464. /** @hidden */
  26465. /**
  26466. * Updates the submesh BoundingInfo.
  26467. * Returns the Submesh.
  26468. */
  26469. updateBoundingInfo(world: Matrix): SubMesh;
  26470. /**
  26471. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  26472. * Boolean returned.
  26473. */
  26474. isInFrustum(frustumPlanes: Plane[]): boolean;
  26475. /**
  26476. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes.
  26477. * Boolean returned.
  26478. */
  26479. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  26480. /**
  26481. * Renders the submesh.
  26482. * Returns it.
  26483. */
  26484. render(enableAlphaMode: boolean): SubMesh;
  26485. /**
  26486. * Returns a new Index Buffer.
  26487. * Type returned : WebGLBuffer.
  26488. */
  26489. getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  26490. /**
  26491. * True is the passed Ray intersects the submesh bounding box.
  26492. * Boolean returned.
  26493. */
  26494. canIntersects(ray: Ray): boolean;
  26495. /**
  26496. * Returns an object IntersectionInfo.
  26497. */
  26498. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean): Nullable<IntersectionInfo>;
  26499. /** @hidden */
  26500. /**
  26501. * Creates a new Submesh from the passed Mesh.
  26502. */
  26503. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  26504. /**
  26505. * Disposes the Submesh.
  26506. * Returns nothing.
  26507. */
  26508. dispose(): void;
  26509. /**
  26510. * Creates a new Submesh from the passed parameters :
  26511. * - materialIndex (integer) : the index of the main mesh material.
  26512. * - startIndex (integer) : the index where to start the copy in the mesh indices array.
  26513. * - indexCount (integer) : the number of indices to copy then from the startIndex.
  26514. * - mesh (Mesh) : the main mesh to create the submesh from.
  26515. * - renderingMesh (optional Mesh) : rendering mesh.
  26516. */
  26517. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  26518. }
  26519. }
  26520. declare module BABYLON {
  26521. class TransformNode extends Node {
  26522. static BILLBOARDMODE_NONE: number;
  26523. static BILLBOARDMODE_X: number;
  26524. static BILLBOARDMODE_Y: number;
  26525. static BILLBOARDMODE_Z: number;
  26526. static BILLBOARDMODE_ALL: number;
  26527. private _forward;
  26528. private _forwardInverted;
  26529. private _up;
  26530. private _right;
  26531. private _rightInverted;
  26532. private _position;
  26533. private _rotation;
  26534. private _rotationQuaternion;
  26535. protected _scaling: Vector3;
  26536. protected _isDirty: boolean;
  26537. private _transformToBoneReferal;
  26538. /**
  26539. * Set the billboard mode. Default is 0.
  26540. *
  26541. * | Value | Type | Description |
  26542. * | --- | --- | --- |
  26543. * | 0 | BILLBOARDMODE_NONE | |
  26544. * | 1 | BILLBOARDMODE_X | |
  26545. * | 2 | BILLBOARDMODE_Y | |
  26546. * | 4 | BILLBOARDMODE_Z | |
  26547. * | 7 | BILLBOARDMODE_ALL | |
  26548. *
  26549. */
  26550. billboardMode: number;
  26551. scalingDeterminant: number;
  26552. infiniteDistance: boolean;
  26553. /**
  26554. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  26555. * By default the system will update normals to compensate
  26556. */
  26557. ignoreNonUniformScaling: boolean;
  26558. /** @hidden */
  26559. private _localWorld;
  26560. private _absolutePosition;
  26561. private _pivotMatrix;
  26562. private _pivotMatrixInverse;
  26563. private _postMultiplyPivotMatrix;
  26564. protected _isWorldMatrixFrozen: boolean;
  26565. /**
  26566. * An event triggered after the world matrix is updated
  26567. */
  26568. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  26569. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  26570. /**
  26571. * Gets a string identifying the name of the class
  26572. * @returns "TransformNode" string
  26573. */
  26574. getClassName(): string;
  26575. /**
  26576. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  26577. */
  26578. position: Vector3;
  26579. /**
  26580. * 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)).
  26581. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  26582. */
  26583. rotation: Vector3;
  26584. /**
  26585. * 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)).
  26586. */
  26587. scaling: Vector3;
  26588. /**
  26589. * Gets or sets the rotation Quaternion property : this a Quaternion object defining the node rotation by using a unit quaternion (null by default).
  26590. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  26591. */
  26592. rotationQuaternion: Nullable<Quaternion>;
  26593. /**
  26594. * The forward direction of that transform in world space.
  26595. */
  26596. readonly forward: Vector3;
  26597. /**
  26598. * The up direction of that transform in world space.
  26599. */
  26600. readonly up: Vector3;
  26601. /**
  26602. * The right direction of that transform in world space.
  26603. */
  26604. readonly right: Vector3;
  26605. /**
  26606. * Copies the parameter passed Matrix into the mesh Pose matrix.
  26607. * Returns the TransformNode.
  26608. */
  26609. updatePoseMatrix(matrix: Matrix): TransformNode;
  26610. /**
  26611. * Returns the mesh Pose matrix.
  26612. * Returned object : Matrix
  26613. */
  26614. getPoseMatrix(): Matrix;
  26615. /** @hidden */
  26616. /** @hidden */
  26617. markAsDirty(property: string): TransformNode;
  26618. /**
  26619. * Returns the current mesh absolute position.
  26620. * Returns a Vector3.
  26621. */
  26622. readonly absolutePosition: Vector3;
  26623. /**
  26624. * Sets a new matrix to apply before all other transformation
  26625. * @param matrix defines the transform matrix
  26626. * @returns the current TransformNode
  26627. */
  26628. setPreTransformMatrix(matrix: Matrix): TransformNode;
  26629. /**
  26630. * Sets a new pivot matrix to the current node
  26631. * @param matrix defines the new pivot matrix to use
  26632. * @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
  26633. * @returns the current TransformNode
  26634. */
  26635. setPivotMatrix(matrix: Matrix, postMultiplyPivotMatrix?: boolean): TransformNode;
  26636. /**
  26637. * Returns the mesh pivot matrix.
  26638. * Default : Identity.
  26639. * A Matrix is returned.
  26640. */
  26641. getPivotMatrix(): Matrix;
  26642. /**
  26643. * Prevents the World matrix to be computed any longer.
  26644. * Returns the TransformNode.
  26645. */
  26646. freezeWorldMatrix(): TransformNode;
  26647. /**
  26648. * Allows back the World matrix computation.
  26649. * Returns the TransformNode.
  26650. */
  26651. unfreezeWorldMatrix(): this;
  26652. /**
  26653. * True if the World matrix has been frozen.
  26654. * Returns a boolean.
  26655. */
  26656. readonly isWorldMatrixFrozen: boolean;
  26657. /**
  26658. * Retuns the mesh absolute position in the World.
  26659. * Returns a Vector3.
  26660. */
  26661. getAbsolutePosition(): Vector3;
  26662. /**
  26663. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  26664. * Returns the TransformNode.
  26665. */
  26666. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  26667. /**
  26668. * Sets the mesh position in its local space.
  26669. * Returns the TransformNode.
  26670. */
  26671. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  26672. /**
  26673. * Returns the mesh position in the local space from the current World matrix values.
  26674. * Returns a new Vector3.
  26675. */
  26676. getPositionExpressedInLocalSpace(): Vector3;
  26677. /**
  26678. * Translates the mesh along the passed Vector3 in its local space.
  26679. * Returns the TransformNode.
  26680. */
  26681. locallyTranslate(vector3: Vector3): TransformNode;
  26682. private static _lookAtVectorCache;
  26683. /**
  26684. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  26685. * @param targetPoint the position (must be in same space as current mesh) to look at
  26686. * @param yawCor optional yaw (y-axis) correction in radians
  26687. * @param pitchCor optional pitch (x-axis) correction in radians
  26688. * @param rollCor optional roll (z-axis) correction in radians
  26689. * @param space the choosen space of the target
  26690. * @returns the TransformNode.
  26691. */
  26692. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  26693. /**
  26694. * Returns a new Vector3 what is the localAxis, expressed in the mesh local space, rotated like the mesh.
  26695. * This Vector3 is expressed in the World space.
  26696. */
  26697. getDirection(localAxis: Vector3): Vector3;
  26698. /**
  26699. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  26700. * localAxis is expressed in the mesh local space.
  26701. * result is computed in the Wordl space from the mesh World matrix.
  26702. * Returns the TransformNode.
  26703. */
  26704. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  26705. /**
  26706. * Sets a new pivot point to the current node
  26707. * @param point defines the new pivot point to use
  26708. * @param space defines if the point is in world or local space (local by default)
  26709. * @returns the current TransformNode
  26710. */
  26711. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  26712. /**
  26713. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  26714. */
  26715. getPivotPoint(): Vector3;
  26716. /**
  26717. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  26718. * Returns the TransformNode.
  26719. */
  26720. getPivotPointToRef(result: Vector3): TransformNode;
  26721. /**
  26722. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  26723. */
  26724. getAbsolutePivotPoint(): Vector3;
  26725. /**
  26726. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  26727. * Returns the TransformNode.
  26728. */
  26729. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  26730. /**
  26731. * Defines the passed node as the parent of the current node.
  26732. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  26733. * Returns the TransformNode.
  26734. */
  26735. setParent(node: Nullable<Node>): TransformNode;
  26736. private _nonUniformScaling;
  26737. readonly nonUniformScaling: boolean;
  26738. /** @hidden */
  26739. /**
  26740. * Attach the current TransformNode to another TransformNode associated with a bone
  26741. * @param bone Bone affecting the TransformNode
  26742. * @param affectedTransformNode TransformNode associated with the bone
  26743. */
  26744. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  26745. detachFromBone(): TransformNode;
  26746. private static _rotationAxisCache;
  26747. /**
  26748. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  26749. * space (default LOCAL) can be either BABYLON.Space.LOCAL, either BABYLON.Space.WORLD.
  26750. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  26751. * The passed axis is also normalized.
  26752. * Returns the TransformNode.
  26753. */
  26754. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  26755. /**
  26756. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  26757. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  26758. * The passed axis is also normalized.
  26759. * Returns the TransformNode.
  26760. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  26761. */
  26762. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  26763. /**
  26764. * Translates the mesh along the axis vector for the passed distance in the given space.
  26765. * space (default LOCAL) can be either BABYLON.Space.LOCAL, either BABYLON.Space.WORLD.
  26766. * Returns the TransformNode.
  26767. */
  26768. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  26769. /**
  26770. * Adds a rotation step to the mesh current rotation.
  26771. * x, y, z are Euler angles expressed in radians.
  26772. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  26773. * This means this rotation is made in the mesh local space only.
  26774. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  26775. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  26776. * ```javascript
  26777. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  26778. * ```
  26779. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  26780. * 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.
  26781. * Returns the TransformNode.
  26782. */
  26783. addRotation(x: number, y: number, z: number): TransformNode;
  26784. /**
  26785. * Computes the world matrix of the node
  26786. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  26787. * @returns the world matrix
  26788. */
  26789. computeWorldMatrix(force?: boolean): Matrix;
  26790. protected _afterComputeWorldMatrix(): void;
  26791. /**
  26792. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  26793. * @param func: callback function to add
  26794. *
  26795. * Returns the TransformNode.
  26796. */
  26797. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  26798. /**
  26799. * Removes a registered callback function.
  26800. * Returns the TransformNode.
  26801. */
  26802. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  26803. /**
  26804. * Clone the current transform node
  26805. * Returns the new transform node
  26806. * @param name Name of the new clone
  26807. * @param newParent New parent for the clone
  26808. * @param doNotCloneChildren Do not clone children hierarchy
  26809. */
  26810. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  26811. serialize(currentSerializationObject?: any): any;
  26812. /**
  26813. * Returns a new TransformNode object parsed from the source provided.
  26814. * The parameter `parsedMesh` is the source.
  26815. * The parameter `rootUrl` is a string, it's the root URL to prefix the `delayLoadingFile` property with
  26816. */
  26817. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  26818. /**
  26819. * Releases resources associated with this transform node.
  26820. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26821. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26822. */
  26823. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26824. }
  26825. }
  26826. declare module BABYLON {
  26827. class VertexBuffer {
  26828. /** @hidden */
  26829. private _kind;
  26830. private _size;
  26831. private _ownsBuffer;
  26832. private _instanced;
  26833. private _instanceDivisor;
  26834. /**
  26835. * The byte type.
  26836. */
  26837. static readonly BYTE: number;
  26838. /**
  26839. * The unsigned byte type.
  26840. */
  26841. static readonly UNSIGNED_BYTE: number;
  26842. /**
  26843. * The short type.
  26844. */
  26845. static readonly SHORT: number;
  26846. /**
  26847. * The unsigned short type.
  26848. */
  26849. static readonly UNSIGNED_SHORT: number;
  26850. /**
  26851. * The integer type.
  26852. */
  26853. static readonly INT: number;
  26854. /**
  26855. * The unsigned integer type.
  26856. */
  26857. static readonly UNSIGNED_INT: number;
  26858. /**
  26859. * The float type.
  26860. */
  26861. static readonly FLOAT: number;
  26862. /**
  26863. * Gets or sets the instance divisor when in instanced mode
  26864. */
  26865. instanceDivisor: number;
  26866. /**
  26867. * Gets the byte stride.
  26868. */
  26869. readonly byteStride: number;
  26870. /**
  26871. * Gets the byte offset.
  26872. */
  26873. readonly byteOffset: number;
  26874. /**
  26875. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  26876. */
  26877. readonly normalized: boolean;
  26878. /**
  26879. * Gets the data type of each component in the array.
  26880. */
  26881. readonly type: number;
  26882. /**
  26883. * Constructor
  26884. * @param engine the engine
  26885. * @param data the data to use for this vertex buffer
  26886. * @param kind the vertex buffer kind
  26887. * @param updatable whether the data is updatable
  26888. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  26889. * @param stride the stride (optional)
  26890. * @param instanced whether the buffer is instanced (optional)
  26891. * @param offset the offset of the data (optional)
  26892. * @param size the number of components (optional)
  26893. * @param type the type of the component (optional)
  26894. * @param normalized whether the data contains normalized data (optional)
  26895. * @param useBytes set to true if stride and offset are in bytes (optional)
  26896. */
  26897. 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);
  26898. /** @hidden */
  26899. /**
  26900. * Returns the kind of the VertexBuffer (string).
  26901. */
  26902. getKind(): string;
  26903. /**
  26904. * Boolean : is the VertexBuffer updatable ?
  26905. */
  26906. isUpdatable(): boolean;
  26907. /**
  26908. * Returns an array of numbers or a typed array containing the VertexBuffer data.
  26909. */
  26910. getData(): Nullable<DataArray>;
  26911. /**
  26912. * Returns the WebGLBuffer associated to the VertexBuffer.
  26913. */
  26914. getBuffer(): Nullable<WebGLBuffer>;
  26915. /**
  26916. * Returns the stride as a multiple of the type byte length.
  26917. * DEPRECATED. Use byteStride instead.
  26918. */
  26919. getStrideSize(): number;
  26920. /**
  26921. * Returns the offset as a multiple of the type byte length.
  26922. * DEPRECATED. Use byteOffset instead.
  26923. */
  26924. getOffset(): number;
  26925. /**
  26926. * Returns the number of components per vertex attribute (integer).
  26927. */
  26928. getSize(): number;
  26929. /**
  26930. * Boolean : is the WebGLBuffer of the VertexBuffer instanced now ?
  26931. */
  26932. getIsInstanced(): boolean;
  26933. /**
  26934. * Returns the instancing divisor, zero for non-instanced (integer).
  26935. */
  26936. getInstanceDivisor(): number;
  26937. /**
  26938. * Creates the underlying WebGLBuffer from the passed numeric array or Float32Array.
  26939. * Returns the created WebGLBuffer.
  26940. */
  26941. create(data?: DataArray): void;
  26942. /**
  26943. * Updates the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  26944. * This function will create a new buffer if the current one is not updatable
  26945. * Returns the updated WebGLBuffer.
  26946. */
  26947. update(data: DataArray): void;
  26948. /**
  26949. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  26950. * Returns the directly updated WebGLBuffer.
  26951. * @param data the new data
  26952. * @param offset the new offset
  26953. * @param useBytes set to true if the offset is in bytes
  26954. */
  26955. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  26956. /**
  26957. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  26958. */
  26959. dispose(): void;
  26960. /**
  26961. * Enumerates each value of this vertex buffer as numbers.
  26962. * @param count the number of values to enumerate
  26963. * @param callback the callback function called for each value
  26964. */
  26965. forEach(count: number, callback: (value: number, index: number) => void): void;
  26966. private static _PositionKind;
  26967. private static _NormalKind;
  26968. private static _TangentKind;
  26969. private static _UVKind;
  26970. private static _UV2Kind;
  26971. private static _UV3Kind;
  26972. private static _UV4Kind;
  26973. private static _UV5Kind;
  26974. private static _UV6Kind;
  26975. private static _ColorKind;
  26976. private static _MatricesIndicesKind;
  26977. private static _MatricesWeightsKind;
  26978. private static _MatricesIndicesExtraKind;
  26979. private static _MatricesWeightsExtraKind;
  26980. static readonly PositionKind: string;
  26981. static readonly NormalKind: string;
  26982. static readonly TangentKind: string;
  26983. static readonly UVKind: string;
  26984. static readonly UV2Kind: string;
  26985. static readonly UV3Kind: string;
  26986. static readonly UV4Kind: string;
  26987. static readonly UV5Kind: string;
  26988. static readonly UV6Kind: string;
  26989. static readonly ColorKind: string;
  26990. static readonly MatricesIndicesKind: string;
  26991. static readonly MatricesWeightsKind: string;
  26992. static readonly MatricesIndicesExtraKind: string;
  26993. static readonly MatricesWeightsExtraKind: string;
  26994. /**
  26995. * Deduces the stride given a kind.
  26996. * @param kind The kind string to deduce
  26997. * @returns The deduced stride
  26998. */
  26999. static DeduceStride(kind: string): number;
  27000. /**
  27001. * Gets the byte length of the given type.
  27002. * @param type the type
  27003. * @returns the number of bytes
  27004. */
  27005. static GetTypeByteLength(type: number): number;
  27006. /**
  27007. * Enumerates each value of the given parameters as numbers.
  27008. * @param data the data to enumerate
  27009. * @param byteOffset the byte offset of the data
  27010. * @param byteStride the byte stride of the data
  27011. * @param componentCount the number of components per element
  27012. * @param componentType the type of the component
  27013. * @param count the total number of components
  27014. * @param normalized whether the data is normalized
  27015. * @param callback the callback function called for each value
  27016. */
  27017. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  27018. private static _GetFloatValue;
  27019. }
  27020. }
  27021. declare module BABYLON {
  27022. /**
  27023. * This represents the base class for particle system in Babylon.
  27024. * 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.
  27025. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  27026. * @example https://doc.babylonjs.com/babylon101/particles
  27027. */
  27028. class BaseParticleSystem {
  27029. /**
  27030. * Source color is added to the destination color without alpha affecting the result
  27031. */
  27032. static BLENDMODE_ONEONE: number;
  27033. /**
  27034. * Blend current color and particle color using particle’s alpha
  27035. */
  27036. static BLENDMODE_STANDARD: number;
  27037. /**
  27038. * Add current color and particle color multiplied by particle’s alpha
  27039. */
  27040. static BLENDMODE_ADD: number;
  27041. /**
  27042. * Multiply current color with particle color
  27043. */
  27044. static BLENDMODE_MULTIPLY: number;
  27045. /**
  27046. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  27047. */
  27048. static BLENDMODE_MULTIPLYADD: number;
  27049. /**
  27050. * List of animations used by the particle system.
  27051. */
  27052. animations: Animation[];
  27053. /**
  27054. * The id of the Particle system.
  27055. */
  27056. id: string;
  27057. /**
  27058. * The friendly name of the Particle system.
  27059. */
  27060. name: string;
  27061. /**
  27062. * The rendering group used by the Particle system to chose when to render.
  27063. */
  27064. renderingGroupId: number;
  27065. /**
  27066. * The emitter represents the Mesh or position we are attaching the particle system to.
  27067. */
  27068. emitter: Nullable<AbstractMesh | Vector3>;
  27069. /**
  27070. * The maximum number of particles to emit per frame
  27071. */
  27072. emitRate: number;
  27073. /**
  27074. * If you want to launch only a few particles at once, that can be done, as well.
  27075. */
  27076. manualEmitCount: number;
  27077. /**
  27078. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  27079. */
  27080. updateSpeed: number;
  27081. /**
  27082. * The amount of time the particle system is running (depends of the overall update speed).
  27083. */
  27084. targetStopDuration: number;
  27085. /**
  27086. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  27087. */
  27088. disposeOnStop: boolean;
  27089. /**
  27090. * Minimum power of emitting particles.
  27091. */
  27092. minEmitPower: number;
  27093. /**
  27094. * Maximum power of emitting particles.
  27095. */
  27096. maxEmitPower: number;
  27097. /**
  27098. * Minimum life time of emitting particles.
  27099. */
  27100. minLifeTime: number;
  27101. /**
  27102. * Maximum life time of emitting particles.
  27103. */
  27104. maxLifeTime: number;
  27105. /**
  27106. * Minimum Size of emitting particles.
  27107. */
  27108. minSize: number;
  27109. /**
  27110. * Maximum Size of emitting particles.
  27111. */
  27112. maxSize: number;
  27113. /**
  27114. * Minimum scale of emitting particles on X axis.
  27115. */
  27116. minScaleX: number;
  27117. /**
  27118. * Maximum scale of emitting particles on X axis.
  27119. */
  27120. maxScaleX: number;
  27121. /**
  27122. * Minimum scale of emitting particles on Y axis.
  27123. */
  27124. minScaleY: number;
  27125. /**
  27126. * Maximum scale of emitting particles on Y axis.
  27127. */
  27128. maxScaleY: number;
  27129. /**
  27130. * Gets or sets the minimal initial rotation in radians.
  27131. */
  27132. minInitialRotation: number;
  27133. /**
  27134. * Gets or sets the maximal initial rotation in radians.
  27135. */
  27136. maxInitialRotation: number;
  27137. /**
  27138. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  27139. */
  27140. minAngularSpeed: number;
  27141. /**
  27142. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  27143. */
  27144. maxAngularSpeed: number;
  27145. /**
  27146. * The texture used to render each particle. (this can be a spritesheet)
  27147. */
  27148. particleTexture: Nullable<Texture>;
  27149. /**
  27150. * The layer mask we are rendering the particles through.
  27151. */
  27152. layerMask: number;
  27153. /**
  27154. * This can help using your own shader to render the particle system.
  27155. * The according effect will be created
  27156. */
  27157. customShader: any;
  27158. /**
  27159. * By default particle system starts as soon as they are created. This prevents the
  27160. * automatic start to happen and let you decide when to start emitting particles.
  27161. */
  27162. preventAutoStart: boolean;
  27163. /**
  27164. * Gets or sets a texture used to add random noise to particle positions
  27165. */
  27166. noiseTexture: Nullable<ProceduralTexture>;
  27167. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  27168. noiseStrength: Vector3;
  27169. /**
  27170. * Callback triggered when the particle animation is ending.
  27171. */
  27172. onAnimationEnd: Nullable<() => void>;
  27173. /**
  27174. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  27175. */
  27176. blendMode: number;
  27177. /**
  27178. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  27179. * to override the particles.
  27180. */
  27181. forceDepthWrite: boolean;
  27182. /** 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 */
  27183. preWarmCycles: number;
  27184. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  27185. preWarmStepOffset: number;
  27186. /**
  27187. * 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)
  27188. */
  27189. spriteCellChangeSpeed: number;
  27190. /**
  27191. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  27192. */
  27193. startSpriteCellID: number;
  27194. /**
  27195. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  27196. */
  27197. endSpriteCellID: number;
  27198. /**
  27199. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  27200. */
  27201. spriteCellWidth: number;
  27202. /**
  27203. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  27204. */
  27205. spriteCellHeight: number;
  27206. /**
  27207. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  27208. */
  27209. spriteRandomStartCell: boolean;
  27210. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  27211. translationPivot: Vector2;
  27212. /** @hidden */
  27213. protected _isAnimationSheetEnabled: boolean;
  27214. /**
  27215. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  27216. */
  27217. beginAnimationOnStart: boolean;
  27218. /**
  27219. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  27220. */
  27221. beginAnimationFrom: number;
  27222. /**
  27223. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  27224. */
  27225. beginAnimationTo: number;
  27226. /**
  27227. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  27228. */
  27229. beginAnimationLoop: boolean;
  27230. /**
  27231. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  27232. */
  27233. isAnimationSheetEnabled: boolean;
  27234. /**
  27235. * Get hosting scene
  27236. * @returns the scene
  27237. */
  27238. getScene(): Scene;
  27239. /**
  27240. * You can use gravity if you want to give an orientation to your particles.
  27241. */
  27242. gravity: Vector3;
  27243. protected _colorGradients: Nullable<Array<ColorGradient>>;
  27244. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  27245. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  27246. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  27247. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  27248. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  27249. protected _dragGradients: Nullable<Array<FactorGradient>>;
  27250. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  27251. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  27252. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  27253. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  27254. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  27255. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  27256. /**
  27257. * Defines the delay in milliseconds before starting the system (0 by default)
  27258. */
  27259. startDelay: number;
  27260. /**
  27261. * Gets the current list of drag gradients.
  27262. * You must use addDragGradient and removeDragGradient to udpate this list
  27263. * @returns the list of drag gradients
  27264. */
  27265. getDragGradients(): Nullable<Array<FactorGradient>>;
  27266. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  27267. limitVelocityDamping: number;
  27268. /**
  27269. * Gets the current list of limit velocity gradients.
  27270. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  27271. * @returns the list of limit velocity gradients
  27272. */
  27273. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  27274. /**
  27275. * Gets the current list of color gradients.
  27276. * You must use addColorGradient and removeColorGradient to udpate this list
  27277. * @returns the list of color gradients
  27278. */
  27279. getColorGradients(): Nullable<Array<ColorGradient>>;
  27280. /**
  27281. * Gets the current list of size gradients.
  27282. * You must use addSizeGradient and removeSizeGradient to udpate this list
  27283. * @returns the list of size gradients
  27284. */
  27285. getSizeGradients(): Nullable<Array<FactorGradient>>;
  27286. /**
  27287. * Gets the current list of color remap gradients.
  27288. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  27289. * @returns the list of color remap gradients
  27290. */
  27291. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  27292. /**
  27293. * Gets the current list of alpha remap gradients.
  27294. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  27295. * @returns the list of alpha remap gradients
  27296. */
  27297. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  27298. /**
  27299. * Gets the current list of life time gradients.
  27300. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  27301. * @returns the list of life time gradients
  27302. */
  27303. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  27304. /**
  27305. * Gets the current list of angular speed gradients.
  27306. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  27307. * @returns the list of angular speed gradients
  27308. */
  27309. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  27310. /**
  27311. * Gets the current list of velocity gradients.
  27312. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  27313. * @returns the list of velocity gradients
  27314. */
  27315. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  27316. /**
  27317. * Gets the current list of start size gradients.
  27318. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  27319. * @returns the list of start size gradients
  27320. */
  27321. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  27322. /**
  27323. * Gets the current list of emit rate gradients.
  27324. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  27325. * @returns the list of emit rate gradients
  27326. */
  27327. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  27328. /**
  27329. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  27330. * This only works when particleEmitterTyps is a BoxParticleEmitter
  27331. */
  27332. direction1: Vector3;
  27333. /**
  27334. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  27335. * This only works when particleEmitterTyps is a BoxParticleEmitter
  27336. */
  27337. direction2: Vector3;
  27338. /**
  27339. * 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.
  27340. * This only works when particleEmitterTyps is a BoxParticleEmitter
  27341. */
  27342. minEmitBox: Vector3;
  27343. /**
  27344. * 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.
  27345. * This only works when particleEmitterTyps is a BoxParticleEmitter
  27346. */
  27347. maxEmitBox: Vector3;
  27348. /**
  27349. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  27350. */
  27351. color1: Color4;
  27352. /**
  27353. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  27354. */
  27355. color2: Color4;
  27356. /**
  27357. * Color the particle will have at the end of its lifetime
  27358. */
  27359. colorDead: Color4;
  27360. /**
  27361. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  27362. */
  27363. textureMask: Color4;
  27364. /**
  27365. * The particle emitter type defines the emitter used by the particle system.
  27366. * It can be for example box, sphere, or cone...
  27367. */
  27368. particleEmitterType: IParticleEmitterType;
  27369. /** @hidden */
  27370. /**
  27371. * Gets or sets the billboard mode to use when isBillboardBased = true.
  27372. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  27373. */
  27374. billboardMode: number;
  27375. protected _isBillboardBased: boolean;
  27376. /**
  27377. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  27378. */
  27379. isBillboardBased: boolean;
  27380. /**
  27381. * The scene the particle system belongs to.
  27382. */
  27383. protected _scene: Scene;
  27384. /**
  27385. * Local cache of defines for image processing.
  27386. */
  27387. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  27388. /**
  27389. * Default configuration related to image processing available in the standard Material.
  27390. */
  27391. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  27392. /**
  27393. * Gets the image processing configuration used either in this material.
  27394. */
  27395. /**
  27396. * Sets the Default image processing configuration used either in the this material.
  27397. *
  27398. * If sets to null, the scene one is in use.
  27399. */
  27400. imageProcessingConfiguration: ImageProcessingConfiguration;
  27401. /**
  27402. * Attaches a new image processing configuration to the Standard Material.
  27403. * @param configuration
  27404. */
  27405. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  27406. /** @hidden */
  27407. protected _reset(): void;
  27408. /** @hidden */
  27409. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  27410. /**
  27411. * Instantiates a particle system.
  27412. * 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.
  27413. * @param name The name of the particle system
  27414. */
  27415. constructor(name: string);
  27416. /**
  27417. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  27418. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  27419. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  27420. * @returns the emitter
  27421. */
  27422. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  27423. /**
  27424. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  27425. * @param radius The radius of the hemisphere to emit from
  27426. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  27427. * @returns the emitter
  27428. */
  27429. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  27430. /**
  27431. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  27432. * @param radius The radius of the sphere to emit from
  27433. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  27434. * @returns the emitter
  27435. */
  27436. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  27437. /**
  27438. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  27439. * @param radius The radius of the sphere to emit from
  27440. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  27441. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  27442. * @returns the emitter
  27443. */
  27444. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  27445. /**
  27446. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  27447. * @param radius The radius of the emission cylinder
  27448. * @param height The height of the emission cylinder
  27449. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  27450. * @param directionRandomizer How much to randomize the particle direction [0-1]
  27451. * @returns the emitter
  27452. */
  27453. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  27454. /**
  27455. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  27456. * @param radius The radius of the cylinder to emit from
  27457. * @param height The height of the emission cylinder
  27458. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  27459. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  27460. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  27461. * @returns the emitter
  27462. */
  27463. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  27464. /**
  27465. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  27466. * @param radius The radius of the cone to emit from
  27467. * @param angle The base angle of the cone
  27468. * @returns the emitter
  27469. */
  27470. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  27471. /**
  27472. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  27473. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  27474. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  27475. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  27476. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  27477. * @returns the emitter
  27478. */
  27479. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  27480. }
  27481. }
  27482. declare module BABYLON {
  27483. /**
  27484. * This represents a GPU particle system in Babylon
  27485. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  27486. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  27487. */
  27488. class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  27489. /**
  27490. * The layer mask we are rendering the particles through.
  27491. */
  27492. layerMask: number;
  27493. private _capacity;
  27494. private _activeCount;
  27495. private _currentActiveCount;
  27496. private _accumulatedCount;
  27497. private _renderEffect;
  27498. private _updateEffect;
  27499. private _buffer0;
  27500. private _buffer1;
  27501. private _spriteBuffer;
  27502. private _updateVAO;
  27503. private _renderVAO;
  27504. private _targetIndex;
  27505. private _sourceBuffer;
  27506. private _targetBuffer;
  27507. private _engine;
  27508. private _currentRenderId;
  27509. private _started;
  27510. private _stopped;
  27511. private _timeDelta;
  27512. private _randomTexture;
  27513. private _randomTexture2;
  27514. private _attributesStrideSize;
  27515. private _updateEffectOptions;
  27516. private _randomTextureSize;
  27517. private _actualFrame;
  27518. private readonly _rawTextureWidth;
  27519. /**
  27520. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  27521. */
  27522. static readonly IsSupported: boolean;
  27523. /**
  27524. * An event triggered when the system is disposed.
  27525. */
  27526. onDisposeObservable: Observable<GPUParticleSystem>;
  27527. /**
  27528. * Gets the maximum number of particles active at the same time.
  27529. * @returns The max number of active particles.
  27530. */
  27531. getCapacity(): number;
  27532. /**
  27533. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  27534. * to override the particles.
  27535. */
  27536. forceDepthWrite: boolean;
  27537. /**
  27538. * Gets or set the number of active particles
  27539. */
  27540. activeParticleCount: number;
  27541. private _preWarmDone;
  27542. /**
  27543. * Is this system ready to be used/rendered
  27544. * @return true if the system is ready
  27545. */
  27546. isReady(): boolean;
  27547. /**
  27548. * Gets if the system has been started. (Note: this will still be true after stop is called)
  27549. * @returns True if it has been started, otherwise false.
  27550. */
  27551. isStarted(): boolean;
  27552. /**
  27553. * Starts the particle system and begins to emit
  27554. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  27555. */
  27556. start(delay?: number): void;
  27557. /**
  27558. * Stops the particle system.
  27559. */
  27560. stop(): void;
  27561. /**
  27562. * Remove all active particles
  27563. */
  27564. reset(): void;
  27565. /**
  27566. * Returns the string "GPUParticleSystem"
  27567. * @returns a string containing the class name
  27568. */
  27569. getClassName(): string;
  27570. private _colorGradientsTexture;
  27571. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  27572. /**
  27573. * Adds a new color gradient
  27574. * @param gradient defines the gradient to use (between 0 and 1)
  27575. * @param color1 defines the color to affect to the specified gradient
  27576. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  27577. * @returns the current particle system
  27578. */
  27579. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  27580. /**
  27581. * Remove a specific color gradient
  27582. * @param gradient defines the gradient to remove
  27583. * @returns the current particle system
  27584. */
  27585. removeColorGradient(gradient: number): GPUParticleSystem;
  27586. private _angularSpeedGradientsTexture;
  27587. private _sizeGradientsTexture;
  27588. private _velocityGradientsTexture;
  27589. private _limitVelocityGradientsTexture;
  27590. private _dragGradientsTexture;
  27591. private _addFactorGradient;
  27592. /**
  27593. * Adds a new size gradient
  27594. * @param gradient defines the gradient to use (between 0 and 1)
  27595. * @param factor defines the size factor to affect to the specified gradient
  27596. * @returns the current particle system
  27597. */
  27598. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  27599. /**
  27600. * Remove a specific size gradient
  27601. * @param gradient defines the gradient to remove
  27602. * @returns the current particle system
  27603. */
  27604. removeSizeGradient(gradient: number): GPUParticleSystem;
  27605. /**
  27606. * Adds a new angular speed gradient
  27607. * @param gradient defines the gradient to use (between 0 and 1)
  27608. * @param factor defines the angular speed to affect to the specified gradient
  27609. * @returns the current particle system
  27610. */
  27611. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  27612. /**
  27613. * Remove a specific angular speed gradient
  27614. * @param gradient defines the gradient to remove
  27615. * @returns the current particle system
  27616. */
  27617. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  27618. /**
  27619. * Adds a new velocity gradient
  27620. * @param gradient defines the gradient to use (between 0 and 1)
  27621. * @param factor defines the velocity to affect to the specified gradient
  27622. * @returns the current particle system
  27623. */
  27624. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  27625. /**
  27626. * Remove a specific velocity gradient
  27627. * @param gradient defines the gradient to remove
  27628. * @returns the current particle system
  27629. */
  27630. removeVelocityGradient(gradient: number): GPUParticleSystem;
  27631. /**
  27632. * Adds a new limit velocity gradient
  27633. * @param gradient defines the gradient to use (between 0 and 1)
  27634. * @param factor defines the limit velocity value to affect to the specified gradient
  27635. * @returns the current particle system
  27636. */
  27637. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  27638. /**
  27639. * Remove a specific limit velocity gradient
  27640. * @param gradient defines the gradient to remove
  27641. * @returns the current particle system
  27642. */
  27643. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  27644. /**
  27645. * Adds a new drag gradient
  27646. * @param gradient defines the gradient to use (between 0 and 1)
  27647. * @param factor defines the drag value to affect to the specified gradient
  27648. * @returns the current particle system
  27649. */
  27650. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  27651. /**
  27652. * Remove a specific drag gradient
  27653. * @param gradient defines the gradient to remove
  27654. * @returns the current particle system
  27655. */
  27656. removeDragGradient(gradient: number): GPUParticleSystem;
  27657. /**
  27658. * Not supported by GPUParticleSystem
  27659. * @param gradient defines the gradient to use (between 0 and 1)
  27660. * @param factor defines the emit rate value to affect to the specified gradient
  27661. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  27662. * @returns the current particle system
  27663. */
  27664. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  27665. /**
  27666. * Not supported by GPUParticleSystem
  27667. * @param gradient defines the gradient to remove
  27668. * @returns the current particle system
  27669. */
  27670. removeEmitRateGradient(gradient: number): IParticleSystem;
  27671. /**
  27672. * Not supported by GPUParticleSystem
  27673. * @param gradient defines the gradient to use (between 0 and 1)
  27674. * @param factor defines the start size value to affect to the specified gradient
  27675. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  27676. * @returns the current particle system
  27677. */
  27678. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  27679. /**
  27680. * Not supported by GPUParticleSystem
  27681. * @param gradient defines the gradient to remove
  27682. * @returns the current particle system
  27683. */
  27684. removeStartSizeGradient(gradient: number): IParticleSystem;
  27685. /**
  27686. * Not supported by GPUParticleSystem
  27687. * @param gradient defines the gradient to use (between 0 and 1)
  27688. * @param min defines the color remap minimal range
  27689. * @param max defines the color remap maximal range
  27690. * @returns the current particle system
  27691. */
  27692. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  27693. /**
  27694. * Not supported by GPUParticleSystem
  27695. * @param gradient defines the gradient to remove
  27696. * @returns the current particle system
  27697. */
  27698. removeColorRemapGradient(gradient: number): IParticleSystem;
  27699. /**
  27700. * Not supported by GPUParticleSystem
  27701. * @param gradient defines the gradient to use (between 0 and 1)
  27702. * @param min defines the alpha remap minimal range
  27703. * @param max defines the alpha remap maximal range
  27704. * @returns the current particle system
  27705. */
  27706. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  27707. /**
  27708. * Not supported by GPUParticleSystem
  27709. * @param gradient defines the gradient to remove
  27710. * @returns the current particle system
  27711. */
  27712. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  27713. /**
  27714. * Not supported by GPUParticleSystem
  27715. * @param gradient defines the gradient to use (between 0 and 1)
  27716. * @param color defines the color to affect to the specified gradient
  27717. * @returns the current particle system
  27718. */
  27719. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  27720. /**
  27721. * Not supported by GPUParticleSystem
  27722. * @param gradient defines the gradient to remove
  27723. * @returns the current particle system
  27724. */
  27725. removeRampGradient(gradient: number): IParticleSystem;
  27726. /**
  27727. * Not supported by GPUParticleSystem
  27728. * @returns the list of ramp gradients
  27729. */
  27730. getRampGradients(): Nullable<Array<Color3Gradient>>;
  27731. /**
  27732. * Not supported by GPUParticleSystem
  27733. * Gets or sets a boolean indicating that ramp gradients must be used
  27734. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  27735. */
  27736. useRampGradients: boolean;
  27737. /**
  27738. * Instantiates a GPU particle system.
  27739. * 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.
  27740. * @param name The name of the particle system
  27741. * @param options The options used to create the system
  27742. * @param scene The scene the particle system belongs to
  27743. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  27744. */
  27745. constructor(name: string, options: Partial<{
  27746. capacity: number;
  27747. randomTextureSize: number;
  27748. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  27749. protected _reset(): void;
  27750. private _createUpdateVAO;
  27751. private _createRenderVAO;
  27752. private _initialize;
  27753. /** @hidden */
  27754. /** @hidden */
  27755. /**
  27756. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  27757. * @param preWarm defines if we are in the pre-warmimg phase
  27758. */
  27759. animate(preWarm?: boolean): void;
  27760. private _createFactorGradientTexture;
  27761. private _createSizeGradientTexture;
  27762. private _createAngularSpeedGradientTexture;
  27763. private _createVelocityGradientTexture;
  27764. private _createLimitVelocityGradientTexture;
  27765. private _createDragGradientTexture;
  27766. private _createColorGradientTexture;
  27767. /**
  27768. * Renders the particle system in its current state
  27769. * @param preWarm defines if the system should only update the particles but not render them
  27770. * @returns the current number of particles
  27771. */
  27772. render(preWarm?: boolean): number;
  27773. /**
  27774. * Rebuilds the particle system
  27775. */
  27776. rebuild(): void;
  27777. private _releaseBuffers;
  27778. private _releaseVAOs;
  27779. /**
  27780. * Disposes the particle system and free the associated resources
  27781. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  27782. */
  27783. dispose(disposeTexture?: boolean): void;
  27784. /**
  27785. * Clones the particle system.
  27786. * @param name The name of the cloned object
  27787. * @param newEmitter The new emitter to use
  27788. * @returns the cloned particle system
  27789. */
  27790. clone(name: string, newEmitter: any): GPUParticleSystem;
  27791. /**
  27792. * Serializes the particle system to a JSON object.
  27793. * @returns the JSON object
  27794. */
  27795. serialize(): any;
  27796. /**
  27797. * Parses a JSON object to create a GPU particle system.
  27798. * @param parsedParticleSystem The JSON object to parse
  27799. * @param scene The scene to create the particle system in
  27800. * @param rootUrl The root url to use to load external dependencies like texture
  27801. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  27802. * @returns the parsed GPU particle system
  27803. */
  27804. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  27805. }
  27806. }
  27807. declare module BABYLON {
  27808. /**
  27809. * Interface representing a particle system in Babylon.js.
  27810. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  27811. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  27812. */
  27813. interface IParticleSystem {
  27814. /**
  27815. * List of animations used by the particle system.
  27816. */
  27817. animations: Animation[];
  27818. /**
  27819. * The id of the Particle system.
  27820. */
  27821. id: string;
  27822. /**
  27823. * The name of the Particle system.
  27824. */
  27825. name: string;
  27826. /**
  27827. * The emitter represents the Mesh or position we are attaching the particle system to.
  27828. */
  27829. emitter: Nullable<AbstractMesh | Vector3>;
  27830. /**
  27831. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  27832. */
  27833. isBillboardBased: boolean;
  27834. /**
  27835. * The rendering group used by the Particle system to chose when to render.
  27836. */
  27837. renderingGroupId: number;
  27838. /**
  27839. * The layer mask we are rendering the particles through.
  27840. */
  27841. layerMask: number;
  27842. /**
  27843. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  27844. */
  27845. updateSpeed: number;
  27846. /**
  27847. * The amount of time the particle system is running (depends of the overall update speed).
  27848. */
  27849. targetStopDuration: number;
  27850. /**
  27851. * The texture used to render each particle. (this can be a spritesheet)
  27852. */
  27853. particleTexture: Nullable<Texture>;
  27854. /**
  27855. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  27856. */
  27857. blendMode: number;
  27858. /**
  27859. * Minimum life time of emitting particles.
  27860. */
  27861. minLifeTime: number;
  27862. /**
  27863. * Maximum life time of emitting particles.
  27864. */
  27865. maxLifeTime: number;
  27866. /**
  27867. * Minimum Size of emitting particles.
  27868. */
  27869. minSize: number;
  27870. /**
  27871. * Maximum Size of emitting particles.
  27872. */
  27873. maxSize: number;
  27874. /**
  27875. * Minimum scale of emitting particles on X axis.
  27876. */
  27877. minScaleX: number;
  27878. /**
  27879. * Maximum scale of emitting particles on X axis.
  27880. */
  27881. maxScaleX: number;
  27882. /**
  27883. * Minimum scale of emitting particles on Y axis.
  27884. */
  27885. minScaleY: number;
  27886. /**
  27887. * Maximum scale of emitting particles on Y axis.
  27888. */
  27889. maxScaleY: number;
  27890. /**
  27891. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  27892. */
  27893. color1: Color4;
  27894. /**
  27895. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  27896. */
  27897. color2: Color4;
  27898. /**
  27899. * Color the particle will have at the end of its lifetime.
  27900. */
  27901. colorDead: Color4;
  27902. /**
  27903. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  27904. */
  27905. emitRate: number;
  27906. /**
  27907. * You can use gravity if you want to give an orientation to your particles.
  27908. */
  27909. gravity: Vector3;
  27910. /**
  27911. * Minimum power of emitting particles.
  27912. */
  27913. minEmitPower: number;
  27914. /**
  27915. * Maximum power of emitting particles.
  27916. */
  27917. maxEmitPower: number;
  27918. /**
  27919. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  27920. */
  27921. minAngularSpeed: number;
  27922. /**
  27923. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  27924. */
  27925. maxAngularSpeed: number;
  27926. /**
  27927. * Gets or sets the minimal initial rotation in radians.
  27928. */
  27929. minInitialRotation: number;
  27930. /**
  27931. * Gets or sets the maximal initial rotation in radians.
  27932. */
  27933. maxInitialRotation: number;
  27934. /**
  27935. * The particle emitter type defines the emitter used by the particle system.
  27936. * It can be for example box, sphere, or cone...
  27937. */
  27938. particleEmitterType: Nullable<IParticleEmitterType>;
  27939. /**
  27940. * Defines the delay in milliseconds before starting the system (0 by default)
  27941. */
  27942. startDelay: number;
  27943. /**
  27944. * 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
  27945. */
  27946. preWarmCycles: number;
  27947. /**
  27948. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  27949. */
  27950. preWarmStepOffset: number;
  27951. /**
  27952. * 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)
  27953. */
  27954. spriteCellChangeSpeed: number;
  27955. /**
  27956. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  27957. */
  27958. startSpriteCellID: number;
  27959. /**
  27960. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  27961. */
  27962. endSpriteCellID: number;
  27963. /**
  27964. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  27965. */
  27966. spriteCellWidth: number;
  27967. /**
  27968. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  27969. */
  27970. spriteCellHeight: number;
  27971. /**
  27972. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  27973. */
  27974. spriteRandomStartCell: boolean;
  27975. /**
  27976. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  27977. */
  27978. isAnimationSheetEnabled: boolean;
  27979. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  27980. translationPivot: Vector2;
  27981. /**
  27982. * Gets or sets a texture used to add random noise to particle positions
  27983. */
  27984. noiseTexture: Nullable<BaseTexture>;
  27985. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  27986. noiseStrength: Vector3;
  27987. /**
  27988. * Gets or sets the billboard mode to use when isBillboardBased = true.
  27989. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  27990. */
  27991. billboardMode: number;
  27992. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  27993. limitVelocityDamping: number;
  27994. /**
  27995. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  27996. */
  27997. beginAnimationOnStart: boolean;
  27998. /**
  27999. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  28000. */
  28001. beginAnimationFrom: number;
  28002. /**
  28003. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  28004. */
  28005. beginAnimationTo: number;
  28006. /**
  28007. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  28008. */
  28009. beginAnimationLoop: boolean;
  28010. /**
  28011. * Gets the maximum number of particles active at the same time.
  28012. * @returns The max number of active particles.
  28013. */
  28014. getCapacity(): number;
  28015. /**
  28016. * Gets if the system has been started. (Note: this will still be true after stop is called)
  28017. * @returns True if it has been started, otherwise false.
  28018. */
  28019. isStarted(): boolean;
  28020. /**
  28021. * Animates the particle system for this frame.
  28022. */
  28023. animate(): void;
  28024. /**
  28025. * Renders the particle system in its current state.
  28026. * @returns the current number of particles
  28027. */
  28028. render(): number;
  28029. /**
  28030. * Dispose the particle system and frees its associated resources.
  28031. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  28032. */
  28033. dispose(disposeTexture?: boolean): void;
  28034. /**
  28035. * Clones the particle system.
  28036. * @param name The name of the cloned object
  28037. * @param newEmitter The new emitter to use
  28038. * @returns the cloned particle system
  28039. */
  28040. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  28041. /**
  28042. * Serializes the particle system to a JSON object.
  28043. * @returns the JSON object
  28044. */
  28045. serialize(): any;
  28046. /**
  28047. * Rebuild the particle system
  28048. */
  28049. rebuild(): void;
  28050. /**
  28051. * Starts the particle system and begins to emit
  28052. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  28053. */
  28054. start(delay?: number): void;
  28055. /**
  28056. * Stops the particle system.
  28057. */
  28058. stop(): void;
  28059. /**
  28060. * Remove all active particles
  28061. */
  28062. reset(): void;
  28063. /**
  28064. * Is this system ready to be used/rendered
  28065. * @return true if the system is ready
  28066. */
  28067. isReady(): boolean;
  28068. /**
  28069. * Adds a new color gradient
  28070. * @param gradient defines the gradient to use (between 0 and 1)
  28071. * @param color1 defines the color to affect to the specified gradient
  28072. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  28073. * @returns the current particle system
  28074. */
  28075. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  28076. /**
  28077. * Remove a specific color gradient
  28078. * @param gradient defines the gradient to remove
  28079. * @returns the current particle system
  28080. */
  28081. removeColorGradient(gradient: number): IParticleSystem;
  28082. /**
  28083. * Adds a new size gradient
  28084. * @param gradient defines the gradient to use (between 0 and 1)
  28085. * @param factor defines the size factor to affect to the specified gradient
  28086. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  28087. * @returns the current particle system
  28088. */
  28089. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  28090. /**
  28091. * Remove a specific size gradient
  28092. * @param gradient defines the gradient to remove
  28093. * @returns the current particle system
  28094. */
  28095. removeSizeGradient(gradient: number): IParticleSystem;
  28096. /**
  28097. * Gets the current list of color gradients.
  28098. * You must use addColorGradient and removeColorGradient to udpate this list
  28099. * @returns the list of color gradients
  28100. */
  28101. getColorGradients(): Nullable<Array<ColorGradient>>;
  28102. /**
  28103. * Gets the current list of size gradients.
  28104. * You must use addSizeGradient and removeSizeGradient to udpate this list
  28105. * @returns the list of size gradients
  28106. */
  28107. getSizeGradients(): Nullable<Array<FactorGradient>>;
  28108. /**
  28109. * Gets the current list of angular speed gradients.
  28110. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  28111. * @returns the list of angular speed gradients
  28112. */
  28113. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  28114. /**
  28115. * Adds a new angular speed gradient
  28116. * @param gradient defines the gradient to use (between 0 and 1)
  28117. * @param factor defines the angular speed to affect to the specified gradient
  28118. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  28119. * @returns the current particle system
  28120. */
  28121. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  28122. /**
  28123. * Remove a specific angular speed gradient
  28124. * @param gradient defines the gradient to remove
  28125. * @returns the current particle system
  28126. */
  28127. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  28128. /**
  28129. * Gets the current list of velocity gradients.
  28130. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  28131. * @returns the list of velocity gradients
  28132. */
  28133. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  28134. /**
  28135. * Adds a new velocity gradient
  28136. * @param gradient defines the gradient to use (between 0 and 1)
  28137. * @param factor defines the velocity to affect to the specified gradient
  28138. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  28139. * @returns the current particle system
  28140. */
  28141. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  28142. /**
  28143. * Remove a specific velocity gradient
  28144. * @param gradient defines the gradient to remove
  28145. * @returns the current particle system
  28146. */
  28147. removeVelocityGradient(gradient: number): IParticleSystem;
  28148. /**
  28149. * Gets the current list of limit velocity gradients.
  28150. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  28151. * @returns the list of limit velocity gradients
  28152. */
  28153. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  28154. /**
  28155. * Adds a new limit velocity gradient
  28156. * @param gradient defines the gradient to use (between 0 and 1)
  28157. * @param factor defines the limit velocity to affect to the specified gradient
  28158. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  28159. * @returns the current particle system
  28160. */
  28161. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  28162. /**
  28163. * Remove a specific limit velocity gradient
  28164. * @param gradient defines the gradient to remove
  28165. * @returns the current particle system
  28166. */
  28167. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  28168. /**
  28169. * Adds a new drag gradient
  28170. * @param gradient defines the gradient to use (between 0 and 1)
  28171. * @param factor defines the drag to affect to the specified gradient
  28172. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  28173. * @returns the current particle system
  28174. */
  28175. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  28176. /**
  28177. * Remove a specific drag gradient
  28178. * @param gradient defines the gradient to remove
  28179. * @returns the current particle system
  28180. */
  28181. removeDragGradient(gradient: number): IParticleSystem;
  28182. /**
  28183. * Gets the current list of drag gradients.
  28184. * You must use addDragGradient and removeDragGradient to udpate this list
  28185. * @returns the list of drag gradients
  28186. */
  28187. getDragGradients(): Nullable<Array<FactorGradient>>;
  28188. /**
  28189. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  28190. * @param gradient defines the gradient to use (between 0 and 1)
  28191. * @param factor defines the emit rate to affect to the specified gradient
  28192. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  28193. * @returns the current particle system
  28194. */
  28195. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  28196. /**
  28197. * Remove a specific emit rate gradient
  28198. * @param gradient defines the gradient to remove
  28199. * @returns the current particle system
  28200. */
  28201. removeEmitRateGradient(gradient: number): IParticleSystem;
  28202. /**
  28203. * Gets the current list of emit rate gradients.
  28204. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  28205. * @returns the list of emit rate gradients
  28206. */
  28207. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  28208. /**
  28209. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  28210. * @param gradient defines the gradient to use (between 0 and 1)
  28211. * @param factor defines the start size to affect to the specified gradient
  28212. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  28213. * @returns the current particle system
  28214. */
  28215. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  28216. /**
  28217. * Remove a specific start size gradient
  28218. * @param gradient defines the gradient to remove
  28219. * @returns the current particle system
  28220. */
  28221. removeStartSizeGradient(gradient: number): IParticleSystem;
  28222. /**
  28223. * Gets the current list of start size gradients.
  28224. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  28225. * @returns the list of start size gradients
  28226. */
  28227. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  28228. /**
  28229. * Gets the current list of color gradients.
  28230. * You must use addColorGradient and removeColorGradient to udpate this list
  28231. * @returns the list of color gradients
  28232. */
  28233. getColorGradients(): Nullable<Array<ColorGradient>>;
  28234. /**
  28235. * Adds a new ramp gradient used to remap particle colors
  28236. * @param gradient defines the gradient to use (between 0 and 1)
  28237. * @param color defines the color to affect to the specified gradient
  28238. * @returns the current particle system
  28239. */
  28240. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  28241. /**
  28242. * Gets the current list of ramp gradients.
  28243. * You must use addRampGradient and removeRampGradient to udpate this list
  28244. * @returns the list of ramp gradients
  28245. */
  28246. getRampGradients(): Nullable<Array<Color3Gradient>>;
  28247. /** Gets or sets a boolean indicating that ramp gradients must be used
  28248. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  28249. */
  28250. useRampGradients: boolean;
  28251. /**
  28252. * Adds a new color remap gradient
  28253. * @param gradient defines the gradient to use (between 0 and 1)
  28254. * @param min defines the color remap minimal range
  28255. * @param max defines the color remap maximal range
  28256. * @returns the current particle system
  28257. */
  28258. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  28259. /**
  28260. * Gets the current list of color remap gradients.
  28261. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  28262. * @returns the list of color remap gradients
  28263. */
  28264. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  28265. /**
  28266. * Adds a new alpha remap gradient
  28267. * @param gradient defines the gradient to use (between 0 and 1)
  28268. * @param min defines the alpha remap minimal range
  28269. * @param max defines the alpha remap maximal range
  28270. * @returns the current particle system
  28271. */
  28272. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  28273. /**
  28274. * Gets the current list of alpha remap gradients.
  28275. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  28276. * @returns the list of alpha remap gradients
  28277. */
  28278. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  28279. /**
  28280. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  28281. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  28282. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  28283. * @returns the emitter
  28284. */
  28285. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  28286. /**
  28287. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  28288. * @param radius The radius of the hemisphere to emit from
  28289. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  28290. * @returns the emitter
  28291. */
  28292. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  28293. /**
  28294. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  28295. * @param radius The radius of the sphere to emit from
  28296. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  28297. * @returns the emitter
  28298. */
  28299. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  28300. /**
  28301. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  28302. * @param radius The radius of the sphere to emit from
  28303. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  28304. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  28305. * @returns the emitter
  28306. */
  28307. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  28308. /**
  28309. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  28310. * @param radius The radius of the emission cylinder
  28311. * @param height The height of the emission cylinder
  28312. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  28313. * @param directionRandomizer How much to randomize the particle direction [0-1]
  28314. * @returns the emitter
  28315. */
  28316. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  28317. /**
  28318. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  28319. * @param radius The radius of the cylinder to emit from
  28320. * @param height The height of the emission cylinder
  28321. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  28322. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  28323. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  28324. * @returns the emitter
  28325. */
  28326. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  28327. /**
  28328. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  28329. * @param radius The radius of the cone to emit from
  28330. * @param angle The base angle of the cone
  28331. * @returns the emitter
  28332. */
  28333. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  28334. /**
  28335. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  28336. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  28337. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  28338. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  28339. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  28340. * @returns the emitter
  28341. */
  28342. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  28343. /**
  28344. * Get hosting scene
  28345. * @returns the scene
  28346. */
  28347. getScene(): Scene;
  28348. }
  28349. }
  28350. declare module BABYLON {
  28351. /**
  28352. * A particle represents one of the element emitted by a particle system.
  28353. * This is mainly define by its coordinates, direction, velocity and age.
  28354. */
  28355. class Particle {
  28356. /**
  28357. * The particle system the particle belongs to.
  28358. */
  28359. particleSystem: ParticleSystem;
  28360. private static _Count;
  28361. /**
  28362. * Unique ID of the particle
  28363. */
  28364. id: number;
  28365. /**
  28366. * The world position of the particle in the scene.
  28367. */
  28368. position: Vector3;
  28369. /**
  28370. * The world direction of the particle in the scene.
  28371. */
  28372. direction: Vector3;
  28373. /**
  28374. * The color of the particle.
  28375. */
  28376. color: Color4;
  28377. /**
  28378. * The color change of the particle per step.
  28379. */
  28380. colorStep: Color4;
  28381. /**
  28382. * Defines how long will the life of the particle be.
  28383. */
  28384. lifeTime: number;
  28385. /**
  28386. * The current age of the particle.
  28387. */
  28388. age: number;
  28389. /**
  28390. * The current size of the particle.
  28391. */
  28392. size: number;
  28393. /**
  28394. * The current scale of the particle.
  28395. */
  28396. scale: Vector2;
  28397. /**
  28398. * The current angle of the particle.
  28399. */
  28400. angle: number;
  28401. /**
  28402. * Defines how fast is the angle changing.
  28403. */
  28404. angularSpeed: number;
  28405. /**
  28406. * Defines the cell index used by the particle to be rendered from a sprite.
  28407. */
  28408. cellIndex: number;
  28409. /**
  28410. * The information required to support color remapping
  28411. */
  28412. remapData: Vector4;
  28413. /** @hidden */
  28414. /** @hidden */
  28415. /** @hidden */
  28416. /** @hidden */
  28417. /** @hidden */
  28418. /** @hidden */
  28419. /** @hidden */
  28420. /** @hidden */
  28421. /** @hidden */
  28422. /** @hidden */
  28423. /** @hidden */
  28424. /** @hidden */
  28425. /** @hidden */
  28426. /** @hidden */
  28427. /** @hidden */
  28428. /** @hidden */
  28429. /** @hidden */
  28430. /** @hidden */
  28431. /** @hidden */
  28432. /** @hidden */
  28433. /** @hidden */
  28434. /** @hidden */
  28435. /** @hidden */
  28436. /** @hidden */
  28437. /**
  28438. * Creates a new instance Particle
  28439. * @param particleSystem the particle system the particle belongs to
  28440. */
  28441. constructor(
  28442. /**
  28443. * The particle system the particle belongs to.
  28444. */
  28445. particleSystem: ParticleSystem);
  28446. private updateCellInfoFromSystem;
  28447. /**
  28448. * Defines how the sprite cell index is updated for the particle
  28449. */
  28450. updateCellIndex(): void;
  28451. /** @hidden */
  28452. /** @hidden */
  28453. /** @hidden */
  28454. /**
  28455. * Copy the properties of particle to another one.
  28456. * @param other the particle to copy the information to.
  28457. */
  28458. copyTo(other: Particle): void;
  28459. }
  28460. }
  28461. declare module BABYLON {
  28462. /**
  28463. * This class is made for on one-liner static method to help creating particle system set.
  28464. */
  28465. class ParticleHelper {
  28466. /**
  28467. * Gets or sets base Assets URL
  28468. */
  28469. static BaseAssetsUrl: string;
  28470. /**
  28471. * Create a default particle system that you can tweak
  28472. * @param emitter defines the emitter to use
  28473. * @param capacity defines the system capacity (default is 500 particles)
  28474. * @param scene defines the hosting scene
  28475. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  28476. * @returns the new Particle system
  28477. */
  28478. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  28479. /**
  28480. * This is the main static method (one-liner) of this helper to create different particle systems
  28481. * @param type This string represents the type to the particle system to create
  28482. * @param scene The scene where the particle system should live
  28483. * @param gpu If the system will use gpu
  28484. * @returns the ParticleSystemSet created
  28485. */
  28486. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  28487. /**
  28488. * Static function used to export a particle system to a ParticleSystemSet variable.
  28489. * Please note that the emitter shape is not exported
  28490. * @param system defines the particle systems to export
  28491. */
  28492. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  28493. }
  28494. }
  28495. declare module BABYLON {
  28496. /**
  28497. * This represents a particle system in Babylon.
  28498. * 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.
  28499. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  28500. * @example https://doc.babylonjs.com/babylon101/particles
  28501. */
  28502. class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  28503. /**
  28504. * Billboard mode will only apply to Y axis
  28505. */
  28506. static readonly BILLBOARDMODE_Y: number;
  28507. /**
  28508. * Billboard mode will apply to all axes
  28509. */
  28510. static readonly BILLBOARDMODE_ALL: number;
  28511. /**
  28512. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  28513. */
  28514. static readonly BILLBOARDMODE_STRETCHED: number;
  28515. /**
  28516. * This function can be defined to provide custom update for active particles.
  28517. * This function will be called instead of regular update (age, position, color, etc.).
  28518. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  28519. */
  28520. updateFunction: (particles: Particle[]) => void;
  28521. private _emitterWorldMatrix;
  28522. /**
  28523. * This function can be defined to specify initial direction for every new particle.
  28524. * It by default use the emitterType defined function
  28525. */
  28526. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  28527. /**
  28528. * This function can be defined to specify initial position for every new particle.
  28529. * It by default use the emitterType defined function
  28530. */
  28531. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  28532. /**
  28533. * @hidden
  28534. */
  28535. /**
  28536. * An event triggered when the system is disposed
  28537. */
  28538. onDisposeObservable: Observable<ParticleSystem>;
  28539. private _onDisposeObserver;
  28540. /**
  28541. * Sets a callback that will be triggered when the system is disposed
  28542. */
  28543. onDispose: () => void;
  28544. private _particles;
  28545. private _epsilon;
  28546. private _capacity;
  28547. private _stockParticles;
  28548. private _newPartsExcess;
  28549. private _vertexData;
  28550. private _vertexBuffer;
  28551. private _vertexBuffers;
  28552. private _spriteBuffer;
  28553. private _indexBuffer;
  28554. private _effect;
  28555. private _customEffect;
  28556. private _cachedDefines;
  28557. private _scaledColorStep;
  28558. private _colorDiff;
  28559. private _scaledDirection;
  28560. private _scaledGravity;
  28561. private _currentRenderId;
  28562. private _alive;
  28563. private _useInstancing;
  28564. private _started;
  28565. private _stopped;
  28566. private _actualFrame;
  28567. private _scaledUpdateSpeed;
  28568. private _vertexBufferSize;
  28569. /** @hidden */
  28570. /** @hidden */
  28571. /** @hidden */
  28572. /** @hidden */
  28573. /** @hidden */
  28574. /** @hidden */
  28575. private readonly _rawTextureWidth;
  28576. private _rampGradientsTexture;
  28577. private _useRampGradients;
  28578. /** Gets or sets a boolean indicating that ramp gradients must be used
  28579. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  28580. */
  28581. useRampGradients: boolean;
  28582. /**
  28583. * 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.
  28584. * 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: [])
  28585. */
  28586. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  28587. private _subEmitters;
  28588. /**
  28589. * @hidden
  28590. * If the particle systems emitter should be disposed when the particle system is disposed
  28591. */
  28592. /**
  28593. * The current active Sub-systems, this property is used by the root particle system only.
  28594. */
  28595. activeSubSystems: Array<ParticleSystem>;
  28596. private _rootParticleSystem;
  28597. /**
  28598. * Gets the current list of active particles
  28599. */
  28600. readonly particles: Particle[];
  28601. /**
  28602. * Returns the string "ParticleSystem"
  28603. * @returns a string containing the class name
  28604. */
  28605. getClassName(): string;
  28606. /**
  28607. * Instantiates a particle system.
  28608. * 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.
  28609. * @param name The name of the particle system
  28610. * @param capacity The max number of particles alive at the same time
  28611. * @param scene The scene the particle system belongs to
  28612. * @param customEffect a custom effect used to change the way particles are rendered by default
  28613. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  28614. * @param epsilon Offset used to render the particles
  28615. */
  28616. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  28617. private _addFactorGradient;
  28618. private _removeFactorGradient;
  28619. /**
  28620. * Adds a new life time gradient
  28621. * @param gradient defines the gradient to use (between 0 and 1)
  28622. * @param factor defines the life time factor to affect to the specified gradient
  28623. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  28624. * @returns the current particle system
  28625. */
  28626. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  28627. /**
  28628. * Remove a specific life time gradient
  28629. * @param gradient defines the gradient to remove
  28630. * @returns the current particle system
  28631. */
  28632. removeLifeTimeGradient(gradient: number): IParticleSystem;
  28633. /**
  28634. * Adds a new size gradient
  28635. * @param gradient defines the gradient to use (between 0 and 1)
  28636. * @param factor defines the size factor to affect to the specified gradient
  28637. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  28638. * @returns the current particle system
  28639. */
  28640. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  28641. /**
  28642. * Remove a specific size gradient
  28643. * @param gradient defines the gradient to remove
  28644. * @returns the current particle system
  28645. */
  28646. removeSizeGradient(gradient: number): IParticleSystem;
  28647. /**
  28648. * Adds a new color remap gradient
  28649. * @param gradient defines the gradient to use (between 0 and 1)
  28650. * @param min defines the color remap minimal range
  28651. * @param max defines the color remap maximal range
  28652. * @returns the current particle system
  28653. */
  28654. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  28655. /**
  28656. * Remove a specific color remap gradient
  28657. * @param gradient defines the gradient to remove
  28658. * @returns the current particle system
  28659. */
  28660. removeColorRemapGradient(gradient: number): IParticleSystem;
  28661. /**
  28662. * Adds a new alpha remap gradient
  28663. * @param gradient defines the gradient to use (between 0 and 1)
  28664. * @param min defines the alpha remap minimal range
  28665. * @param max defines the alpha remap maximal range
  28666. * @returns the current particle system
  28667. */
  28668. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  28669. /**
  28670. * Remove a specific alpha remap gradient
  28671. * @param gradient defines the gradient to remove
  28672. * @returns the current particle system
  28673. */
  28674. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  28675. /**
  28676. * Adds a new angular speed gradient
  28677. * @param gradient defines the gradient to use (between 0 and 1)
  28678. * @param factor defines the angular speed to affect to the specified gradient
  28679. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  28680. * @returns the current particle system
  28681. */
  28682. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  28683. /**
  28684. * Remove a specific angular speed gradient
  28685. * @param gradient defines the gradient to remove
  28686. * @returns the current particle system
  28687. */
  28688. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  28689. /**
  28690. * Adds a new velocity gradient
  28691. * @param gradient defines the gradient to use (between 0 and 1)
  28692. * @param factor defines the velocity to affect to the specified gradient
  28693. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  28694. * @returns the current particle system
  28695. */
  28696. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  28697. /**
  28698. * Remove a specific velocity gradient
  28699. * @param gradient defines the gradient to remove
  28700. * @returns the current particle system
  28701. */
  28702. removeVelocityGradient(gradient: number): IParticleSystem;
  28703. /**
  28704. * Adds a new limit velocity gradient
  28705. * @param gradient defines the gradient to use (between 0 and 1)
  28706. * @param factor defines the limit velocity value to affect to the specified gradient
  28707. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  28708. * @returns the current particle system
  28709. */
  28710. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  28711. /**
  28712. * Remove a specific limit velocity gradient
  28713. * @param gradient defines the gradient to remove
  28714. * @returns the current particle system
  28715. */
  28716. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  28717. /**
  28718. * Adds a new drag gradient
  28719. * @param gradient defines the gradient to use (between 0 and 1)
  28720. * @param factor defines the drag value to affect to the specified gradient
  28721. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  28722. * @returns the current particle system
  28723. */
  28724. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  28725. /**
  28726. * Remove a specific drag gradient
  28727. * @param gradient defines the gradient to remove
  28728. * @returns the current particle system
  28729. */
  28730. removeDragGradient(gradient: number): IParticleSystem;
  28731. /**
  28732. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  28733. * @param gradient defines the gradient to use (between 0 and 1)
  28734. * @param factor defines the emit rate value to affect to the specified gradient
  28735. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  28736. * @returns the current particle system
  28737. */
  28738. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  28739. /**
  28740. * Remove a specific emit rate gradient
  28741. * @param gradient defines the gradient to remove
  28742. * @returns the current particle system
  28743. */
  28744. removeEmitRateGradient(gradient: number): IParticleSystem;
  28745. /**
  28746. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  28747. * @param gradient defines the gradient to use (between 0 and 1)
  28748. * @param factor defines the start size value to affect to the specified gradient
  28749. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  28750. * @returns the current particle system
  28751. */
  28752. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  28753. /**
  28754. * Remove a specific start size gradient
  28755. * @param gradient defines the gradient to remove
  28756. * @returns the current particle system
  28757. */
  28758. removeStartSizeGradient(gradient: number): IParticleSystem;
  28759. private _createRampGradientTexture;
  28760. /**
  28761. * Gets the current list of ramp gradients.
  28762. * You must use addRampGradient and removeRampGradient to udpate this list
  28763. * @returns the list of ramp gradients
  28764. */
  28765. getRampGradients(): Nullable<Array<Color3Gradient>>;
  28766. /**
  28767. * Adds a new ramp gradient used to remap particle colors
  28768. * @param gradient defines the gradient to use (between 0 and 1)
  28769. * @param color defines the color to affect to the specified gradient
  28770. * @returns the current particle system
  28771. */
  28772. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  28773. /**
  28774. * Remove a specific ramp gradient
  28775. * @param gradient defines the gradient to remove
  28776. * @returns the current particle system
  28777. */
  28778. removeRampGradient(gradient: number): ParticleSystem;
  28779. /**
  28780. * Adds a new color gradient
  28781. * @param gradient defines the gradient to use (between 0 and 1)
  28782. * @param color1 defines the color to affect to the specified gradient
  28783. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  28784. */
  28785. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  28786. /**
  28787. * Remove a specific color gradient
  28788. * @param gradient defines the gradient to remove
  28789. */
  28790. removeColorGradient(gradient: number): IParticleSystem;
  28791. private _fetchR;
  28792. protected _reset(): void;
  28793. private _resetEffect;
  28794. private _createVertexBuffers;
  28795. private _createIndexBuffer;
  28796. /**
  28797. * Gets the maximum number of particles active at the same time.
  28798. * @returns The max number of active particles.
  28799. */
  28800. getCapacity(): number;
  28801. /**
  28802. * Gets whether there are still active particles in the system.
  28803. * @returns True if it is alive, otherwise false.
  28804. */
  28805. isAlive(): boolean;
  28806. /**
  28807. * Gets if the system has been started. (Note: this will still be true after stop is called)
  28808. * @returns True if it has been started, otherwise false.
  28809. */
  28810. isStarted(): boolean;
  28811. private _prepareSubEmitterInternalArray;
  28812. /**
  28813. * Starts the particle system and begins to emit
  28814. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  28815. */
  28816. start(delay?: number): void;
  28817. /**
  28818. * Stops the particle system.
  28819. * @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.
  28820. */
  28821. stop(stopSubEmitters?: boolean): void;
  28822. /**
  28823. * Remove all active particles
  28824. */
  28825. reset(): void;
  28826. /**
  28827. * @hidden (for internal use only)
  28828. */
  28829. /**
  28830. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  28831. * Its lifetime will start back at 0.
  28832. */
  28833. recycleParticle: (particle: Particle) => void;
  28834. private _stopSubEmitters;
  28835. private _createParticle;
  28836. private _removeFromRoot;
  28837. private _emitFromParticle;
  28838. private _update;
  28839. /** @hidden */
  28840. private static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  28841. private static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  28842. private _getEffect;
  28843. /**
  28844. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  28845. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  28846. */
  28847. animate(preWarmOnly?: boolean): void;
  28848. private _appendParticleVertices;
  28849. /**
  28850. * Rebuilds the particle system.
  28851. */
  28852. rebuild(): void;
  28853. /**
  28854. * Is this system ready to be used/rendered
  28855. * @return true if the system is ready
  28856. */
  28857. isReady(): boolean;
  28858. private _render;
  28859. /**
  28860. * Renders the particle system in its current state.
  28861. * @returns the current number of particles
  28862. */
  28863. render(): number;
  28864. /**
  28865. * Disposes the particle system and free the associated resources
  28866. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  28867. */
  28868. dispose(disposeTexture?: boolean): void;
  28869. /**
  28870. * Clones the particle system.
  28871. * @param name The name of the cloned object
  28872. * @param newEmitter The new emitter to use
  28873. * @returns the cloned particle system
  28874. */
  28875. clone(name: string, newEmitter: any): ParticleSystem;
  28876. /**
  28877. * Serializes the particle system to a JSON object.
  28878. * @returns the JSON object
  28879. */
  28880. serialize(): any;
  28881. /** @hidden */
  28882. private static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  28883. /** @hidden */
  28884. private static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  28885. /**
  28886. * Parses a JSON object to create a particle system.
  28887. * @param parsedParticleSystem The JSON object to parse
  28888. * @param scene The scene to create the particle system in
  28889. * @param rootUrl The root url to use to load external dependencies like texture
  28890. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  28891. * @returns the Parsed particle system
  28892. */
  28893. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  28894. }
  28895. }
  28896. declare module BABYLON {
  28897. interface Engine {
  28898. /**
  28899. * Create an effect to use with particle systems.
  28900. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  28901. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  28902. * @param uniformsNames defines a list of attribute names
  28903. * @param samplers defines an array of string used to represent textures
  28904. * @param defines defines the string containing the defines to use to compile the shaders
  28905. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  28906. * @param onCompiled defines a function to call when the effect creation is successful
  28907. * @param onError defines a function to call when the effect creation has failed
  28908. * @returns the new Effect
  28909. */
  28910. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  28911. }
  28912. interface Mesh {
  28913. /**
  28914. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  28915. * @returns an array of IParticleSystem
  28916. */
  28917. getEmittedParticleSystems(): IParticleSystem[];
  28918. /**
  28919. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  28920. * @returns an array of IParticleSystem
  28921. */
  28922. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  28923. }
  28924. }
  28925. declare module BABYLON {
  28926. /**
  28927. * Represents a set of particle systems working together to create a specific effect
  28928. */
  28929. class ParticleSystemSet implements IDisposable {
  28930. private _emitterCreationOptions;
  28931. private _emitterNode;
  28932. /**
  28933. * Gets the particle system list
  28934. */
  28935. systems: IParticleSystem[];
  28936. /**
  28937. * Gets the emitter node used with this set
  28938. */
  28939. readonly emitterNode: Nullable<TransformNode>;
  28940. /**
  28941. * Creates a new emitter mesh as a sphere
  28942. * @param options defines the options used to create the sphere
  28943. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  28944. * @param scene defines the hosting scene
  28945. */
  28946. setEmitterAsSphere(options: {
  28947. diameter: number;
  28948. segments: number;
  28949. color: Color3;
  28950. }, renderingGroupId: number, scene: Scene): void;
  28951. /**
  28952. * Starts all particle systems of the set
  28953. * @param emitter defines an optional mesh to use as emitter for the particle systems
  28954. */
  28955. start(emitter?: AbstractMesh): void;
  28956. /**
  28957. * Release all associated resources
  28958. */
  28959. dispose(): void;
  28960. /**
  28961. * Serialize the set into a JSON compatible object
  28962. * @returns a JSON compatible representation of the set
  28963. */
  28964. serialize(): any;
  28965. /**
  28966. * Parse a new ParticleSystemSet from a serialized source
  28967. * @param data defines a JSON compatible representation of the set
  28968. * @param scene defines the hosting scene
  28969. * @param gpu defines if we want GPU particles or CPU particles
  28970. * @returns a new ParticleSystemSet
  28971. */
  28972. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  28973. }
  28974. }
  28975. declare module BABYLON {
  28976. /**
  28977. * Represents one particle of a solid particle system.
  28978. */
  28979. class SolidParticle {
  28980. /**
  28981. * particle global index
  28982. */
  28983. idx: number;
  28984. /**
  28985. * The color of the particle
  28986. */
  28987. color: Nullable<Color4>;
  28988. /**
  28989. * The world space position of the particle.
  28990. */
  28991. position: Vector3;
  28992. /**
  28993. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  28994. */
  28995. rotation: Vector3;
  28996. /**
  28997. * The world space rotation quaternion of the particle.
  28998. */
  28999. rotationQuaternion: Nullable<Quaternion>;
  29000. /**
  29001. * The scaling of the particle.
  29002. */
  29003. scaling: Vector3;
  29004. /**
  29005. * The uvs of the particle.
  29006. */
  29007. uvs: Vector4;
  29008. /**
  29009. * The current speed of the particle.
  29010. */
  29011. velocity: Vector3;
  29012. /**
  29013. * The pivot point in the particle local space.
  29014. */
  29015. pivot: Vector3;
  29016. /**
  29017. * Must the particle be translated from its pivot point in its local space ?
  29018. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  29019. * Default : false
  29020. */
  29021. translateFromPivot: boolean;
  29022. /**
  29023. * Is the particle active or not ?
  29024. */
  29025. alive: boolean;
  29026. /**
  29027. * Is the particle visible or not ?
  29028. */
  29029. isVisible: boolean;
  29030. /**
  29031. * Index of this particle in the global "positions" array (Internal use)
  29032. * @hidden
  29033. */
  29034. /**
  29035. * @hidden Index of this particle in the global "indices" array (Internal use)
  29036. */
  29037. /**
  29038. * @hidden ModelShape of this particle (Internal use)
  29039. */
  29040. /**
  29041. * ModelShape id of this particle
  29042. */
  29043. shapeId: number;
  29044. /**
  29045. * Index of the particle in its shape id (Internal use)
  29046. */
  29047. idxInShape: number;
  29048. /**
  29049. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  29050. */
  29051. /**
  29052. * @hidden Particle BoundingInfo object (Internal use)
  29053. */
  29054. /**
  29055. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  29056. */
  29057. /**
  29058. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  29059. */
  29060. /**
  29061. * @hidden Last computed particle rotation matrix
  29062. */
  29063. /**
  29064. * Parent particle Id, if any.
  29065. * Default null.
  29066. */
  29067. parentId: Nullable<number>;
  29068. /**
  29069. * @hidden Internal global position in the SPS.
  29070. */
  29071. /**
  29072. * Creates a Solid Particle object.
  29073. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  29074. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  29075. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  29076. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  29077. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  29078. * @param shapeId (integer) is the model shape identifier in the SPS.
  29079. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  29080. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  29081. */
  29082. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  29083. /**
  29084. * Legacy support, changed scale to scaling
  29085. */
  29086. /**
  29087. * Legacy support, changed scale to scaling
  29088. */
  29089. scale: Vector3;
  29090. /**
  29091. * Legacy support, changed quaternion to rotationQuaternion
  29092. */
  29093. /**
  29094. * Legacy support, changed quaternion to rotationQuaternion
  29095. */
  29096. quaternion: Nullable<Quaternion>;
  29097. /**
  29098. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  29099. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  29100. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  29101. * @returns true if it intersects
  29102. */
  29103. intersectsMesh(target: Mesh | SolidParticle): boolean;
  29104. }
  29105. /**
  29106. * Represents the shape of the model used by one particle of a solid particle system.
  29107. * SPS internal tool, don't use it manually.
  29108. */
  29109. class ModelShape {
  29110. /**
  29111. * The shape id
  29112. * @hidden
  29113. */
  29114. shapeID: number;
  29115. /**
  29116. * flat array of model positions (internal use)
  29117. * @hidden
  29118. */
  29119. /**
  29120. * flat array of model UVs (internal use)
  29121. * @hidden
  29122. */
  29123. /**
  29124. * length of the shape in the model indices array (internal use)
  29125. * @hidden
  29126. */
  29127. /**
  29128. * Custom position function (internal use)
  29129. * @hidden
  29130. */
  29131. /**
  29132. * Custom vertex function (internal use)
  29133. * @hidden
  29134. */
  29135. /**
  29136. * 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.
  29137. * SPS internal tool, don't use it manually.
  29138. * @hidden
  29139. */
  29140. 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>);
  29141. }
  29142. /**
  29143. * Represents a Depth Sorted Particle in the solid particle system.
  29144. */
  29145. class DepthSortedParticle {
  29146. /**
  29147. * Index of the particle in the "indices" array
  29148. */
  29149. ind: number;
  29150. /**
  29151. * Length of the particle shape in the "indices" array
  29152. */
  29153. indicesLength: number;
  29154. /**
  29155. * Squared distance from the particle to the camera
  29156. */
  29157. sqDistance: number;
  29158. }
  29159. }
  29160. declare module BABYLON {
  29161. /**
  29162. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  29163. *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.
  29164. * The SPS is also a particle system. It provides some methods to manage the particles.
  29165. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  29166. *
  29167. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  29168. */
  29169. class SolidParticleSystem implements IDisposable {
  29170. /**
  29171. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  29172. * Example : var p = SPS.particles[i];
  29173. */
  29174. particles: SolidParticle[];
  29175. /**
  29176. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  29177. */
  29178. nbParticles: number;
  29179. /**
  29180. * If the particles must ever face the camera (default false). Useful for planar particles.
  29181. */
  29182. billboard: boolean;
  29183. /**
  29184. * Recompute normals when adding a shape
  29185. */
  29186. recomputeNormals: boolean;
  29187. /**
  29188. * This a counter ofr your own usage. It's not set by any SPS functions.
  29189. */
  29190. counter: number;
  29191. /**
  29192. * The SPS name. This name is also given to the underlying mesh.
  29193. */
  29194. name: string;
  29195. /**
  29196. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  29197. */
  29198. mesh: Mesh;
  29199. /**
  29200. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  29201. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  29202. */
  29203. vars: any;
  29204. /**
  29205. * This array is populated when the SPS is set as 'pickable'.
  29206. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  29207. * Each element of this array is an object `{idx: int, faceId: int}`.
  29208. * `idx` is the picked particle index in the `SPS.particles` array
  29209. * `faceId` is the picked face index counted within this particle.
  29210. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  29211. */
  29212. pickedParticles: {
  29213. idx: number;
  29214. faceId: number;
  29215. }[];
  29216. /**
  29217. * This array is populated when `enableDepthSort` is set to true.
  29218. * Each element of this array is an instance of the class DepthSortedParticle.
  29219. */
  29220. depthSortedParticles: DepthSortedParticle[];
  29221. /**
  29222. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  29223. * @hidden
  29224. */
  29225. /**
  29226. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  29227. * @hidden
  29228. */
  29229. private _scene;
  29230. private _positions;
  29231. private _indices;
  29232. private _normals;
  29233. private _colors;
  29234. private _uvs;
  29235. private _indices32;
  29236. private _positions32;
  29237. private _normals32;
  29238. private _fixedNormal32;
  29239. private _colors32;
  29240. private _uvs32;
  29241. private _index;
  29242. private _updatable;
  29243. private _pickable;
  29244. private _isVisibilityBoxLocked;
  29245. private _alwaysVisible;
  29246. private _depthSort;
  29247. private _shapeCounter;
  29248. private _copy;
  29249. private _shape;
  29250. private _shapeUV;
  29251. private _color;
  29252. private _computeParticleColor;
  29253. private _computeParticleTexture;
  29254. private _computeParticleRotation;
  29255. private _computeParticleVertex;
  29256. private _computeBoundingBox;
  29257. private _depthSortParticles;
  29258. private _cam_axisZ;
  29259. private _cam_axisY;
  29260. private _cam_axisX;
  29261. private _axisZ;
  29262. private _camera;
  29263. private _particle;
  29264. private _camDir;
  29265. private _camInvertedPosition;
  29266. private _rotMatrix;
  29267. private _invertMatrix;
  29268. private _rotated;
  29269. private _quaternion;
  29270. private _vertex;
  29271. private _normal;
  29272. private _yaw;
  29273. private _pitch;
  29274. private _roll;
  29275. private _halfroll;
  29276. private _halfpitch;
  29277. private _halfyaw;
  29278. private _sinRoll;
  29279. private _cosRoll;
  29280. private _sinPitch;
  29281. private _cosPitch;
  29282. private _sinYaw;
  29283. private _cosYaw;
  29284. private _mustUnrotateFixedNormals;
  29285. private _minimum;
  29286. private _maximum;
  29287. private _minBbox;
  29288. private _maxBbox;
  29289. private _particlesIntersect;
  29290. private _depthSortFunction;
  29291. private _needs32Bits;
  29292. private _pivotBackTranslation;
  29293. private _scaledPivot;
  29294. private _particleHasParent;
  29295. private _parent;
  29296. /**
  29297. * Creates a SPS (Solid Particle System) object.
  29298. * @param name (String) is the SPS name, this will be the underlying mesh name.
  29299. * @param scene (Scene) is the scene in which the SPS is added.
  29300. * @param updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  29301. * @param isPickable (optional boolean, default false) : if the solid particles must be pickable.
  29302. * @param enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  29303. * @param particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  29304. * @param boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  29305. * @param bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  29306. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  29307. */
  29308. constructor(name: string, scene: Scene, options?: {
  29309. updatable?: boolean;
  29310. isPickable?: boolean;
  29311. enableDepthSort?: boolean;
  29312. particleIntersection?: boolean;
  29313. boundingSphereOnly?: boolean;
  29314. bSphereRadiusFactor?: number;
  29315. });
  29316. /**
  29317. * Builds the SPS underlying mesh. Returns a standard Mesh.
  29318. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  29319. * @returns the created mesh
  29320. */
  29321. buildMesh(): Mesh;
  29322. /**
  29323. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  29324. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  29325. * Thus the particles generated from `digest()` have their property `position` set yet.
  29326. * @param mesh ( Mesh ) is the mesh to be digested
  29327. * @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
  29328. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  29329. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  29330. * @returns the current SPS
  29331. */
  29332. digest(mesh: Mesh, options?: {
  29333. facetNb?: number;
  29334. number?: number;
  29335. delta?: number;
  29336. }): SolidParticleSystem;
  29337. private _unrotateFixedNormals;
  29338. private _resetCopy;
  29339. private _meshBuilder;
  29340. private _posToShape;
  29341. private _uvsToShapeUV;
  29342. private _addParticle;
  29343. /**
  29344. * Adds some particles to the SPS from the model shape. Returns the shape id.
  29345. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  29346. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  29347. * @param nb (positive integer) the number of particles to be created from this model
  29348. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  29349. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  29350. * @returns the number of shapes in the system
  29351. */
  29352. addShape(mesh: Mesh, nb: number, options?: {
  29353. positionFunction?: any;
  29354. vertexFunction?: any;
  29355. }): number;
  29356. private _rebuildParticle;
  29357. /**
  29358. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  29359. * @returns the SPS.
  29360. */
  29361. rebuildMesh(): SolidParticleSystem;
  29362. /**
  29363. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  29364. * This method calls `updateParticle()` for each particle of the SPS.
  29365. * For an animated SPS, it is usually called within the render loop.
  29366. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  29367. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  29368. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  29369. * @returns the SPS.
  29370. */
  29371. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  29372. private _quaternionRotationYPR;
  29373. private _quaternionToRotationMatrix;
  29374. /**
  29375. * Disposes the SPS.
  29376. */
  29377. dispose(): void;
  29378. /**
  29379. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  29380. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  29381. * @returns the SPS.
  29382. */
  29383. refreshVisibleSize(): SolidParticleSystem;
  29384. /**
  29385. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  29386. * @param size the size (float) of the visibility box
  29387. * note : this doesn't lock the SPS mesh bounding box.
  29388. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  29389. */
  29390. setVisibilityBox(size: number): void;
  29391. /**
  29392. * Gets whether the SPS as always visible or not
  29393. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  29394. */
  29395. /**
  29396. * Sets the SPS as always visible or not
  29397. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  29398. */
  29399. isAlwaysVisible: boolean;
  29400. /**
  29401. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  29402. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  29403. */
  29404. /**
  29405. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  29406. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  29407. */
  29408. isVisibilityBoxLocked: boolean;
  29409. /**
  29410. * Tells to `setParticles()` to compute the particle rotations or not.
  29411. * Default value : true. The SPS is faster when it's set to false.
  29412. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  29413. */
  29414. /**
  29415. * Gets if `setParticles()` computes the particle rotations or not.
  29416. * Default value : true. The SPS is faster when it's set to false.
  29417. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  29418. */
  29419. computeParticleRotation: boolean;
  29420. /**
  29421. * Tells to `setParticles()` to compute the particle colors or not.
  29422. * Default value : true. The SPS is faster when it's set to false.
  29423. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  29424. */
  29425. /**
  29426. * Gets if `setParticles()` computes the particle colors or not.
  29427. * Default value : true. The SPS is faster when it's set to false.
  29428. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  29429. */
  29430. computeParticleColor: boolean;
  29431. /**
  29432. * Gets if `setParticles()` computes the particle textures or not.
  29433. * Default value : true. The SPS is faster when it's set to false.
  29434. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  29435. */
  29436. computeParticleTexture: boolean;
  29437. /**
  29438. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  29439. * Default value : false. The SPS is faster when it's set to false.
  29440. * Note : the particle custom vertex positions aren't stored values.
  29441. */
  29442. /**
  29443. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  29444. * Default value : false. The SPS is faster when it's set to false.
  29445. * Note : the particle custom vertex positions aren't stored values.
  29446. */
  29447. computeParticleVertex: boolean;
  29448. /**
  29449. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  29450. */
  29451. /**
  29452. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  29453. */
  29454. computeBoundingBox: boolean;
  29455. /**
  29456. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  29457. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  29458. * Default : `true`
  29459. */
  29460. /**
  29461. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  29462. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  29463. * Default : `true`
  29464. */
  29465. depthSortParticles: boolean;
  29466. /**
  29467. * This function does nothing. It may be overwritten to set all the particle first values.
  29468. * The SPS doesn't call this function, you may have to call it by your own.
  29469. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  29470. */
  29471. initParticles(): void;
  29472. /**
  29473. * This function does nothing. It may be overwritten to recycle a particle.
  29474. * The SPS doesn't call this function, you may have to call it by your own.
  29475. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  29476. * @param particle The particle to recycle
  29477. * @returns the recycled particle
  29478. */
  29479. recycleParticle(particle: SolidParticle): SolidParticle;
  29480. /**
  29481. * Updates a particle : this function should be overwritten by the user.
  29482. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  29483. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  29484. * @example : just set a particle position or velocity and recycle conditions
  29485. * @param particle The particle to update
  29486. * @returns the updated particle
  29487. */
  29488. updateParticle(particle: SolidParticle): SolidParticle;
  29489. /**
  29490. * Updates a vertex of a particle : it can be overwritten by the user.
  29491. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  29492. * @param particle the current particle
  29493. * @param vertex the current index of the current particle
  29494. * @param pt the index of the current vertex in the particle shape
  29495. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  29496. * @example : just set a vertex particle position
  29497. * @returns the updated vertex
  29498. */
  29499. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  29500. /**
  29501. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  29502. * This does nothing and may be overwritten by the user.
  29503. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  29504. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  29505. * @param update the boolean update value actually passed to setParticles()
  29506. */
  29507. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  29508. /**
  29509. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  29510. * This will be passed three parameters.
  29511. * This does nothing and may be overwritten by the user.
  29512. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  29513. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  29514. * @param update the boolean update value actually passed to setParticles()
  29515. */
  29516. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  29517. }
  29518. }
  29519. declare module BABYLON {
  29520. /**
  29521. * Type of sub emitter
  29522. */
  29523. enum SubEmitterType {
  29524. /**
  29525. * Attached to the particle over it's lifetime
  29526. */
  29527. ATTACHED = 0,
  29528. /**
  29529. * Created when the particle dies
  29530. */
  29531. END = 1
  29532. }
  29533. /**
  29534. * Sub emitter class used to emit particles from an existing particle
  29535. */
  29536. class SubEmitter {
  29537. /**
  29538. * the particle system to be used by the sub emitter
  29539. */
  29540. particleSystem: ParticleSystem;
  29541. /**
  29542. * Type of the submitter (Default: END)
  29543. */
  29544. type: SubEmitterType;
  29545. /**
  29546. * 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)
  29547. * Note: This only is supported when using an emitter of type Mesh
  29548. */
  29549. inheritDirection: boolean;
  29550. /**
  29551. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  29552. */
  29553. inheritedVelocityAmount: number;
  29554. /**
  29555. * Creates a sub emitter
  29556. * @param particleSystem the particle system to be used by the sub emitter
  29557. */
  29558. constructor(
  29559. /**
  29560. * the particle system to be used by the sub emitter
  29561. */
  29562. particleSystem: ParticleSystem);
  29563. /**
  29564. * Clones the sub emitter
  29565. * @returns the cloned sub emitter
  29566. */
  29567. clone(): SubEmitter;
  29568. /**
  29569. * Serialize current object to a JSON object
  29570. * @returns the serialized object
  29571. */
  29572. serialize(): any;
  29573. /**
  29574. * Creates a new SubEmitter from a serialized JSON version
  29575. * @param serializationObject defines the JSON object to read from
  29576. * @param scene defines the hosting scene
  29577. * @param rootUrl defines the rootUrl for data loading
  29578. * @returns a new SubEmitter
  29579. */
  29580. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  29581. /** Release associated resources */
  29582. dispose(): void;
  29583. }
  29584. }
  29585. declare module BABYLON {
  29586. /**
  29587. * Interface used to describe a physics joint
  29588. */
  29589. interface PhysicsImpostorJoint {
  29590. /** Defines the main impostor to which the joint is linked */
  29591. mainImpostor: PhysicsImpostor;
  29592. /** Defines the impostor that is connected to the main impostor using this joint */
  29593. connectedImpostor: PhysicsImpostor;
  29594. /** Defines the joint itself */
  29595. joint: PhysicsJoint;
  29596. }
  29597. /** @hidden */
  29598. interface IPhysicsEnginePlugin {
  29599. world: any;
  29600. name: string;
  29601. setGravity(gravity: Vector3): void;
  29602. setTimeStep(timeStep: number): void;
  29603. getTimeStep(): number;
  29604. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  29605. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  29606. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  29607. generatePhysicsBody(impostor: PhysicsImpostor): void;
  29608. removePhysicsBody(impostor: PhysicsImpostor): void;
  29609. generateJoint(joint: PhysicsImpostorJoint): void;
  29610. removeJoint(joint: PhysicsImpostorJoint): void;
  29611. isSupported(): boolean;
  29612. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  29613. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  29614. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  29615. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  29616. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  29617. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  29618. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  29619. getBodyMass(impostor: PhysicsImpostor): number;
  29620. getBodyFriction(impostor: PhysicsImpostor): number;
  29621. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  29622. getBodyRestitution(impostor: PhysicsImpostor): number;
  29623. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  29624. sleepBody(impostor: PhysicsImpostor): void;
  29625. wakeUpBody(impostor: PhysicsImpostor): void;
  29626. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  29627. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  29628. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  29629. getRadius(impostor: PhysicsImpostor): number;
  29630. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  29631. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  29632. dispose(): void;
  29633. }
  29634. /**
  29635. * Interface used to define a physics engine
  29636. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  29637. */
  29638. interface IPhysicsEngine {
  29639. /**
  29640. * Gets the gravity vector used by the simulation
  29641. */
  29642. gravity: Vector3;
  29643. /**
  29644. * Sets the gravity vector used by the simulation
  29645. * @param gravity defines the gravity vector to use
  29646. */
  29647. setGravity(gravity: Vector3): void;
  29648. /**
  29649. * Set the time step of the physics engine.
  29650. * Default is 1/60.
  29651. * To slow it down, enter 1/600 for example.
  29652. * To speed it up, 1/30
  29653. * @param newTimeStep the new timestep to apply to this world.
  29654. */
  29655. setTimeStep(newTimeStep: number): void;
  29656. /**
  29657. * Get the time step of the physics engine.
  29658. * @returns the current time step
  29659. */
  29660. getTimeStep(): number;
  29661. /**
  29662. * Release all resources
  29663. */
  29664. dispose(): void;
  29665. /**
  29666. * Gets the name of the current physics plugin
  29667. * @returns the name of the plugin
  29668. */
  29669. getPhysicsPluginName(): string;
  29670. /**
  29671. * Adding a new impostor for the impostor tracking.
  29672. * This will be done by the impostor itself.
  29673. * @param impostor the impostor to add
  29674. */
  29675. addImpostor(impostor: PhysicsImpostor): void;
  29676. /**
  29677. * Remove an impostor from the engine.
  29678. * This impostor and its mesh will not longer be updated by the physics engine.
  29679. * @param impostor the impostor to remove
  29680. */
  29681. removeImpostor(impostor: PhysicsImpostor): void;
  29682. /**
  29683. * Add a joint to the physics engine
  29684. * @param mainImpostor defines the main impostor to which the joint is added.
  29685. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  29686. * @param joint defines the joint that will connect both impostors.
  29687. */
  29688. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  29689. /**
  29690. * Removes a joint from the simulation
  29691. * @param mainImpostor defines the impostor used with the joint
  29692. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  29693. * @param joint defines the joint to remove
  29694. */
  29695. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  29696. /**
  29697. * Gets the current plugin used to run the simulation
  29698. * @returns current plugin
  29699. */
  29700. getPhysicsPlugin(): IPhysicsEnginePlugin;
  29701. /**
  29702. * Gets the list of physic impostors
  29703. * @returns an array of PhysicsImpostor
  29704. */
  29705. getImpostors(): Array<PhysicsImpostor>;
  29706. /**
  29707. * Gets the impostor for a physics enabled object
  29708. * @param object defines the object impersonated by the impostor
  29709. * @returns the PhysicsImpostor or null if not found
  29710. */
  29711. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  29712. /**
  29713. * Gets the impostor for a physics body object
  29714. * @param body defines physics body used by the impostor
  29715. * @returns the PhysicsImpostor or null if not found
  29716. */
  29717. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  29718. /**
  29719. * Called by the scene. No need to call it.
  29720. * @param delta defines the timespam between frames
  29721. */
  29722. }
  29723. }
  29724. declare module BABYLON {
  29725. /**
  29726. * Class used to control physics engine
  29727. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  29728. */
  29729. class PhysicsEngine implements IPhysicsEngine {
  29730. private _physicsPlugin;
  29731. /**
  29732. * Global value used to control the smallest number supported by the simulation
  29733. */
  29734. static Epsilon: number;
  29735. private _impostors;
  29736. private _joints;
  29737. /**
  29738. * Gets the gravity vector used by the simulation
  29739. */
  29740. gravity: Vector3;
  29741. /**
  29742. * Creates a new Physics Engine
  29743. * @param gravity defines the gravity vector used by the simulation
  29744. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  29745. */
  29746. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  29747. /**
  29748. * Sets the gravity vector used by the simulation
  29749. * @param gravity defines the gravity vector to use
  29750. */
  29751. setGravity(gravity: Vector3): void;
  29752. /**
  29753. * Set the time step of the physics engine.
  29754. * Default is 1/60.
  29755. * To slow it down, enter 1/600 for example.
  29756. * To speed it up, 1/30
  29757. * @param newTimeStep defines the new timestep to apply to this world.
  29758. */
  29759. setTimeStep(newTimeStep?: number): void;
  29760. /**
  29761. * Get the time step of the physics engine.
  29762. * @returns the current time step
  29763. */
  29764. getTimeStep(): number;
  29765. /**
  29766. * Release all resources
  29767. */
  29768. dispose(): void;
  29769. /**
  29770. * Gets the name of the current physics plugin
  29771. * @returns the name of the plugin
  29772. */
  29773. getPhysicsPluginName(): string;
  29774. /**
  29775. * Adding a new impostor for the impostor tracking.
  29776. * This will be done by the impostor itself.
  29777. * @param impostor the impostor to add
  29778. */
  29779. addImpostor(impostor: PhysicsImpostor): void;
  29780. /**
  29781. * Remove an impostor from the engine.
  29782. * This impostor and its mesh will not longer be updated by the physics engine.
  29783. * @param impostor the impostor to remove
  29784. */
  29785. removeImpostor(impostor: PhysicsImpostor): void;
  29786. /**
  29787. * Add a joint to the physics engine
  29788. * @param mainImpostor defines the main impostor to which the joint is added.
  29789. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  29790. * @param joint defines the joint that will connect both impostors.
  29791. */
  29792. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  29793. /**
  29794. * Removes a joint from the simulation
  29795. * @param mainImpostor defines the impostor used with the joint
  29796. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  29797. * @param joint defines the joint to remove
  29798. */
  29799. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  29800. /**
  29801. * Called by the scene. No need to call it.
  29802. * @param delta defines the timespam between frames
  29803. */
  29804. /**
  29805. * Gets the current plugin used to run the simulation
  29806. * @returns current plugin
  29807. */
  29808. getPhysicsPlugin(): IPhysicsEnginePlugin;
  29809. /**
  29810. * Gets the list of physic impostors
  29811. * @returns an array of PhysicsImpostor
  29812. */
  29813. getImpostors(): Array<PhysicsImpostor>;
  29814. /**
  29815. * Gets the impostor for a physics enabled object
  29816. * @param object defines the object impersonated by the impostor
  29817. * @returns the PhysicsImpostor or null if not found
  29818. */
  29819. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  29820. /**
  29821. * Gets the impostor for a physics body object
  29822. * @param body defines physics body used by the impostor
  29823. * @returns the PhysicsImpostor or null if not found
  29824. */
  29825. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  29826. }
  29827. }
  29828. declare module BABYLON {
  29829. interface Scene {
  29830. /** @hidden (Backing field) */
  29831. /**
  29832. * Gets the current physics engine
  29833. * @returns a IPhysicsEngine or null if none attached
  29834. */
  29835. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  29836. /**
  29837. * Enables physics to the current scene
  29838. * @param gravity defines the scene's gravity for the physics engine
  29839. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  29840. * @return a boolean indicating if the physics engine was initialized
  29841. */
  29842. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  29843. /**
  29844. * Disables and disposes the physics engine associated with the scene
  29845. */
  29846. disablePhysicsEngine(): void;
  29847. /**
  29848. * Gets a boolean indicating if there is an active physics engine
  29849. * @returns a boolean indicating if there is an active physics engine
  29850. */
  29851. isPhysicsEnabled(): boolean;
  29852. /**
  29853. * Deletes a physics compound impostor
  29854. * @param compound defines the compound to delete
  29855. */
  29856. deleteCompoundImpostor(compound: any): void;
  29857. /**
  29858. * An event triggered when physic simulation is about to be run
  29859. */
  29860. onBeforePhysicsObservable: Observable<Scene>;
  29861. /**
  29862. * An event triggered when physic simulation has been done
  29863. */
  29864. onAfterPhysicsObservable: Observable<Scene>;
  29865. }
  29866. interface AbstractMesh {
  29867. /** @hidden */
  29868. /**
  29869. * Gets or sets impostor used for physic simulation
  29870. * @see http://doc.babylonjs.com/features/physics_engine
  29871. */
  29872. physicsImpostor: Nullable<PhysicsImpostor>;
  29873. /**
  29874. * Gets the current physics impostor
  29875. * @see http://doc.babylonjs.com/features/physics_engine
  29876. * @returns a physics impostor or null
  29877. */
  29878. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  29879. /** Apply a physic impulse to the mesh
  29880. * @param force defines the force to apply
  29881. * @param contactPoint defines where to apply the force
  29882. * @returns the current mesh
  29883. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  29884. */
  29885. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  29886. /**
  29887. * Creates a physic joint between two meshes
  29888. * @param otherMesh defines the other mesh to use
  29889. * @param pivot1 defines the pivot to use on this mesh
  29890. * @param pivot2 defines the pivot to use on the other mesh
  29891. * @param options defines additional options (can be plugin dependent)
  29892. * @returns the current mesh
  29893. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  29894. */
  29895. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  29896. /** @hidden */
  29897. }
  29898. /**
  29899. * Defines the physics engine scene component responsible to manage a physics engine
  29900. */
  29901. class PhysicsEngineSceneComponent implements ISceneComponent {
  29902. /**
  29903. * The component name helpful to identify the component in the list of scene components.
  29904. */
  29905. readonly name: string;
  29906. /**
  29907. * The scene the component belongs to.
  29908. */
  29909. scene: Scene;
  29910. /**
  29911. * Creates a new instance of the component for the given scene
  29912. * @param scene Defines the scene to register the component in
  29913. */
  29914. constructor(scene: Scene);
  29915. /**
  29916. * Registers the component in a given scene
  29917. */
  29918. register(): void;
  29919. /**
  29920. * Rebuilds the elements related to this component in case of
  29921. * context lost for instance.
  29922. */
  29923. rebuild(): void;
  29924. /**
  29925. * Disposes the component and the associated ressources
  29926. */
  29927. dispose(): void;
  29928. }
  29929. }
  29930. declare module BABYLON {
  29931. class PhysicsHelper {
  29932. private _scene;
  29933. private _physicsEngine;
  29934. constructor(scene: Scene);
  29935. /**
  29936. * @param {Vector3} origin the origin of the explosion
  29937. * @param {number} radius the explosion radius
  29938. * @param {number} strength the explosion strength
  29939. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear. Defaults to Constant
  29940. */
  29941. applyRadialExplosionImpulse(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  29942. /**
  29943. * @param {Vector3} origin the origin of the explosion
  29944. * @param {number} radius the explosion radius
  29945. * @param {number} strength the explosion strength
  29946. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear. Defaults to Constant
  29947. */
  29948. applyRadialExplosionForce(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  29949. /**
  29950. * @param {Vector3} origin the origin of the explosion
  29951. * @param {number} radius the explosion radius
  29952. * @param {number} strength the explosion strength
  29953. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear. Defaults to Constant
  29954. */
  29955. gravitationalField(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  29956. /**
  29957. * @param {Vector3} origin the origin of the updraft
  29958. * @param {number} radius the radius of the updraft
  29959. * @param {number} strength the strength of the updraft
  29960. * @param {number} height the height of the updraft
  29961. * @param {PhysicsUpdraftMode} updraftMode possible options: Center & Perpendicular. Defaults to Center
  29962. */
  29963. updraft(origin: Vector3, radius: number, strength: number, height: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  29964. /**
  29965. * @param {Vector3} origin the of the vortex
  29966. * @param {number} radius the radius of the vortex
  29967. * @param {number} strength the strength of the vortex
  29968. * @param {number} height the height of the vortex
  29969. */
  29970. vortex(origin: Vector3, radius: number, strength: number, height: number): Nullable<PhysicsVortexEvent>;
  29971. }
  29972. /***** Radial explosion *****/
  29973. class PhysicsRadialExplosionEvent {
  29974. private _scene;
  29975. private _sphere;
  29976. private _sphereOptions;
  29977. private _rays;
  29978. private _dataFetched;
  29979. constructor(scene: Scene);
  29980. /**
  29981. * Returns the data related to the radial explosion event (sphere & rays).
  29982. * @returns {PhysicsRadialExplosionEventData}
  29983. */
  29984. getData(): PhysicsRadialExplosionEventData;
  29985. /**
  29986. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  29987. * @param impostor
  29988. * @param {Vector3} origin the origin of the explosion
  29989. * @param {number} radius the explosion radius
  29990. * @param {number} strength the explosion strength
  29991. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear
  29992. * @returns {Nullable<PhysicsForceAndContactPoint>}
  29993. */
  29994. getImpostorForceAndContactPoint(impostor: PhysicsImpostor, origin: Vector3, radius: number, strength: number, falloff: PhysicsRadialImpulseFalloff): Nullable<PhysicsForceAndContactPoint>;
  29995. /**
  29996. * Disposes the sphere.
  29997. * @param {bolean} force
  29998. */
  29999. dispose(force?: boolean): void;
  30000. /*** Helpers ***/
  30001. private _prepareSphere;
  30002. private _intersectsWithSphere;
  30003. }
  30004. /***** Gravitational Field *****/
  30005. class PhysicsGravitationalFieldEvent {
  30006. private _physicsHelper;
  30007. private _scene;
  30008. private _origin;
  30009. private _radius;
  30010. private _strength;
  30011. private _falloff;
  30012. private _tickCallback;
  30013. private _sphere;
  30014. private _dataFetched;
  30015. constructor(physicsHelper: PhysicsHelper, scene: Scene, origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff);
  30016. /**
  30017. * Returns the data related to the gravitational field event (sphere).
  30018. * @returns {PhysicsGravitationalFieldEventData}
  30019. */
  30020. getData(): PhysicsGravitationalFieldEventData;
  30021. /**
  30022. * Enables the gravitational field.
  30023. */
  30024. enable(): void;
  30025. /**
  30026. * Disables the gravitational field.
  30027. */
  30028. disable(): void;
  30029. /**
  30030. * Disposes the sphere.
  30031. * @param {bolean} force
  30032. */
  30033. dispose(force?: boolean): void;
  30034. private _tick;
  30035. }
  30036. /***** Updraft *****/
  30037. class PhysicsUpdraftEvent {
  30038. private _scene;
  30039. private _origin;
  30040. private _radius;
  30041. private _strength;
  30042. private _height;
  30043. private _updraftMode;
  30044. private _physicsEngine;
  30045. private _originTop;
  30046. private _originDirection;
  30047. private _tickCallback;
  30048. private _cylinder;
  30049. private _cylinderPosition;
  30050. private _dataFetched;
  30051. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number, _updraftMode: PhysicsUpdraftMode);
  30052. /**
  30053. * Returns the data related to the updraft event (cylinder).
  30054. * @returns {PhysicsUpdraftEventData}
  30055. */
  30056. getData(): PhysicsUpdraftEventData;
  30057. /**
  30058. * Enables the updraft.
  30059. */
  30060. enable(): void;
  30061. /**
  30062. * Disables the cortex.
  30063. */
  30064. disable(): void;
  30065. /**
  30066. * Disposes the sphere.
  30067. * @param {bolean} force
  30068. */
  30069. dispose(force?: boolean): void;
  30070. private getImpostorForceAndContactPoint;
  30071. private _tick;
  30072. /*** Helpers ***/
  30073. private _prepareCylinder;
  30074. private _intersectsWithCylinder;
  30075. }
  30076. /***** Vortex *****/
  30077. class PhysicsVortexEvent {
  30078. private _scene;
  30079. private _origin;
  30080. private _radius;
  30081. private _strength;
  30082. private _height;
  30083. private _physicsEngine;
  30084. private _originTop;
  30085. private _centripetalForceThreshold;
  30086. private _updraftMultiplier;
  30087. private _tickCallback;
  30088. private _cylinder;
  30089. private _cylinderPosition;
  30090. private _dataFetched;
  30091. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number);
  30092. /**
  30093. * Returns the data related to the vortex event (cylinder).
  30094. * @returns {PhysicsVortexEventData}
  30095. */
  30096. getData(): PhysicsVortexEventData;
  30097. /**
  30098. * Enables the vortex.
  30099. */
  30100. enable(): void;
  30101. /**
  30102. * Disables the cortex.
  30103. */
  30104. disable(): void;
  30105. /**
  30106. * Disposes the sphere.
  30107. * @param {bolean} force
  30108. */
  30109. dispose(force?: boolean): void;
  30110. private getImpostorForceAndContactPoint;
  30111. private _tick;
  30112. /*** Helpers ***/
  30113. private _prepareCylinder;
  30114. private _intersectsWithCylinder;
  30115. }
  30116. /***** Enums *****/
  30117. /**
  30118. * The strenght of the force in correspondence to the distance of the affected object
  30119. */
  30120. enum PhysicsRadialImpulseFalloff {
  30121. /** Defines that impulse is constant in strength across it's whole radius */
  30122. Constant = 0,
  30123. /** DEfines that impulse gets weaker if it's further from the origin */
  30124. Linear = 1
  30125. }
  30126. /**
  30127. * The strenght of the force in correspondence to the distance of the affected object
  30128. */
  30129. enum PhysicsUpdraftMode {
  30130. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  30131. Center = 0,
  30132. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  30133. Perpendicular = 1
  30134. }
  30135. /***** Data interfaces *****/
  30136. interface PhysicsForceAndContactPoint {
  30137. force: Vector3;
  30138. contactPoint: Vector3;
  30139. }
  30140. interface PhysicsRadialExplosionEventData {
  30141. sphere: Mesh;
  30142. rays: Array<Ray>;
  30143. }
  30144. interface PhysicsGravitationalFieldEventData {
  30145. sphere: Mesh;
  30146. }
  30147. interface PhysicsUpdraftEventData {
  30148. cylinder: Mesh;
  30149. }
  30150. interface PhysicsVortexEventData {
  30151. cylinder: Mesh;
  30152. }
  30153. }
  30154. declare module BABYLON {
  30155. interface PhysicsImpostorParameters {
  30156. mass: number;
  30157. friction?: number;
  30158. restitution?: number;
  30159. nativeOptions?: any;
  30160. ignoreParent?: boolean;
  30161. disableBidirectionalTransformation?: boolean;
  30162. }
  30163. interface IPhysicsEnabledObject {
  30164. position: Vector3;
  30165. rotationQuaternion: Nullable<Quaternion>;
  30166. scaling: Vector3;
  30167. rotation?: Vector3;
  30168. parent?: any;
  30169. getBoundingInfo(): BoundingInfo;
  30170. computeWorldMatrix(force: boolean): Matrix;
  30171. getWorldMatrix?(): Matrix;
  30172. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  30173. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  30174. getIndices?(): Nullable<IndicesArray>;
  30175. getScene?(): Scene;
  30176. getAbsolutePosition(): Vector3;
  30177. getAbsolutePivotPoint(): Vector3;
  30178. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  30179. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  30180. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  30181. getClassName(): string;
  30182. }
  30183. class PhysicsImpostor {
  30184. object: IPhysicsEnabledObject;
  30185. type: number;
  30186. private _options;
  30187. private _scene?;
  30188. static DEFAULT_OBJECT_SIZE: Vector3;
  30189. static IDENTITY_QUATERNION: Quaternion;
  30190. private _physicsEngine;
  30191. private _physicsBody;
  30192. private _bodyUpdateRequired;
  30193. private _onBeforePhysicsStepCallbacks;
  30194. private _onAfterPhysicsStepCallbacks;
  30195. private _onPhysicsCollideCallbacks;
  30196. private _deltaPosition;
  30197. private _deltaRotation;
  30198. private _deltaRotationConjugated;
  30199. private _parent;
  30200. private _isDisposed;
  30201. private static _tmpVecs;
  30202. private static _tmpQuat;
  30203. readonly isDisposed: boolean;
  30204. mass: number;
  30205. friction: number;
  30206. restitution: number;
  30207. uniqueId: number;
  30208. private _joints;
  30209. constructor(object: IPhysicsEnabledObject, type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  30210. /**
  30211. * This function will completly initialize this impostor.
  30212. * It will create a new body - but only if this mesh has no parent.
  30213. * If it has, this impostor will not be used other than to define the impostor
  30214. * of the child mesh.
  30215. * @hidden
  30216. */
  30217. private _getPhysicsParent;
  30218. /**
  30219. * Should a new body be generated.
  30220. */
  30221. isBodyInitRequired(): boolean;
  30222. setScalingUpdated(updated: boolean): void;
  30223. /**
  30224. * Force a regeneration of this or the parent's impostor's body.
  30225. * Use under cautious - This will remove all joints already implemented.
  30226. */
  30227. forceUpdate(): void;
  30228. /**
  30229. * Gets the body that holds this impostor. Either its own, or its parent.
  30230. */
  30231. /**
  30232. * Set the physics body. Used mainly by the physics engine/plugin
  30233. */
  30234. physicsBody: any;
  30235. parent: Nullable<PhysicsImpostor>;
  30236. resetUpdateFlags(): void;
  30237. getObjectExtendSize(): Vector3;
  30238. getObjectCenter(): Vector3;
  30239. /**
  30240. * Get a specific parametes from the options parameter.
  30241. */
  30242. getParam(paramName: string): any;
  30243. /**
  30244. * Sets a specific parameter in the options given to the physics plugin
  30245. */
  30246. setParam(paramName: string, value: number): void;
  30247. /**
  30248. * Specifically change the body's mass option. Won't recreate the physics body object
  30249. */
  30250. setMass(mass: number): void;
  30251. getLinearVelocity(): Nullable<Vector3>;
  30252. setLinearVelocity(velocity: Nullable<Vector3>): void;
  30253. getAngularVelocity(): Nullable<Vector3>;
  30254. setAngularVelocity(velocity: Nullable<Vector3>): void;
  30255. /**
  30256. * Execute a function with the physics plugin native code.
  30257. * Provide a function the will have two variables - the world object and the physics body object.
  30258. */
  30259. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  30260. /**
  30261. * Register a function that will be executed before the physics world is stepping forward.
  30262. */
  30263. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  30264. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  30265. /**
  30266. * Register a function that will be executed after the physics step
  30267. */
  30268. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  30269. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  30270. /**
  30271. * register a function that will be executed when this impostor collides against a different body.
  30272. */
  30273. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  30274. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  30275. private _tmpQuat;
  30276. private _tmpQuat2;
  30277. getParentsRotation(): Quaternion;
  30278. /**
  30279. * this function is executed by the physics engine.
  30280. */
  30281. beforeStep: () => void;
  30282. /**
  30283. * this function is executed by the physics engine.
  30284. */
  30285. afterStep: () => void;
  30286. /**
  30287. * Legacy collision detection event support
  30288. */
  30289. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  30290. onCollide: (e: {
  30291. body: any;
  30292. }) => void;
  30293. /**
  30294. * Apply a force
  30295. */
  30296. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  30297. /**
  30298. * Apply an impulse
  30299. */
  30300. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  30301. /**
  30302. * A help function to create a joint.
  30303. */
  30304. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  30305. /**
  30306. * Add a joint to this impostor with a different impostor.
  30307. */
  30308. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  30309. /**
  30310. * Will keep this body still, in a sleep mode.
  30311. */
  30312. sleep(): PhysicsImpostor;
  30313. /**
  30314. * Wake the body up.
  30315. */
  30316. wakeUp(): PhysicsImpostor;
  30317. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  30318. dispose(): void;
  30319. setDeltaPosition(position: Vector3): void;
  30320. setDeltaRotation(rotation: Quaternion): void;
  30321. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  30322. getRadius(): number;
  30323. /**
  30324. * Sync a bone with this impostor
  30325. * @param bone The bone to sync to the impostor.
  30326. * @param boneMesh The mesh that the bone is influencing.
  30327. * @param jointPivot The pivot of the joint / bone in local space.
  30328. * @param distToJoint Optional distance from the impostor to the joint.
  30329. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  30330. */
  30331. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  30332. /**
  30333. * Sync impostor to a bone
  30334. * @param bone The bone that the impostor will be synced to.
  30335. * @param boneMesh The mesh that the bone is influencing.
  30336. * @param jointPivot The pivot of the joint / bone in local space.
  30337. * @param distToJoint Optional distance from the impostor to the joint.
  30338. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  30339. * @param boneAxis Optional vector3 axis the bone is aligned with
  30340. */
  30341. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  30342. static NoImpostor: number;
  30343. static SphereImpostor: number;
  30344. static BoxImpostor: number;
  30345. static PlaneImpostor: number;
  30346. static MeshImpostor: number;
  30347. static CylinderImpostor: number;
  30348. static ParticleImpostor: number;
  30349. static HeightmapImpostor: number;
  30350. }
  30351. }
  30352. declare module BABYLON {
  30353. interface PhysicsJointData {
  30354. mainPivot?: Vector3;
  30355. connectedPivot?: Vector3;
  30356. mainAxis?: Vector3;
  30357. connectedAxis?: Vector3;
  30358. collision?: boolean;
  30359. nativeParams?: any;
  30360. }
  30361. /**
  30362. * This is a holder class for the physics joint created by the physics plugin.
  30363. * It holds a set of functions to control the underlying joint.
  30364. */
  30365. class PhysicsJoint {
  30366. type: number;
  30367. jointData: PhysicsJointData;
  30368. private _physicsJoint;
  30369. protected _physicsPlugin: IPhysicsEnginePlugin;
  30370. constructor(type: number, jointData: PhysicsJointData);
  30371. physicsJoint: any;
  30372. physicsPlugin: IPhysicsEnginePlugin;
  30373. /**
  30374. * Execute a function that is physics-plugin specific.
  30375. * @param {Function} func the function that will be executed.
  30376. * It accepts two parameters: the physics world and the physics joint.
  30377. */
  30378. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  30379. static DistanceJoint: number;
  30380. static HingeJoint: number;
  30381. static BallAndSocketJoint: number;
  30382. static WheelJoint: number;
  30383. static SliderJoint: number;
  30384. static PrismaticJoint: number;
  30385. static UniversalJoint: number;
  30386. static Hinge2Joint: number;
  30387. static PointToPointJoint: number;
  30388. static SpringJoint: number;
  30389. static LockJoint: number;
  30390. }
  30391. /**
  30392. * A class representing a physics distance joint.
  30393. */
  30394. class DistanceJoint extends PhysicsJoint {
  30395. constructor(jointData: DistanceJointData);
  30396. /**
  30397. * Update the predefined distance.
  30398. */
  30399. updateDistance(maxDistance: number, minDistance?: number): void;
  30400. }
  30401. class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  30402. constructor(type: number, jointData: PhysicsJointData);
  30403. /**
  30404. * Set the motor values.
  30405. * Attention, this function is plugin specific. Engines won't react 100% the same.
  30406. * @param {number} force the force to apply
  30407. * @param {number} maxForce max force for this motor.
  30408. */
  30409. setMotor(force?: number, maxForce?: number): void;
  30410. /**
  30411. * Set the motor's limits.
  30412. * Attention, this function is plugin specific. Engines won't react 100% the same.
  30413. */
  30414. setLimit(upperLimit: number, lowerLimit?: number): void;
  30415. }
  30416. /**
  30417. * This class represents a single hinge physics joint
  30418. */
  30419. class HingeJoint extends MotorEnabledJoint {
  30420. constructor(jointData: PhysicsJointData);
  30421. /**
  30422. * Set the motor values.
  30423. * Attention, this function is plugin specific. Engines won't react 100% the same.
  30424. * @param {number} force the force to apply
  30425. * @param {number} maxForce max force for this motor.
  30426. */
  30427. setMotor(force?: number, maxForce?: number): void;
  30428. /**
  30429. * Set the motor's limits.
  30430. * Attention, this function is plugin specific. Engines won't react 100% the same.
  30431. */
  30432. setLimit(upperLimit: number, lowerLimit?: number): void;
  30433. }
  30434. /**
  30435. * This class represents a dual hinge physics joint (same as wheel joint)
  30436. */
  30437. class Hinge2Joint extends MotorEnabledJoint {
  30438. constructor(jointData: PhysicsJointData);
  30439. /**
  30440. * Set the motor values.
  30441. * Attention, this function is plugin specific. Engines won't react 100% the same.
  30442. * @param {number} force the force to apply
  30443. * @param {number} maxForce max force for this motor.
  30444. * @param {motorIndex} the motor's index, 0 or 1.
  30445. */
  30446. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  30447. /**
  30448. * Set the motor limits.
  30449. * Attention, this function is plugin specific. Engines won't react 100% the same.
  30450. * @param {number} upperLimit the upper limit
  30451. * @param {number} lowerLimit lower limit
  30452. * @param {motorIndex} the motor's index, 0 or 1.
  30453. */
  30454. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  30455. }
  30456. interface IMotorEnabledJoint {
  30457. physicsJoint: any;
  30458. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  30459. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  30460. }
  30461. interface DistanceJointData extends PhysicsJointData {
  30462. maxDistance: number;
  30463. }
  30464. interface SpringJointData extends PhysicsJointData {
  30465. length: number;
  30466. stiffness: number;
  30467. damping: number;
  30468. /** this callback will be called when applying the force to the impostors. */
  30469. forceApplicationCallback: () => void;
  30470. }
  30471. }
  30472. declare module BABYLON {
  30473. interface Scene {
  30474. /**
  30475. * The list of reflection probes added to the scene
  30476. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  30477. */
  30478. reflectionProbes: Array<ReflectionProbe>;
  30479. }
  30480. /**
  30481. * Class used to generate realtime reflection / refraction cube textures
  30482. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  30483. */
  30484. class ReflectionProbe {
  30485. /** defines the name of the probe */
  30486. name: string;
  30487. private _scene;
  30488. private _renderTargetTexture;
  30489. private _projectionMatrix;
  30490. private _viewMatrix;
  30491. private _target;
  30492. private _add;
  30493. private _attachedMesh;
  30494. private _invertYAxis;
  30495. /** Gets or sets probe position (center of the cube map) */
  30496. position: Vector3;
  30497. /**
  30498. * Creates a new reflection probe
  30499. * @param name defines the name of the probe
  30500. * @param size defines the texture resolution (for each face)
  30501. * @param scene defines the hosting scene
  30502. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  30503. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  30504. */
  30505. constructor(
  30506. /** defines the name of the probe */
  30507. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  30508. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  30509. samples: number;
  30510. /** Gets or sets the refresh rate to use (on every frame by default) */
  30511. refreshRate: number;
  30512. /**
  30513. * Gets the hosting scene
  30514. * @returns a Scene
  30515. */
  30516. getScene(): Scene;
  30517. /** Gets the internal CubeTexture used to render to */
  30518. readonly cubeTexture: RenderTargetTexture;
  30519. /** Gets the list of meshes to render */
  30520. readonly renderList: Nullable<AbstractMesh[]>;
  30521. /**
  30522. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  30523. * @param mesh defines the mesh to attach to
  30524. */
  30525. attachToMesh(mesh: AbstractMesh): void;
  30526. /**
  30527. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  30528. * @param renderingGroupId The rendering group id corresponding to its index
  30529. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  30530. */
  30531. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  30532. /**
  30533. * Clean all associated resources
  30534. */
  30535. dispose(): void;
  30536. }
  30537. }
  30538. declare module BABYLON {
  30539. /**
  30540. * Postprocess used to generate anaglyphic rendering
  30541. */
  30542. class AnaglyphPostProcess extends PostProcess {
  30543. private _passedProcess;
  30544. /**
  30545. * Creates a new AnaglyphPostProcess
  30546. * @param name defines postprocess name
  30547. * @param options defines creation options or target ratio scale
  30548. * @param rigCameras defines cameras using this postprocess
  30549. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  30550. * @param engine defines hosting engine
  30551. * @param reusable defines if the postprocess will be reused multiple times per frame
  30552. */
  30553. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  30554. }
  30555. }
  30556. declare module BABYLON {
  30557. class BlackAndWhitePostProcess extends PostProcess {
  30558. degree: number;
  30559. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  30560. }
  30561. }
  30562. declare module BABYLON {
  30563. /**
  30564. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  30565. */
  30566. class BloomEffect extends PostProcessRenderEffect {
  30567. private bloomScale;
  30568. /**
  30569. * @hidden Internal
  30570. */
  30571. /**
  30572. * @hidden Internal
  30573. */
  30574. private _blurX;
  30575. private _blurY;
  30576. private _merge;
  30577. /**
  30578. * The luminance threshold to find bright areas of the image to bloom.
  30579. */
  30580. threshold: number;
  30581. /**
  30582. * The strength of the bloom.
  30583. */
  30584. weight: number;
  30585. /**
  30586. * Specifies the size of the bloom blur kernel, relative to the final output size
  30587. */
  30588. kernel: number;
  30589. /**
  30590. * Creates a new instance of @see BloomEffect
  30591. * @param scene The scene the effect belongs to.
  30592. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  30593. * @param bloomKernel The size of the kernel to be used when applying the blur.
  30594. * @param bloomWeight The the strength of bloom.
  30595. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  30596. * @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)
  30597. */
  30598. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  30599. /**
  30600. * Disposes each of the internal effects for a given camera.
  30601. * @param camera The camera to dispose the effect on.
  30602. */
  30603. disposeEffects(camera: Camera): void;
  30604. /**
  30605. * @hidden Internal
  30606. */
  30607. /**
  30608. * Internal
  30609. * @returns if all the contained post processes are ready.
  30610. * @hidden
  30611. */
  30612. }
  30613. }
  30614. declare module BABYLON {
  30615. /**
  30616. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  30617. */
  30618. class BloomMergePostProcess extends PostProcess {
  30619. /** Weight of the bloom to be added to the original input. */
  30620. weight: number;
  30621. /**
  30622. * Creates a new instance of @see BloomMergePostProcess
  30623. * @param name The name of the effect.
  30624. * @param originalFromInput Post process which's input will be used for the merge.
  30625. * @param blurred Blurred highlights post process which's output will be used.
  30626. * @param weight Weight of the bloom to be added to the original input.
  30627. * @param options The required width/height ratio to downsize to before computing the render pass.
  30628. * @param camera The camera to apply the render pass to.
  30629. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  30630. * @param engine The engine which the post process will be applied. (default: current engine)
  30631. * @param reusable If the post process can be reused on the same frame. (default: false)
  30632. * @param textureType Type of textures used when performing the post process. (default: 0)
  30633. * @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)
  30634. */
  30635. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  30636. /** Weight of the bloom to be added to the original input. */
  30637. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  30638. }
  30639. }
  30640. declare module BABYLON {
  30641. /**
  30642. * The Blur Post Process which blurs an image based on a kernel and direction.
  30643. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  30644. */
  30645. class BlurPostProcess extends PostProcess {
  30646. /** The direction in which to blur the image. */
  30647. direction: Vector2;
  30648. private blockCompilation;
  30649. protected _kernel: number;
  30650. protected _idealKernel: number;
  30651. protected _packedFloat: boolean;
  30652. private _staticDefines;
  30653. /**
  30654. * Sets the length in pixels of the blur sample region
  30655. */
  30656. /**
  30657. * Gets the length in pixels of the blur sample region
  30658. */
  30659. kernel: number;
  30660. /**
  30661. * Sets wether or not the blur needs to unpack/repack floats
  30662. */
  30663. /**
  30664. * Gets wether or not the blur is unpacking/repacking floats
  30665. */
  30666. packedFloat: boolean;
  30667. /**
  30668. * Creates a new instance BlurPostProcess
  30669. * @param name The name of the effect.
  30670. * @param direction The direction in which to blur the image.
  30671. * @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.
  30672. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  30673. * @param camera The camera to apply the render pass to.
  30674. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  30675. * @param engine The engine which the post process will be applied. (default: current engine)
  30676. * @param reusable If the post process can be reused on the same frame. (default: false)
  30677. * @param textureType Type of textures used when performing the post process. (default: 0)
  30678. * @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)
  30679. */
  30680. constructor(name: string,
  30681. /** The direction in which to blur the image. */
  30682. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  30683. /**
  30684. * Updates the effect with the current post process compile time values and recompiles the shader.
  30685. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  30686. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  30687. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  30688. * @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
  30689. * @param onCompiled Called when the shader has been compiled.
  30690. * @param onError Called if there is an error when compiling a shader.
  30691. */
  30692. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  30693. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  30694. /**
  30695. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  30696. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  30697. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  30698. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  30699. * The gaps between physical kernels are compensated for in the weighting of the samples
  30700. * @param idealKernel Ideal blur kernel.
  30701. * @return Nearest best kernel.
  30702. */
  30703. protected _nearestBestKernel(idealKernel: number): number;
  30704. /**
  30705. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  30706. * @param x The point on the Gaussian distribution to sample.
  30707. * @return the value of the Gaussian function at x.
  30708. */
  30709. protected _gaussianWeight(x: number): number;
  30710. /**
  30711. * Generates a string that can be used as a floating point number in GLSL.
  30712. * @param x Value to print.
  30713. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  30714. * @return GLSL float string.
  30715. */
  30716. protected _glslFloat(x: number, decimalFigures?: number): string;
  30717. }
  30718. }
  30719. declare module BABYLON {
  30720. /**
  30721. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  30722. */
  30723. class ChromaticAberrationPostProcess extends PostProcess {
  30724. /**
  30725. * The amount of seperation of rgb channels (default: 30)
  30726. */
  30727. aberrationAmount: number;
  30728. /**
  30729. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  30730. */
  30731. radialIntensity: number;
  30732. /**
  30733. * 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))
  30734. */
  30735. direction: Vector2;
  30736. /**
  30737. * 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))
  30738. */
  30739. centerPosition: Vector2;
  30740. /**
  30741. * Creates a new instance ChromaticAberrationPostProcess
  30742. * @param name The name of the effect.
  30743. * @param screenWidth The width of the screen to apply the effect on.
  30744. * @param screenHeight The height of the screen to apply the effect on.
  30745. * @param options The required width/height ratio to downsize to before computing the render pass.
  30746. * @param camera The camera to apply the render pass to.
  30747. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  30748. * @param engine The engine which the post process will be applied. (default: current engine)
  30749. * @param reusable If the post process can be reused on the same frame. (default: false)
  30750. * @param textureType Type of textures used when performing the post process. (default: 0)
  30751. * @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)
  30752. */
  30753. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  30754. }
  30755. }
  30756. declare module BABYLON {
  30757. /**
  30758. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  30759. */
  30760. class CircleOfConfusionPostProcess extends PostProcess {
  30761. /**
  30762. * 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.
  30763. */
  30764. lensSize: number;
  30765. /**
  30766. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  30767. */
  30768. fStop: number;
  30769. /**
  30770. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  30771. */
  30772. focusDistance: number;
  30773. /**
  30774. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  30775. */
  30776. focalLength: number;
  30777. private _depthTexture;
  30778. /**
  30779. * Creates a new instance CircleOfConfusionPostProcess
  30780. * @param name The name of the effect.
  30781. * @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.
  30782. * @param options The required width/height ratio to downsize to before computing the render pass.
  30783. * @param camera The camera to apply the render pass to.
  30784. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  30785. * @param engine The engine which the post process will be applied. (default: current engine)
  30786. * @param reusable If the post process can be reused on the same frame. (default: false)
  30787. * @param textureType Type of textures used when performing the post process. (default: 0)
  30788. * @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)
  30789. */
  30790. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  30791. /**
  30792. * 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.
  30793. */
  30794. depthTexture: RenderTargetTexture;
  30795. }
  30796. }
  30797. declare module BABYLON {
  30798. class ColorCorrectionPostProcess extends PostProcess {
  30799. private _colorTableTexture;
  30800. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  30801. }
  30802. }
  30803. declare module BABYLON {
  30804. /**
  30805. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  30806. * input texture to perform effects such as edge detection or sharpening
  30807. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  30808. */
  30809. class ConvolutionPostProcess extends PostProcess {
  30810. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  30811. kernel: number[];
  30812. /**
  30813. * Creates a new instance ConvolutionPostProcess
  30814. * @param name The name of the effect.
  30815. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  30816. * @param options The required width/height ratio to downsize to before computing the render pass.
  30817. * @param camera The camera to apply the render pass to.
  30818. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  30819. * @param engine The engine which the post process will be applied. (default: current engine)
  30820. * @param reusable If the post process can be reused on the same frame. (default: false)
  30821. * @param textureType Type of textures used when performing the post process. (default: 0)
  30822. */
  30823. constructor(name: string,
  30824. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  30825. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  30826. /**
  30827. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  30828. */
  30829. static EdgeDetect0Kernel: number[];
  30830. /**
  30831. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  30832. */
  30833. static EdgeDetect1Kernel: number[];
  30834. /**
  30835. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  30836. */
  30837. static EdgeDetect2Kernel: number[];
  30838. /**
  30839. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  30840. */
  30841. static SharpenKernel: number[];
  30842. /**
  30843. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  30844. */
  30845. static EmbossKernel: number[];
  30846. /**
  30847. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  30848. */
  30849. static GaussianKernel: number[];
  30850. }
  30851. }
  30852. declare module BABYLON {
  30853. /**
  30854. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  30855. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  30856. * based on samples that have a large difference in distance than the center pixel.
  30857. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  30858. */
  30859. class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  30860. direction: Vector2;
  30861. /**
  30862. * Creates a new instance CircleOfConfusionPostProcess
  30863. * @param name The name of the effect.
  30864. * @param scene The scene the effect belongs to.
  30865. * @param direction The direction the blur should be applied.
  30866. * @param kernel The size of the kernel used to blur.
  30867. * @param options The required width/height ratio to downsize to before computing the render pass.
  30868. * @param camera The camera to apply the render pass to.
  30869. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  30870. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  30871. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  30872. * @param engine The engine which the post process will be applied. (default: current engine)
  30873. * @param reusable If the post process can be reused on the same frame. (default: false)
  30874. * @param textureType Type of textures used when performing the post process. (default: 0)
  30875. * @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)
  30876. */
  30877. 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);
  30878. }
  30879. }
  30880. declare module BABYLON {
  30881. /**
  30882. * Specifies the level of max blur that should be applied when using the depth of field effect
  30883. */
  30884. enum DepthOfFieldEffectBlurLevel {
  30885. /**
  30886. * Subtle blur
  30887. */
  30888. Low = 0,
  30889. /**
  30890. * Medium blur
  30891. */
  30892. Medium = 1,
  30893. /**
  30894. * Large blur
  30895. */
  30896. High = 2
  30897. }
  30898. /**
  30899. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  30900. */
  30901. class DepthOfFieldEffect extends PostProcessRenderEffect {
  30902. private _circleOfConfusion;
  30903. /**
  30904. * @hidden Internal, blurs from high to low
  30905. */
  30906. private _depthOfFieldBlurY;
  30907. private _dofMerge;
  30908. /**
  30909. * @hidden Internal post processes in depth of field effect
  30910. */
  30911. /**
  30912. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  30913. */
  30914. focalLength: number;
  30915. /**
  30916. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  30917. */
  30918. fStop: number;
  30919. /**
  30920. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  30921. */
  30922. focusDistance: number;
  30923. /**
  30924. * 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.
  30925. */
  30926. lensSize: number;
  30927. /**
  30928. * Creates a new instance DepthOfFieldEffect
  30929. * @param scene The scene the effect belongs to.
  30930. * @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.
  30931. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  30932. * @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)
  30933. */
  30934. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  30935. /**
  30936. * 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.
  30937. */
  30938. depthTexture: RenderTargetTexture;
  30939. /**
  30940. * Disposes each of the internal effects for a given camera.
  30941. * @param camera The camera to dispose the effect on.
  30942. */
  30943. disposeEffects(camera: Camera): void;
  30944. /**
  30945. * @hidden Internal
  30946. */
  30947. /**
  30948. * Internal
  30949. * @returns if all the contained post processes are ready.
  30950. * @hidden
  30951. */
  30952. }
  30953. }
  30954. declare module BABYLON {
  30955. /**
  30956. * Options to be set when merging outputs from the default pipeline.
  30957. */
  30958. class DepthOfFieldMergePostProcessOptions {
  30959. /**
  30960. * The original image to merge on top of
  30961. */
  30962. originalFromInput: PostProcess;
  30963. /**
  30964. * Parameters to perform the merge of the depth of field effect
  30965. */
  30966. depthOfField?: {
  30967. circleOfConfusion: PostProcess;
  30968. blurSteps: Array<PostProcess>;
  30969. };
  30970. /**
  30971. * Parameters to perform the merge of bloom effect
  30972. */
  30973. bloom?: {
  30974. blurred: PostProcess;
  30975. weight: number;
  30976. };
  30977. }
  30978. /**
  30979. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  30980. */
  30981. class DepthOfFieldMergePostProcess extends PostProcess {
  30982. private blurSteps;
  30983. /**
  30984. * Creates a new instance of DepthOfFieldMergePostProcess
  30985. * @param name The name of the effect.
  30986. * @param originalFromInput Post process which's input will be used for the merge.
  30987. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  30988. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  30989. * @param options The required width/height ratio to downsize to before computing the render pass.
  30990. * @param camera The camera to apply the render pass to.
  30991. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  30992. * @param engine The engine which the post process will be applied. (default: current engine)
  30993. * @param reusable If the post process can be reused on the same frame. (default: false)
  30994. * @param textureType Type of textures used when performing the post process. (default: 0)
  30995. * @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)
  30996. */
  30997. 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);
  30998. /**
  30999. * Updates the effect with the current post process compile time values and recompiles the shader.
  31000. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  31001. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  31002. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  31003. * @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
  31004. * @param onCompiled Called when the shader has been compiled.
  31005. * @param onError Called if there is an error when compiling a shader.
  31006. */
  31007. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  31008. }
  31009. }
  31010. declare module BABYLON {
  31011. class DisplayPassPostProcess extends PostProcess {
  31012. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  31013. }
  31014. }
  31015. declare module BABYLON {
  31016. /**
  31017. * 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.
  31018. */
  31019. class ExtractHighlightsPostProcess extends PostProcess {
  31020. /**
  31021. * The luminance threshold, pixels below this value will be set to black.
  31022. */
  31023. threshold: number;
  31024. /** @hidden */
  31025. /**
  31026. * Post process which has the input texture to be used when performing highlight extraction
  31027. * @hidden
  31028. */
  31029. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  31030. }
  31031. }
  31032. declare module BABYLON {
  31033. class FilterPostProcess extends PostProcess {
  31034. kernelMatrix: Matrix;
  31035. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  31036. }
  31037. }
  31038. declare module BABYLON {
  31039. class FxaaPostProcess extends PostProcess {
  31040. texelWidth: number;
  31041. texelHeight: number;
  31042. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  31043. private _getDefines;
  31044. }
  31045. }
  31046. declare module BABYLON {
  31047. /**
  31048. * The GrainPostProcess adds noise to the image at mid luminance levels
  31049. */
  31050. class GrainPostProcess extends PostProcess {
  31051. /**
  31052. * The intensity of the grain added (default: 30)
  31053. */
  31054. intensity: number;
  31055. /**
  31056. * If the grain should be randomized on every frame
  31057. */
  31058. animated: boolean;
  31059. /**
  31060. * Creates a new instance of @see GrainPostProcess
  31061. * @param name The name of the effect.
  31062. * @param options The required width/height ratio to downsize to before computing the render pass.
  31063. * @param camera The camera to apply the render pass to.
  31064. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  31065. * @param engine The engine which the post process will be applied. (default: current engine)
  31066. * @param reusable If the post process can be reused on the same frame. (default: false)
  31067. * @param textureType Type of textures used when performing the post process. (default: 0)
  31068. * @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)
  31069. */
  31070. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  31071. }
  31072. }
  31073. declare module BABYLON {
  31074. class HighlightsPostProcess extends PostProcess {
  31075. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  31076. }
  31077. }
  31078. declare module BABYLON {
  31079. class ImageProcessingPostProcess extends PostProcess {
  31080. /**
  31081. * Default configuration related to image processing available in the PBR Material.
  31082. */
  31083. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  31084. /**
  31085. * Gets the image processing configuration used either in this material.
  31086. */
  31087. /**
  31088. * Sets the Default image processing configuration used either in the this material.
  31089. *
  31090. * If sets to null, the scene one is in use.
  31091. */
  31092. imageProcessingConfiguration: ImageProcessingConfiguration;
  31093. /**
  31094. * Keep track of the image processing observer to allow dispose and replace.
  31095. */
  31096. private _imageProcessingObserver;
  31097. /**
  31098. * Attaches a new image processing configuration to the PBR Material.
  31099. * @param configuration
  31100. */
  31101. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  31102. /**
  31103. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  31104. */
  31105. /**
  31106. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  31107. */
  31108. colorCurves: Nullable<ColorCurves>;
  31109. /**
  31110. * Gets wether the color curves effect is enabled.
  31111. */
  31112. /**
  31113. * Sets wether the color curves effect is enabled.
  31114. */
  31115. colorCurvesEnabled: boolean;
  31116. /**
  31117. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  31118. */
  31119. /**
  31120. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  31121. */
  31122. colorGradingTexture: Nullable<BaseTexture>;
  31123. /**
  31124. * Gets wether the color grading effect is enabled.
  31125. */
  31126. /**
  31127. * Gets wether the color grading effect is enabled.
  31128. */
  31129. colorGradingEnabled: boolean;
  31130. /**
  31131. * Gets exposure used in the effect.
  31132. */
  31133. /**
  31134. * Sets exposure used in the effect.
  31135. */
  31136. exposure: number;
  31137. /**
  31138. * Gets wether tonemapping is enabled or not.
  31139. */
  31140. /**
  31141. * Sets wether tonemapping is enabled or not
  31142. */
  31143. toneMappingEnabled: boolean;
  31144. /**
  31145. * Gets contrast used in the effect.
  31146. */
  31147. /**
  31148. * Sets contrast used in the effect.
  31149. */
  31150. contrast: number;
  31151. /**
  31152. * Gets Vignette stretch size.
  31153. */
  31154. /**
  31155. * Sets Vignette stretch size.
  31156. */
  31157. vignetteStretch: number;
  31158. /**
  31159. * Gets Vignette centre X Offset.
  31160. */
  31161. /**
  31162. * Sets Vignette centre X Offset.
  31163. */
  31164. vignetteCentreX: number;
  31165. /**
  31166. * Gets Vignette centre Y Offset.
  31167. */
  31168. /**
  31169. * Sets Vignette centre Y Offset.
  31170. */
  31171. vignetteCentreY: number;
  31172. /**
  31173. * Gets Vignette weight or intensity of the vignette effect.
  31174. */
  31175. /**
  31176. * Sets Vignette weight or intensity of the vignette effect.
  31177. */
  31178. vignetteWeight: number;
  31179. /**
  31180. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  31181. * if vignetteEnabled is set to true.
  31182. */
  31183. /**
  31184. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  31185. * if vignetteEnabled is set to true.
  31186. */
  31187. vignetteColor: Color4;
  31188. /**
  31189. * Gets Camera field of view used by the Vignette effect.
  31190. */
  31191. /**
  31192. * Sets Camera field of view used by the Vignette effect.
  31193. */
  31194. vignetteCameraFov: number;
  31195. /**
  31196. * Gets the vignette blend mode allowing different kind of effect.
  31197. */
  31198. /**
  31199. * Sets the vignette blend mode allowing different kind of effect.
  31200. */
  31201. vignetteBlendMode: number;
  31202. /**
  31203. * Gets wether the vignette effect is enabled.
  31204. */
  31205. /**
  31206. * Sets wether the vignette effect is enabled.
  31207. */
  31208. vignetteEnabled: boolean;
  31209. private _fromLinearSpace;
  31210. /**
  31211. * Gets wether the input of the processing is in Gamma or Linear Space.
  31212. */
  31213. /**
  31214. * Sets wether the input of the processing is in Gamma or Linear Space.
  31215. */
  31216. fromLinearSpace: boolean;
  31217. /**
  31218. * Defines cache preventing GC.
  31219. */
  31220. private _defines;
  31221. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  31222. getClassName(): string;
  31223. protected _updateParameters(): void;
  31224. dispose(camera?: Camera): void;
  31225. }
  31226. }
  31227. declare module BABYLON {
  31228. class PassPostProcess extends PostProcess {
  31229. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  31230. }
  31231. }
  31232. declare module BABYLON {
  31233. type PostProcessOptions = {
  31234. width: number;
  31235. height: number;
  31236. };
  31237. /**
  31238. * PostProcess can be used to apply a shader to a texture after it has been rendered
  31239. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  31240. */
  31241. class PostProcess {
  31242. /** Name of the PostProcess. */
  31243. name: string;
  31244. /**
  31245. * Width of the texture to apply the post process on
  31246. */
  31247. width: number;
  31248. /**
  31249. * Height of the texture to apply the post process on
  31250. */
  31251. height: number;
  31252. /**
  31253. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  31254. * @hidden
  31255. */
  31256. /**
  31257. * Sampling mode used by the shader
  31258. * See https://doc.babylonjs.com/classes/3.1/texture
  31259. */
  31260. renderTargetSamplingMode: number;
  31261. /**
  31262. * Clear color to use when screen clearing
  31263. */
  31264. clearColor: Color4;
  31265. /**
  31266. * If the buffer needs to be cleared before applying the post process. (default: true)
  31267. * Should be set to false if shader will overwrite all previous pixels.
  31268. */
  31269. autoClear: boolean;
  31270. /**
  31271. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  31272. */
  31273. alphaMode: number;
  31274. /**
  31275. * Sets the setAlphaBlendConstants of the babylon engine
  31276. */
  31277. alphaConstants: Color4;
  31278. /**
  31279. * Animations to be used for the post processing
  31280. */
  31281. animations: Animation[];
  31282. /**
  31283. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  31284. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  31285. */
  31286. enablePixelPerfectMode: boolean;
  31287. /**
  31288. * Force the postprocess to be applied without taking in account viewport
  31289. */
  31290. forceFullscreenViewport: boolean;
  31291. /**
  31292. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  31293. *
  31294. * | Value | Type | Description |
  31295. * | ----- | ----------------------------------- | ----------- |
  31296. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  31297. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  31298. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  31299. *
  31300. */
  31301. scaleMode: number;
  31302. /**
  31303. * Force textures to be a power of two (default: false)
  31304. */
  31305. alwaysForcePOT: boolean;
  31306. private _samples;
  31307. /**
  31308. * Number of sample textures (default: 1)
  31309. */
  31310. samples: number;
  31311. /**
  31312. * Modify the scale of the post process to be the same as the viewport (default: false)
  31313. */
  31314. adaptScaleToCurrentViewport: boolean;
  31315. private _camera;
  31316. private _scene;
  31317. private _engine;
  31318. private _options;
  31319. private _reusable;
  31320. private _textureType;
  31321. /**
  31322. * Smart array of input and output textures for the post process.
  31323. * @hidden
  31324. */
  31325. /**
  31326. * The index in _textures that corresponds to the output texture.
  31327. * @hidden
  31328. */
  31329. private _effect;
  31330. private _samplers;
  31331. private _fragmentUrl;
  31332. private _vertexUrl;
  31333. private _parameters;
  31334. private _scaleRatio;
  31335. protected _indexParameters: any;
  31336. private _shareOutputWithPostProcess;
  31337. private _texelSize;
  31338. private _forcedOutputTexture;
  31339. /**
  31340. * An event triggered when the postprocess is activated.
  31341. */
  31342. onActivateObservable: Observable<Camera>;
  31343. private _onActivateObserver;
  31344. /**
  31345. * A function that is added to the onActivateObservable
  31346. */
  31347. onActivate: Nullable<(camera: Camera) => void>;
  31348. /**
  31349. * An event triggered when the postprocess changes its size.
  31350. */
  31351. onSizeChangedObservable: Observable<PostProcess>;
  31352. private _onSizeChangedObserver;
  31353. /**
  31354. * A function that is added to the onSizeChangedObservable
  31355. */
  31356. onSizeChanged: (postProcess: PostProcess) => void;
  31357. /**
  31358. * An event triggered when the postprocess applies its effect.
  31359. */
  31360. onApplyObservable: Observable<Effect>;
  31361. private _onApplyObserver;
  31362. /**
  31363. * A function that is added to the onApplyObservable
  31364. */
  31365. onApply: (effect: Effect) => void;
  31366. /**
  31367. * An event triggered before rendering the postprocess
  31368. */
  31369. onBeforeRenderObservable: Observable<Effect>;
  31370. private _onBeforeRenderObserver;
  31371. /**
  31372. * A function that is added to the onBeforeRenderObservable
  31373. */
  31374. onBeforeRender: (effect: Effect) => void;
  31375. /**
  31376. * An event triggered after rendering the postprocess
  31377. */
  31378. onAfterRenderObservable: Observable<Effect>;
  31379. private _onAfterRenderObserver;
  31380. /**
  31381. * A function that is added to the onAfterRenderObservable
  31382. */
  31383. onAfterRender: (efect: Effect) => void;
  31384. /**
  31385. * 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
  31386. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  31387. */
  31388. inputTexture: InternalTexture;
  31389. /**
  31390. * Gets the camera which post process is applied to.
  31391. * @returns The camera the post process is applied to.
  31392. */
  31393. getCamera(): Camera;
  31394. /**
  31395. * Gets the texel size of the postprocess.
  31396. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  31397. */
  31398. readonly texelSize: Vector2;
  31399. /**
  31400. * Creates a new instance PostProcess
  31401. * @param name The name of the PostProcess.
  31402. * @param fragmentUrl The url of the fragment shader to be used.
  31403. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  31404. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  31405. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  31406. * @param camera The camera to apply the render pass to.
  31407. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  31408. * @param engine The engine which the post process will be applied. (default: current engine)
  31409. * @param reusable If the post process can be reused on the same frame. (default: false)
  31410. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  31411. * @param textureType Type of textures used when performing the post process. (default: 0)
  31412. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  31413. * @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
  31414. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  31415. */
  31416. constructor(
  31417. /** Name of the PostProcess. */
  31418. 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);
  31419. /**
  31420. * Gets the engine which this post process belongs to.
  31421. * @returns The engine the post process was enabled with.
  31422. */
  31423. getEngine(): Engine;
  31424. /**
  31425. * The effect that is created when initializing the post process.
  31426. * @returns The created effect corrisponding the the postprocess.
  31427. */
  31428. getEffect(): Effect;
  31429. /**
  31430. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  31431. * @param postProcess The post process to share the output with.
  31432. * @returns This post process.
  31433. */
  31434. shareOutputWith(postProcess: PostProcess): PostProcess;
  31435. /**
  31436. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  31437. * This should be called if the post process that shares output with this post process is disabled/disposed.
  31438. */
  31439. useOwnOutput(): void;
  31440. /**
  31441. * Updates the effect with the current post process compile time values and recompiles the shader.
  31442. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  31443. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  31444. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  31445. * @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
  31446. * @param onCompiled Called when the shader has been compiled.
  31447. * @param onError Called if there is an error when compiling a shader.
  31448. */
  31449. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  31450. /**
  31451. * The post process is reusable if it can be used multiple times within one frame.
  31452. * @returns If the post process is reusable
  31453. */
  31454. isReusable(): boolean;
  31455. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  31456. markTextureDirty(): void;
  31457. /**
  31458. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  31459. * 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.
  31460. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  31461. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  31462. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  31463. * @returns The target texture that was bound to be written to.
  31464. */
  31465. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  31466. /**
  31467. * If the post process is supported.
  31468. */
  31469. readonly isSupported: boolean;
  31470. /**
  31471. * The aspect ratio of the output texture.
  31472. */
  31473. readonly aspectRatio: number;
  31474. /**
  31475. * Get a value indicating if the post-process is ready to be used
  31476. * @returns true if the post-process is ready (shader is compiled)
  31477. */
  31478. isReady(): boolean;
  31479. /**
  31480. * Binds all textures and uniforms to the shader, this will be run on every pass.
  31481. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  31482. */
  31483. apply(): Nullable<Effect>;
  31484. private _disposeTextures;
  31485. /**
  31486. * Disposes the post process.
  31487. * @param camera The camera to dispose the post process on.
  31488. */
  31489. dispose(camera?: Camera): void;
  31490. }
  31491. }
  31492. declare module BABYLON {
  31493. /**
  31494. * PostProcessManager is used to manage one or more post processes or post process pipelines
  31495. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  31496. */
  31497. class PostProcessManager {
  31498. private _scene;
  31499. private _indexBuffer;
  31500. private _vertexBuffers;
  31501. /**
  31502. * Creates a new instance PostProcess
  31503. * @param scene The scene that the post process is associated with.
  31504. */
  31505. constructor(scene: Scene);
  31506. private _prepareBuffers;
  31507. private _buildIndexBuffer;
  31508. /**
  31509. * Rebuilds the vertex buffers of the manager.
  31510. * @hidden
  31511. */
  31512. /**
  31513. * Prepares a frame to be run through a post process.
  31514. * @param sourceTexture The input texture to the post procesess. (default: null)
  31515. * @param postProcesses An array of post processes to be run. (default: null)
  31516. * @returns True if the post processes were able to be run.
  31517. * @hidden
  31518. */
  31519. /**
  31520. * Manually render a set of post processes to a texture.
  31521. * @param postProcesses An array of post processes to be run.
  31522. * @param targetTexture The target texture to render to.
  31523. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  31524. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  31525. * @param lodLevel defines which lod of the texture to render to
  31526. */
  31527. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  31528. /**
  31529. * Finalize the result of the output of the postprocesses.
  31530. * @param doNotPresent If true the result will not be displayed to the screen.
  31531. * @param targetTexture The target texture to render to.
  31532. * @param faceIndex The index of the face to bind the target texture to.
  31533. * @param postProcesses The array of post processes to render.
  31534. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  31535. * @hidden
  31536. */
  31537. /**
  31538. * Disposes of the post process manager.
  31539. */
  31540. dispose(): void;
  31541. }
  31542. }
  31543. declare module BABYLON {
  31544. class RefractionPostProcess extends PostProcess {
  31545. color: Color3;
  31546. depth: number;
  31547. colorLevel: number;
  31548. private _refTexture;
  31549. private _ownRefractionTexture;
  31550. /**
  31551. * Gets or sets the refraction texture
  31552. * Please note that you are responsible for disposing the texture if you set it manually
  31553. */
  31554. refractionTexture: Texture;
  31555. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  31556. dispose(camera: Camera): void;
  31557. }
  31558. }
  31559. declare module BABYLON {
  31560. /**
  31561. * The SharpenPostProcess applies a sharpen kernel to every pixel
  31562. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  31563. */
  31564. class SharpenPostProcess extends PostProcess {
  31565. /**
  31566. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  31567. */
  31568. colorAmount: number;
  31569. /**
  31570. * How much sharpness should be applied (default: 0.3)
  31571. */
  31572. edgeAmount: number;
  31573. /**
  31574. * Creates a new instance ConvolutionPostProcess
  31575. * @param name The name of the effect.
  31576. * @param options The required width/height ratio to downsize to before computing the render pass.
  31577. * @param camera The camera to apply the render pass to.
  31578. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  31579. * @param engine The engine which the post process will be applied. (default: current engine)
  31580. * @param reusable If the post process can be reused on the same frame. (default: false)
  31581. * @param textureType Type of textures used when performing the post process. (default: 0)
  31582. * @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)
  31583. */
  31584. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  31585. }
  31586. }
  31587. declare module BABYLON {
  31588. class StereoscopicInterlacePostProcess extends PostProcess {
  31589. private _stepSize;
  31590. private _passedProcess;
  31591. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  31592. }
  31593. }
  31594. declare module BABYLON {
  31595. /** Defines operator used for tonemapping */
  31596. enum TonemappingOperator {
  31597. /** Hable */
  31598. Hable = 0,
  31599. /** Reinhard */
  31600. Reinhard = 1,
  31601. /** HejiDawson */
  31602. HejiDawson = 2,
  31603. /** Photographic */
  31604. Photographic = 3
  31605. }
  31606. /**
  31607. * Defines a post process to apply tone mapping
  31608. */
  31609. class TonemapPostProcess extends PostProcess {
  31610. private _operator;
  31611. /** Defines the required exposure adjustement */
  31612. exposureAdjustment: number;
  31613. /**
  31614. * Creates a new TonemapPostProcess
  31615. * @param name defines the name of the postprocess
  31616. * @param _operator defines the operator to use
  31617. * @param exposureAdjustment defines the required exposure adjustement
  31618. * @param camera defines the camera to use (can be null)
  31619. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  31620. * @param engine defines the hosting engine (can be ignore if camera is set)
  31621. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  31622. */
  31623. constructor(name: string, _operator: TonemappingOperator,
  31624. /** Defines the required exposure adjustement */
  31625. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  31626. }
  31627. }
  31628. declare module BABYLON {
  31629. class VolumetricLightScatteringPostProcess extends PostProcess {
  31630. private _volumetricLightScatteringPass;
  31631. private _volumetricLightScatteringRTT;
  31632. private _viewPort;
  31633. private _screenCoordinates;
  31634. private _cachedDefines;
  31635. /**
  31636. * If not undefined, the mesh position is computed from the attached node position
  31637. */
  31638. attachedNode: {
  31639. position: Vector3;
  31640. };
  31641. /**
  31642. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  31643. */
  31644. customMeshPosition: Vector3;
  31645. /**
  31646. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  31647. */
  31648. useCustomMeshPosition: boolean;
  31649. /**
  31650. * If the post-process should inverse the light scattering direction
  31651. */
  31652. invert: boolean;
  31653. /**
  31654. * The internal mesh used by the post-process
  31655. */
  31656. mesh: Mesh;
  31657. useDiffuseColor: boolean;
  31658. /**
  31659. * Array containing the excluded meshes not rendered in the internal pass
  31660. */
  31661. excludedMeshes: AbstractMesh[];
  31662. /**
  31663. * Controls the overall intensity of the post-process
  31664. */
  31665. exposure: number;
  31666. /**
  31667. * Dissipates each sample's contribution in range [0, 1]
  31668. */
  31669. decay: number;
  31670. /**
  31671. * Controls the overall intensity of each sample
  31672. */
  31673. weight: number;
  31674. /**
  31675. * Controls the density of each sample
  31676. */
  31677. density: number;
  31678. /**
  31679. * @constructor
  31680. * @param {string} name - The post-process name
  31681. * @param {any} 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)
  31682. * @param {BABYLON.Camera} camera - The camera that the post-process will be attached to
  31683. * @param {BABYLON.Mesh} mesh - The mesh used to create the light scattering
  31684. * @param {number} samples - The post-process quality, default 100
  31685. * @param {number} samplingMode - The post-process filtering mode
  31686. * @param {BABYLON.Engine} engine - The babylon engine
  31687. * @param {boolean} reusable - If the post-process is reusable
  31688. * @param {BABYLON.Scene} scene - The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  31689. */
  31690. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  31691. getClassName(): string;
  31692. private _isReady;
  31693. /**
  31694. * Sets the new light position for light scattering effect
  31695. * @param {BABYLON.Vector3} The new custom light position
  31696. */
  31697. setCustomMeshPosition(position: Vector3): void;
  31698. /**
  31699. * Returns the light position for light scattering effect
  31700. * @return {BABYLON.Vector3} The custom light position
  31701. */
  31702. getCustomMeshPosition(): Vector3;
  31703. /**
  31704. * Disposes the internal assets and detaches the post-process from the camera
  31705. */
  31706. dispose(camera: Camera): void;
  31707. /**
  31708. * Returns the render target texture used by the post-process
  31709. * @return {BABYLON.RenderTargetTexture} The render target texture used by the post-process
  31710. */
  31711. getPass(): RenderTargetTexture;
  31712. private _meshExcluded;
  31713. private _createPass;
  31714. private _updateMeshScreenCoordinates;
  31715. /**
  31716. * Creates a default mesh for the Volumeric Light Scattering post-process
  31717. * @param {string} The mesh name
  31718. * @param {BABYLON.Scene} The scene where to create the mesh
  31719. * @return {BABYLON.Mesh} the default mesh
  31720. */
  31721. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  31722. }
  31723. }
  31724. declare module BABYLON {
  31725. class VRDistortionCorrectionPostProcess extends PostProcess {
  31726. private _isRightEye;
  31727. private _distortionFactors;
  31728. private _postProcessScaleFactor;
  31729. private _lensCenterOffset;
  31730. private _scaleIn;
  31731. private _scaleFactor;
  31732. private _lensCenter;
  31733. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  31734. }
  31735. }
  31736. declare module BABYLON {
  31737. class Sprite {
  31738. name: string;
  31739. position: Vector3;
  31740. color: Color4;
  31741. width: number;
  31742. height: number;
  31743. angle: number;
  31744. cellIndex: number;
  31745. invertU: number;
  31746. invertV: number;
  31747. disposeWhenFinishedAnimating: boolean;
  31748. animations: Animation[];
  31749. isPickable: boolean;
  31750. actionManager: ActionManager;
  31751. private _animationStarted;
  31752. private _loopAnimation;
  31753. private _fromIndex;
  31754. private _toIndex;
  31755. private _delay;
  31756. private _direction;
  31757. private _manager;
  31758. private _time;
  31759. private _onAnimationEnd;
  31760. /**
  31761. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  31762. */
  31763. isVisible: boolean;
  31764. size: number;
  31765. constructor(name: string, manager: ISpriteManager);
  31766. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  31767. stopAnimation(): void;
  31768. /** @hidden */
  31769. dispose(): void;
  31770. }
  31771. }
  31772. declare module BABYLON {
  31773. /**
  31774. * Defines the minimum interface to fullfil in order to be a sprite manager.
  31775. */
  31776. interface ISpriteManager extends IDisposable {
  31777. /**
  31778. * Restricts the camera to viewing objects with the same layerMask.
  31779. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  31780. */
  31781. layerMask: number;
  31782. /**
  31783. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  31784. */
  31785. isPickable: boolean;
  31786. /**
  31787. * Specifies the rendering group id for this mesh (0 by default)
  31788. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  31789. */
  31790. renderingGroupId: number;
  31791. /**
  31792. * Defines the list of sprites managed by the manager.
  31793. */
  31794. sprites: Array<Sprite>;
  31795. /**
  31796. * Tests the intersection of a sprite with a specific ray.
  31797. * @param ray The ray we are sending to test the collision
  31798. * @param camera The camera space we are sending rays in
  31799. * @param predicate A predicate allowing excluding sprites from the list of object to test
  31800. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  31801. * @returns picking info or null.
  31802. */
  31803. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  31804. /**
  31805. * Renders the list of sprites on screen.
  31806. */
  31807. render(): void;
  31808. }
  31809. class SpriteManager implements ISpriteManager {
  31810. name: string;
  31811. sprites: Sprite[];
  31812. renderingGroupId: number;
  31813. layerMask: number;
  31814. fogEnabled: boolean;
  31815. isPickable: boolean;
  31816. cellWidth: number;
  31817. cellHeight: number;
  31818. /**
  31819. * An event triggered when the manager is disposed.
  31820. */
  31821. onDisposeObservable: Observable<SpriteManager>;
  31822. private _onDisposeObserver;
  31823. onDispose: () => void;
  31824. private _capacity;
  31825. private _spriteTexture;
  31826. private _epsilon;
  31827. private _scene;
  31828. private _vertexData;
  31829. private _buffer;
  31830. private _vertexBuffers;
  31831. private _indexBuffer;
  31832. private _effectBase;
  31833. private _effectFog;
  31834. texture: Texture;
  31835. constructor(name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  31836. private _appendSpriteVertex;
  31837. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  31838. render(): void;
  31839. dispose(): void;
  31840. }
  31841. }
  31842. declare module BABYLON {
  31843. interface Scene {
  31844. /** @hidden */
  31845. /** @hidden */
  31846. /** @hidden */
  31847. /**
  31848. * All of the sprite managers added to this scene
  31849. * @see http://doc.babylonjs.com/babylon101/sprites
  31850. */
  31851. spriteManagers: Array<ISpriteManager>;
  31852. /**
  31853. * An event triggered when sprites rendering is about to start
  31854. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  31855. */
  31856. onBeforeSpritesRenderingObservable: Observable<Scene>;
  31857. /**
  31858. * An event triggered when sprites rendering is done
  31859. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  31860. */
  31861. onAfterSpritesRenderingObservable: Observable<Scene>;
  31862. /** @hidden */
  31863. /** Launch a ray to try to pick a sprite in the scene
  31864. * @param x position on screen
  31865. * @param y position on screen
  31866. * @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
  31867. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  31868. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  31869. * @returns a PickingInfo
  31870. */
  31871. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  31872. /** Use the given ray to pick a sprite in the scene
  31873. * @param ray The ray (in world space) to use to pick meshes
  31874. * @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
  31875. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  31876. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  31877. * @returns a PickingInfo
  31878. */
  31879. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  31880. /**
  31881. * Force the sprite under the pointer
  31882. * @param sprite defines the sprite to use
  31883. */
  31884. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  31885. /**
  31886. * Gets the sprite under the pointer
  31887. * @returns a Sprite or null if no sprite is under the pointer
  31888. */
  31889. getPointerOverSprite(): Nullable<Sprite>;
  31890. }
  31891. /**
  31892. * Defines the sprite scene component responsible to manage sprites
  31893. * in a given scene.
  31894. */
  31895. class SpriteSceneComponent implements ISceneComponent {
  31896. /**
  31897. * The component name helpfull to identify the component in the list of scene components.
  31898. */
  31899. readonly name: string;
  31900. /**
  31901. * The scene the component belongs to.
  31902. */
  31903. scene: Scene;
  31904. /** @hidden */
  31905. private _spritePredicate;
  31906. /**
  31907. * Creates a new instance of the component for the given scene
  31908. * @param scene Defines the scene to register the component in
  31909. */
  31910. constructor(scene: Scene);
  31911. /**
  31912. * Registers the component in a given scene
  31913. */
  31914. register(): void;
  31915. /**
  31916. * Rebuilds the elements related to this component in case of
  31917. * context lost for instance.
  31918. */
  31919. rebuild(): void;
  31920. /**
  31921. * Disposes the component and the associated ressources.
  31922. */
  31923. dispose(): void;
  31924. private _pickSpriteButKeepRay;
  31925. private _pointerMove;
  31926. private _pointerDown;
  31927. private _pointerUp;
  31928. }
  31929. }
  31930. declare module BABYLON {
  31931. /**
  31932. * @hidden
  31933. **/
  31934. class _AlphaState {
  31935. private _isAlphaBlendDirty;
  31936. private _isBlendFunctionParametersDirty;
  31937. private _isBlendEquationParametersDirty;
  31938. private _isBlendConstantsDirty;
  31939. private _alphaBlend;
  31940. private _blendFunctionParameters;
  31941. private _blendEquationParameters;
  31942. private _blendConstants;
  31943. /**
  31944. * Initializes the state.
  31945. */
  31946. constructor();
  31947. readonly isDirty: boolean;
  31948. alphaBlend: boolean;
  31949. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  31950. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  31951. setAlphaEquationParameters(rgb: number, alpha: number): void;
  31952. reset(): void;
  31953. apply(gl: WebGLRenderingContext): void;
  31954. }
  31955. }
  31956. declare module BABYLON {
  31957. /**
  31958. * @hidden
  31959. **/
  31960. class _DepthCullingState {
  31961. private _isDepthTestDirty;
  31962. private _isDepthMaskDirty;
  31963. private _isDepthFuncDirty;
  31964. private _isCullFaceDirty;
  31965. private _isCullDirty;
  31966. private _isZOffsetDirty;
  31967. private _isFrontFaceDirty;
  31968. private _depthTest;
  31969. private _depthMask;
  31970. private _depthFunc;
  31971. private _cull;
  31972. private _cullFace;
  31973. private _zOffset;
  31974. private _frontFace;
  31975. /**
  31976. * Initializes the state.
  31977. */
  31978. constructor();
  31979. readonly isDirty: boolean;
  31980. zOffset: number;
  31981. cullFace: Nullable<number>;
  31982. cull: Nullable<boolean>;
  31983. depthFunc: Nullable<number>;
  31984. depthMask: boolean;
  31985. depthTest: boolean;
  31986. frontFace: Nullable<number>;
  31987. reset(): void;
  31988. apply(gl: WebGLRenderingContext): void;
  31989. }
  31990. }
  31991. declare module BABYLON {
  31992. /**
  31993. * @hidden
  31994. **/
  31995. class _StencilState {
  31996. private _isStencilTestDirty;
  31997. private _isStencilMaskDirty;
  31998. private _isStencilFuncDirty;
  31999. private _isStencilOpDirty;
  32000. private _stencilTest;
  32001. private _stencilMask;
  32002. private _stencilFunc;
  32003. private _stencilFuncRef;
  32004. private _stencilFuncMask;
  32005. private _stencilOpStencilFail;
  32006. private _stencilOpDepthFail;
  32007. private _stencilOpStencilDepthPass;
  32008. readonly isDirty: boolean;
  32009. stencilFunc: number;
  32010. stencilFuncRef: number;
  32011. stencilFuncMask: number;
  32012. stencilOpStencilFail: number;
  32013. stencilOpDepthFail: number;
  32014. stencilOpStencilDepthPass: number;
  32015. stencilMask: number;
  32016. stencilTest: boolean;
  32017. constructor();
  32018. reset(): void;
  32019. apply(gl: WebGLRenderingContext): void;
  32020. }
  32021. }
  32022. declare module BABYLON {
  32023. interface Scene {
  32024. /** @hidden (Backing field) */
  32025. /** @hidden (Backing field) */
  32026. /**
  32027. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  32028. */
  32029. forceShowBoundingBoxes: boolean;
  32030. /**
  32031. * Gets the bounding box renderer associated with the scene
  32032. * @returns a BoundingBoxRenderer
  32033. */
  32034. getBoundingBoxRenderer(): BoundingBoxRenderer;
  32035. }
  32036. interface AbstractMesh {
  32037. /** @hidden (Backing field) */
  32038. /**
  32039. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  32040. */
  32041. showBoundingBox: boolean;
  32042. }
  32043. /**
  32044. * Component responsible of rendering the bounding box of the meshes in a scene.
  32045. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  32046. */
  32047. class BoundingBoxRenderer implements ISceneComponent {
  32048. /**
  32049. * The component name helpfull to identify the component in the list of scene components.
  32050. */
  32051. readonly name: string;
  32052. /**
  32053. * The scene the component belongs to.
  32054. */
  32055. scene: Scene;
  32056. /**
  32057. * Color of the bounding box lines placed in front of an object
  32058. */
  32059. frontColor: Color3;
  32060. /**
  32061. * Color of the bounding box lines placed behind an object
  32062. */
  32063. backColor: Color3;
  32064. /**
  32065. * Defines if the renderer should show the back lines or not
  32066. */
  32067. showBackLines: boolean;
  32068. /**
  32069. * @hidden
  32070. */
  32071. renderList: SmartArray<BoundingBox>;
  32072. private _colorShader;
  32073. private _vertexBuffers;
  32074. private _indexBuffer;
  32075. /**
  32076. * Instantiates a new bounding box renderer in a scene.
  32077. * @param scene the scene the renderer renders in
  32078. */
  32079. constructor(scene: Scene);
  32080. /**
  32081. * Registers the component in a given scene
  32082. */
  32083. register(): void;
  32084. private _evaluateSubMesh;
  32085. private _activeMesh;
  32086. private _prepareRessources;
  32087. private _createIndexBuffer;
  32088. /**
  32089. * Rebuilds the elements related to this component in case of
  32090. * context lost for instance.
  32091. */
  32092. rebuild(): void;
  32093. /**
  32094. * @hidden
  32095. */
  32096. reset(): void;
  32097. /**
  32098. * Render the bounding boxes of a specific rendering group
  32099. * @param renderingGroupId defines the rendering group to render
  32100. */
  32101. render(renderingGroupId: number): void;
  32102. /**
  32103. * In case of occlusion queries, we can render the occlusion bounding box through this method
  32104. * @param mesh Define the mesh to render the occlusion bounding box for
  32105. */
  32106. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  32107. /**
  32108. * Dispose and release the resources attached to this renderer.
  32109. */
  32110. dispose(): void;
  32111. }
  32112. }
  32113. declare module BABYLON {
  32114. /**
  32115. * This represents a depth renderer in Babylon.
  32116. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  32117. */
  32118. class DepthRenderer {
  32119. private _scene;
  32120. private _depthMap;
  32121. private _effect;
  32122. private _cachedDefines;
  32123. private _camera;
  32124. /**
  32125. * Specifiess that the depth renderer will only be used within
  32126. * the camera it is created for.
  32127. * This can help forcing its rendering during the camera processing.
  32128. */
  32129. useOnlyInActiveCamera: boolean;
  32130. /**
  32131. * Instantiates a depth renderer
  32132. * @param scene The scene the renderer belongs to
  32133. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  32134. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  32135. */
  32136. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  32137. /**
  32138. * Creates the depth rendering effect and checks if the effect is ready.
  32139. * @param subMesh The submesh to be used to render the depth map of
  32140. * @param useInstances If multiple world instances should be used
  32141. * @returns if the depth renderer is ready to render the depth map
  32142. */
  32143. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  32144. /**
  32145. * Gets the texture which the depth map will be written to.
  32146. * @returns The depth map texture
  32147. */
  32148. getDepthMap(): RenderTargetTexture;
  32149. /**
  32150. * Disposes of the depth renderer.
  32151. */
  32152. dispose(): void;
  32153. }
  32154. }
  32155. declare module BABYLON {
  32156. interface Scene {
  32157. /** @hidden (Backing field) */
  32158. ;
  32159. /**
  32160. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  32161. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  32162. * @returns the created depth renderer
  32163. */
  32164. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  32165. /**
  32166. * Disables a depth renderer for a given camera
  32167. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  32168. */
  32169. disableDepthRenderer(camera?: Nullable<Camera>): void;
  32170. }
  32171. /**
  32172. * Defines the Depth Renderer scene component responsible to manage a depth buffer usefull
  32173. * in several rendering techniques.
  32174. */
  32175. class DepthRendererSceneComponent implements ISceneComponent {
  32176. /**
  32177. * The component name helpfull to identify the component in the list of scene components.
  32178. */
  32179. readonly name: string;
  32180. /**
  32181. * The scene the component belongs to.
  32182. */
  32183. scene: Scene;
  32184. /**
  32185. * Creates a new instance of the component for the given scene
  32186. * @param scene Defines the scene to register the component in
  32187. */
  32188. constructor(scene: Scene);
  32189. /**
  32190. * Registers the component in a given scene
  32191. */
  32192. register(): void;
  32193. /**
  32194. * Rebuilds the elements related to this component in case of
  32195. * context lost for instance.
  32196. */
  32197. rebuild(): void;
  32198. /**
  32199. * Disposes the component and the associated ressources
  32200. */
  32201. dispose(): void;
  32202. private _gatherRenderTargets;
  32203. private _gatherActiveCameraRenderTargets;
  32204. }
  32205. }
  32206. declare module BABYLON {
  32207. interface AbstractMesh {
  32208. /**
  32209. * Disables the mesh edge rendering mode
  32210. * @returns the currentAbstractMesh
  32211. */
  32212. disableEdgesRendering(): AbstractMesh;
  32213. /**
  32214. * Enables the edge rendering mode on the mesh.
  32215. * This mode makes the mesh edges visible
  32216. * @param epsilon defines the maximal distance between two angles to detect a face
  32217. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  32218. * @returns the currentAbstractMesh
  32219. * @see https://www.babylonjs-playground.com/#19O9TU#0
  32220. */
  32221. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  32222. /**
  32223. * Gets the edgesRenderer associated with the mesh
  32224. */
  32225. edgesRenderer: Nullable<EdgesRenderer>;
  32226. }
  32227. interface LinesMesh {
  32228. /**
  32229. * Enables the edge rendering mode on the mesh.
  32230. * This mode makes the mesh edges visible
  32231. * @param epsilon defines the maximal distance between two angles to detect a face
  32232. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  32233. * @returns the currentAbstractMesh
  32234. * @see https://www.babylonjs-playground.com/#19O9TU#0
  32235. */
  32236. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  32237. }
  32238. /**
  32239. * Defines the minimum contract an Edges renderer should follow.
  32240. */
  32241. interface IEdgesRenderer extends IDisposable {
  32242. /**
  32243. * Gets or sets a boolean indicating if the edgesRenderer is active
  32244. */
  32245. isEnabled: boolean;
  32246. /**
  32247. * Renders the edges of the attached mesh,
  32248. */
  32249. render(): void;
  32250. /**
  32251. * Checks wether or not the edges renderer is ready to render.
  32252. * @return true if ready, otherwise false.
  32253. */
  32254. isReady(): boolean;
  32255. }
  32256. /**
  32257. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  32258. */
  32259. class EdgesRenderer implements IEdgesRenderer {
  32260. /**
  32261. * Define the size of the edges with an orthographic camera
  32262. */
  32263. edgesWidthScalerForOrthographic: number;
  32264. /**
  32265. * Define the size of the edges with a perspective camera
  32266. */
  32267. edgesWidthScalerForPerspective: number;
  32268. protected _source: AbstractMesh;
  32269. protected _linesPositions: number[];
  32270. protected _linesNormals: number[];
  32271. protected _linesIndices: number[];
  32272. protected _epsilon: number;
  32273. protected _indicesCount: number;
  32274. protected _lineShader: ShaderMaterial;
  32275. protected _ib: WebGLBuffer;
  32276. protected _buffers: {
  32277. [key: string]: Nullable<VertexBuffer>;
  32278. };
  32279. protected _checkVerticesInsteadOfIndices: boolean;
  32280. private _meshRebuildObserver;
  32281. private _meshDisposeObserver;
  32282. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  32283. isEnabled: boolean;
  32284. /**
  32285. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  32286. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  32287. * @param source Mesh used to create edges
  32288. * @param epsilon sum of angles in adjacency to check for edge
  32289. * @param checkVerticesInsteadOfIndices
  32290. * @param generateEdgesLines - should generate Lines or only prepare resources.
  32291. */
  32292. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  32293. protected _prepareRessources(): void;
  32294. /** @hidden */
  32295. /**
  32296. * Releases the required resources for the edges renderer
  32297. */
  32298. dispose(): void;
  32299. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  32300. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  32301. /**
  32302. * Checks if the pair of p0 and p1 is en edge
  32303. * @param faceIndex
  32304. * @param edge
  32305. * @param faceNormals
  32306. * @param p0
  32307. * @param p1
  32308. * @private
  32309. */
  32310. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  32311. /**
  32312. * Generates lines edges from adjacencjes
  32313. * @private
  32314. */
  32315. /**
  32316. * Checks wether or not the edges renderer is ready to render.
  32317. * @return true if ready, otherwise false.
  32318. */
  32319. isReady(): boolean;
  32320. /**
  32321. * Renders the edges of the attached mesh,
  32322. */
  32323. render(): void;
  32324. }
  32325. }
  32326. declare module BABYLON {
  32327. /**
  32328. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  32329. */
  32330. class GeometryBufferRenderer {
  32331. private _scene;
  32332. private _multiRenderTarget;
  32333. private _ratio;
  32334. private _enablePosition;
  32335. protected _effect: Effect;
  32336. protected _cachedDefines: string;
  32337. /**
  32338. * Set the render list (meshes to be rendered) used in the G buffer.
  32339. */
  32340. renderList: Mesh[];
  32341. /**
  32342. * Gets wether or not G buffer are supported by the running hardware.
  32343. * This requires draw buffer supports
  32344. */
  32345. readonly isSupported: boolean;
  32346. /**
  32347. * Gets wether or not position are enabled for the G buffer.
  32348. */
  32349. /**
  32350. * Sets wether or not position are enabled for the G buffer.
  32351. */
  32352. enablePosition: boolean;
  32353. /**
  32354. * Gets the scene associated with the buffer.
  32355. */
  32356. readonly scene: Scene;
  32357. /**
  32358. * Gets the ratio used by the buffer during its creation.
  32359. * How big is the buffer related to the main canvas.
  32360. */
  32361. readonly ratio: number;
  32362. /**
  32363. * Creates a new G Buffer for the scene
  32364. * @param scene The scene the buffer belongs to
  32365. * @param ratio How big is the buffer related to the main canvas.
  32366. */
  32367. constructor(scene: Scene, ratio?: number);
  32368. /**
  32369. * Checks wether everything is ready to render a submesh to the G buffer.
  32370. * @param subMesh the submesh to check readiness for
  32371. * @param useInstances is the mesh drawn using instance or not
  32372. * @returns true if ready otherwise false
  32373. */
  32374. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  32375. /**
  32376. * Gets the current underlying G Buffer.
  32377. * @returns the buffer
  32378. */
  32379. getGBuffer(): MultiRenderTarget;
  32380. /**
  32381. * Gets the number of samples used to render the buffer (anti aliasing).
  32382. */
  32383. /**
  32384. * Sets the number of samples used to render the buffer (anti aliasing).
  32385. */
  32386. samples: number;
  32387. /**
  32388. * Disposes the renderer and frees up associated resources.
  32389. */
  32390. dispose(): void;
  32391. protected _createRenderTargets(): void;
  32392. }
  32393. }
  32394. declare module BABYLON {
  32395. interface Scene {
  32396. /** @hidden (Backing field) */
  32397. /**
  32398. * Gets or Sets the current geometry buffer associated to the scene.
  32399. */
  32400. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  32401. /**
  32402. * Enables a GeometryBufferRender and associates it with the scene
  32403. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  32404. * @returns the GeometryBufferRenderer
  32405. */
  32406. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  32407. /**
  32408. * Disables the GeometryBufferRender associated with the scene
  32409. */
  32410. disableGeometryBufferRenderer(): void;
  32411. }
  32412. /**
  32413. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  32414. * in several rendering techniques.
  32415. */
  32416. class GeometryBufferRendererSceneComponent implements ISceneComponent {
  32417. /**
  32418. * The component name helpful to identify the component in the list of scene components.
  32419. */
  32420. readonly name: string;
  32421. /**
  32422. * The scene the component belongs to.
  32423. */
  32424. scene: Scene;
  32425. /**
  32426. * Creates a new instance of the component for the given scene
  32427. * @param scene Defines the scene to register the component in
  32428. */
  32429. constructor(scene: Scene);
  32430. /**
  32431. * Registers the component in a given scene
  32432. */
  32433. register(): void;
  32434. /**
  32435. * Rebuilds the elements related to this component in case of
  32436. * context lost for instance.
  32437. */
  32438. rebuild(): void;
  32439. /**
  32440. * Disposes the component and the associated ressources
  32441. */
  32442. dispose(): void;
  32443. private _gatherRenderTargets;
  32444. }
  32445. }
  32446. declare module BABYLON {
  32447. /**
  32448. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  32449. */
  32450. class LineEdgesRenderer extends EdgesRenderer {
  32451. /**
  32452. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  32453. * @param source LineMesh used to generate edges
  32454. * @param epsilon not important (specified angle for edge detection)
  32455. * @param checkVerticesInsteadOfIndices not important for LineMesh
  32456. */
  32457. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  32458. /**
  32459. * Always create the edge since its a line so only important things are p0 and p1
  32460. * @param faceIndex not important for LineMesh
  32461. * @param edge not important for LineMesh
  32462. * @param faceNormals not important for LineMesh
  32463. * @param p0 beginnig of line
  32464. * @param p1 end of line
  32465. */
  32466. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  32467. /**
  32468. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  32469. */
  32470. }
  32471. }
  32472. declare module BABYLON {
  32473. interface Scene {
  32474. /** @hidden */
  32475. /**
  32476. * Gets the outline renderer associated with the scene
  32477. * @returns a OutlineRenderer
  32478. */
  32479. getOutlineRenderer(): OutlineRenderer;
  32480. }
  32481. interface AbstractMesh {
  32482. /** @hidden (Backing field) */
  32483. /**
  32484. * Gets or sets a boolean indicating if the outline must be rendered as well
  32485. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  32486. */
  32487. renderOutline: boolean;
  32488. /** @hidden (Backing field) */
  32489. /**
  32490. * Gets or sets a boolean indicating if the overlay must be rendered as well
  32491. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  32492. */
  32493. renderOverlay: boolean;
  32494. }
  32495. /**
  32496. * This class is responsible to draw bothe outline/overlay of meshes.
  32497. * It should not be used directly but through the available method on mesh.
  32498. */
  32499. class OutlineRenderer implements ISceneComponent {
  32500. /**
  32501. * The name of the component. Each component must have a unique name.
  32502. */
  32503. name: string;
  32504. /**
  32505. * The scene the component belongs to.
  32506. */
  32507. scene: Scene;
  32508. /**
  32509. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  32510. */
  32511. zOffset: number;
  32512. private _engine;
  32513. private _effect;
  32514. private _cachedDefines;
  32515. private _savedDepthWrite;
  32516. /**
  32517. * Instantiates a new outline renderer. (There could be only one per scene).
  32518. * @param scene Defines the scene it belongs to
  32519. */
  32520. constructor(scene: Scene);
  32521. /**
  32522. * Register the component to one instance of a scene.
  32523. */
  32524. register(): void;
  32525. /**
  32526. * Rebuilds the elements related to this component in case of
  32527. * context lost for instance.
  32528. */
  32529. rebuild(): void;
  32530. /**
  32531. * Disposes the component and the associated ressources.
  32532. */
  32533. dispose(): void;
  32534. /**
  32535. * Renders the outline in the canvas.
  32536. * @param subMesh Defines the sumesh to render
  32537. * @param batch Defines the batch of meshes in case of instances
  32538. * @param useOverlay Defines if the rendering is for the overlay or the outline
  32539. */
  32540. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  32541. /**
  32542. * Returns whether or not the outline renderer is ready for a given submesh.
  32543. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  32544. * @param subMesh Defines the submesh to check readyness for
  32545. * @param useInstances Defines wheter wee are trying to render instances or not
  32546. * @returns true if ready otherwise false
  32547. */
  32548. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  32549. private _beforeRenderingMesh;
  32550. private _afterRenderingMesh;
  32551. }
  32552. }
  32553. declare module BABYLON {
  32554. /**
  32555. * This represents the object necessary to create a rendering group.
  32556. * This is exclusively used and created by the rendering manager.
  32557. * To modify the behavior, you use the available helpers in your scene or meshes.
  32558. * @hidden
  32559. */
  32560. class RenderingGroup {
  32561. index: number;
  32562. private _scene;
  32563. private _opaqueSubMeshes;
  32564. private _transparentSubMeshes;
  32565. private _alphaTestSubMeshes;
  32566. private _depthOnlySubMeshes;
  32567. private _particleSystems;
  32568. private _spriteManagers;
  32569. private _opaqueSortCompareFn;
  32570. private _alphaTestSortCompareFn;
  32571. private _transparentSortCompareFn;
  32572. private _renderOpaque;
  32573. private _renderAlphaTest;
  32574. private _renderTransparent;
  32575. private _edgesRenderers;
  32576. onBeforeTransparentRendering: () => void;
  32577. /**
  32578. * Set the opaque sort comparison function.
  32579. * If null the sub meshes will be render in the order they were created
  32580. */
  32581. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  32582. /**
  32583. * Set the alpha test sort comparison function.
  32584. * If null the sub meshes will be render in the order they were created
  32585. */
  32586. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  32587. /**
  32588. * Set the transparent sort comparison function.
  32589. * If null the sub meshes will be render in the order they were created
  32590. */
  32591. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  32592. /**
  32593. * Creates a new rendering group.
  32594. * @param index The rendering group index
  32595. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  32596. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  32597. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  32598. */
  32599. 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>);
  32600. /**
  32601. * Render all the sub meshes contained in the group.
  32602. * @param customRenderFunction Used to override the default render behaviour of the group.
  32603. * @returns true if rendered some submeshes.
  32604. */
  32605. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  32606. /**
  32607. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  32608. * @param subMeshes The submeshes to render
  32609. */
  32610. private renderOpaqueSorted;
  32611. /**
  32612. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  32613. * @param subMeshes The submeshes to render
  32614. */
  32615. private renderAlphaTestSorted;
  32616. /**
  32617. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  32618. * @param subMeshes The submeshes to render
  32619. */
  32620. private renderTransparentSorted;
  32621. /**
  32622. * Renders the submeshes in a specified order.
  32623. * @param subMeshes The submeshes to sort before render
  32624. * @param sortCompareFn The comparison function use to sort
  32625. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  32626. * @param transparent Specifies to activate blending if true
  32627. */
  32628. private static renderSorted;
  32629. /**
  32630. * Renders the submeshes in the order they were dispatched (no sort applied).
  32631. * @param subMeshes The submeshes to render
  32632. */
  32633. private static renderUnsorted;
  32634. /**
  32635. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  32636. * are rendered back to front if in the same alpha index.
  32637. *
  32638. * @param a The first submesh
  32639. * @param b The second submesh
  32640. * @returns The result of the comparison
  32641. */
  32642. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  32643. /**
  32644. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  32645. * are rendered back to front.
  32646. *
  32647. * @param a The first submesh
  32648. * @param b The second submesh
  32649. * @returns The result of the comparison
  32650. */
  32651. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  32652. /**
  32653. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  32654. * are rendered front to back (prevent overdraw).
  32655. *
  32656. * @param a The first submesh
  32657. * @param b The second submesh
  32658. * @returns The result of the comparison
  32659. */
  32660. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  32661. /**
  32662. * Resets the different lists of submeshes to prepare a new frame.
  32663. */
  32664. prepare(): void;
  32665. dispose(): void;
  32666. /**
  32667. * Inserts the submesh in its correct queue depending on its material.
  32668. * @param subMesh The submesh to dispatch
  32669. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  32670. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  32671. */
  32672. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  32673. dispatchSprites(spriteManager: ISpriteManager): void;
  32674. dispatchParticles(particleSystem: IParticleSystem): void;
  32675. private _renderParticles;
  32676. private _renderSprites;
  32677. }
  32678. }
  32679. declare module BABYLON {
  32680. /**
  32681. * Interface describing the different options available in the rendering manager
  32682. * regarding Auto Clear between groups.
  32683. */
  32684. interface IRenderingManagerAutoClearSetup {
  32685. /**
  32686. * Defines whether or not autoclear is enable.
  32687. */
  32688. autoClear: boolean;
  32689. /**
  32690. * Defines whether or not to autoclear the depth buffer.
  32691. */
  32692. depth: boolean;
  32693. /**
  32694. * Defines whether or not to autoclear the stencil buffer.
  32695. */
  32696. stencil: boolean;
  32697. }
  32698. /**
  32699. * This is the manager responsible of all the rendering for meshes sprites and particles.
  32700. * It is enable to manage the different groups as well as the different necessary sort functions.
  32701. * This should not be used directly aside of the few static configurations
  32702. */
  32703. class RenderingManager {
  32704. /**
  32705. * The max id used for rendering groups (not included)
  32706. */
  32707. static MAX_RENDERINGGROUPS: number;
  32708. /**
  32709. * The min id used for rendering groups (included)
  32710. */
  32711. static MIN_RENDERINGGROUPS: number;
  32712. /**
  32713. * Used to globally prevent autoclearing scenes.
  32714. */
  32715. static AUTOCLEAR: boolean;
  32716. /**
  32717. * @hidden
  32718. */
  32719. private _scene;
  32720. private _renderingGroups;
  32721. private _depthStencilBufferAlreadyCleaned;
  32722. private _autoClearDepthStencil;
  32723. private _customOpaqueSortCompareFn;
  32724. private _customAlphaTestSortCompareFn;
  32725. private _customTransparentSortCompareFn;
  32726. private _renderingGroupInfo;
  32727. /**
  32728. * Instantiates a new rendering group for a particular scene
  32729. * @param scene Defines the scene the groups belongs to
  32730. */
  32731. constructor(scene: Scene);
  32732. private _clearDepthStencilBuffer;
  32733. /**
  32734. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  32735. * @hidden
  32736. */
  32737. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  32738. /**
  32739. * Resets the different information of the group to prepare a new frame
  32740. * @hidden
  32741. */
  32742. reset(): void;
  32743. /**
  32744. * Dispose and release the group and its associated resources.
  32745. * @hidden
  32746. */
  32747. dispose(): void;
  32748. /**
  32749. * Clear the info related to rendering groups preventing retention points during dispose.
  32750. */
  32751. freeRenderingGroups(): void;
  32752. private _prepareRenderingGroup;
  32753. /**
  32754. * Add a sprite manager to the rendering manager in order to render it this frame.
  32755. * @param spriteManager Define the sprite manager to render
  32756. */
  32757. dispatchSprites(spriteManager: ISpriteManager): void;
  32758. /**
  32759. * Add a particle system to the rendering manager in order to render it this frame.
  32760. * @param particleSystem Define the particle system to render
  32761. */
  32762. dispatchParticles(particleSystem: IParticleSystem): void;
  32763. /**
  32764. * Add a submesh to the manager in order to render it this frame
  32765. * @param subMesh The submesh to dispatch
  32766. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  32767. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  32768. */
  32769. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  32770. /**
  32771. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  32772. * This allowed control for front to back rendering or reversly depending of the special needs.
  32773. *
  32774. * @param renderingGroupId The rendering group id corresponding to its index
  32775. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  32776. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  32777. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  32778. */
  32779. 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;
  32780. /**
  32781. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  32782. *
  32783. * @param renderingGroupId The rendering group id corresponding to its index
  32784. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  32785. * @param depth Automatically clears depth between groups if true and autoClear is true.
  32786. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  32787. */
  32788. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  32789. /**
  32790. * Gets the current auto clear configuration for one rendering group of the rendering
  32791. * manager.
  32792. * @param index the rendering group index to get the information for
  32793. * @returns The auto clear setup for the requested rendering group
  32794. */
  32795. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  32796. }
  32797. }
  32798. declare module BABYLON {
  32799. /**
  32800. * Renders a layer on top of an existing scene
  32801. */
  32802. class UtilityLayerRenderer implements IDisposable {
  32803. /** the original scene that will be rendered on top of */
  32804. originalScene: Scene;
  32805. private _pointerCaptures;
  32806. private _lastPointerEvents;
  32807. private static _DefaultUtilityLayer;
  32808. private static _DefaultKeepDepthUtilityLayer;
  32809. /**
  32810. * 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)
  32811. */
  32812. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  32813. /**
  32814. * 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)
  32815. */
  32816. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  32817. /**
  32818. * The scene that is rendered on top of the original scene
  32819. */
  32820. utilityLayerScene: Scene;
  32821. /**
  32822. * If the utility layer should automatically be rendered on top of existing scene
  32823. */
  32824. shouldRender: boolean;
  32825. /**
  32826. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  32827. */
  32828. onlyCheckPointerDownEvents: boolean;
  32829. /**
  32830. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  32831. */
  32832. processAllEvents: boolean;
  32833. /**
  32834. * Observable raised when the pointer move from the utility layer scene to the main scene
  32835. */
  32836. onPointerOutObservable: Observable<number>;
  32837. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  32838. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  32839. private _afterRenderObserver;
  32840. private _sceneDisposeObserver;
  32841. private _originalPointerObserver;
  32842. /**
  32843. * Instantiates a UtilityLayerRenderer
  32844. * @param originalScene the original scene that will be rendered on top of
  32845. */
  32846. constructor(
  32847. /** the original scene that will be rendered on top of */
  32848. originalScene: Scene);
  32849. private _notifyObservers;
  32850. /**
  32851. * Renders the utility layers scene on top of the original scene
  32852. */
  32853. render(): void;
  32854. /**
  32855. * Disposes of the renderer
  32856. */
  32857. dispose(): void;
  32858. private _updateCamera;
  32859. }
  32860. }
  32861. declare module BABYLON {
  32862. /**
  32863. * Class used to evalaute queries containing `and` and `or` operators
  32864. */
  32865. class AndOrNotEvaluator {
  32866. /**
  32867. * Evaluate a query
  32868. * @param query defines the query to evaluate
  32869. * @param evaluateCallback defines the callback used to filter result
  32870. * @returns true if the query matches
  32871. */
  32872. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  32873. private static _HandleParenthesisContent;
  32874. private static _SimplifyNegation;
  32875. }
  32876. }
  32877. declare module BABYLON {
  32878. /**
  32879. * Defines the list of states available for a task inside a {BABYLON.AssetsManager}
  32880. */
  32881. enum AssetTaskState {
  32882. /**
  32883. * Initialization
  32884. */
  32885. INIT = 0,
  32886. /**
  32887. * Running
  32888. */
  32889. RUNNING = 1,
  32890. /**
  32891. * Done
  32892. */
  32893. DONE = 2,
  32894. /**
  32895. * Error
  32896. */
  32897. ERROR = 3
  32898. }
  32899. /**
  32900. * Define an abstract asset task used with a {BABYLON.AssetsManager} class to load assets into a scene
  32901. */
  32902. abstract class AbstractAssetTask {
  32903. /**
  32904. * Task name
  32905. */ name: string;
  32906. /**
  32907. * Callback called when the task is successful
  32908. */
  32909. onSuccess: (task: any) => void;
  32910. /**
  32911. * Callback called when the task is not successful
  32912. */
  32913. onError: (task: any, message?: string, exception?: any) => void;
  32914. /**
  32915. * Creates a new {BABYLON.AssetsManager}
  32916. * @param name defines the name of the task
  32917. */
  32918. constructor(
  32919. /**
  32920. * Task name
  32921. */ name: string);
  32922. private _isCompleted;
  32923. private _taskState;
  32924. private _errorObject;
  32925. /**
  32926. * Get if the task is completed
  32927. */
  32928. readonly isCompleted: boolean;
  32929. /**
  32930. * Gets the current state of the task
  32931. */
  32932. readonly taskState: AssetTaskState;
  32933. /**
  32934. * Gets the current error object (if task is in error)
  32935. */
  32936. readonly errorObject: {
  32937. message?: string;
  32938. exception?: any;
  32939. };
  32940. /**
  32941. * Internal only
  32942. * @hidden
  32943. */
  32944. /**
  32945. * Execute the current task
  32946. * @param scene defines the scene where you want your assets to be loaded
  32947. * @param onSuccess is a callback called when the task is successfully executed
  32948. * @param onError is a callback called if an error occurs
  32949. */
  32950. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  32951. /**
  32952. * Execute the current task
  32953. * @param scene defines the scene where you want your assets to be loaded
  32954. * @param onSuccess is a callback called when the task is successfully executed
  32955. * @param onError is a callback called if an error occurs
  32956. */
  32957. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  32958. /**
  32959. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  32960. * This can be used with failed tasks that have the reason for failure fixed.
  32961. */
  32962. reset(): void;
  32963. private onErrorCallback;
  32964. private onDoneCallback;
  32965. }
  32966. /**
  32967. * Define the interface used by progress events raised during assets loading
  32968. */
  32969. interface IAssetsProgressEvent {
  32970. /**
  32971. * Defines the number of remaining tasks to process
  32972. */
  32973. remainingCount: number;
  32974. /**
  32975. * Defines the total number of tasks
  32976. */
  32977. totalCount: number;
  32978. /**
  32979. * Defines the task that was just processed
  32980. */
  32981. task: AbstractAssetTask;
  32982. }
  32983. /**
  32984. * Class used to share progress information about assets loading
  32985. */
  32986. class AssetsProgressEvent implements IAssetsProgressEvent {
  32987. /**
  32988. * Defines the number of remaining tasks to process
  32989. */
  32990. remainingCount: number;
  32991. /**
  32992. * Defines the total number of tasks
  32993. */
  32994. totalCount: number;
  32995. /**
  32996. * Defines the task that was just processed
  32997. */
  32998. task: AbstractAssetTask;
  32999. /**
  33000. * Creates a {BABYLON.AssetsProgressEvent}
  33001. * @param remainingCount defines the number of remaining tasks to process
  33002. * @param totalCount defines the total number of tasks
  33003. * @param task defines the task that was just processed
  33004. */
  33005. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  33006. }
  33007. /**
  33008. * Define a task used by {BABYLON.AssetsManager} to load meshes
  33009. */
  33010. class MeshAssetTask extends AbstractAssetTask {
  33011. /**
  33012. * Defines the name of the task
  33013. */
  33014. name: string;
  33015. /**
  33016. * Defines the list of mesh's names you want to load
  33017. */
  33018. meshesNames: any;
  33019. /**
  33020. * Defines the root url to use as a base to load your meshes and associated resources
  33021. */
  33022. rootUrl: string;
  33023. /**
  33024. * Defines the filename of the scene to load from
  33025. */
  33026. sceneFilename: string;
  33027. /**
  33028. * Gets the list of loaded meshes
  33029. */
  33030. loadedMeshes: Array<AbstractMesh>;
  33031. /**
  33032. * Gets the list of loaded particle systems
  33033. */
  33034. loadedParticleSystems: Array<IParticleSystem>;
  33035. /**
  33036. * Gets the list of loaded skeletons
  33037. */
  33038. loadedSkeletons: Array<Skeleton>;
  33039. /**
  33040. * Callback called when the task is successful
  33041. */
  33042. onSuccess: (task: MeshAssetTask) => void;
  33043. /**
  33044. * Callback called when the task is successful
  33045. */
  33046. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  33047. /**
  33048. * Creates a new {BABYLON.MeshAssetTask}
  33049. * @param name defines the name of the task
  33050. * @param meshesNames defines the list of mesh's names you want to load
  33051. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  33052. * @param sceneFilename defines the filename of the scene to load from
  33053. */
  33054. constructor(
  33055. /**
  33056. * Defines the name of the task
  33057. */
  33058. name: string,
  33059. /**
  33060. * Defines the list of mesh's names you want to load
  33061. */
  33062. meshesNames: any,
  33063. /**
  33064. * Defines the root url to use as a base to load your meshes and associated resources
  33065. */
  33066. rootUrl: string,
  33067. /**
  33068. * Defines the filename of the scene to load from
  33069. */
  33070. sceneFilename: string);
  33071. /**
  33072. * Execute the current task
  33073. * @param scene defines the scene where you want your assets to be loaded
  33074. * @param onSuccess is a callback called when the task is successfully executed
  33075. * @param onError is a callback called if an error occurs
  33076. */
  33077. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  33078. }
  33079. /**
  33080. * Define a task used by {BABYLON.AssetsManager} to load text content
  33081. */
  33082. class TextFileAssetTask extends AbstractAssetTask {
  33083. /**
  33084. * Defines the name of the task
  33085. */
  33086. name: string;
  33087. /**
  33088. * Defines the location of the file to load
  33089. */
  33090. url: string;
  33091. /**
  33092. * Gets the loaded text string
  33093. */
  33094. text: string;
  33095. /**
  33096. * Callback called when the task is successful
  33097. */
  33098. onSuccess: (task: TextFileAssetTask) => void;
  33099. /**
  33100. * Callback called when the task is successful
  33101. */
  33102. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  33103. /**
  33104. * Creates a new TextFileAssetTask object
  33105. * @param name defines the name of the task
  33106. * @param url defines the location of the file to load
  33107. */
  33108. constructor(
  33109. /**
  33110. * Defines the name of the task
  33111. */
  33112. name: string,
  33113. /**
  33114. * Defines the location of the file to load
  33115. */
  33116. url: string);
  33117. /**
  33118. * Execute the current task
  33119. * @param scene defines the scene where you want your assets to be loaded
  33120. * @param onSuccess is a callback called when the task is successfully executed
  33121. * @param onError is a callback called if an error occurs
  33122. */
  33123. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  33124. }
  33125. /**
  33126. * Define a task used by {BABYLON.AssetsManager} to load binary data
  33127. */
  33128. class BinaryFileAssetTask extends AbstractAssetTask {
  33129. /**
  33130. * Defines the name of the task
  33131. */
  33132. name: string;
  33133. /**
  33134. * Defines the location of the file to load
  33135. */
  33136. url: string;
  33137. /**
  33138. * Gets the lodaded data (as an array buffer)
  33139. */
  33140. data: ArrayBuffer;
  33141. /**
  33142. * Callback called when the task is successful
  33143. */
  33144. onSuccess: (task: BinaryFileAssetTask) => void;
  33145. /**
  33146. * Callback called when the task is successful
  33147. */
  33148. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  33149. /**
  33150. * Creates a new BinaryFileAssetTask object
  33151. * @param name defines the name of the new task
  33152. * @param url defines the location of the file to load
  33153. */
  33154. constructor(
  33155. /**
  33156. * Defines the name of the task
  33157. */
  33158. name: string,
  33159. /**
  33160. * Defines the location of the file to load
  33161. */
  33162. url: string);
  33163. /**
  33164. * Execute the current task
  33165. * @param scene defines the scene where you want your assets to be loaded
  33166. * @param onSuccess is a callback called when the task is successfully executed
  33167. * @param onError is a callback called if an error occurs
  33168. */
  33169. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  33170. }
  33171. /**
  33172. * Define a task used by {BABYLON.AssetsManager} to load images
  33173. */
  33174. class ImageAssetTask extends AbstractAssetTask {
  33175. /**
  33176. * Defines the name of the task
  33177. */
  33178. name: string;
  33179. /**
  33180. * Defines the location of the image to load
  33181. */
  33182. url: string;
  33183. /**
  33184. * Gets the loaded images
  33185. */
  33186. image: HTMLImageElement;
  33187. /**
  33188. * Callback called when the task is successful
  33189. */
  33190. onSuccess: (task: ImageAssetTask) => void;
  33191. /**
  33192. * Callback called when the task is successful
  33193. */
  33194. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  33195. /**
  33196. * Creates a new ImageAssetTask
  33197. * @param name defines the name of the task
  33198. * @param url defines the location of the image to load
  33199. */
  33200. constructor(
  33201. /**
  33202. * Defines the name of the task
  33203. */
  33204. name: string,
  33205. /**
  33206. * Defines the location of the image to load
  33207. */
  33208. url: string);
  33209. /**
  33210. * Execute the current task
  33211. * @param scene defines the scene where you want your assets to be loaded
  33212. * @param onSuccess is a callback called when the task is successfully executed
  33213. * @param onError is a callback called if an error occurs
  33214. */
  33215. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  33216. }
  33217. /**
  33218. * Defines the interface used by texture loading tasks
  33219. */
  33220. interface ITextureAssetTask<TEX extends BaseTexture> {
  33221. /**
  33222. * Gets the loaded texture
  33223. */
  33224. texture: TEX;
  33225. }
  33226. /**
  33227. * Define a task used by {BABYLON.AssetsManager} to load 2D textures
  33228. */
  33229. class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  33230. /**
  33231. * Defines the name of the task
  33232. */
  33233. name: string;
  33234. /**
  33235. * Defines the location of the file to load
  33236. */
  33237. url: string;
  33238. /**
  33239. * Defines if mipmap should not be generated (default is false)
  33240. */
  33241. noMipmap?: boolean | undefined;
  33242. /**
  33243. * Defines if texture must be inverted on Y axis (default is false)
  33244. */
  33245. invertY?: boolean | undefined;
  33246. /**
  33247. * Defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  33248. */
  33249. samplingMode: number;
  33250. /**
  33251. * Gets the loaded texture
  33252. */
  33253. texture: Texture;
  33254. /**
  33255. * Callback called when the task is successful
  33256. */
  33257. onSuccess: (task: TextureAssetTask) => void;
  33258. /**
  33259. * Callback called when the task is successful
  33260. */
  33261. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  33262. /**
  33263. * Creates a new TextureAssetTask object
  33264. * @param name defines the name of the task
  33265. * @param url defines the location of the file to load
  33266. * @param noMipmap defines if mipmap should not be generated (default is false)
  33267. * @param invertY defines if texture must be inverted on Y axis (default is false)
  33268. * @param samplingMode defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  33269. */
  33270. constructor(
  33271. /**
  33272. * Defines the name of the task
  33273. */
  33274. name: string,
  33275. /**
  33276. * Defines the location of the file to load
  33277. */
  33278. url: string,
  33279. /**
  33280. * Defines if mipmap should not be generated (default is false)
  33281. */
  33282. noMipmap?: boolean | undefined,
  33283. /**
  33284. * Defines if texture must be inverted on Y axis (default is false)
  33285. */
  33286. invertY?: boolean | undefined,
  33287. /**
  33288. * Defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  33289. */
  33290. samplingMode?: number);
  33291. /**
  33292. * Execute the current task
  33293. * @param scene defines the scene where you want your assets to be loaded
  33294. * @param onSuccess is a callback called when the task is successfully executed
  33295. * @param onError is a callback called if an error occurs
  33296. */
  33297. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  33298. }
  33299. /**
  33300. * Define a task used by {BABYLON.AssetsManager} to load cube textures
  33301. */
  33302. class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  33303. /**
  33304. * Defines the name of the task
  33305. */
  33306. name: string;
  33307. /**
  33308. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  33309. */
  33310. url: string;
  33311. /**
  33312. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  33313. */
  33314. extensions?: string[] | undefined;
  33315. /**
  33316. * Defines if mipmaps should not be generated (default is false)
  33317. */
  33318. noMipmap?: boolean | undefined;
  33319. /**
  33320. * Defines the explicit list of files (undefined by default)
  33321. */
  33322. files?: string[] | undefined;
  33323. /**
  33324. * Gets the loaded texture
  33325. */
  33326. texture: CubeTexture;
  33327. /**
  33328. * Callback called when the task is successful
  33329. */
  33330. onSuccess: (task: CubeTextureAssetTask) => void;
  33331. /**
  33332. * Callback called when the task is successful
  33333. */
  33334. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  33335. /**
  33336. * Creates a new CubeTextureAssetTask
  33337. * @param name defines the name of the task
  33338. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  33339. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  33340. * @param noMipmap defines if mipmaps should not be generated (default is false)
  33341. * @param files defines the explicit list of files (undefined by default)
  33342. */
  33343. constructor(
  33344. /**
  33345. * Defines the name of the task
  33346. */
  33347. name: string,
  33348. /**
  33349. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  33350. */
  33351. url: string,
  33352. /**
  33353. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  33354. */
  33355. extensions?: string[] | undefined,
  33356. /**
  33357. * Defines if mipmaps should not be generated (default is false)
  33358. */
  33359. noMipmap?: boolean | undefined,
  33360. /**
  33361. * Defines the explicit list of files (undefined by default)
  33362. */
  33363. files?: string[] | undefined);
  33364. /**
  33365. * Execute the current task
  33366. * @param scene defines the scene where you want your assets to be loaded
  33367. * @param onSuccess is a callback called when the task is successfully executed
  33368. * @param onError is a callback called if an error occurs
  33369. */
  33370. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  33371. }
  33372. /**
  33373. * Define a task used by {BABYLON.AssetsManager} to load HDR cube textures
  33374. */
  33375. class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  33376. /**
  33377. * Defines the name of the task
  33378. */
  33379. name: string;
  33380. /**
  33381. * Defines the location of the file to load
  33382. */
  33383. url: string;
  33384. /**
  33385. * Defines the desired size (the more it increases the longer the generation will be)
  33386. */
  33387. size: number;
  33388. /**
  33389. * Defines if mipmaps should not be generated (default is false)
  33390. */
  33391. noMipmap: boolean;
  33392. /**
  33393. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  33394. */
  33395. generateHarmonics: boolean;
  33396. /**
  33397. * 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)
  33398. */
  33399. gammaSpace: boolean;
  33400. /**
  33401. * Internal Use Only
  33402. */
  33403. reserved: boolean;
  33404. /**
  33405. * Gets the loaded texture
  33406. */
  33407. texture: HDRCubeTexture;
  33408. /**
  33409. * Callback called when the task is successful
  33410. */
  33411. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  33412. /**
  33413. * Callback called when the task is successful
  33414. */
  33415. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  33416. /**
  33417. * Creates a new HDRCubeTextureAssetTask object
  33418. * @param name defines the name of the task
  33419. * @param url defines the location of the file to load
  33420. * @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.
  33421. * @param noMipmap defines if mipmaps should not be generated (default is false)
  33422. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  33423. * @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)
  33424. * @param reserved Internal use only
  33425. */
  33426. constructor(
  33427. /**
  33428. * Defines the name of the task
  33429. */
  33430. name: string,
  33431. /**
  33432. * Defines the location of the file to load
  33433. */
  33434. url: string,
  33435. /**
  33436. * Defines the desired size (the more it increases the longer the generation will be)
  33437. */
  33438. size: number,
  33439. /**
  33440. * Defines if mipmaps should not be generated (default is false)
  33441. */
  33442. noMipmap?: boolean,
  33443. /**
  33444. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  33445. */
  33446. generateHarmonics?: boolean,
  33447. /**
  33448. * 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)
  33449. */
  33450. gammaSpace?: boolean,
  33451. /**
  33452. * Internal Use Only
  33453. */
  33454. reserved?: boolean);
  33455. /**
  33456. * Execute the current task
  33457. * @param scene defines the scene where you want your assets to be loaded
  33458. * @param onSuccess is a callback called when the task is successfully executed
  33459. * @param onError is a callback called if an error occurs
  33460. */
  33461. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  33462. }
  33463. /**
  33464. * This class can be used to easily import assets into a scene
  33465. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  33466. */
  33467. class AssetsManager {
  33468. private _scene;
  33469. private _isLoading;
  33470. protected _tasks: AbstractAssetTask[];
  33471. protected _waitingTasksCount: number;
  33472. protected _totalTasksCount: number;
  33473. /**
  33474. * Callback called when all tasks are processed
  33475. */
  33476. onFinish: (tasks: AbstractAssetTask[]) => void;
  33477. /**
  33478. * Callback called when a task is successful
  33479. */
  33480. onTaskSuccess: (task: AbstractAssetTask) => void;
  33481. /**
  33482. * Callback called when a task had an error
  33483. */
  33484. onTaskError: (task: AbstractAssetTask) => void;
  33485. /**
  33486. * Callback called when a task is done (whatever the result is)
  33487. */
  33488. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  33489. /**
  33490. * Observable called when all tasks are processed
  33491. */
  33492. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  33493. /**
  33494. * Observable called when a task had an error
  33495. */
  33496. onTaskErrorObservable: Observable<AbstractAssetTask>;
  33497. /**
  33498. * Observable called when a task is successful
  33499. */
  33500. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  33501. /**
  33502. * Observable called when a task is done (whatever the result is)
  33503. */
  33504. onProgressObservable: Observable<IAssetsProgressEvent>;
  33505. /**
  33506. * Gets or sets a boolean defining if the {BABYLON.AssetsManager} should use the default loading screen
  33507. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33508. */
  33509. useDefaultLoadingScreen: boolean;
  33510. /**
  33511. * Creates a new AssetsManager
  33512. * @param scene defines the scene to work on
  33513. */
  33514. constructor(scene: Scene);
  33515. /**
  33516. * Add a {BABYLON.MeshAssetTask} to the list of active tasks
  33517. * @param taskName defines the name of the new task
  33518. * @param meshesNames defines the name of meshes to load
  33519. * @param rootUrl defines the root url to use to locate files
  33520. * @param sceneFilename defines the filename of the scene file
  33521. * @returns a new {BABYLON.MeshAssetTask} object
  33522. */
  33523. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  33524. /**
  33525. * Add a {BABYLON.TextFileAssetTask} to the list of active tasks
  33526. * @param taskName defines the name of the new task
  33527. * @param url defines the url of the file to load
  33528. * @returns a new {BABYLON.TextFileAssetTask} object
  33529. */
  33530. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  33531. /**
  33532. * Add a {BABYLON.BinaryFileAssetTask} to the list of active tasks
  33533. * @param taskName defines the name of the new task
  33534. * @param url defines the url of the file to load
  33535. * @returns a new {BABYLON.BinaryFileAssetTask} object
  33536. */
  33537. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  33538. /**
  33539. * Add a {BABYLON.ImageAssetTask} to the list of active tasks
  33540. * @param taskName defines the name of the new task
  33541. * @param url defines the url of the file to load
  33542. * @returns a new {BABYLON.ImageAssetTask} object
  33543. */
  33544. addImageTask(taskName: string, url: string): ImageAssetTask;
  33545. /**
  33546. * Add a {BABYLON.TextureAssetTask} to the list of active tasks
  33547. * @param taskName defines the name of the new task
  33548. * @param url defines the url of the file to load
  33549. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  33550. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  33551. * @param samplingMode defines the sampling mode to use (BABYLON.Texture.TRILINEAR_SAMPLINGMODE by default)
  33552. * @returns a new {BABYLON.TextureAssetTask} object
  33553. */
  33554. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  33555. /**
  33556. * Add a {BABYLON.CubeTextureAssetTask} to the list of active tasks
  33557. * @param taskName defines the name of the new task
  33558. * @param url defines the url of the file to load
  33559. * @param extensions defines the extension to use to load the cube map (can be null)
  33560. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  33561. * @param files defines the list of files to load (can be null)
  33562. * @returns a new {BABYLON.CubeTextureAssetTask} object
  33563. */
  33564. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  33565. /**
  33566. *
  33567. * Add a {BABYLON.HDRCubeTextureAssetTask} to the list of active tasks
  33568. * @param taskName defines the name of the new task
  33569. * @param url defines the url of the file to load
  33570. * @param size defines the size you want for the cubemap (can be null)
  33571. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  33572. * @param generateHarmonics defines if you want to automatically generate (true by default)
  33573. * @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)
  33574. * @param reserved Internal use only
  33575. * @returns a new {BABYLON.HDRCubeTextureAssetTask} object
  33576. */
  33577. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  33578. /**
  33579. * Remove a task from the assets manager.
  33580. * @param task the task to remove
  33581. */
  33582. removeTask(task: AbstractAssetTask): void;
  33583. private _decreaseWaitingTasksCount;
  33584. private _runTask;
  33585. /**
  33586. * Reset the {BABYLON.AssetsManager} and remove all tasks
  33587. * @return the current instance of the {BABYLON.AssetsManager}
  33588. */
  33589. reset(): AssetsManager;
  33590. /**
  33591. * Start the loading process
  33592. * @return the current instance of the {BABYLON.AssetsManager}
  33593. */
  33594. load(): AssetsManager;
  33595. }
  33596. }
  33597. declare module BABYLON {
  33598. /**
  33599. * Class used to enable access to IndexedDB
  33600. * @see @https://developer.mozilla.org/en-US/docs/Web/API/IndexedDB_API
  33601. */
  33602. class Database {
  33603. private callbackManifestChecked;
  33604. private currentSceneUrl;
  33605. private db;
  33606. private _enableSceneOffline;
  33607. private _enableTexturesOffline;
  33608. private manifestVersionFound;
  33609. private mustUpdateRessources;
  33610. private hasReachedQuota;
  33611. private isSupported;
  33612. private idbFactory;
  33613. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  33614. static IsUASupportingBlobStorage: boolean;
  33615. /** Gets a boolean indicating if Database storate is enabled */
  33616. static IDBStorageEnabled: boolean;
  33617. /**
  33618. * Gets a boolean indicating if scene must be saved in the database
  33619. */
  33620. readonly enableSceneOffline: boolean;
  33621. /**
  33622. * Gets a boolean indicating if textures must be saved in the database
  33623. */
  33624. readonly enableTexturesOffline: boolean;
  33625. /**
  33626. * Creates a new Database
  33627. * @param urlToScene defines the url to load the scene
  33628. * @param callbackManifestChecked defines the callback to use when manifest is checked
  33629. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  33630. */
  33631. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  33632. private static _ParseURL;
  33633. private static _ReturnFullUrlLocation;
  33634. private _checkManifestFile;
  33635. /**
  33636. * Open the database and make it available
  33637. * @param successCallback defines the callback to call on success
  33638. * @param errorCallback defines the callback to call on error
  33639. */
  33640. openAsync(successCallback: () => void, errorCallback: () => void): void;
  33641. /**
  33642. * Loads an image from the database
  33643. * @param url defines the url to load from
  33644. * @param image defines the target DOM image
  33645. */
  33646. loadImageFromDB(url: string, image: HTMLImageElement): void;
  33647. private _loadImageFromDBAsync;
  33648. private _saveImageIntoDBAsync;
  33649. private _checkVersionFromDB;
  33650. private _loadVersionFromDBAsync;
  33651. private _saveVersionIntoDBAsync;
  33652. /**
  33653. * Loads a file from database
  33654. * @param url defines the URL to load from
  33655. * @param sceneLoaded defines a callback to call on success
  33656. * @param progressCallBack defines a callback to call when progress changed
  33657. * @param errorCallback defines a callback to call on error
  33658. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  33659. */
  33660. loadFileFromDB(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  33661. private _loadFileFromDBAsync;
  33662. private _saveFileIntoDBAsync;
  33663. }
  33664. }
  33665. declare module BABYLON {
  33666. interface DDSInfo {
  33667. width: number;
  33668. height: number;
  33669. mipmapCount: number;
  33670. isFourCC: boolean;
  33671. isRGB: boolean;
  33672. isLuminance: boolean;
  33673. isCube: boolean;
  33674. isCompressed: boolean;
  33675. dxgiFormat: number;
  33676. textureType: number;
  33677. /** Sphericle polynomial created for the dds texture */
  33678. sphericalPolynomial?: SphericalPolynomial;
  33679. }
  33680. class DDSTools {
  33681. static StoreLODInAlphaChannel: boolean;
  33682. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  33683. private static _FloatView;
  33684. private static _Int32View;
  33685. private static _ToHalfFloat;
  33686. private static _FromHalfFloat;
  33687. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  33688. private static _GetHalfFloatRGBAArrayBuffer;
  33689. private static _GetFloatRGBAArrayBuffer;
  33690. private static _GetFloatAsUIntRGBAArrayBuffer;
  33691. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  33692. private static _GetRGBAArrayBuffer;
  33693. private static _ExtractLongWordOrder;
  33694. private static _GetRGBArrayBuffer;
  33695. private static _GetLuminanceArrayBuffer;
  33696. /**
  33697. * Uploads DDS Levels to a Babylon Texture
  33698. * @hidden
  33699. */
  33700. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  33701. }
  33702. }
  33703. declare module BABYLON {
  33704. function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  33705. function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33706. function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33707. function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33708. function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33709. function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33710. function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33711. function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33712. function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33713. function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33714. function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33715. function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33716. /**
  33717. * Decorator used to define property that can be serialized as reference to a camera
  33718. * @param sourceName defines the name of the property to decorate
  33719. */
  33720. function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33721. class SerializationHelper {
  33722. static Serialize<T>(entity: T, serializationObject?: any): any;
  33723. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  33724. static Clone<T>(creationFunction: () => T, source: T): T;
  33725. static Instanciate<T>(creationFunction: () => T, source: T): T;
  33726. }
  33727. }
  33728. declare module BABYLON {
  33729. /**
  33730. * Wrapper class for promise with external resolve and reject.
  33731. */
  33732. class Deferred<T> {
  33733. /**
  33734. * The promise associated with this deferred object.
  33735. */
  33736. readonly promise: Promise<T>;
  33737. private _resolve;
  33738. private _reject;
  33739. /**
  33740. * The resolve method of the promise associated with this deferred object.
  33741. */
  33742. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  33743. /**
  33744. * The reject method of the promise associated with this deferred object.
  33745. */
  33746. readonly reject: (reason?: any) => void;
  33747. /**
  33748. * Constructor for this deferred object.
  33749. */
  33750. constructor();
  33751. }
  33752. }
  33753. declare module BABYLON {
  33754. /**
  33755. * Raw texture data and descriptor sufficient for WebGL texture upload
  33756. */
  33757. interface EnvironmentTextureInfo {
  33758. /**
  33759. * Version of the environment map
  33760. */
  33761. version: number;
  33762. /**
  33763. * Width of image
  33764. */
  33765. width: number;
  33766. /**
  33767. * Irradiance information stored in the file.
  33768. */
  33769. irradiance: any;
  33770. /**
  33771. * Specular information stored in the file.
  33772. */
  33773. specular: any;
  33774. }
  33775. /**
  33776. * Sets of helpers addressing the serialization and deserialization of environment texture
  33777. * stored in a BabylonJS env file.
  33778. * Those files are usually stored as .env files.
  33779. */
  33780. class EnvironmentTextureTools {
  33781. /**
  33782. * Magic number identifying the env file.
  33783. */
  33784. private static _MagicBytes;
  33785. /**
  33786. * Gets the environment info from an env file.
  33787. * @param data The array buffer containing the .env bytes.
  33788. * @returns the environment file info (the json header) if successfully parsed.
  33789. */
  33790. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  33791. /**
  33792. * Creates an environment texture from a loaded cube texture.
  33793. * @param texture defines the cube texture to convert in env file
  33794. * @return a promise containing the environment data if succesfull.
  33795. */
  33796. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  33797. /**
  33798. * Creates a JSON representation of the spherical data.
  33799. * @param texture defines the texture containing the polynomials
  33800. * @return the JSON representation of the spherical info
  33801. */
  33802. private static _CreateEnvTextureIrradiance;
  33803. /**
  33804. * Uploads the texture info contained in the env file to the GPU.
  33805. * @param texture defines the internal texture to upload to
  33806. * @param arrayBuffer defines the buffer cotaining the data to load
  33807. * @param info defines the texture info retrieved through the GetEnvInfo method
  33808. * @returns a promise
  33809. */
  33810. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  33811. /**
  33812. * Uploads the levels of image data to the GPU.
  33813. * @param texture defines the internal texture to upload to
  33814. * @param imageData defines the array buffer views of image data [mipmap][face]
  33815. * @returns a promise
  33816. */
  33817. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  33818. /**
  33819. * Uploads spherical polynomials information to the texture.
  33820. * @param texture defines the texture we are trying to upload the information to
  33821. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  33822. */
  33823. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  33824. }
  33825. }
  33826. declare module BABYLON {
  33827. class FilesInput {
  33828. static FilesToLoad: {
  33829. [key: string]: File;
  33830. };
  33831. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  33832. private _engine;
  33833. private _currentScene;
  33834. private _sceneLoadedCallback;
  33835. private _progressCallback;
  33836. private _additionalRenderLoopLogicCallback;
  33837. private _textureLoadingCallback;
  33838. private _startingProcessingFilesCallback;
  33839. private _onReloadCallback;
  33840. private _errorCallback;
  33841. private _elementToMonitor;
  33842. private _sceneFileToLoad;
  33843. private _filesToLoad;
  33844. 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);
  33845. private _dragEnterHandler;
  33846. private _dragOverHandler;
  33847. private _dropHandler;
  33848. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  33849. dispose(): void;
  33850. private renderFunction;
  33851. private drag;
  33852. private drop;
  33853. private _traverseFolder;
  33854. private _processFiles;
  33855. loadFiles(event: any): void;
  33856. private _processReload;
  33857. reload(): void;
  33858. }
  33859. }
  33860. declare module BABYLON {
  33861. /**
  33862. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  33863. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  33864. */
  33865. class KhronosTextureContainer {
  33866. arrayBuffer: any;
  33867. static HEADER_LEN: number;
  33868. static COMPRESSED_2D: number;
  33869. static COMPRESSED_3D: number;
  33870. static TEX_2D: number;
  33871. static TEX_3D: number;
  33872. glType: number;
  33873. glTypeSize: number;
  33874. glFormat: number;
  33875. glInternalFormat: number;
  33876. glBaseInternalFormat: number;
  33877. pixelWidth: number;
  33878. pixelHeight: number;
  33879. pixelDepth: number;
  33880. numberOfArrayElements: number;
  33881. numberOfFaces: number;
  33882. numberOfMipmapLevels: number;
  33883. bytesOfKeyValueData: number;
  33884. loadType: number;
  33885. /**
  33886. * @param {ArrayBuffer} arrayBuffer- contents of the KTX container file
  33887. * @param {number} facesExpected- should be either 1 or 6, based whether a cube texture or or
  33888. * @param {boolean} threeDExpected- provision for indicating that data should be a 3D texture, not implemented
  33889. * @param {boolean} textureArrayExpected- provision for indicating that data should be a texture array, not implemented
  33890. */
  33891. constructor(arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  33892. switchEndainness(val: number): number;
  33893. /**
  33894. * Uploads KTX content to a Babylon Texture.
  33895. * It is assumed that the texture has already been created & is currently bound
  33896. * @hidden
  33897. */
  33898. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  33899. private _upload2DCompressedLevels;
  33900. }
  33901. }
  33902. declare module BABYLON {
  33903. /**
  33904. * A class serves as a medium between the observable and its observers
  33905. */
  33906. class EventState {
  33907. /**
  33908. * Create a new EventState
  33909. * @param mask defines the mask associated with this state
  33910. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  33911. * @param target defines the original target of the state
  33912. * @param currentTarget defines the current target of the state
  33913. */
  33914. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  33915. /**
  33916. * Initialize the current event state
  33917. * @param mask defines the mask associated with this state
  33918. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  33919. * @param target defines the original target of the state
  33920. * @param currentTarget defines the current target of the state
  33921. * @returns the current event state
  33922. */
  33923. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  33924. /**
  33925. * An Observer can set this property to true to prevent subsequent observers of being notified
  33926. */
  33927. skipNextObservers: boolean;
  33928. /**
  33929. * Get the mask value that were used to trigger the event corresponding to this EventState object
  33930. */
  33931. mask: number;
  33932. /**
  33933. * The object that originally notified the event
  33934. */
  33935. target?: any;
  33936. /**
  33937. * The current object in the bubbling phase
  33938. */
  33939. currentTarget?: any;
  33940. /**
  33941. * This will be populated with the return value of the last function that was executed.
  33942. * If it is the first function in the callback chain it will be the event data.
  33943. */
  33944. lastReturnValue?: any;
  33945. }
  33946. /**
  33947. * Represent an Observer registered to a given Observable object.
  33948. */
  33949. class Observer<T> {
  33950. /**
  33951. * Defines the callback to call when the observer is notified
  33952. */
  33953. callback: (eventData: T, eventState: EventState) => void;
  33954. /**
  33955. * Defines the mask of the observer (used to filter notifications)
  33956. */
  33957. mask: number;
  33958. /**
  33959. * Defines the current scope used to restore the JS context
  33960. */
  33961. scope: any;
  33962. /** @hidden */
  33963. /**
  33964. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  33965. */
  33966. unregisterOnNextCall: boolean;
  33967. /**
  33968. * Creates a new observer
  33969. * @param callback defines the callback to call when the observer is notified
  33970. * @param mask defines the mask of the observer (used to filter notifications)
  33971. * @param scope defines the current scope used to restore the JS context
  33972. */
  33973. constructor(
  33974. /**
  33975. * Defines the callback to call when the observer is notified
  33976. */
  33977. callback: (eventData: T, eventState: EventState) => void,
  33978. /**
  33979. * Defines the mask of the observer (used to filter notifications)
  33980. */
  33981. mask: number,
  33982. /**
  33983. * Defines the current scope used to restore the JS context
  33984. */
  33985. scope?: any);
  33986. }
  33987. /**
  33988. * Represent a list of observers registered to multiple Observables object.
  33989. */
  33990. class MultiObserver<T> {
  33991. private _observers;
  33992. private _observables;
  33993. /**
  33994. * Release associated resources
  33995. */
  33996. dispose(): void;
  33997. /**
  33998. * Raise a callback when one of the observable will notify
  33999. * @param observables defines a list of observables to watch
  34000. * @param callback defines the callback to call on notification
  34001. * @param mask defines the mask used to filter notifications
  34002. * @param scope defines the current scope used to restore the JS context
  34003. * @returns the new MultiObserver
  34004. */
  34005. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  34006. }
  34007. /**
  34008. * The Observable class is a simple implementation of the Observable pattern.
  34009. *
  34010. * 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.
  34011. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  34012. * 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).
  34013. * 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.
  34014. */
  34015. class Observable<T> {
  34016. private _observers;
  34017. private _eventState;
  34018. private _onObserverAdded;
  34019. /**
  34020. * Creates a new observable
  34021. * @param onObserverAdded defines a callback to call when a new observer is added
  34022. */
  34023. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  34024. /**
  34025. * Create a new Observer with the specified callback
  34026. * @param callback the callback that will be executed for that Observer
  34027. * @param mask the mask used to filter observers
  34028. * @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.
  34029. * @param scope optional scope for the callback to be called from
  34030. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  34031. * @returns the new observer created for the callback
  34032. */
  34033. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  34034. /**
  34035. * Create a new Observer with the specified callback and unregisters after the next notification
  34036. * @param callback the callback that will be executed for that Observer
  34037. * @returns the new observer created for the callback
  34038. */
  34039. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  34040. /**
  34041. * Remove an Observer from the Observable object
  34042. * @param observer the instance of the Observer to remove
  34043. * @returns false if it doesn't belong to this Observable
  34044. */
  34045. remove(observer: Nullable<Observer<T>>): boolean;
  34046. /**
  34047. * Remove a callback from the Observable object
  34048. * @param callback the callback to remove
  34049. * @param scope optional scope. If used only the callbacks with this scope will be removed
  34050. * @returns false if it doesn't belong to this Observable
  34051. */
  34052. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  34053. private _deferUnregister;
  34054. private _remove;
  34055. /**
  34056. * Notify all Observers by calling their respective callback with the given data
  34057. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  34058. * @param eventData defines the data to send to all observers
  34059. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  34060. * @param target defines the original target of the state
  34061. * @param currentTarget defines the current target of the state
  34062. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  34063. */
  34064. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  34065. /**
  34066. * Calling this will execute each callback, expecting it to be a promise or return a value.
  34067. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  34068. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  34069. * and it is crucial that all callbacks will be executed.
  34070. * The order of the callbacks is kept, callbacks are not executed parallel.
  34071. *
  34072. * @param eventData The data to be sent to each callback
  34073. * @param mask is used to filter observers defaults to -1
  34074. * @param target defines the callback target (see EventState)
  34075. * @param currentTarget defines he current object in the bubbling phase
  34076. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  34077. */
  34078. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  34079. /**
  34080. * Notify a specific observer
  34081. * @param observer defines the observer to notify
  34082. * @param eventData defines the data to be sent to each callback
  34083. * @param mask is used to filter observers defaults to -1
  34084. */
  34085. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  34086. /**
  34087. * Gets a boolean indicating if the observable has at least one observer
  34088. * @returns true is the Observable has at least one Observer registered
  34089. */
  34090. hasObservers(): boolean;
  34091. /**
  34092. * Clear the list of observers
  34093. */
  34094. clear(): void;
  34095. /**
  34096. * Clone the current observable
  34097. * @returns a new observable
  34098. */
  34099. clone(): Observable<T>;
  34100. /**
  34101. * Does this observable handles observer registered with a given mask
  34102. * @param mask defines the mask to be tested
  34103. * @return whether or not one observer registered with the given mask is handeled
  34104. **/
  34105. hasSpecificMask(mask?: number): boolean;
  34106. }
  34107. }
  34108. declare module BABYLON {
  34109. /**
  34110. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  34111. */
  34112. class PerformanceMonitor {
  34113. private _enabled;
  34114. private _rollingFrameTime;
  34115. private _lastFrameTimeMs;
  34116. /**
  34117. * constructor
  34118. * @param frameSampleSize The number of samples required to saturate the sliding window
  34119. */
  34120. constructor(frameSampleSize?: number);
  34121. /**
  34122. * Samples current frame
  34123. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  34124. */
  34125. sampleFrame(timeMs?: number): void;
  34126. /**
  34127. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  34128. * @return Average frame time in milliseconds
  34129. */
  34130. readonly averageFrameTime: number;
  34131. /**
  34132. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  34133. * @return Frame time variance in milliseconds squared
  34134. */
  34135. readonly averageFrameTimeVariance: number;
  34136. /**
  34137. * Returns the frame time of the most recent frame
  34138. * @return Frame time in milliseconds
  34139. */
  34140. readonly instantaneousFrameTime: number;
  34141. /**
  34142. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  34143. * @return Framerate in frames per second
  34144. */
  34145. readonly averageFPS: number;
  34146. /**
  34147. * Returns the average framerate in frames per second using the most recent frame time
  34148. * @return Framerate in frames per second
  34149. */
  34150. readonly instantaneousFPS: number;
  34151. /**
  34152. * Returns true if enough samples have been taken to completely fill the sliding window
  34153. * @return true if saturated
  34154. */
  34155. readonly isSaturated: boolean;
  34156. /**
  34157. * Enables contributions to the sliding window sample set
  34158. */
  34159. enable(): void;
  34160. /**
  34161. * Disables contributions to the sliding window sample set
  34162. * Samples will not be interpolated over the disabled period
  34163. */
  34164. disable(): void;
  34165. /**
  34166. * Returns true if sampling is enabled
  34167. * @return true if enabled
  34168. */
  34169. readonly isEnabled: boolean;
  34170. /**
  34171. * Resets performance monitor
  34172. */
  34173. reset(): void;
  34174. }
  34175. /**
  34176. * RollingAverage
  34177. *
  34178. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  34179. */
  34180. class RollingAverage {
  34181. /**
  34182. * Current average
  34183. */
  34184. average: number;
  34185. /**
  34186. * Current variance
  34187. */
  34188. variance: number;
  34189. protected _samples: Array<number>;
  34190. protected _sampleCount: number;
  34191. protected _pos: number;
  34192. protected _m2: number;
  34193. /**
  34194. * constructor
  34195. * @param length The number of samples required to saturate the sliding window
  34196. */
  34197. constructor(length: number);
  34198. /**
  34199. * Adds a sample to the sample set
  34200. * @param v The sample value
  34201. */
  34202. add(v: number): void;
  34203. /**
  34204. * Returns previously added values or null if outside of history or outside the sliding window domain
  34205. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  34206. * @return Value previously recorded with add() or null if outside of range
  34207. */
  34208. history(i: number): number;
  34209. /**
  34210. * Returns true if enough samples have been taken to completely fill the sliding window
  34211. * @return true if sample-set saturated
  34212. */
  34213. isSaturated(): boolean;
  34214. /**
  34215. * Resets the rolling average (equivalent to 0 samples taken so far)
  34216. */
  34217. reset(): void;
  34218. /**
  34219. * Wraps a value around the sample range boundaries
  34220. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  34221. * @return Wrapped position in sample range
  34222. */
  34223. protected _wrapPosition(i: number): number;
  34224. }
  34225. }
  34226. declare module BABYLON {
  34227. /**
  34228. * Helper class that provides a small promise polyfill
  34229. */
  34230. class PromisePolyfill {
  34231. /**
  34232. * Static function used to check if the polyfill is required
  34233. * If this is the case then the function will inject the polyfill to window.Promise
  34234. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  34235. */
  34236. static Apply(force?: boolean): void;
  34237. }
  34238. }
  34239. declare module BABYLON {
  34240. /**
  34241. * Defines the root class used to create scene optimization to use with SceneOptimizer
  34242. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  34243. */
  34244. class SceneOptimization {
  34245. /**
  34246. * Defines the priority of this optimization (0 by default which means first in the list)
  34247. */
  34248. priority: number;
  34249. /**
  34250. * Gets a string describing the action executed by the current optimization
  34251. * @returns description string
  34252. */
  34253. getDescription(): string;
  34254. /**
  34255. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  34256. * @param scene defines the current scene where to apply this optimization
  34257. * @param optimizer defines the current optimizer
  34258. * @returns true if everything that can be done was applied
  34259. */
  34260. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  34261. /**
  34262. * Creates the SceneOptimization object
  34263. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  34264. * @param desc defines the description associated with the optimization
  34265. */
  34266. constructor(
  34267. /**
  34268. * Defines the priority of this optimization (0 by default which means first in the list)
  34269. */
  34270. priority?: number);
  34271. }
  34272. /**
  34273. * Defines an optimization used to reduce the size of render target textures
  34274. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  34275. */
  34276. class TextureOptimization extends SceneOptimization {
  34277. /**
  34278. * Defines the priority of this optimization (0 by default which means first in the list)
  34279. */
  34280. priority: number;
  34281. /**
  34282. * 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
  34283. */
  34284. maximumSize: number;
  34285. /**
  34286. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  34287. */
  34288. step: number;
  34289. /**
  34290. * Gets a string describing the action executed by the current optimization
  34291. * @returns description string
  34292. */
  34293. getDescription(): string;
  34294. /**
  34295. * Creates the TextureOptimization object
  34296. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  34297. * @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
  34298. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  34299. */
  34300. constructor(
  34301. /**
  34302. * Defines the priority of this optimization (0 by default which means first in the list)
  34303. */
  34304. priority?: number,
  34305. /**
  34306. * 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
  34307. */
  34308. maximumSize?: number,
  34309. /**
  34310. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  34311. */
  34312. step?: number);
  34313. /**
  34314. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  34315. * @param scene defines the current scene where to apply this optimization
  34316. * @param optimizer defines the current optimizer
  34317. * @returns true if everything that can be done was applied
  34318. */
  34319. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  34320. }
  34321. /**
  34322. * Defines an optimization used to increase or decrease the rendering resolution
  34323. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  34324. */
  34325. class HardwareScalingOptimization extends SceneOptimization {
  34326. /**
  34327. * Defines the priority of this optimization (0 by default which means first in the list)
  34328. */
  34329. priority: number;
  34330. /**
  34331. * Defines the maximum scale to use (2 by default)
  34332. */
  34333. maximumScale: number;
  34334. /**
  34335. * Defines the step to use between two passes (0.5 by default)
  34336. */
  34337. step: number;
  34338. private _currentScale;
  34339. private _directionOffset;
  34340. /**
  34341. * Gets a string describing the action executed by the current optimization
  34342. * @return description string
  34343. */
  34344. getDescription(): string;
  34345. /**
  34346. * Creates the HardwareScalingOptimization object
  34347. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  34348. * @param maximumScale defines the maximum scale to use (2 by default)
  34349. * @param step defines the step to use between two passes (0.5 by default)
  34350. */
  34351. constructor(
  34352. /**
  34353. * Defines the priority of this optimization (0 by default which means first in the list)
  34354. */
  34355. priority?: number,
  34356. /**
  34357. * Defines the maximum scale to use (2 by default)
  34358. */
  34359. maximumScale?: number,
  34360. /**
  34361. * Defines the step to use between two passes (0.5 by default)
  34362. */
  34363. step?: number);
  34364. /**
  34365. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  34366. * @param scene defines the current scene where to apply this optimization
  34367. * @param optimizer defines the current optimizer
  34368. * @returns true if everything that can be done was applied
  34369. */
  34370. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  34371. }
  34372. /**
  34373. * Defines an optimization used to remove shadows
  34374. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  34375. */
  34376. class ShadowsOptimization extends SceneOptimization {
  34377. /**
  34378. * Gets a string describing the action executed by the current optimization
  34379. * @return description string
  34380. */
  34381. getDescription(): string;
  34382. /**
  34383. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  34384. * @param scene defines the current scene where to apply this optimization
  34385. * @param optimizer defines the current optimizer
  34386. * @returns true if everything that can be done was applied
  34387. */
  34388. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  34389. }
  34390. /**
  34391. * Defines an optimization used to turn post-processes off
  34392. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  34393. */
  34394. class PostProcessesOptimization extends SceneOptimization {
  34395. /**
  34396. * Gets a string describing the action executed by the current optimization
  34397. * @return description string
  34398. */
  34399. getDescription(): string;
  34400. /**
  34401. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  34402. * @param scene defines the current scene where to apply this optimization
  34403. * @param optimizer defines the current optimizer
  34404. * @returns true if everything that can be done was applied
  34405. */
  34406. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  34407. }
  34408. /**
  34409. * Defines an optimization used to turn lens flares off
  34410. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  34411. */
  34412. class LensFlaresOptimization extends SceneOptimization {
  34413. /**
  34414. * Gets a string describing the action executed by the current optimization
  34415. * @return description string
  34416. */
  34417. getDescription(): string;
  34418. /**
  34419. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  34420. * @param scene defines the current scene where to apply this optimization
  34421. * @param optimizer defines the current optimizer
  34422. * @returns true if everything that can be done was applied
  34423. */
  34424. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  34425. }
  34426. /**
  34427. * Defines an optimization based on user defined callback.
  34428. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  34429. */
  34430. class CustomOptimization extends SceneOptimization {
  34431. /**
  34432. * Callback called to apply the custom optimization.
  34433. */
  34434. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  34435. /**
  34436. * Callback called to get custom description
  34437. */
  34438. onGetDescription: () => string;
  34439. /**
  34440. * Gets a string describing the action executed by the current optimization
  34441. * @returns description string
  34442. */
  34443. getDescription(): string;
  34444. /**
  34445. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  34446. * @param scene defines the current scene where to apply this optimization
  34447. * @param optimizer defines the current optimizer
  34448. * @returns true if everything that can be done was applied
  34449. */
  34450. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  34451. }
  34452. /**
  34453. * Defines an optimization used to turn particles off
  34454. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  34455. */
  34456. class ParticlesOptimization extends SceneOptimization {
  34457. /**
  34458. * Gets a string describing the action executed by the current optimization
  34459. * @return description string
  34460. */
  34461. getDescription(): string;
  34462. /**
  34463. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  34464. * @param scene defines the current scene where to apply this optimization
  34465. * @param optimizer defines the current optimizer
  34466. * @returns true if everything that can be done was applied
  34467. */
  34468. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  34469. }
  34470. /**
  34471. * Defines an optimization used to turn render targets off
  34472. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  34473. */
  34474. class RenderTargetsOptimization extends SceneOptimization {
  34475. /**
  34476. * Gets a string describing the action executed by the current optimization
  34477. * @return description string
  34478. */
  34479. getDescription(): string;
  34480. /**
  34481. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  34482. * @param scene defines the current scene where to apply this optimization
  34483. * @param optimizer defines the current optimizer
  34484. * @returns true if everything that can be done was applied
  34485. */
  34486. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  34487. }
  34488. /**
  34489. * Defines an optimization used to merge meshes with compatible materials
  34490. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  34491. */
  34492. class MergeMeshesOptimization extends SceneOptimization {
  34493. private static _UpdateSelectionTree;
  34494. /**
  34495. * Gets or sets a boolean which defines if optimization octree has to be updated
  34496. */
  34497. /**
  34498. * Gets or sets a boolean which defines if optimization octree has to be updated
  34499. */
  34500. static UpdateSelectionTree: boolean;
  34501. /**
  34502. * Gets a string describing the action executed by the current optimization
  34503. * @return description string
  34504. */
  34505. getDescription(): string;
  34506. private _canBeMerged;
  34507. /**
  34508. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  34509. * @param scene defines the current scene where to apply this optimization
  34510. * @param optimizer defines the current optimizer
  34511. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  34512. * @returns true if everything that can be done was applied
  34513. */
  34514. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  34515. }
  34516. /**
  34517. * Defines a list of options used by SceneOptimizer
  34518. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  34519. */
  34520. class SceneOptimizerOptions {
  34521. /**
  34522. * Defines the target frame rate to reach (60 by default)
  34523. */
  34524. targetFrameRate: number;
  34525. /**
  34526. * Defines the interval between two checkes (2000ms by default)
  34527. */
  34528. trackerDuration: number;
  34529. /**
  34530. * Gets the list of optimizations to apply
  34531. */
  34532. optimizations: SceneOptimization[];
  34533. /**
  34534. * Creates a new list of options used by SceneOptimizer
  34535. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  34536. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  34537. */
  34538. constructor(
  34539. /**
  34540. * Defines the target frame rate to reach (60 by default)
  34541. */
  34542. targetFrameRate?: number,
  34543. /**
  34544. * Defines the interval between two checkes (2000ms by default)
  34545. */
  34546. trackerDuration?: number);
  34547. /**
  34548. * Add a new optimization
  34549. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  34550. * @returns the current SceneOptimizerOptions
  34551. */
  34552. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  34553. /**
  34554. * Add a new custom optimization
  34555. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  34556. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  34557. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  34558. * @returns the current SceneOptimizerOptions
  34559. */
  34560. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  34561. /**
  34562. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  34563. * @param targetFrameRate defines the target frame rate (60 by default)
  34564. * @returns a SceneOptimizerOptions object
  34565. */
  34566. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  34567. /**
  34568. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  34569. * @param targetFrameRate defines the target frame rate (60 by default)
  34570. * @returns a SceneOptimizerOptions object
  34571. */
  34572. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  34573. /**
  34574. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  34575. * @param targetFrameRate defines the target frame rate (60 by default)
  34576. * @returns a SceneOptimizerOptions object
  34577. */
  34578. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  34579. }
  34580. /**
  34581. * Class used to run optimizations in order to reach a target frame rate
  34582. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  34583. */
  34584. class SceneOptimizer implements IDisposable {
  34585. private _isRunning;
  34586. private _options;
  34587. private _scene;
  34588. private _currentPriorityLevel;
  34589. private _targetFrameRate;
  34590. private _trackerDuration;
  34591. private _currentFrameRate;
  34592. private _sceneDisposeObserver;
  34593. private _improvementMode;
  34594. /**
  34595. * Defines an observable called when the optimizer reaches the target frame rate
  34596. */
  34597. onSuccessObservable: Observable<SceneOptimizer>;
  34598. /**
  34599. * Defines an observable called when the optimizer enables an optimization
  34600. */
  34601. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  34602. /**
  34603. * Defines an observable called when the optimizer is not able to reach the target frame rate
  34604. */
  34605. onFailureObservable: Observable<SceneOptimizer>;
  34606. /**
  34607. * Gets a boolean indicating if the optimizer is in improvement mode
  34608. */
  34609. readonly isInImprovementMode: boolean;
  34610. /**
  34611. * Gets the current priority level (0 at start)
  34612. */
  34613. readonly currentPriorityLevel: number;
  34614. /**
  34615. * Gets the current frame rate checked by the SceneOptimizer
  34616. */
  34617. readonly currentFrameRate: number;
  34618. /**
  34619. * Gets or sets the current target frame rate (60 by default)
  34620. */
  34621. /**
  34622. * Gets or sets the current target frame rate (60 by default)
  34623. */
  34624. targetFrameRate: number;
  34625. /**
  34626. * Gets or sets the current interval between two checks (every 2000ms by default)
  34627. */
  34628. /**
  34629. * Gets or sets the current interval between two checks (every 2000ms by default)
  34630. */
  34631. trackerDuration: number;
  34632. /**
  34633. * Gets the list of active optimizations
  34634. */
  34635. readonly optimizations: SceneOptimization[];
  34636. /**
  34637. * Creates a new SceneOptimizer
  34638. * @param scene defines the scene to work on
  34639. * @param options defines the options to use with the SceneOptimizer
  34640. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  34641. * @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)
  34642. */
  34643. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  34644. /**
  34645. * Stops the current optimizer
  34646. */
  34647. stop(): void;
  34648. /**
  34649. * Reset the optimizer to initial step (current priority level = 0)
  34650. */
  34651. reset(): void;
  34652. /**
  34653. * Start the optimizer. By default it will try to reach a specific framerate
  34654. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  34655. */
  34656. start(): void;
  34657. private _checkCurrentState;
  34658. /**
  34659. * Release all resources
  34660. */
  34661. dispose(): void;
  34662. /**
  34663. * Helper function to create a SceneOptimizer with one single line of code
  34664. * @param scene defines the scene to work on
  34665. * @param options defines the options to use with the SceneOptimizer
  34666. * @param onSuccess defines a callback to call on success
  34667. * @param onFailure defines a callback to call on failure
  34668. * @returns the new SceneOptimizer object
  34669. */
  34670. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  34671. }
  34672. }
  34673. declare module BABYLON {
  34674. class SceneSerializer {
  34675. static ClearCache(): void;
  34676. static Serialize(scene: Scene): any;
  34677. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  34678. }
  34679. }
  34680. declare module BABYLON {
  34681. /**
  34682. * Defines an array and its length.
  34683. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  34684. */
  34685. interface ISmartArrayLike<T> {
  34686. /**
  34687. * The data of the array.
  34688. */
  34689. data: Array<T>;
  34690. /**
  34691. * The active length of the array.
  34692. */
  34693. length: number;
  34694. }
  34695. /**
  34696. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  34697. */
  34698. class SmartArray<T> implements ISmartArrayLike<T> {
  34699. /**
  34700. * The full set of data from the array.
  34701. */
  34702. data: Array<T>;
  34703. /**
  34704. * The active length of the array.
  34705. */
  34706. length: number;
  34707. protected _id: number;
  34708. /**
  34709. * Instantiates a Smart Array.
  34710. * @param capacity defines the default capacity of the array.
  34711. */
  34712. constructor(capacity: number);
  34713. /**
  34714. * Pushes a value at the end of the active data.
  34715. * @param value defines the object to push in the array.
  34716. */
  34717. push(value: T): void;
  34718. /**
  34719. * Iterates over the active data and apply the lambda to them.
  34720. * @param func defines the action to apply on each value.
  34721. */
  34722. forEach(func: (content: T) => void): void;
  34723. /**
  34724. * Sorts the full sets of data.
  34725. * @param compareFn defines the comparison function to apply.
  34726. */
  34727. sort(compareFn: (a: T, b: T) => number): void;
  34728. /**
  34729. * Resets the active data to an empty array.
  34730. */
  34731. reset(): void;
  34732. /**
  34733. * Releases all the data from the array as well as the array.
  34734. */
  34735. dispose(): void;
  34736. /**
  34737. * Concats the active data with a given array.
  34738. * @param array defines the data to concatenate with.
  34739. */
  34740. concat(array: any): void;
  34741. /**
  34742. * Returns the position of a value in the active data.
  34743. * @param value defines the value to find the index for
  34744. * @returns the index if found in the active data otherwise -1
  34745. */
  34746. indexOf(value: T): number;
  34747. /**
  34748. * Returns whether an element is part of the active data.
  34749. * @param value defines the value to look for
  34750. * @returns true if found in the active data otherwise false
  34751. */
  34752. contains(value: T): boolean;
  34753. private static _GlobalId;
  34754. }
  34755. /**
  34756. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  34757. * The data in this array can only be present once
  34758. */
  34759. class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  34760. private _duplicateId;
  34761. /**
  34762. * Pushes a value at the end of the active data.
  34763. * THIS DOES NOT PREVENT DUPPLICATE DATA
  34764. * @param value defines the object to push in the array.
  34765. */
  34766. push(value: T): void;
  34767. /**
  34768. * Pushes a value at the end of the active data.
  34769. * If the data is already present, it won t be added again
  34770. * @param value defines the object to push in the array.
  34771. * @returns true if added false if it was already present
  34772. */
  34773. pushNoDuplicate(value: T): boolean;
  34774. /**
  34775. * Resets the active data to an empty array.
  34776. */
  34777. reset(): void;
  34778. /**
  34779. * Concats the active data with a given array.
  34780. * This ensures no dupplicate will be present in the result.
  34781. * @param array defines the data to concatenate with.
  34782. */
  34783. concatWithNoDuplicate(array: any): void;
  34784. }
  34785. }
  34786. declare module BABYLON {
  34787. /**
  34788. * This class implement a typical dictionary using a string as key and the generic type T as value.
  34789. * The underlying implementation relies on an associative array to ensure the best performances.
  34790. * The value can be anything including 'null' but except 'undefined'
  34791. */
  34792. class StringDictionary<T> {
  34793. /**
  34794. * This will clear this dictionary and copy the content from the 'source' one.
  34795. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  34796. * @param source the dictionary to take the content from and copy to this dictionary
  34797. */
  34798. copyFrom(source: StringDictionary<T>): void;
  34799. /**
  34800. * Get a value based from its key
  34801. * @param key the given key to get the matching value from
  34802. * @return the value if found, otherwise undefined is returned
  34803. */
  34804. get(key: string): T | undefined;
  34805. /**
  34806. * Get a value from its key or add it if it doesn't exist.
  34807. * This method will ensure you that a given key/data will be present in the dictionary.
  34808. * @param key the given key to get the matching value from
  34809. * @param factory the factory that will create the value if the key is not present in the dictionary.
  34810. * The factory will only be invoked if there's no data for the given key.
  34811. * @return the value corresponding to the key.
  34812. */
  34813. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  34814. /**
  34815. * Get a value from its key if present in the dictionary otherwise add it
  34816. * @param key the key to get the value from
  34817. * @param val if there's no such key/value pair in the dictionary add it with this value
  34818. * @return the value corresponding to the key
  34819. */
  34820. getOrAdd(key: string, val: T): T;
  34821. /**
  34822. * Check if there's a given key in the dictionary
  34823. * @param key the key to check for
  34824. * @return true if the key is present, false otherwise
  34825. */
  34826. contains(key: string): boolean;
  34827. /**
  34828. * Add a new key and its corresponding value
  34829. * @param key the key to add
  34830. * @param value the value corresponding to the key
  34831. * @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
  34832. */
  34833. add(key: string, value: T): boolean;
  34834. set(key: string, value: T): boolean;
  34835. /**
  34836. * Get the element of the given key and remove it from the dictionary
  34837. * @param key
  34838. */
  34839. getAndRemove(key: string): Nullable<T>;
  34840. /**
  34841. * Remove a key/value from the dictionary.
  34842. * @param key the key to remove
  34843. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  34844. */
  34845. remove(key: string): boolean;
  34846. /**
  34847. * Clear the whole content of the dictionary
  34848. */
  34849. clear(): void;
  34850. readonly count: number;
  34851. /**
  34852. * Execute a callback on each key/val of the dictionary.
  34853. * Note that you can remove any element in this dictionary in the callback implementation
  34854. * @param callback the callback to execute on a given key/value pair
  34855. */
  34856. forEach(callback: (key: string, val: T) => void): void;
  34857. /**
  34858. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  34859. * If the callback returns null or undefined the method will iterate to the next key/value pair
  34860. * Note that you can remove any element in this dictionary in the callback implementation
  34861. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  34862. */
  34863. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  34864. private _count;
  34865. private _data;
  34866. }
  34867. }
  34868. declare module BABYLON {
  34869. class Tags {
  34870. static EnableFor(obj: any): void;
  34871. static DisableFor(obj: any): void;
  34872. static HasTags(obj: any): boolean;
  34873. static GetTags(obj: any, asString?: boolean): any;
  34874. static AddTagsTo(obj: any, tagsString: string): void;
  34875. private static _AddTagTo(obj: any, tag: string): void;
  34876. static RemoveTagsFrom(obj: any, tagsString: string): void;
  34877. private static _RemoveTagFrom(obj: any, tag: string): void;
  34878. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  34879. }
  34880. }
  34881. declare module BABYLON {
  34882. class TextureTools {
  34883. /**
  34884. * Uses the GPU to create a copy texture rescaled at a given size
  34885. * @param texture Texture to copy from
  34886. * @param width Desired width
  34887. * @param height Desired height
  34888. * @return Generated texture
  34889. */
  34890. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  34891. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  34892. private static _environmentBRDFBase64Texture;
  34893. }
  34894. }
  34895. declare module BABYLON {
  34896. class TGATools {
  34897. private static _TYPE_INDEXED;
  34898. private static _TYPE_RGB;
  34899. private static _TYPE_GREY;
  34900. private static _TYPE_RLE_INDEXED;
  34901. private static _TYPE_RLE_RGB;
  34902. private static _TYPE_RLE_GREY;
  34903. private static _ORIGIN_MASK;
  34904. private static _ORIGIN_SHIFT;
  34905. private static _ORIGIN_BL;
  34906. private static _ORIGIN_BR;
  34907. private static _ORIGIN_UL;
  34908. private static _ORIGIN_UR;
  34909. static GetTGAHeader(data: Uint8Array): any;
  34910. /**
  34911. * Uploads TGA content to a Babylon Texture
  34912. * @hidden
  34913. */
  34914. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  34915. 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;
  34916. 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;
  34917. 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;
  34918. 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;
  34919. 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;
  34920. 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;
  34921. }
  34922. }
  34923. declare module BABYLON {
  34924. interface IAnimatable {
  34925. animations: Array<Animation>;
  34926. }
  34927. /** Interface used by value gradients (color, factor, ...) */
  34928. interface IValueGradient {
  34929. /**
  34930. * Gets or sets the gradient value (between 0 and 1)
  34931. */
  34932. gradient: number;
  34933. }
  34934. /** Class used to store color4 gradient */
  34935. class ColorGradient implements IValueGradient {
  34936. /**
  34937. * Gets or sets the gradient value (between 0 and 1)
  34938. */
  34939. gradient: number;
  34940. /**
  34941. * Gets or sets first associated color
  34942. */
  34943. color1: Color4;
  34944. /**
  34945. * Gets or sets second associated color
  34946. */
  34947. color2?: Color4;
  34948. /**
  34949. * Will get a color picked randomly between color1 and color2.
  34950. * If color2 is undefined then color1 will be used
  34951. * @param result defines the target Color4 to store the result in
  34952. */
  34953. getColorToRef(result: Color4): void;
  34954. }
  34955. /** Class used to store color 3 gradient */
  34956. class Color3Gradient implements IValueGradient {
  34957. /**
  34958. * Gets or sets the gradient value (between 0 and 1)
  34959. */
  34960. gradient: number;
  34961. /**
  34962. * Gets or sets the associated color
  34963. */
  34964. color: Color3;
  34965. }
  34966. /** Class used to store factor gradient */
  34967. class FactorGradient implements IValueGradient {
  34968. /**
  34969. * Gets or sets the gradient value (between 0 and 1)
  34970. */
  34971. gradient: number;
  34972. /**
  34973. * Gets or sets first associated factor
  34974. */
  34975. factor1: number;
  34976. /**
  34977. * Gets or sets second associated factor
  34978. */
  34979. factor2?: number;
  34980. /**
  34981. * Will get a number picked randomly between factor1 and factor2.
  34982. * If factor2 is undefined then factor1 will be used
  34983. * @returns the picked number
  34984. */
  34985. getFactor(): number;
  34986. }
  34987. class LoadFileError extends Error {
  34988. request?: XMLHttpRequest | undefined;
  34989. private static _setPrototypeOf;
  34990. constructor(message: string, request?: XMLHttpRequest | undefined);
  34991. }
  34992. class RetryStrategy {
  34993. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  34994. }
  34995. interface IFileRequest {
  34996. /**
  34997. * Raised when the request is complete (success or error).
  34998. */
  34999. onCompleteObservable: Observable<IFileRequest>;
  35000. /**
  35001. * Aborts the request for a file.
  35002. */
  35003. abort: () => void;
  35004. }
  35005. class Tools {
  35006. static BaseUrl: string;
  35007. static DefaultRetryStrategy: (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  35008. /**
  35009. * Default behaviour for cors in the application.
  35010. * It can be a string if the expected behavior is identical in the entire app.
  35011. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  35012. */
  35013. static CorsBehavior: string | ((url: string | string[]) => string);
  35014. static UseFallbackTexture: boolean;
  35015. /**
  35016. * Use this object to register external classes like custom textures or material
  35017. * to allow the laoders to instantiate them
  35018. */
  35019. static RegisteredExternalClasses: {
  35020. [key: string]: Object;
  35021. };
  35022. static fallbackTexture: string;
  35023. /**
  35024. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  35025. * @param u defines the coordinate on X axis
  35026. * @param v defines the coordinate on Y axis
  35027. * @param width defines the width of the source data
  35028. * @param height defines the height of the source data
  35029. * @param pixels defines the source byte array
  35030. * @param color defines the output color
  35031. */
  35032. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  35033. /**
  35034. * Interpolates between a and b via alpha
  35035. * @param a The lower value (returned when alpha = 0)
  35036. * @param b The upper value (returned when alpha = 1)
  35037. * @param alpha The interpolation-factor
  35038. * @return The mixed value
  35039. */
  35040. static Mix(a: number, b: number, alpha: number): number;
  35041. static Instantiate(className: string): any;
  35042. /**
  35043. * Provides a slice function that will work even on IE
  35044. * @param data defines the array to slice
  35045. * @param start defines the start of the data (optional)
  35046. * @param end defines the end of the data (optional)
  35047. * @returns the new sliced array
  35048. */
  35049. static Slice<T>(data: T, start?: number, end?: number): T;
  35050. static SetImmediate(action: () => void): void;
  35051. static IsExponentOfTwo(value: number): boolean;
  35052. private static _tmpFloatArray;
  35053. /**
  35054. * Returns the nearest 32-bit single precision float representation of a Number
  35055. * @param value A Number. If the parameter is of a different type, it will get converted
  35056. * to a number or to NaN if it cannot be converted
  35057. * @returns number
  35058. */
  35059. static FloatRound(value: number): number;
  35060. /**
  35061. * Find the next highest power of two.
  35062. * @param x Number to start search from.
  35063. * @return Next highest power of two.
  35064. */
  35065. static CeilingPOT(x: number): number;
  35066. /**
  35067. * Find the next lowest power of two.
  35068. * @param x Number to start search from.
  35069. * @return Next lowest power of two.
  35070. */
  35071. static FloorPOT(x: number): number;
  35072. /**
  35073. * Find the nearest power of two.
  35074. * @param x Number to start search from.
  35075. * @return Next nearest power of two.
  35076. */
  35077. static NearestPOT(x: number): number;
  35078. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  35079. static GetFilename(path: string): string;
  35080. /**
  35081. * Extracts the "folder" part of a path (everything before the filename).
  35082. * @param uri The URI to extract the info from
  35083. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  35084. * @returns The "folder" part of the path
  35085. */
  35086. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  35087. static GetDOMTextContent(element: HTMLElement): string;
  35088. static ToDegrees(angle: number): number;
  35089. static ToRadians(angle: number): number;
  35090. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  35091. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  35092. minimum: Vector3;
  35093. maximum: Vector3;
  35094. };
  35095. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  35096. minimum: Vector3;
  35097. maximum: Vector3;
  35098. };
  35099. static Vector2ArrayFeeder(array: Array<Vector2> | Float32Array): (i: number) => Nullable<Vector2>;
  35100. static ExtractMinAndMaxVector2(feeder: (index: number) => Vector2, bias?: Nullable<Vector2>): {
  35101. minimum: Vector2;
  35102. maximum: Vector2;
  35103. };
  35104. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  35105. static GetPointerPrefix(): string;
  35106. /**
  35107. * @param func - the function to be called
  35108. * @param requester - the object that will request the next frame. Falls back to window.
  35109. */
  35110. static QueueNewFrame(func: () => void, requester?: any): number;
  35111. static RequestFullscreen(element: HTMLElement): void;
  35112. static ExitFullscreen(): void;
  35113. /**
  35114. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  35115. * @param url define the url we are trying
  35116. * @param element define the dom element where to configure the cors policy
  35117. */
  35118. static SetCorsBehavior(url: string | string[], element: {
  35119. crossOrigin: string | null;
  35120. }): void;
  35121. static CleanUrl(url: string): string;
  35122. static PreprocessUrl: (url: string) => string;
  35123. /**
  35124. * Loads an image as an HTMLImageElement.
  35125. * @param input url string, ArrayBuffer, or Blob to load
  35126. * @param onLoad callback called when the image successfully loads
  35127. * @param onError callback called when the image fails to load
  35128. * @param database database for caching
  35129. * @returns the HTMLImageElement of the loaded image
  35130. */
  35131. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, database: Nullable<Database>): HTMLImageElement;
  35132. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, database?: Database, useArrayBuffer?: boolean, onError?: (request?: XMLHttpRequest, exception?: any) => void): IFileRequest;
  35133. /**
  35134. * Load a script (identified by an url). When the url returns, the
  35135. * content of this file is added into a new script element, attached to the DOM (body element)
  35136. */
  35137. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void): void;
  35138. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  35139. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  35140. static FileAsURL(content: string): string;
  35141. static Format(value: number, decimals?: number): string;
  35142. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  35143. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  35144. static IsEmpty(obj: any): boolean;
  35145. static RegisterTopRootEvents(events: {
  35146. name: string;
  35147. handler: Nullable<(e: FocusEvent) => any>;
  35148. }[]): void;
  35149. static UnregisterTopRootEvents(events: {
  35150. name: string;
  35151. handler: Nullable<(e: FocusEvent) => any>;
  35152. }[]): void;
  35153. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  35154. /**
  35155. * Converts the canvas data to blob.
  35156. * This acts as a polyfill for browsers not supporting the to blob function.
  35157. * @param canvas Defines the canvas to extract the data from
  35158. * @param successCallback Defines the callback triggered once the data are available
  35159. * @param mimeType Defines the mime type of the result
  35160. */
  35161. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  35162. /**
  35163. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  35164. * @param successCallback Defines the callback triggered once the data are available
  35165. * @param mimeType Defines the mime type of the result
  35166. * @param fileName The filename to download. If present, the result will automatically be downloaded
  35167. */
  35168. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  35169. /**
  35170. * Downloads a blob in the browser
  35171. * @param blob defines the blob to download
  35172. * @param fileName defines the name of the downloaded file
  35173. */
  35174. static Download(blob: Blob, fileName: string): void;
  35175. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  35176. /**
  35177. * Generates an image screenshot from the specified camera.
  35178. *
  35179. * @param engine The engine to use for rendering
  35180. * @param camera The camera to use for rendering
  35181. * @param size This parameter can be set to a single number or to an object with the
  35182. * following (optional) properties: precision, width, height. If a single number is passed,
  35183. * it will be used for both width and height. If an object is passed, the screenshot size
  35184. * will be derived from the parameters. The precision property is a multiplier allowing
  35185. * rendering at a higher or lower resolution.
  35186. * @param successCallback The callback receives a single parameter which contains the
  35187. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  35188. * src parameter of an <img> to display it.
  35189. * @param mimeType The MIME type of the screenshot image (default: image/png).
  35190. * Check your browser for supported MIME types.
  35191. * @param samples Texture samples (default: 1)
  35192. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  35193. * @param fileName A name for for the downloaded file.
  35194. * @constructor
  35195. */
  35196. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  35197. static ValidateXHRData(xhr: XMLHttpRequest, dataType?: number): boolean;
  35198. /**
  35199. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  35200. * Be aware Math.random() could cause collisions, but:
  35201. * "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"
  35202. */
  35203. static RandomId(): string;
  35204. /**
  35205. * Test if the given uri is a base64 string.
  35206. * @param uri The uri to test
  35207. * @return True if the uri is a base64 string or false otherwise.
  35208. */
  35209. static IsBase64(uri: string): boolean;
  35210. /**
  35211. * Decode the given base64 uri.
  35212. * @param uri The uri to decode
  35213. * @return The decoded base64 data.
  35214. */
  35215. static DecodeBase64(uri: string): ArrayBuffer;
  35216. private static _NoneLogLevel;
  35217. private static _MessageLogLevel;
  35218. private static _WarningLogLevel;
  35219. private static _ErrorLogLevel;
  35220. private static _LogCache;
  35221. static errorsCount: number;
  35222. static OnNewCacheEntry: (entry: string) => void;
  35223. static readonly NoneLogLevel: number;
  35224. static readonly MessageLogLevel: number;
  35225. static readonly WarningLogLevel: number;
  35226. static readonly ErrorLogLevel: number;
  35227. static readonly AllLogLevel: number;
  35228. private static _AddLogEntry;
  35229. private static _FormatMessage;
  35230. private static _LogDisabled;
  35231. private static _LogEnabled;
  35232. private static _WarnDisabled;
  35233. private static _WarnEnabled;
  35234. private static _ErrorDisabled;
  35235. private static _ErrorEnabled;
  35236. static Log: (message: string) => void;
  35237. static Warn: (message: string) => void;
  35238. static Error: (message: string) => void;
  35239. static readonly LogCache: string;
  35240. static ClearLogCache(): void;
  35241. static LogLevels: number;
  35242. /**
  35243. * Check if the loaded document was accessed via `file:`-Protocol.
  35244. * @returns boolean
  35245. */
  35246. static IsFileURL(): boolean;
  35247. static IsWindowObjectExist(): boolean;
  35248. private static _PerformanceNoneLogLevel;
  35249. private static _PerformanceUserMarkLogLevel;
  35250. private static _PerformanceConsoleLogLevel;
  35251. private static _performance;
  35252. static readonly PerformanceNoneLogLevel: number;
  35253. static readonly PerformanceUserMarkLogLevel: number;
  35254. static readonly PerformanceConsoleLogLevel: number;
  35255. static PerformanceLogLevel: number;
  35256. private static _StartPerformanceCounterDisabled(counterName: string, condition?: boolean): void;
  35257. private static _EndPerformanceCounterDisabled(counterName: string, condition?: boolean): void;
  35258. private static _StartUserMark(counterName: string, condition?: boolean): void;
  35259. private static _EndUserMark(counterName: string, condition?: boolean): void;
  35260. private static _StartPerformanceConsole(counterName: string, condition?: boolean): void;
  35261. private static _EndPerformanceConsole(counterName: string, condition?: boolean): void;
  35262. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  35263. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  35264. static readonly Now: number;
  35265. /**
  35266. * This method will return the name of the class used to create the instance of the given object.
  35267. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  35268. * @param object the object to get the class name from
  35269. * @return the name of the class, will be "object" for a custom data type not using the @className decorator
  35270. */
  35271. static GetClassName(object: any, isType?: boolean): string;
  35272. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  35273. /**
  35274. * This method will return the name of the full name of the class, including its owning module (if any).
  35275. * 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).
  35276. * @param object the object to get the class name from
  35277. * @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.
  35278. */
  35279. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  35280. /**
  35281. * This method can be used with hashCodeFromStream when your input is an array of values that are either: number, string, boolean or custom type implementing the getHashCode():number method.
  35282. * @param array
  35283. */
  35284. static arrayOrStringFeeder(array: any): (i: number) => number;
  35285. /**
  35286. * Compute the hashCode of a stream of number
  35287. * To compute the HashCode on a string or an Array of data types implementing the getHashCode() method, use the arrayOrStringFeeder method.
  35288. * @param feeder a callback that will be called until it returns null, each valid returned values will be used to compute the hash code.
  35289. * @return the hash code computed
  35290. */
  35291. static hashCodeFromStream(feeder: (index: number) => number): number;
  35292. /**
  35293. * Returns a promise that resolves after the given amount of time.
  35294. * @param delay Number of milliseconds to delay
  35295. * @returns Promise that resolves after the given amount of time
  35296. */
  35297. static DelayAsync(delay: number): Promise<void>;
  35298. /**
  35299. * Gets the current gradient from an array of IValueGradient
  35300. * @param ratio defines the current ratio to get
  35301. * @param gradients defines the array of IValueGradient
  35302. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  35303. */
  35304. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  35305. }
  35306. /**
  35307. * This class is used to track a performance counter which is number based.
  35308. * The user has access to many properties which give statistics of different nature
  35309. *
  35310. * The implementer can track two kinds of Performance Counter: time and count
  35311. * 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.
  35312. * 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.
  35313. */
  35314. class PerfCounter {
  35315. static Enabled: boolean;
  35316. /**
  35317. * Returns the smallest value ever
  35318. */
  35319. readonly min: number;
  35320. /**
  35321. * Returns the biggest value ever
  35322. */
  35323. readonly max: number;
  35324. /**
  35325. * Returns the average value since the performance counter is running
  35326. */
  35327. readonly average: number;
  35328. /**
  35329. * Returns the average value of the last second the counter was monitored
  35330. */
  35331. readonly lastSecAverage: number;
  35332. /**
  35333. * Returns the current value
  35334. */
  35335. readonly current: number;
  35336. readonly total: number;
  35337. readonly count: number;
  35338. constructor();
  35339. /**
  35340. * Call this method to start monitoring a new frame.
  35341. * 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.
  35342. */
  35343. fetchNewFrame(): void;
  35344. /**
  35345. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  35346. * @param newCount the count value to add to the monitored count
  35347. * @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.
  35348. */
  35349. addCount(newCount: number, fetchResult: boolean): void;
  35350. /**
  35351. * Start monitoring this performance counter
  35352. */
  35353. beginMonitoring(): void;
  35354. /**
  35355. * Compute the time lapsed since the previous beginMonitoring() call.
  35356. * @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
  35357. */
  35358. endMonitoring(newFrame?: boolean): void;
  35359. private _fetchResult;
  35360. private _startMonitoringTime;
  35361. private _min;
  35362. private _max;
  35363. private _average;
  35364. private _current;
  35365. private _totalValueCount;
  35366. private _totalAccumulated;
  35367. private _lastSecAverage;
  35368. private _lastSecAccumulated;
  35369. private _lastSecTime;
  35370. private _lastSecValueCount;
  35371. }
  35372. /**
  35373. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  35374. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  35375. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  35376. * @param name The name of the class, case should be preserved
  35377. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  35378. */
  35379. function className(name: string, module?: string): (target: Object) => void;
  35380. /**
  35381. * An implementation of a loop for asynchronous functions.
  35382. */
  35383. class AsyncLoop {
  35384. /**
  35385. * Defines the number of iterations for the loop
  35386. */
  35387. iterations: number;
  35388. /**
  35389. * Defines the current index of the loop.
  35390. */
  35391. index: number;
  35392. private _done;
  35393. private _fn;
  35394. private _successCallback;
  35395. /**
  35396. * Constructor.
  35397. * @param iterations the number of iterations.
  35398. * @param func the function to run each iteration
  35399. * @param successCallback the callback that will be called upon succesful execution
  35400. * @param offset starting offset.
  35401. */
  35402. constructor(
  35403. /**
  35404. * Defines the number of iterations for the loop
  35405. */
  35406. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  35407. /**
  35408. * Execute the next iteration. Must be called after the last iteration was finished.
  35409. */
  35410. executeNext(): void;
  35411. /**
  35412. * Break the loop and run the success callback.
  35413. */
  35414. breakLoop(): void;
  35415. /**
  35416. * Create and run an async loop.
  35417. * @param iterations the number of iterations.
  35418. * @param fn the function to run each iteration
  35419. * @param successCallback the callback that will be called upon succesful execution
  35420. * @param offset starting offset.
  35421. * @returns the created async loop object
  35422. */
  35423. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  35424. /**
  35425. * A for-loop that will run a given number of iterations synchronous and the rest async.
  35426. * @param iterations total number of iterations
  35427. * @param syncedIterations number of synchronous iterations in each async iteration.
  35428. * @param fn the function to call each iteration.
  35429. * @param callback a success call back that will be called when iterating stops.
  35430. * @param breakFunction a break condition (optional)
  35431. * @param timeout timeout settings for the setTimeout function. default - 0.
  35432. * @returns the created async loop object
  35433. */
  35434. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  35435. }
  35436. }
  35437. interface HTMLCanvasElement {
  35438. /** Track wether a record is in progress */
  35439. isRecording: boolean;
  35440. /** Capture Stream method defined by some browsers */
  35441. captureStream(fps?: number): MediaStream;
  35442. }
  35443. interface MediaRecorder {
  35444. /** Starts recording */
  35445. start(timeSlice: number): void;
  35446. /** Stops recording */
  35447. stop(): void;
  35448. /** Event raised when an error arised. */
  35449. onerror: (event: ErrorEvent) => void;
  35450. /** Event raised when the recording stops. */
  35451. onstop: (event: Event) => void;
  35452. /** Event raised when a new chunk of data is available and should be tracked. */
  35453. ondataavailable: (event: Event) => void;
  35454. }
  35455. interface MediaRecorderOptions {
  35456. /** The mime type you want to use as the recording container for the new MediaRecorder */
  35457. mimeType?: string;
  35458. /** The chosen bitrate for the audio component of the media. */
  35459. audioBitsPerSecond?: number;
  35460. /** The chosen bitrate for the video component of the media. */
  35461. videoBitsPerSecond?: number;
  35462. /** The chosen bitrate for the audio and video components of the media. This can be specified instead of the above two properties. If this is specified along with one or the other of the above properties, this will be used for the one that isn't specified. */
  35463. bitsPerSecond?: number;
  35464. }
  35465. interface MediaRecorderConstructor {
  35466. /**
  35467. * A reference to the prototype.
  35468. */
  35469. readonly prototype: MediaRecorder;
  35470. /**
  35471. * Creates a new MediaRecorder.
  35472. * @param stream Defines the stream to record.
  35473. * @param options Defines the options for the recorder available in the type MediaRecorderOptions.
  35474. */
  35475. new (stream: MediaStream, options?: MediaRecorderOptions): MediaRecorder;
  35476. }
  35477. /**
  35478. * MediaRecoreder object available in some browsers.
  35479. */
  35480. declare var MediaRecorder: MediaRecorderConstructor;
  35481. declare module BABYLON {
  35482. /**
  35483. * This represents the different options avilable for the video capture.
  35484. */
  35485. interface VideoRecorderOptions {
  35486. /** Defines the mime type of the video */
  35487. mimeType: string;
  35488. /** Defines the video the video should be recorded at */
  35489. fps: number;
  35490. /** Defines the chunk size for the recording data */
  35491. recordChunckSize: number;
  35492. }
  35493. /**
  35494. * This can helps recording videos from BabylonJS.
  35495. * This is based on the available WebRTC functionalities of the browser.
  35496. *
  35497. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  35498. */
  35499. class VideoRecorder {
  35500. private static readonly _defaultOptions;
  35501. /**
  35502. * Returns wehther or not the VideoRecorder is available in your browser.
  35503. * @param engine Defines the Babylon Engine to check the support for
  35504. * @returns true if supported otherwise false
  35505. */
  35506. static IsSupported(engine: Engine): boolean;
  35507. private readonly _options;
  35508. private _canvas;
  35509. private _mediaRecorder;
  35510. private _recordedChunks;
  35511. private _fileName;
  35512. private _resolve;
  35513. private _reject;
  35514. /**
  35515. * True wether a recording is already in progress.
  35516. */
  35517. readonly isRecording: boolean;
  35518. /**
  35519. * Create a new VideoCapture object which can help converting what you see in Babylon to
  35520. * a video file.
  35521. * @param engine Defines the BabylonJS Engine you wish to record
  35522. * @param options Defines options that can be used to customized the capture
  35523. */
  35524. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  35525. /**
  35526. * Stops the current recording before the default capture timeout passed in the startRecording
  35527. * functions.
  35528. */
  35529. stopRecording(): void;
  35530. /**
  35531. * Starts recording the canvas for a max duration specified in parameters.
  35532. * @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.
  35533. * @param maxDuration Defines the maximum recording time in seconds.
  35534. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  35535. * @return a promise callback at the end of the recording with the video data in Blob.
  35536. */
  35537. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  35538. /**
  35539. * Releases internal resources used during the recording.
  35540. */
  35541. dispose(): void;
  35542. private _handleDataAvailable;
  35543. private _handleError;
  35544. private _handleStop;
  35545. }
  35546. }
  35547. declare module BABYLON {
  35548. /**
  35549. * Defines the potential axis of a Joystick
  35550. */
  35551. enum JoystickAxis {
  35552. /** X axis */
  35553. X = 0,
  35554. /** Y axis */
  35555. Y = 1,
  35556. /** Z axis */
  35557. Z = 2
  35558. }
  35559. /**
  35560. * Class used to define virtual joystick (used in touch mode)
  35561. */
  35562. class VirtualJoystick {
  35563. /**
  35564. * Gets or sets a boolean indicating that left and right values must be inverted
  35565. */
  35566. reverseLeftRight: boolean;
  35567. /**
  35568. * Gets or sets a boolean indicating that up and down values must be inverted
  35569. */
  35570. reverseUpDown: boolean;
  35571. /**
  35572. * Gets the offset value for the position (ie. the change of the position value)
  35573. */
  35574. deltaPosition: Vector3;
  35575. /**
  35576. * Gets a boolean indicating if the virtual joystick was pressed
  35577. */
  35578. pressed: boolean;
  35579. private static _globalJoystickIndex;
  35580. private static vjCanvas;
  35581. private static vjCanvasContext;
  35582. private static vjCanvasWidth;
  35583. private static vjCanvasHeight;
  35584. private static halfWidth;
  35585. private _action;
  35586. private _axisTargetedByLeftAndRight;
  35587. private _axisTargetedByUpAndDown;
  35588. private _joystickSensibility;
  35589. private _inversedSensibility;
  35590. private _joystickPointerID;
  35591. private _joystickColor;
  35592. private _joystickPointerPos;
  35593. private _joystickPreviousPointerPos;
  35594. private _joystickPointerStartPos;
  35595. private _deltaJoystickVector;
  35596. private _leftJoystick;
  35597. private _touches;
  35598. private _onPointerDownHandlerRef;
  35599. private _onPointerMoveHandlerRef;
  35600. private _onPointerUpHandlerRef;
  35601. private _onResize;
  35602. /**
  35603. * Creates a new virtual joystick
  35604. * @param leftJoystick defines that the joystick is for left hand (false by default)
  35605. */
  35606. constructor(leftJoystick?: boolean);
  35607. /**
  35608. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  35609. * @param newJoystickSensibility defines the new sensibility
  35610. */
  35611. setJoystickSensibility(newJoystickSensibility: number): void;
  35612. private _onPointerDown;
  35613. private _onPointerMove;
  35614. private _onPointerUp;
  35615. /**
  35616. * Change the color of the virtual joystick
  35617. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  35618. */
  35619. setJoystickColor(newColor: string): void;
  35620. /**
  35621. * Defines a callback to call when the joystick is touched
  35622. * @param action defines the callback
  35623. */
  35624. setActionOnTouch(action: () => any): void;
  35625. /**
  35626. * Defines which axis you'd like to control for left & right
  35627. * @param axis defines the axis to use
  35628. */
  35629. setAxisForLeftRight(axis: JoystickAxis): void;
  35630. /**
  35631. * Defines which axis you'd like to control for up & down
  35632. * @param axis defines the axis to use
  35633. */
  35634. setAxisForUpDown(axis: JoystickAxis): void;
  35635. private _drawVirtualJoystick;
  35636. /**
  35637. * Release internal HTML canvas
  35638. */
  35639. releaseCanvas(): void;
  35640. }
  35641. }
  35642. declare module BABYLON {
  35643. /**
  35644. * Helper class to push actions to a pool of workers.
  35645. */
  35646. class WorkerPool implements IDisposable {
  35647. private _workerInfos;
  35648. private _pendingActions;
  35649. /**
  35650. * Constructor
  35651. * @param workers Array of workers to use for actions
  35652. */
  35653. constructor(workers: Array<Worker>);
  35654. /**
  35655. * Terminates all workers and clears any pending actions.
  35656. */
  35657. dispose(): void;
  35658. /**
  35659. * Pushes an action to the worker pool. If all the workers are active, the action will be
  35660. * pended until a worker has completed its action.
  35661. * @param action The action to perform. Call onComplete when the action is complete.
  35662. */
  35663. push(action: (worker: Worker, onComplete: () => void) => void): void;
  35664. private _execute;
  35665. }
  35666. }
  35667. declare module BABYLON {
  35668. /**
  35669. * The autoRotation behavior (BABYLON.AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  35670. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35671. */
  35672. class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  35673. /**
  35674. * Gets the name of the behavior.
  35675. */
  35676. readonly name: string;
  35677. private _zoomStopsAnimation;
  35678. private _idleRotationSpeed;
  35679. private _idleRotationWaitTime;
  35680. private _idleRotationSpinupTime;
  35681. /**
  35682. * Sets the flag that indicates if user zooming should stop animation.
  35683. */
  35684. /**
  35685. * Gets the flag that indicates if user zooming should stop animation.
  35686. */
  35687. zoomStopsAnimation: boolean;
  35688. /**
  35689. * Sets the default speed at which the camera rotates around the model.
  35690. */
  35691. /**
  35692. * Gets the default speed at which the camera rotates around the model.
  35693. */
  35694. idleRotationSpeed: number;
  35695. /**
  35696. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  35697. */
  35698. /**
  35699. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  35700. */
  35701. idleRotationWaitTime: number;
  35702. /**
  35703. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  35704. */
  35705. /**
  35706. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  35707. */
  35708. idleRotationSpinupTime: number;
  35709. /**
  35710. * Gets a value indicating if the camera is currently rotating because of this behavior
  35711. */
  35712. readonly rotationInProgress: boolean;
  35713. private _onPrePointerObservableObserver;
  35714. private _onAfterCheckInputsObserver;
  35715. private _attachedCamera;
  35716. private _isPointerDown;
  35717. private _lastFrameTime;
  35718. private _lastInteractionTime;
  35719. private _cameraRotationSpeed;
  35720. /**
  35721. * Initializes the behavior.
  35722. */
  35723. init(): void;
  35724. /**
  35725. * Attaches the behavior to its arc rotate camera.
  35726. * @param camera Defines the camera to attach the behavior to
  35727. */
  35728. attach(camera: ArcRotateCamera): void;
  35729. /**
  35730. * Detaches the behavior from its current arc rotate camera.
  35731. */
  35732. detach(): void;
  35733. /**
  35734. * Returns true if user is scrolling.
  35735. * @return true if user is scrolling.
  35736. */
  35737. private _userIsZooming;
  35738. private _lastFrameRadius;
  35739. private _shouldAnimationStopForInteraction;
  35740. /**
  35741. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  35742. */
  35743. private _applyUserInteraction;
  35744. private _userIsMoving;
  35745. }
  35746. }
  35747. declare module BABYLON {
  35748. /**
  35749. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  35750. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35751. */
  35752. class BouncingBehavior implements Behavior<ArcRotateCamera> {
  35753. /**
  35754. * Gets the name of the behavior.
  35755. */
  35756. readonly name: string;
  35757. /**
  35758. * The easing function used by animations
  35759. */
  35760. static EasingFunction: BackEase;
  35761. /**
  35762. * The easing mode used by animations
  35763. */
  35764. static EasingMode: number;
  35765. /**
  35766. * The duration of the animation, in milliseconds
  35767. */
  35768. transitionDuration: number;
  35769. /**
  35770. * Length of the distance animated by the transition when lower radius is reached
  35771. */
  35772. lowerRadiusTransitionRange: number;
  35773. /**
  35774. * Length of the distance animated by the transition when upper radius is reached
  35775. */
  35776. upperRadiusTransitionRange: number;
  35777. private _autoTransitionRange;
  35778. /**
  35779. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35780. */
  35781. /**
  35782. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35783. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  35784. */
  35785. autoTransitionRange: boolean;
  35786. private _attachedCamera;
  35787. private _onAfterCheckInputsObserver;
  35788. private _onMeshTargetChangedObserver;
  35789. /**
  35790. * Initializes the behavior.
  35791. */
  35792. init(): void;
  35793. /**
  35794. * Attaches the behavior to its arc rotate camera.
  35795. * @param camera Defines the camera to attach the behavior to
  35796. */
  35797. attach(camera: ArcRotateCamera): void;
  35798. /**
  35799. * Detaches the behavior from its current arc rotate camera.
  35800. */
  35801. detach(): void;
  35802. private _radiusIsAnimating;
  35803. private _radiusBounceTransition;
  35804. private _animatables;
  35805. private _cachedWheelPrecision;
  35806. /**
  35807. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  35808. * @param radiusLimit The limit to check against.
  35809. * @return Bool to indicate if at limit.
  35810. */
  35811. private _isRadiusAtLimit;
  35812. /**
  35813. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  35814. * @param radiusDelta The delta by which to animate to. Can be negative.
  35815. */
  35816. private _applyBoundRadiusAnimation;
  35817. /**
  35818. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  35819. */
  35820. protected _clearAnimationLocks(): void;
  35821. /**
  35822. * Stops and removes all animations that have been applied to the camera
  35823. */
  35824. stopAllAnimations(): void;
  35825. }
  35826. }
  35827. declare module BABYLON {
  35828. /**
  35829. * The framing behavior (BABYLON.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.
  35830. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35831. */
  35832. class FramingBehavior implements Behavior<ArcRotateCamera> {
  35833. /**
  35834. * Gets the name of the behavior.
  35835. */
  35836. readonly name: string;
  35837. private _mode;
  35838. private _radiusScale;
  35839. private _positionScale;
  35840. private _defaultElevation;
  35841. private _elevationReturnTime;
  35842. private _elevationReturnWaitTime;
  35843. private _zoomStopsAnimation;
  35844. private _framingTime;
  35845. /**
  35846. * The easing function used by animations
  35847. */
  35848. static EasingFunction: ExponentialEase;
  35849. /**
  35850. * The easing mode used by animations
  35851. */
  35852. static EasingMode: number;
  35853. /**
  35854. * Sets the current mode used by the behavior
  35855. */
  35856. /**
  35857. * Gets current mode used by the behavior.
  35858. */
  35859. mode: number;
  35860. /**
  35861. * Sets the scale applied to the radius (1 by default)
  35862. */
  35863. /**
  35864. * Gets the scale applied to the radius
  35865. */
  35866. radiusScale: number;
  35867. /**
  35868. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  35869. */
  35870. /**
  35871. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  35872. */
  35873. positionScale: number;
  35874. /**
  35875. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  35876. * behaviour is triggered, in radians.
  35877. */
  35878. /**
  35879. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  35880. * behaviour is triggered, in radians.
  35881. */
  35882. defaultElevation: number;
  35883. /**
  35884. * Sets the time (in milliseconds) taken to return to the default beta position.
  35885. * Negative value indicates camera should not return to default.
  35886. */
  35887. /**
  35888. * Gets the time (in milliseconds) taken to return to the default beta position.
  35889. * Negative value indicates camera should not return to default.
  35890. */
  35891. elevationReturnTime: number;
  35892. /**
  35893. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  35894. */
  35895. /**
  35896. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  35897. */
  35898. elevationReturnWaitTime: number;
  35899. /**
  35900. * Sets the flag that indicates if user zooming should stop animation.
  35901. */
  35902. /**
  35903. * Gets the flag that indicates if user zooming should stop animation.
  35904. */
  35905. zoomStopsAnimation: boolean;
  35906. /**
  35907. * Sets the transition time when framing the mesh, in milliseconds
  35908. */
  35909. /**
  35910. * Gets the transition time when framing the mesh, in milliseconds
  35911. */
  35912. framingTime: number;
  35913. /**
  35914. * Define if the behavior should automatically change the configured
  35915. * camera limits and sensibilities.
  35916. */
  35917. autoCorrectCameraLimitsAndSensibility: boolean;
  35918. private _onPrePointerObservableObserver;
  35919. private _onAfterCheckInputsObserver;
  35920. private _onMeshTargetChangedObserver;
  35921. private _attachedCamera;
  35922. private _isPointerDown;
  35923. private _lastInteractionTime;
  35924. /**
  35925. * Initializes the behavior.
  35926. */
  35927. init(): void;
  35928. /**
  35929. * Attaches the behavior to its arc rotate camera.
  35930. * @param camera Defines the camera to attach the behavior to
  35931. */
  35932. attach(camera: ArcRotateCamera): void;
  35933. /**
  35934. * Detaches the behavior from its current arc rotate camera.
  35935. */
  35936. detach(): void;
  35937. private _animatables;
  35938. private _betaIsAnimating;
  35939. private _betaTransition;
  35940. private _radiusTransition;
  35941. private _vectorTransition;
  35942. /**
  35943. * Targets the given mesh and updates zoom level accordingly.
  35944. * @param mesh The mesh to target.
  35945. * @param radius Optional. If a cached radius position already exists, overrides default.
  35946. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35947. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35948. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35949. */
  35950. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35951. /**
  35952. * Targets the given mesh with its children and updates zoom level accordingly.
  35953. * @param mesh The mesh to target.
  35954. * @param radius Optional. If a cached radius position already exists, overrides default.
  35955. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35956. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35957. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35958. */
  35959. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35960. /**
  35961. * Targets the given meshes with their children and updates zoom level accordingly.
  35962. * @param meshes The mesh to target.
  35963. * @param radius Optional. If a cached radius position already exists, overrides default.
  35964. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35965. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35966. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35967. */
  35968. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35969. /**
  35970. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  35971. * @param minimumWorld Determines the smaller position of the bounding box extend
  35972. * @param maximumWorld Determines the bigger position of the bounding box extend
  35973. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35974. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35975. */
  35976. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35977. /**
  35978. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  35979. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  35980. * frustum width.
  35981. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  35982. * to fully enclose the mesh in the viewing frustum.
  35983. */
  35984. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  35985. /**
  35986. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  35987. * is automatically returned to its default position (expected to be above ground plane).
  35988. */
  35989. private _maintainCameraAboveGround;
  35990. /**
  35991. * Returns the frustum slope based on the canvas ratio and camera FOV
  35992. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  35993. */
  35994. private _getFrustumSlope;
  35995. /**
  35996. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  35997. */
  35998. private _clearAnimationLocks;
  35999. /**
  36000. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  36001. */
  36002. private _applyUserInteraction;
  36003. /**
  36004. * Stops and removes all animations that have been applied to the camera
  36005. */
  36006. stopAllAnimations(): void;
  36007. /**
  36008. * Gets a value indicating if the user is moving the camera
  36009. */
  36010. readonly isUserIsMoving: boolean;
  36011. /**
  36012. * The camera can move all the way towards the mesh.
  36013. */
  36014. static IgnoreBoundsSizeMode: number;
  36015. /**
  36016. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  36017. */
  36018. static FitFrustumSidesMode: number;
  36019. }
  36020. }
  36021. declare module BABYLON {
  36022. /**
  36023. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  36024. */
  36025. class AttachToBoxBehavior implements BABYLON.Behavior<BABYLON.Mesh> {
  36026. private ui;
  36027. /**
  36028. * The name of the behavior
  36029. */
  36030. name: string;
  36031. /**
  36032. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  36033. */
  36034. distanceAwayFromFace: number;
  36035. /**
  36036. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  36037. */
  36038. distanceAwayFromBottomOfFace: number;
  36039. private _faceVectors;
  36040. private _target;
  36041. private _scene;
  36042. private _onRenderObserver;
  36043. private _tmpMatrix;
  36044. private _tmpVector;
  36045. /**
  36046. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  36047. * @param ui The transform node that should be attched to the mesh
  36048. */
  36049. constructor(ui: BABYLON.TransformNode);
  36050. /**
  36051. * Initializes the behavior
  36052. */
  36053. init(): void;
  36054. private _closestFace;
  36055. private _zeroVector;
  36056. private _lookAtTmpMatrix;
  36057. private _lookAtToRef;
  36058. /**
  36059. * Attaches the AttachToBoxBehavior to the passed in mesh
  36060. * @param target The mesh that the specified node will be attached to
  36061. */
  36062. attach(target: BABYLON.Mesh): void;
  36063. /**
  36064. * Detaches the behavior from the mesh
  36065. */
  36066. detach(): void;
  36067. }
  36068. }
  36069. declare module BABYLON {
  36070. /**
  36071. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  36072. */
  36073. class FadeInOutBehavior implements Behavior<Mesh> {
  36074. /**
  36075. * Time in milliseconds to delay before fading in (Default: 0)
  36076. */
  36077. delay: number;
  36078. /**
  36079. * Time in milliseconds for the mesh to fade in (Default: 300)
  36080. */
  36081. fadeInTime: number;
  36082. private _millisecondsPerFrame;
  36083. private _hovered;
  36084. private _hoverValue;
  36085. private _ownerNode;
  36086. /**
  36087. * Instatiates the FadeInOutBehavior
  36088. */
  36089. constructor();
  36090. /**
  36091. * The name of the behavior
  36092. */
  36093. readonly name: string;
  36094. /**
  36095. * Initializes the behavior
  36096. */
  36097. init(): void;
  36098. /**
  36099. * Attaches the fade behavior on the passed in mesh
  36100. * @param ownerNode The mesh that will be faded in/out once attached
  36101. */
  36102. attach(ownerNode: Mesh): void;
  36103. /**
  36104. * Detaches the behavior from the mesh
  36105. */
  36106. detach(): void;
  36107. /**
  36108. * Triggers the mesh to begin fading in or out
  36109. * @param value if the object should fade in or out (true to fade in)
  36110. */
  36111. fadeIn(value: boolean): void;
  36112. private _update;
  36113. private _setAllVisibility;
  36114. }
  36115. }
  36116. declare module BABYLON {
  36117. /**
  36118. * A behavior that when attached to a mesh will allow the mesh to be scaled
  36119. */
  36120. class MultiPointerScaleBehavior implements Behavior<Mesh> {
  36121. private _dragBehaviorA;
  36122. private _dragBehaviorB;
  36123. private _startDistance;
  36124. private _initialScale;
  36125. private _targetScale;
  36126. private _ownerNode;
  36127. private _sceneRenderObserver;
  36128. /**
  36129. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  36130. */
  36131. constructor();
  36132. /**
  36133. * The name of the behavior
  36134. */
  36135. readonly name: string;
  36136. /**
  36137. * Initializes the behavior
  36138. */
  36139. init(): void;
  36140. private _getCurrentDistance;
  36141. /**
  36142. * Attaches the scale behavior the passed in mesh
  36143. * @param ownerNode The mesh that will be scaled around once attached
  36144. */
  36145. attach(ownerNode: Mesh): void;
  36146. /**
  36147. * Detaches the behavior from the mesh
  36148. */
  36149. detach(): void;
  36150. }
  36151. }
  36152. declare module BABYLON {
  36153. /**
  36154. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  36155. */
  36156. class PointerDragBehavior implements Behavior<Mesh> {
  36157. private static _AnyMouseID;
  36158. private _attachedNode;
  36159. private _dragPlane;
  36160. private _scene;
  36161. private _pointerObserver;
  36162. private _beforeRenderObserver;
  36163. private static _planeScene;
  36164. /**
  36165. * 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)
  36166. */
  36167. maxDragAngle: number;
  36168. /**
  36169. * @hidden
  36170. */
  36171. /**
  36172. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  36173. */
  36174. currentDraggingPointerID: number;
  36175. /**
  36176. * The last position where the pointer hit the drag plane in world space
  36177. */
  36178. lastDragPosition: Vector3;
  36179. /**
  36180. * If the behavior is currently in a dragging state
  36181. */
  36182. dragging: boolean;
  36183. /**
  36184. * 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)
  36185. */
  36186. dragDeltaRatio: number;
  36187. /**
  36188. * If the drag plane orientation should be updated during the dragging (Default: true)
  36189. */
  36190. updateDragPlane: boolean;
  36191. private _debugMode;
  36192. private _moving;
  36193. /**
  36194. * Fires each time the attached mesh is dragged with the pointer
  36195. * * delta between last drag position and current drag position in world space
  36196. * * dragDistance along the drag axis
  36197. * * dragPlaneNormal normal of the current drag plane used during the drag
  36198. * * dragPlanePoint in world space where the drag intersects the drag plane
  36199. */
  36200. onDragObservable: Observable<{
  36201. delta: Vector3;
  36202. dragPlanePoint: Vector3;
  36203. dragPlaneNormal: Vector3;
  36204. dragDistance: number;
  36205. pointerId: number;
  36206. }>;
  36207. /**
  36208. * Fires each time a drag begins (eg. mouse down on mesh)
  36209. */
  36210. onDragStartObservable: Observable<{
  36211. dragPlanePoint: Vector3;
  36212. pointerId: number;
  36213. }>;
  36214. /**
  36215. * Fires each time a drag ends (eg. mouse release after drag)
  36216. */
  36217. onDragEndObservable: Observable<{
  36218. dragPlanePoint: Vector3;
  36219. pointerId: number;
  36220. }>;
  36221. /**
  36222. * If the attached mesh should be moved when dragged
  36223. */
  36224. moveAttached: boolean;
  36225. /**
  36226. * If the drag behavior will react to drag events (Default: true)
  36227. */
  36228. enabled: boolean;
  36229. /**
  36230. * If camera controls should be detached during the drag
  36231. */
  36232. detachCameraControls: boolean;
  36233. /**
  36234. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  36235. */
  36236. useObjectOrienationForDragging: boolean;
  36237. private _options;
  36238. /**
  36239. * Creates a pointer drag behavior that can be attached to a mesh
  36240. * @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)
  36241. */
  36242. constructor(options?: {
  36243. dragAxis?: Vector3;
  36244. dragPlaneNormal?: Vector3;
  36245. });
  36246. /**
  36247. * The name of the behavior
  36248. */
  36249. readonly name: string;
  36250. /**
  36251. * Initializes the behavior
  36252. */
  36253. init(): void;
  36254. private _tmpVector;
  36255. private _alternatePickedPoint;
  36256. private _worldDragAxis;
  36257. private _targetPosition;
  36258. private _attachedElement;
  36259. /**
  36260. * Attaches the drag behavior the passed in mesh
  36261. * @param ownerNode The mesh that will be dragged around once attached
  36262. */
  36263. attach(ownerNode: Mesh): void;
  36264. /**
  36265. * Force relase the drag action by code.
  36266. */
  36267. releaseDrag(): void;
  36268. private _startDragRay;
  36269. private _lastPointerRay;
  36270. /**
  36271. * Simulates the start of a pointer drag event on the behavior
  36272. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  36273. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  36274. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  36275. */
  36276. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  36277. private _startDrag;
  36278. private _dragDelta;
  36279. private _moveDrag;
  36280. private _pickWithRayOnDragPlane;
  36281. private _pointA;
  36282. private _pointB;
  36283. private _pointC;
  36284. private _lineA;
  36285. private _lineB;
  36286. private _localAxis;
  36287. private _lookAt;
  36288. private _updateDragPlanePosition;
  36289. /**
  36290. * Detaches the behavior from the mesh
  36291. */
  36292. detach(): void;
  36293. }
  36294. }
  36295. declare module BABYLON {
  36296. /**
  36297. * 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
  36298. */
  36299. class SixDofDragBehavior implements Behavior<Mesh> {
  36300. private static _virtualScene;
  36301. private _ownerNode;
  36302. private _sceneRenderObserver;
  36303. private _scene;
  36304. private _targetPosition;
  36305. private _virtualOriginMesh;
  36306. private _virtualDragMesh;
  36307. private _pointerObserver;
  36308. private _moving;
  36309. private _startingOrientation;
  36310. /**
  36311. * 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)
  36312. */
  36313. private zDragFactor;
  36314. /**
  36315. * If the behavior is currently in a dragging state
  36316. */
  36317. dragging: boolean;
  36318. /**
  36319. * 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)
  36320. */
  36321. dragDeltaRatio: number;
  36322. /**
  36323. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  36324. */
  36325. currentDraggingPointerID: number;
  36326. /**
  36327. * If camera controls should be detached during the drag
  36328. */
  36329. detachCameraControls: boolean;
  36330. /**
  36331. * Fires each time a drag starts
  36332. */
  36333. onDragStartObservable: Observable<{}>;
  36334. /**
  36335. * Fires each time a drag ends (eg. mouse release after drag)
  36336. */
  36337. onDragEndObservable: Observable<{}>;
  36338. /**
  36339. * 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
  36340. */
  36341. constructor();
  36342. /**
  36343. * The name of the behavior
  36344. */
  36345. readonly name: string;
  36346. /**
  36347. * Initializes the behavior
  36348. */
  36349. init(): void;
  36350. /**
  36351. * Attaches the scale behavior the passed in mesh
  36352. * @param ownerNode The mesh that will be scaled around once attached
  36353. */
  36354. attach(ownerNode: Mesh): void;
  36355. /**
  36356. * Detaches the behavior from the mesh
  36357. */
  36358. detach(): void;
  36359. }
  36360. }
  36361. declare module BABYLON {
  36362. /**
  36363. * Manage the gamepad inputs to control an arc rotate camera.
  36364. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36365. */
  36366. class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  36367. /**
  36368. * Defines the camera the input is attached to.
  36369. */
  36370. camera: ArcRotateCamera;
  36371. /**
  36372. * Defines the gamepad the input is gathering event from.
  36373. */
  36374. gamepad: Nullable<Gamepad>;
  36375. /**
  36376. * Defines the gamepad rotation sensiblity.
  36377. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  36378. */
  36379. gamepadRotationSensibility: number;
  36380. /**
  36381. * Defines the gamepad move sensiblity.
  36382. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  36383. */
  36384. gamepadMoveSensibility: number;
  36385. private _onGamepadConnectedObserver;
  36386. private _onGamepadDisconnectedObserver;
  36387. /**
  36388. * Attach the input controls to a specific dom element to get the input from.
  36389. * @param element Defines the element the controls should be listened from
  36390. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36391. */
  36392. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36393. /**
  36394. * Detach the current controls from the specified dom element.
  36395. * @param element Defines the element to stop listening the inputs from
  36396. */
  36397. detachControl(element: Nullable<HTMLElement>): void;
  36398. /**
  36399. * Update the current camera state depending on the inputs that have been used this frame.
  36400. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36401. */
  36402. checkInputs(): void;
  36403. /**
  36404. * Gets the class name of the current intput.
  36405. * @returns the class name
  36406. */
  36407. getClassName(): string;
  36408. /**
  36409. * Get the friendly name associated with the input class.
  36410. * @returns the input friendly name
  36411. */
  36412. getSimpleName(): string;
  36413. }
  36414. }
  36415. declare module BABYLON {
  36416. /**
  36417. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  36418. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36419. */
  36420. class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  36421. /**
  36422. * Defines the camera the input is attached to.
  36423. */
  36424. camera: ArcRotateCamera;
  36425. /**
  36426. * Defines the list of key codes associated with the up action (increase alpha)
  36427. */
  36428. keysUp: number[];
  36429. /**
  36430. * Defines the list of key codes associated with the down action (decrease alpha)
  36431. */
  36432. keysDown: number[];
  36433. /**
  36434. * Defines the list of key codes associated with the left action (increase beta)
  36435. */
  36436. keysLeft: number[];
  36437. /**
  36438. * Defines the list of key codes associated with the right action (decrease beta)
  36439. */
  36440. keysRight: number[];
  36441. /**
  36442. * Defines the list of key codes associated with the reset action.
  36443. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  36444. */
  36445. keysReset: number[];
  36446. /**
  36447. * Defines the panning sensibility of the inputs.
  36448. * (How fast is the camera paning)
  36449. */
  36450. panningSensibility: number;
  36451. /**
  36452. * Defines the zooming sensibility of the inputs.
  36453. * (How fast is the camera zooming)
  36454. */
  36455. zoomingSensibility: number;
  36456. /**
  36457. * Defines wether maintaining the alt key down switch the movement mode from
  36458. * orientation to zoom.
  36459. */
  36460. useAltToZoom: boolean;
  36461. private _keys;
  36462. private _ctrlPressed;
  36463. private _altPressed;
  36464. private _onCanvasBlurObserver;
  36465. private _onKeyboardObserver;
  36466. private _engine;
  36467. private _scene;
  36468. /**
  36469. * Attach the input controls to a specific dom element to get the input from.
  36470. * @param element Defines the element the controls should be listened from
  36471. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36472. */
  36473. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36474. /**
  36475. * Detach the current controls from the specified dom element.
  36476. * @param element Defines the element to stop listening the inputs from
  36477. */
  36478. detachControl(element: Nullable<HTMLElement>): void;
  36479. /**
  36480. * Update the current camera state depending on the inputs that have been used this frame.
  36481. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36482. */
  36483. checkInputs(): void;
  36484. /**
  36485. * Gets the class name of the current intput.
  36486. * @returns the class name
  36487. */
  36488. getClassName(): string;
  36489. /**
  36490. * Get the friendly name associated with the input class.
  36491. * @returns the input friendly name
  36492. */
  36493. getSimpleName(): string;
  36494. }
  36495. }
  36496. declare module BABYLON {
  36497. /**
  36498. * Manage the mouse wheel inputs to control an arc rotate camera.
  36499. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36500. */
  36501. class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  36502. /**
  36503. * Defines the camera the input is attached to.
  36504. */
  36505. camera: ArcRotateCamera;
  36506. /**
  36507. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  36508. */
  36509. wheelPrecision: number;
  36510. /**
  36511. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  36512. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  36513. */
  36514. wheelDeltaPercentage: number;
  36515. private _wheel;
  36516. private _observer;
  36517. /**
  36518. * Attach the input controls to a specific dom element to get the input from.
  36519. * @param element Defines the element the controls should be listened from
  36520. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36521. */
  36522. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36523. /**
  36524. * Detach the current controls from the specified dom element.
  36525. * @param element Defines the element to stop listening the inputs from
  36526. */
  36527. detachControl(element: Nullable<HTMLElement>): void;
  36528. /**
  36529. * Gets the class name of the current intput.
  36530. * @returns the class name
  36531. */
  36532. getClassName(): string;
  36533. /**
  36534. * Get the friendly name associated with the input class.
  36535. * @returns the input friendly name
  36536. */
  36537. getSimpleName(): string;
  36538. }
  36539. }
  36540. declare module BABYLON {
  36541. /**
  36542. * Manage the pointers inputs to control an arc rotate camera.
  36543. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36544. */
  36545. class ArcRotateCameraPointersInput implements ICameraInput<ArcRotateCamera> {
  36546. /**
  36547. * Defines the camera the input is attached to.
  36548. */
  36549. camera: ArcRotateCamera;
  36550. /**
  36551. * Defines the buttons associated with the input to handle camera move.
  36552. */
  36553. buttons: number[];
  36554. /**
  36555. * Defines the pointer angular sensibility along the X axis or how fast is the camera rotating.
  36556. */
  36557. angularSensibilityX: number;
  36558. /**
  36559. * Defines the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  36560. */
  36561. angularSensibilityY: number;
  36562. /**
  36563. * Defines the pointer pinch precision or how fast is the camera zooming.
  36564. */
  36565. pinchPrecision: number;
  36566. /**
  36567. * pinchDeltaPercentage will be used instead of pinchPrecision if different from 0.
  36568. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  36569. */
  36570. pinchDeltaPercentage: number;
  36571. /**
  36572. * Defines the pointer panning sensibility or how fast is the camera moving.
  36573. */
  36574. panningSensibility: number;
  36575. /**
  36576. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  36577. */
  36578. multiTouchPanning: boolean;
  36579. /**
  36580. * Defines whether panning is enabled for both pan (2 fingers swipe) and zoom (pinch) through multitouch.
  36581. */
  36582. multiTouchPanAndZoom: boolean;
  36583. /**
  36584. * Revers pinch action direction.
  36585. */
  36586. pinchInwards: boolean;
  36587. private _isPanClick;
  36588. private _pointerInput;
  36589. private _observer;
  36590. private _onMouseMove;
  36591. private _onGestureStart;
  36592. private _onGesture;
  36593. private _MSGestureHandler;
  36594. private _onLostFocus;
  36595. private _onContextMenu;
  36596. /**
  36597. * Attach the input controls to a specific dom element to get the input from.
  36598. * @param element Defines the element the controls should be listened from
  36599. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36600. */
  36601. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36602. /**
  36603. * Detach the current controls from the specified dom element.
  36604. * @param element Defines the element to stop listening the inputs from
  36605. */
  36606. detachControl(element: Nullable<HTMLElement>): void;
  36607. /**
  36608. * Gets the class name of the current intput.
  36609. * @returns the class name
  36610. */
  36611. getClassName(): string;
  36612. /**
  36613. * Get the friendly name associated with the input class.
  36614. * @returns the input friendly name
  36615. */
  36616. getSimpleName(): string;
  36617. }
  36618. }
  36619. declare module BABYLON {
  36620. /**
  36621. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  36622. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36623. */
  36624. class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  36625. /**
  36626. * Defines the camera the input is attached to.
  36627. */
  36628. camera: ArcRotateCamera;
  36629. /**
  36630. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  36631. */
  36632. alphaCorrection: number;
  36633. /**
  36634. * Defines a correction factor applied on the beta value retrieved from the orientation events.
  36635. */
  36636. betaCorrection: number;
  36637. /**
  36638. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  36639. */
  36640. gammaCorrection: number;
  36641. private _alpha;
  36642. private _gamma;
  36643. private _dirty;
  36644. private _deviceOrientationHandler;
  36645. /**
  36646. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  36647. */
  36648. constructor();
  36649. /**
  36650. * Attach the input controls to a specific dom element to get the input from.
  36651. * @param element Defines the element the controls should be listened from
  36652. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36653. */
  36654. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36655. /** @hidden */
  36656. /**
  36657. * Update the current camera state depending on the inputs that have been used this frame.
  36658. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36659. */
  36660. checkInputs(): void;
  36661. /**
  36662. * Detach the current controls from the specified dom element.
  36663. * @param element Defines the element to stop listening the inputs from
  36664. */
  36665. detachControl(element: Nullable<HTMLElement>): void;
  36666. /**
  36667. * Gets the class name of the current intput.
  36668. * @returns the class name
  36669. */
  36670. getClassName(): string;
  36671. /**
  36672. * Get the friendly name associated with the input class.
  36673. * @returns the input friendly name
  36674. */
  36675. getSimpleName(): string;
  36676. }
  36677. }
  36678. declare module BABYLON {
  36679. /**
  36680. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  36681. * Screen rotation is taken into account.
  36682. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36683. */
  36684. class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  36685. private _camera;
  36686. private _screenOrientationAngle;
  36687. private _constantTranform;
  36688. private _screenQuaternion;
  36689. private _alpha;
  36690. private _beta;
  36691. private _gamma;
  36692. /**
  36693. * Instantiates a new input
  36694. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36695. */
  36696. constructor();
  36697. /**
  36698. * Define the camera controlled by the input.
  36699. */
  36700. camera: FreeCamera;
  36701. /**
  36702. * Attach the input controls to a specific dom element to get the input from.
  36703. * @param element Defines the element the controls should be listened from
  36704. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36705. */
  36706. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36707. private _orientationChanged;
  36708. private _deviceOrientation;
  36709. /**
  36710. * Detach the current controls from the specified dom element.
  36711. * @param element Defines the element to stop listening the inputs from
  36712. */
  36713. detachControl(element: Nullable<HTMLElement>): void;
  36714. /**
  36715. * Update the current camera state depending on the inputs that have been used this frame.
  36716. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36717. */
  36718. checkInputs(): void;
  36719. /**
  36720. * Gets the class name of the current intput.
  36721. * @returns the class name
  36722. */
  36723. getClassName(): string;
  36724. /**
  36725. * Get the friendly name associated with the input class.
  36726. * @returns the input friendly name
  36727. */
  36728. getSimpleName(): string;
  36729. }
  36730. }
  36731. declare module BABYLON {
  36732. /**
  36733. * Manage the gamepad inputs to control a free camera.
  36734. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36735. */
  36736. class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  36737. /**
  36738. * Define the camera the input is attached to.
  36739. */
  36740. camera: FreeCamera;
  36741. /**
  36742. * Define the Gamepad controlling the input
  36743. */
  36744. gamepad: Nullable<Gamepad>;
  36745. /**
  36746. * Defines the gamepad rotation sensiblity.
  36747. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  36748. */
  36749. gamepadAngularSensibility: number;
  36750. /**
  36751. * Defines the gamepad move sensiblity.
  36752. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  36753. */
  36754. gamepadMoveSensibility: number;
  36755. private _onGamepadConnectedObserver;
  36756. private _onGamepadDisconnectedObserver;
  36757. private _cameraTransform;
  36758. private _deltaTransform;
  36759. private _vector3;
  36760. private _vector2;
  36761. /**
  36762. * Attach the input controls to a specific dom element to get the input from.
  36763. * @param element Defines the element the controls should be listened from
  36764. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36765. */
  36766. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36767. /**
  36768. * Detach the current controls from the specified dom element.
  36769. * @param element Defines the element to stop listening the inputs from
  36770. */
  36771. detachControl(element: Nullable<HTMLElement>): void;
  36772. /**
  36773. * Update the current camera state depending on the inputs that have been used this frame.
  36774. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36775. */
  36776. checkInputs(): void;
  36777. /**
  36778. * Gets the class name of the current intput.
  36779. * @returns the class name
  36780. */
  36781. getClassName(): string;
  36782. /**
  36783. * Get the friendly name associated with the input class.
  36784. * @returns the input friendly name
  36785. */
  36786. getSimpleName(): string;
  36787. }
  36788. }
  36789. declare module BABYLON {
  36790. /**
  36791. * Manage the keyboard inputs to control the movement of a free camera.
  36792. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36793. */
  36794. class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  36795. /**
  36796. * Defines the camera the input is attached to.
  36797. */
  36798. camera: FreeCamera;
  36799. /**
  36800. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  36801. */
  36802. keysUp: number[];
  36803. /**
  36804. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  36805. */
  36806. keysDown: number[];
  36807. /**
  36808. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  36809. */
  36810. keysLeft: number[];
  36811. /**
  36812. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  36813. */
  36814. keysRight: number[];
  36815. private _keys;
  36816. private _onCanvasBlurObserver;
  36817. private _onKeyboardObserver;
  36818. private _engine;
  36819. private _scene;
  36820. /**
  36821. * Attach the input controls to a specific dom element to get the input from.
  36822. * @param element Defines the element the controls should be listened from
  36823. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36824. */
  36825. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36826. /**
  36827. * Detach the current controls from the specified dom element.
  36828. * @param element Defines the element to stop listening the inputs from
  36829. */
  36830. detachControl(element: Nullable<HTMLElement>): void;
  36831. /**
  36832. * Update the current camera state depending on the inputs that have been used this frame.
  36833. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36834. */
  36835. checkInputs(): void;
  36836. /**
  36837. * Gets the class name of the current intput.
  36838. * @returns the class name
  36839. */
  36840. getClassName(): string;
  36841. /** @hidden */
  36842. /**
  36843. * Get the friendly name associated with the input class.
  36844. * @returns the input friendly name
  36845. */
  36846. getSimpleName(): string;
  36847. }
  36848. }
  36849. declare module BABYLON {
  36850. /**
  36851. * Manage the mouse inputs to control the movement of a free camera.
  36852. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36853. */
  36854. class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  36855. /**
  36856. * Define if touch is enabled in the mouse input
  36857. */
  36858. touchEnabled: boolean;
  36859. /**
  36860. * Defines the camera the input is attached to.
  36861. */
  36862. camera: FreeCamera;
  36863. /**
  36864. * Defines the buttons associated with the input to handle camera move.
  36865. */
  36866. buttons: number[];
  36867. /**
  36868. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  36869. */
  36870. angularSensibility: number;
  36871. private _pointerInput;
  36872. private _onMouseMove;
  36873. private _observer;
  36874. private previousPosition;
  36875. /**
  36876. * Manage the mouse inputs to control the movement of a free camera.
  36877. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36878. * @param touchEnabled Defines if touch is enabled or not
  36879. */
  36880. constructor(
  36881. /**
  36882. * Define if touch is enabled in the mouse input
  36883. */
  36884. touchEnabled?: boolean);
  36885. /**
  36886. * Attach the input controls to a specific dom element to get the input from.
  36887. * @param element Defines the element the controls should be listened from
  36888. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36889. */
  36890. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36891. /**
  36892. * Detach the current controls from the specified dom element.
  36893. * @param element Defines the element to stop listening the inputs from
  36894. */
  36895. detachControl(element: Nullable<HTMLElement>): void;
  36896. /**
  36897. * Gets the class name of the current intput.
  36898. * @returns the class name
  36899. */
  36900. getClassName(): string;
  36901. /**
  36902. * Get the friendly name associated with the input class.
  36903. * @returns the input friendly name
  36904. */
  36905. getSimpleName(): string;
  36906. }
  36907. }
  36908. declare module BABYLON {
  36909. /**
  36910. * Manage the touch inputs to control the movement of a free camera.
  36911. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36912. */
  36913. class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  36914. /**
  36915. * Defines the camera the input is attached to.
  36916. */
  36917. camera: FreeCamera;
  36918. /**
  36919. * Defines the touch sensibility for rotation.
  36920. * The higher the faster.
  36921. */
  36922. touchAngularSensibility: number;
  36923. /**
  36924. * Defines the touch sensibility for move.
  36925. * The higher the faster.
  36926. */
  36927. touchMoveSensibility: number;
  36928. private _offsetX;
  36929. private _offsetY;
  36930. private _pointerPressed;
  36931. private _pointerInput;
  36932. private _observer;
  36933. private _onLostFocus;
  36934. /**
  36935. * Attach the input controls to a specific dom element to get the input from.
  36936. * @param element Defines the element the controls should be listened from
  36937. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36938. */
  36939. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36940. /**
  36941. * Detach the current controls from the specified dom element.
  36942. * @param element Defines the element to stop listening the inputs from
  36943. */
  36944. detachControl(element: Nullable<HTMLElement>): void;
  36945. /**
  36946. * Update the current camera state depending on the inputs that have been used this frame.
  36947. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36948. */
  36949. checkInputs(): void;
  36950. /**
  36951. * Gets the class name of the current intput.
  36952. * @returns the class name
  36953. */
  36954. getClassName(): string;
  36955. /**
  36956. * Get the friendly name associated with the input class.
  36957. * @returns the input friendly name
  36958. */
  36959. getSimpleName(): string;
  36960. }
  36961. }
  36962. declare module BABYLON {
  36963. /**
  36964. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  36965. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36966. */
  36967. class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  36968. /**
  36969. * Defines the camera the input is attached to.
  36970. */
  36971. camera: FreeCamera;
  36972. private _leftjoystick;
  36973. private _rightjoystick;
  36974. /**
  36975. * Gets the left stick of the virtual joystick.
  36976. * @returns The virtual Joystick
  36977. */
  36978. getLeftJoystick(): VirtualJoystick;
  36979. /**
  36980. * Gets the right stick of the virtual joystick.
  36981. * @returns The virtual Joystick
  36982. */
  36983. getRightJoystick(): VirtualJoystick;
  36984. /**
  36985. * Update the current camera state depending on the inputs that have been used this frame.
  36986. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36987. */
  36988. checkInputs(): void;
  36989. /**
  36990. * Attach the input controls to a specific dom element to get the input from.
  36991. * @param element Defines the element the controls should be listened from
  36992. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36993. */
  36994. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36995. /**
  36996. * Detach the current controls from the specified dom element.
  36997. * @param element Defines the element to stop listening the inputs from
  36998. */
  36999. detachControl(element: Nullable<HTMLElement>): void;
  37000. /**
  37001. * Gets the class name of the current intput.
  37002. * @returns the class name
  37003. */
  37004. getClassName(): string;
  37005. /**
  37006. * Get the friendly name associated with the input class.
  37007. * @returns the input friendly name
  37008. */
  37009. getSimpleName(): string;
  37010. }
  37011. }
  37012. declare module BABYLON {
  37013. /**
  37014. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  37015. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37016. */
  37017. class AnaglyphArcRotateCamera extends ArcRotateCamera {
  37018. /**
  37019. * Creates a new AnaglyphArcRotateCamera
  37020. * @param name defines camera name
  37021. * @param alpha defines alpha angle (in radians)
  37022. * @param beta defines beta angle (in radians)
  37023. * @param radius defines radius
  37024. * @param target defines camera target
  37025. * @param interaxialDistance defines distance between each color axis
  37026. * @param scene defines the hosting scene
  37027. */
  37028. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  37029. /**
  37030. * Gets camera class name
  37031. * @returns AnaglyphArcRotateCamera
  37032. */
  37033. getClassName(): string;
  37034. }
  37035. }
  37036. declare module BABYLON {
  37037. /**
  37038. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  37039. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37040. */
  37041. class AnaglyphFreeCamera extends FreeCamera {
  37042. /**
  37043. * Creates a new AnaglyphFreeCamera
  37044. * @param name defines camera name
  37045. * @param position defines initial position
  37046. * @param interaxialDistance defines distance between each color axis
  37047. * @param scene defines the hosting scene
  37048. */
  37049. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  37050. /**
  37051. * Gets camera class name
  37052. * @returns AnaglyphFreeCamera
  37053. */
  37054. getClassName(): string;
  37055. }
  37056. }
  37057. declare module BABYLON {
  37058. /**
  37059. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  37060. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37061. */
  37062. class AnaglyphGamepadCamera extends GamepadCamera {
  37063. /**
  37064. * Creates a new AnaglyphGamepadCamera
  37065. * @param name defines camera name
  37066. * @param position defines initial position
  37067. * @param interaxialDistance defines distance between each color axis
  37068. * @param scene defines the hosting scene
  37069. */
  37070. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  37071. /**
  37072. * Gets camera class name
  37073. * @returns AnaglyphGamepadCamera
  37074. */
  37075. getClassName(): string;
  37076. }
  37077. }
  37078. declare module BABYLON {
  37079. /**
  37080. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  37081. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37082. */
  37083. class AnaglyphUniversalCamera extends UniversalCamera {
  37084. /**
  37085. * Creates a new AnaglyphUniversalCamera
  37086. * @param name defines camera name
  37087. * @param position defines initial position
  37088. * @param interaxialDistance defines distance between each color axis
  37089. * @param scene defines the hosting scene
  37090. */
  37091. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  37092. /**
  37093. * Gets camera class name
  37094. * @returns AnaglyphUniversalCamera
  37095. */
  37096. getClassName(): string;
  37097. }
  37098. }
  37099. declare module BABYLON {
  37100. /**
  37101. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  37102. * @see http://doc.babylonjs.com/features/cameras
  37103. */
  37104. class StereoscopicArcRotateCamera extends ArcRotateCamera {
  37105. /**
  37106. * Creates a new StereoscopicArcRotateCamera
  37107. * @param name defines camera name
  37108. * @param alpha defines alpha angle (in radians)
  37109. * @param beta defines beta angle (in radians)
  37110. * @param radius defines radius
  37111. * @param target defines camera target
  37112. * @param interaxialDistance defines distance between each color axis
  37113. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37114. * @param scene defines the hosting scene
  37115. */
  37116. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37117. /**
  37118. * Gets camera class name
  37119. * @returns StereoscopicArcRotateCamera
  37120. */
  37121. getClassName(): string;
  37122. }
  37123. }
  37124. declare module BABYLON {
  37125. /**
  37126. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  37127. * @see http://doc.babylonjs.com/features/cameras
  37128. */
  37129. class StereoscopicFreeCamera extends FreeCamera {
  37130. /**
  37131. * Creates a new StereoscopicFreeCamera
  37132. * @param name defines camera name
  37133. * @param position defines initial position
  37134. * @param interaxialDistance defines distance between each color axis
  37135. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37136. * @param scene defines the hosting scene
  37137. */
  37138. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37139. /**
  37140. * Gets camera class name
  37141. * @returns StereoscopicFreeCamera
  37142. */
  37143. getClassName(): string;
  37144. }
  37145. }
  37146. declare module BABYLON {
  37147. /**
  37148. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  37149. * @see http://doc.babylonjs.com/features/cameras
  37150. */
  37151. class StereoscopicGamepadCamera extends GamepadCamera {
  37152. /**
  37153. * Creates a new StereoscopicGamepadCamera
  37154. * @param name defines camera name
  37155. * @param position defines initial position
  37156. * @param interaxialDistance defines distance between each color axis
  37157. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37158. * @param scene defines the hosting scene
  37159. */
  37160. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37161. /**
  37162. * Gets camera class name
  37163. * @returns StereoscopicGamepadCamera
  37164. */
  37165. getClassName(): string;
  37166. }
  37167. }
  37168. declare module BABYLON {
  37169. /**
  37170. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  37171. * @see http://doc.babylonjs.com/features/cameras
  37172. */
  37173. class StereoscopicUniversalCamera extends UniversalCamera {
  37174. /**
  37175. * Creates a new StereoscopicUniversalCamera
  37176. * @param name defines camera name
  37177. * @param position defines initial position
  37178. * @param interaxialDistance defines distance between each color axis
  37179. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37180. * @param scene defines the hosting scene
  37181. */
  37182. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37183. /**
  37184. * Gets camera class name
  37185. * @returns StereoscopicUniversalCamera
  37186. */
  37187. getClassName(): string;
  37188. }
  37189. }
  37190. declare module BABYLON {
  37191. /**
  37192. * This represents all the required metrics to create a VR camera.
  37193. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  37194. */
  37195. class VRCameraMetrics {
  37196. /**
  37197. * Define the horizontal resolution off the screen.
  37198. */
  37199. hResolution: number;
  37200. /**
  37201. * Define the vertical resolution off the screen.
  37202. */
  37203. vResolution: number;
  37204. /**
  37205. * Define the horizontal screen size.
  37206. */
  37207. hScreenSize: number;
  37208. /**
  37209. * Define the vertical screen size.
  37210. */
  37211. vScreenSize: number;
  37212. /**
  37213. * Define the vertical screen center position.
  37214. */
  37215. vScreenCenter: number;
  37216. /**
  37217. * Define the distance of the eyes to the screen.
  37218. */
  37219. eyeToScreenDistance: number;
  37220. /**
  37221. * Define the distance between both lenses
  37222. */
  37223. lensSeparationDistance: number;
  37224. /**
  37225. * Define the distance between both viewer's eyes.
  37226. */
  37227. interpupillaryDistance: number;
  37228. /**
  37229. * Define the distortion factor of the VR postprocess.
  37230. * Please, touch with care.
  37231. */
  37232. distortionK: number[];
  37233. /**
  37234. * Define the chromatic aberration correction factors for the VR post process.
  37235. */
  37236. chromaAbCorrection: number[];
  37237. /**
  37238. * Define the scale factor of the post process.
  37239. * The smaller the better but the slower.
  37240. */
  37241. postProcessScaleFactor: number;
  37242. /**
  37243. * Define an offset for the lens center.
  37244. */
  37245. lensCenterOffset: number;
  37246. /**
  37247. * Define if the current vr camera should compensate the distortion of the lense or not.
  37248. */
  37249. compensateDistortion: boolean;
  37250. /**
  37251. * Gets the rendering aspect ratio based on the provided resolutions.
  37252. */
  37253. readonly aspectRatio: number;
  37254. /**
  37255. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  37256. */
  37257. readonly aspectRatioFov: number;
  37258. /**
  37259. * @hidden
  37260. */
  37261. readonly leftHMatrix: Matrix;
  37262. /**
  37263. * @hidden
  37264. */
  37265. readonly rightHMatrix: Matrix;
  37266. /**
  37267. * @hidden
  37268. */
  37269. readonly leftPreViewMatrix: Matrix;
  37270. /**
  37271. * @hidden
  37272. */
  37273. readonly rightPreViewMatrix: Matrix;
  37274. /**
  37275. * Get the default VRMetrics based on the most generic setup.
  37276. * @returns the default vr metrics
  37277. */
  37278. static GetDefault(): VRCameraMetrics;
  37279. }
  37280. }
  37281. declare module BABYLON {
  37282. /**
  37283. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  37284. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  37285. */
  37286. class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  37287. /**
  37288. * Creates a new VRDeviceOrientationArcRotateCamera
  37289. * @param name defines camera name
  37290. * @param alpha defines the camera rotation along the logitudinal axis
  37291. * @param beta defines the camera rotation along the latitudinal axis
  37292. * @param radius defines the camera distance from its target
  37293. * @param target defines the camera target
  37294. * @param scene defines the scene the camera belongs to
  37295. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  37296. * @param vrCameraMetrics defines the vr metrics associated to the camera
  37297. */
  37298. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  37299. /**
  37300. * Gets camera class name
  37301. * @returns VRDeviceOrientationArcRotateCamera
  37302. */
  37303. getClassName(): string;
  37304. }
  37305. }
  37306. declare module BABYLON {
  37307. /**
  37308. * Camera used to simulate VR rendering (based on FreeCamera)
  37309. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  37310. */
  37311. class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  37312. /**
  37313. * Creates a new VRDeviceOrientationFreeCamera
  37314. * @param name defines camera name
  37315. * @param position defines the start position of the camera
  37316. * @param scene defines the scene the camera belongs to
  37317. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  37318. * @param vrCameraMetrics defines the vr metrics associated to the camera
  37319. */
  37320. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  37321. /**
  37322. * Gets camera class name
  37323. * @returns VRDeviceOrientationFreeCamera
  37324. */
  37325. getClassName(): string;
  37326. }
  37327. }
  37328. declare module BABYLON {
  37329. /**
  37330. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  37331. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  37332. */
  37333. class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  37334. /**
  37335. * Creates a new VRDeviceOrientationGamepadCamera
  37336. * @param name defines camera name
  37337. * @param position defines the start position of the camera
  37338. * @param scene defines the scene the camera belongs to
  37339. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  37340. * @param vrCameraMetrics defines the vr metrics associated to the camera
  37341. */
  37342. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  37343. /**
  37344. * Gets camera class name
  37345. * @returns VRDeviceOrientationGamepadCamera
  37346. */
  37347. getClassName(): string;
  37348. }
  37349. }
  37350. declare module BABYLON {
  37351. /**
  37352. * Options to modify the vr teleportation behavior.
  37353. */
  37354. interface VRTeleportationOptions {
  37355. /**
  37356. * The name of the mesh which should be used as the teleportation floor. (default: null)
  37357. */
  37358. floorMeshName?: string;
  37359. /**
  37360. * A list of meshes to be used as the teleportation floor. (default: empty)
  37361. */
  37362. floorMeshes?: Mesh[];
  37363. }
  37364. /**
  37365. * Options to modify the vr experience helper's behavior.
  37366. */
  37367. interface VRExperienceHelperOptions extends WebVROptions {
  37368. /**
  37369. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  37370. */
  37371. createDeviceOrientationCamera?: boolean;
  37372. /**
  37373. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  37374. */
  37375. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  37376. /**
  37377. * Uses the main button on the controller to toggle the laser casted. (default: true)
  37378. */
  37379. laserToggle?: boolean;
  37380. /**
  37381. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  37382. */
  37383. floorMeshes?: Mesh[];
  37384. }
  37385. /**
  37386. * Helps to quickly add VR support to an existing scene.
  37387. * See http://doc.babylonjs.com/how_to/webvr_helper
  37388. */
  37389. class VRExperienceHelper {
  37390. /** Options to modify the vr experience helper's behavior. */
  37391. webVROptions: VRExperienceHelperOptions;
  37392. private _scene;
  37393. private _position;
  37394. private _btnVR;
  37395. private _btnVRDisplayed;
  37396. private _webVRsupported;
  37397. private _webVRready;
  37398. private _webVRrequesting;
  37399. private _webVRpresenting;
  37400. private _hasEnteredVR;
  37401. private _fullscreenVRpresenting;
  37402. private _canvas;
  37403. private _webVRCamera;
  37404. private _vrDeviceOrientationCamera;
  37405. private _deviceOrientationCamera;
  37406. private _existingCamera;
  37407. private _onKeyDown;
  37408. private _onVrDisplayPresentChange;
  37409. private _onVRDisplayChanged;
  37410. private _onVRRequestPresentStart;
  37411. private _onVRRequestPresentComplete;
  37412. /**
  37413. * Observable raised when entering VR.
  37414. */
  37415. onEnteringVRObservable: Observable<VRExperienceHelper>;
  37416. /**
  37417. * Observable raised when exiting VR.
  37418. */
  37419. onExitingVRObservable: Observable<VRExperienceHelper>;
  37420. /**
  37421. * Observable raised when controller mesh is loaded.
  37422. */
  37423. onControllerMeshLoadedObservable: Observable<WebVRController>;
  37424. /** Return this.onEnteringVRObservable
  37425. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  37426. */
  37427. readonly onEnteringVR: Observable<VRExperienceHelper>;
  37428. /** Return this.onExitingVRObservable
  37429. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  37430. */
  37431. readonly onExitingVR: Observable<VRExperienceHelper>;
  37432. /** Return this.onControllerMeshLoadedObservable
  37433. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  37434. */
  37435. readonly onControllerMeshLoaded: Observable<WebVRController>;
  37436. private _rayLength;
  37437. private _useCustomVRButton;
  37438. private _teleportationRequested;
  37439. private _teleportActive;
  37440. private _floorMeshName;
  37441. private _floorMeshesCollection;
  37442. private _rotationAllowed;
  37443. private _teleportBackwardsVector;
  37444. private _teleportationTarget;
  37445. private _isDefaultTeleportationTarget;
  37446. private _postProcessMove;
  37447. private _teleportationFillColor;
  37448. private _teleportationBorderColor;
  37449. private _rotationAngle;
  37450. private _haloCenter;
  37451. private _cameraGazer;
  37452. private _padSensibilityUp;
  37453. private _padSensibilityDown;
  37454. private _leftController;
  37455. private _rightController;
  37456. /**
  37457. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  37458. */
  37459. onNewMeshSelected: Observable<AbstractMesh>;
  37460. /**
  37461. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  37462. */
  37463. onNewMeshPicked: Observable<PickingInfo>;
  37464. private _circleEase;
  37465. /**
  37466. * Observable raised before camera teleportation
  37467. */
  37468. onBeforeCameraTeleport: Observable<Vector3>;
  37469. /**
  37470. * Observable raised after camera teleportation
  37471. */
  37472. onAfterCameraTeleport: Observable<Vector3>;
  37473. /**
  37474. * Observable raised when current selected mesh gets unselected
  37475. */
  37476. onSelectedMeshUnselected: Observable<AbstractMesh>;
  37477. private _raySelectionPredicate;
  37478. /**
  37479. * To be optionaly changed by user to define custom ray selection
  37480. */
  37481. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  37482. /**
  37483. * To be optionaly changed by user to define custom selection logic (after ray selection)
  37484. */
  37485. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  37486. /**
  37487. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  37488. */
  37489. teleportationEnabled: boolean;
  37490. private _defaultHeight;
  37491. private _teleportationInitialized;
  37492. private _interactionsEnabled;
  37493. private _interactionsRequested;
  37494. private _displayGaze;
  37495. private _displayLaserPointer;
  37496. /**
  37497. * The mesh used to display where the user is going to teleport.
  37498. */
  37499. /**
  37500. * Sets the mesh to be used to display where the user is going to teleport.
  37501. */
  37502. teleportationTarget: Mesh;
  37503. /**
  37504. * 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
  37505. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  37506. * See http://doc.babylonjs.com/resources/baking_transformations
  37507. */
  37508. gazeTrackerMesh: Mesh;
  37509. /**
  37510. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  37511. */
  37512. updateGazeTrackerScale: boolean;
  37513. /**
  37514. * The gaze tracking mesh corresponding to the left controller
  37515. */
  37516. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  37517. /**
  37518. * The gaze tracking mesh corresponding to the right controller
  37519. */
  37520. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  37521. /**
  37522. * If the ray of the gaze should be displayed.
  37523. */
  37524. /**
  37525. * Sets if the ray of the gaze should be displayed.
  37526. */
  37527. displayGaze: boolean;
  37528. /**
  37529. * If the ray of the LaserPointer should be displayed.
  37530. */
  37531. /**
  37532. * Sets if the ray of the LaserPointer should be displayed.
  37533. */
  37534. displayLaserPointer: boolean;
  37535. /**
  37536. * The deviceOrientationCamera used as the camera when not in VR.
  37537. */
  37538. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  37539. /**
  37540. * Based on the current WebVR support, returns the current VR camera used.
  37541. */
  37542. readonly currentVRCamera: Nullable<Camera>;
  37543. /**
  37544. * The webVRCamera which is used when in VR.
  37545. */
  37546. readonly webVRCamera: WebVRFreeCamera;
  37547. /**
  37548. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  37549. */
  37550. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  37551. private readonly _teleportationRequestInitiated;
  37552. /**
  37553. * Instantiates a VRExperienceHelper.
  37554. * Helps to quickly add VR support to an existing scene.
  37555. * @param scene The scene the VRExperienceHelper belongs to.
  37556. * @param webVROptions Options to modify the vr experience helper's behavior.
  37557. */
  37558. constructor(scene: Scene,
  37559. /** Options to modify the vr experience helper's behavior. */
  37560. webVROptions?: VRExperienceHelperOptions);
  37561. private _onDefaultMeshLoaded;
  37562. private _onResize;
  37563. private _onFullscreenChange;
  37564. /**
  37565. * Gets a value indicating if we are currently in VR mode.
  37566. */
  37567. readonly isInVRMode: boolean;
  37568. private onVrDisplayPresentChange;
  37569. private onVRDisplayChanged;
  37570. private moveButtonToBottomRight;
  37571. private displayVRButton;
  37572. private updateButtonVisibility;
  37573. /**
  37574. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  37575. * Otherwise, will use the fullscreen API.
  37576. */
  37577. enterVR(): void;
  37578. /**
  37579. * Attempt to exit VR, or fullscreen.
  37580. */
  37581. exitVR(): void;
  37582. /**
  37583. * The position of the vr experience helper.
  37584. */
  37585. /**
  37586. * Sets the position of the vr experience helper.
  37587. */
  37588. position: Vector3;
  37589. /**
  37590. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  37591. */
  37592. enableInteractions(): void;
  37593. private readonly _noControllerIsActive;
  37594. private beforeRender;
  37595. private _isTeleportationFloor;
  37596. /**
  37597. * Adds a floor mesh to be used for teleportation.
  37598. * @param floorMesh the mesh to be used for teleportation.
  37599. */
  37600. addFloorMesh(floorMesh: Mesh): void;
  37601. /**
  37602. * Removes a floor mesh from being used for teleportation.
  37603. * @param floorMesh the mesh to be removed.
  37604. */
  37605. removeFloorMesh(floorMesh: Mesh): void;
  37606. /**
  37607. * Enables interactions and teleportation using the VR controllers and gaze.
  37608. * @param vrTeleportationOptions options to modify teleportation behavior.
  37609. */
  37610. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  37611. private _onNewGamepadConnected;
  37612. private _tryEnableInteractionOnController;
  37613. private _onNewGamepadDisconnected;
  37614. private _enableInteractionOnController;
  37615. private _checkTeleportWithRay;
  37616. private _checkRotate;
  37617. private _checkTeleportBackwards;
  37618. private _enableTeleportationOnController;
  37619. private _createTeleportationCircles;
  37620. private _displayTeleportationTarget;
  37621. private _hideTeleportationTarget;
  37622. private _rotateCamera;
  37623. private _moveTeleportationSelectorTo;
  37624. private _workingVector;
  37625. private _workingQuaternion;
  37626. private _workingMatrix;
  37627. /**
  37628. * Teleports the users feet to the desired location
  37629. * @param location The location where the user's feet should be placed
  37630. */
  37631. teleportCamera(location: Vector3): void;
  37632. private _convertNormalToDirectionOfRay;
  37633. private _castRayAndSelectObject;
  37634. private _notifySelectedMeshUnselected;
  37635. /**
  37636. * Sets the color of the laser ray from the vr controllers.
  37637. * @param color new color for the ray.
  37638. */
  37639. changeLaserColor(color: Color3): void;
  37640. /**
  37641. * Sets the color of the ray from the vr headsets gaze.
  37642. * @param color new color for the ray.
  37643. */
  37644. changeGazeColor(color: Color3): void;
  37645. /**
  37646. * Exits VR and disposes of the vr experience helper
  37647. */
  37648. dispose(): void;
  37649. /**
  37650. * Gets the name of the VRExperienceHelper class
  37651. * @returns "VRExperienceHelper"
  37652. */
  37653. getClassName(): string;
  37654. }
  37655. }
  37656. declare module BABYLON {
  37657. /**
  37658. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  37659. * IMPORTANT!! The data is right-hand data.
  37660. * @export
  37661. * @interface DevicePose
  37662. */
  37663. interface DevicePose {
  37664. /**
  37665. * The position of the device, values in array are [x,y,z].
  37666. */
  37667. readonly position: Nullable<Float32Array>;
  37668. /**
  37669. * The linearVelocity of the device, values in array are [x,y,z].
  37670. */
  37671. readonly linearVelocity: Nullable<Float32Array>;
  37672. /**
  37673. * The linearAcceleration of the device, values in array are [x,y,z].
  37674. */
  37675. readonly linearAcceleration: Nullable<Float32Array>;
  37676. /**
  37677. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  37678. */
  37679. readonly orientation: Nullable<Float32Array>;
  37680. /**
  37681. * The angularVelocity of the device, values in array are [x,y,z].
  37682. */
  37683. readonly angularVelocity: Nullable<Float32Array>;
  37684. /**
  37685. * The angularAcceleration of the device, values in array are [x,y,z].
  37686. */
  37687. readonly angularAcceleration: Nullable<Float32Array>;
  37688. }
  37689. /**
  37690. * Interface representing a pose controlled object in Babylon.
  37691. * A pose controlled object has both regular pose values as well as pose values
  37692. * from an external device such as a VR head mounted display
  37693. */
  37694. interface PoseControlled {
  37695. /**
  37696. * The position of the object in babylon space.
  37697. */
  37698. position: Vector3;
  37699. /**
  37700. * The rotation quaternion of the object in babylon space.
  37701. */
  37702. rotationQuaternion: Quaternion;
  37703. /**
  37704. * The position of the device in babylon space.
  37705. */
  37706. devicePosition?: Vector3;
  37707. /**
  37708. * The rotation quaternion of the device in babylon space.
  37709. */
  37710. deviceRotationQuaternion: Quaternion;
  37711. /**
  37712. * The raw pose coming from the device.
  37713. */
  37714. rawPose: Nullable<DevicePose>;
  37715. /**
  37716. * The scale of the device to be used when translating from device space to babylon space.
  37717. */
  37718. deviceScaleFactor: number;
  37719. /**
  37720. * Updates the poseControlled values based on the input device pose.
  37721. * @param poseData the pose data to update the object with
  37722. */
  37723. updateFromDevice(poseData: DevicePose): void;
  37724. }
  37725. /**
  37726. * Set of options to customize the webVRCamera
  37727. */
  37728. interface WebVROptions {
  37729. /**
  37730. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  37731. */
  37732. trackPosition?: boolean;
  37733. /**
  37734. * Sets the scale of the vrDevice in babylon space. (default: 1)
  37735. */
  37736. positionScale?: number;
  37737. /**
  37738. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  37739. */
  37740. displayName?: string;
  37741. /**
  37742. * Should the native controller meshes be initialized. (default: true)
  37743. */
  37744. controllerMeshes?: boolean;
  37745. /**
  37746. * Creating a default HemiLight only on controllers. (default: true)
  37747. */
  37748. defaultLightingOnControllers?: boolean;
  37749. /**
  37750. * If you don't want to use the default VR button of the helper. (default: false)
  37751. */
  37752. useCustomVRButton?: boolean;
  37753. /**
  37754. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  37755. */
  37756. customVRButton?: HTMLButtonElement;
  37757. /**
  37758. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  37759. */
  37760. rayLength?: number;
  37761. /**
  37762. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  37763. */
  37764. defaultHeight?: number;
  37765. }
  37766. /**
  37767. * This represents a WebVR camera.
  37768. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  37769. * @example http://doc.babylonjs.com/how_to/webvr_camera
  37770. */
  37771. class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  37772. private webVROptions;
  37773. /**
  37774. * @hidden
  37775. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  37776. */
  37777. /**
  37778. * The rawPose of the vrDevice.
  37779. */
  37780. rawPose: Nullable<DevicePose>;
  37781. private _onVREnabled;
  37782. private _specsVersion;
  37783. private _attached;
  37784. private _frameData;
  37785. protected _descendants: Array<Node>;
  37786. private _deviceRoomPosition;
  37787. /** @hidden */
  37788. private _standingMatrix;
  37789. /**
  37790. * Represents device position in babylon space.
  37791. */
  37792. devicePosition: Vector3;
  37793. /**
  37794. * Represents device rotation in babylon space.
  37795. */
  37796. deviceRotationQuaternion: Quaternion;
  37797. /**
  37798. * The scale of the device to be used when translating from device space to babylon space.
  37799. */
  37800. deviceScaleFactor: number;
  37801. private _deviceToWorld;
  37802. private _worldToDevice;
  37803. /**
  37804. * References to the webVR controllers for the vrDevice.
  37805. */
  37806. controllers: Array<WebVRController>;
  37807. /**
  37808. * Emits an event when a controller is attached.
  37809. */
  37810. onControllersAttachedObservable: Observable<WebVRController[]>;
  37811. /**
  37812. * Emits an event when a controller's mesh has been loaded;
  37813. */
  37814. onControllerMeshLoadedObservable: Observable<WebVRController>;
  37815. /**
  37816. * Emits an event when the HMD's pose has been updated.
  37817. */
  37818. onPoseUpdatedFromDeviceObservable: Observable<any>;
  37819. private _poseSet;
  37820. /**
  37821. * If the rig cameras be used as parent instead of this camera.
  37822. */
  37823. rigParenting: boolean;
  37824. private _lightOnControllers;
  37825. private _defaultHeight?;
  37826. /**
  37827. * Instantiates a WebVRFreeCamera.
  37828. * @param name The name of the WebVRFreeCamera
  37829. * @param position The starting anchor position for the camera
  37830. * @param scene The scene the camera belongs to
  37831. * @param webVROptions a set of customizable options for the webVRCamera
  37832. */
  37833. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  37834. /**
  37835. * Gets the device distance from the ground in meters.
  37836. * @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.
  37837. */
  37838. deviceDistanceToRoomGround(): number;
  37839. /**
  37840. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  37841. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  37842. */
  37843. useStandingMatrix(callback?: (bool: boolean) => void): void;
  37844. /**
  37845. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  37846. * @returns A promise with a boolean set to if the standing matrix is supported.
  37847. */
  37848. useStandingMatrixAsync(): Promise<boolean>;
  37849. /**
  37850. * Disposes the camera
  37851. */
  37852. dispose(): void;
  37853. /**
  37854. * Gets a vrController by name.
  37855. * @param name The name of the controller to retreive
  37856. * @returns the controller matching the name specified or null if not found
  37857. */
  37858. getControllerByName(name: string): Nullable<WebVRController>;
  37859. private _leftController;
  37860. /**
  37861. * The controller corrisponding to the users left hand.
  37862. */
  37863. readonly leftController: Nullable<WebVRController>;
  37864. private _rightController;
  37865. /**
  37866. * The controller corrisponding to the users right hand.
  37867. */
  37868. readonly rightController: Nullable<WebVRController>;
  37869. /**
  37870. * Casts a ray forward from the vrCamera's gaze.
  37871. * @param length Length of the ray (default: 100)
  37872. * @returns the ray corrisponding to the gaze
  37873. */
  37874. getForwardRay(length?: number): Ray;
  37875. /**
  37876. * @hidden
  37877. * Updates the camera based on device's frame data
  37878. */
  37879. /**
  37880. * Updates the poseControlled values based on the input device pose.
  37881. * @param poseData Pose coming from the device
  37882. */
  37883. updateFromDevice(poseData: DevicePose): void;
  37884. private _htmlElementAttached;
  37885. private _detachIfAttached;
  37886. /**
  37887. * WebVR's attach control will start broadcasting frames to the device.
  37888. * Note that in certain browsers (chrome for example) this function must be called
  37889. * within a user-interaction callback. Example:
  37890. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  37891. *
  37892. * @param element html element to attach the vrDevice to
  37893. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  37894. */
  37895. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37896. /**
  37897. * Detaches the camera from the html element and disables VR
  37898. *
  37899. * @param element html element to detach from
  37900. */
  37901. detachControl(element: HTMLElement): void;
  37902. /**
  37903. * @returns the name of this class
  37904. */
  37905. getClassName(): string;
  37906. /**
  37907. * Calls resetPose on the vrDisplay
  37908. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  37909. */
  37910. resetToCurrentRotation(): void;
  37911. /**
  37912. * @hidden
  37913. * Updates the rig cameras (left and right eye)
  37914. */
  37915. private _workingVector;
  37916. private _oneVector;
  37917. private _workingMatrix;
  37918. private updateCacheCalled;
  37919. private _correctPositionIfNotTrackPosition;
  37920. /**
  37921. * @hidden
  37922. * Updates the cached values of the camera
  37923. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  37924. */
  37925. /**
  37926. * @hidden
  37927. * Get current device position in babylon world
  37928. */
  37929. /**
  37930. * Updates the current device position and rotation in the babylon world
  37931. */
  37932. update(): void;
  37933. /**
  37934. * @hidden
  37935. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  37936. * @returns an identity matrix
  37937. */
  37938. private _tmpMatrix;
  37939. /**
  37940. * This function is called by the two RIG cameras.
  37941. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  37942. */
  37943. protected _getWebVRViewMatrix(): Matrix;
  37944. protected _getWebVRProjectionMatrix(): Matrix;
  37945. private _onGamepadConnectedObserver;
  37946. private _onGamepadDisconnectedObserver;
  37947. private _updateCacheWhenTrackingDisabledObserver;
  37948. /**
  37949. * Initializes the controllers and their meshes
  37950. */
  37951. initControllers(): void;
  37952. }
  37953. }
  37954. declare module BABYLON {
  37955. interface IOctreeContainer<T> {
  37956. blocks: Array<OctreeBlock<T>>;
  37957. }
  37958. class Octree<T> {
  37959. maxDepth: number;
  37960. blocks: Array<OctreeBlock<T>>;
  37961. dynamicContent: T[];
  37962. private _maxBlockCapacity;
  37963. private _selectionContent;
  37964. private _creationFunc;
  37965. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number, maxDepth?: number);
  37966. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  37967. addMesh(entry: T): void;
  37968. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  37969. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  37970. intersectsRay(ray: Ray): SmartArray<T>;
  37971. 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;
  37972. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  37973. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  37974. }
  37975. }
  37976. declare module BABYLON {
  37977. /**
  37978. * Class used to store a cell in an octree
  37979. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  37980. */
  37981. class OctreeBlock<T> {
  37982. /**
  37983. * Gets the content of the current block
  37984. */
  37985. entries: T[];
  37986. /**
  37987. * Gets the list of block children
  37988. */
  37989. blocks: Array<OctreeBlock<T>>;
  37990. private _depth;
  37991. private _maxDepth;
  37992. private _capacity;
  37993. private _minPoint;
  37994. private _maxPoint;
  37995. private _boundingVectors;
  37996. private _creationFunc;
  37997. /**
  37998. * Creates a new block
  37999. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  38000. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  38001. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  38002. * @param depth defines the current depth of this block in the octree
  38003. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  38004. * @param creationFunc defines a callback to call when an element is added to the block
  38005. */
  38006. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  38007. /**
  38008. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  38009. */
  38010. readonly capacity: number;
  38011. /**
  38012. * Gets the minimum vector (in world space) of the block's bounding box
  38013. */
  38014. readonly minPoint: Vector3;
  38015. /**
  38016. * Gets the maximum vector (in world space) of the block's bounding box
  38017. */
  38018. readonly maxPoint: Vector3;
  38019. /**
  38020. * Add a new element to this block
  38021. * @param entry defines the element to add
  38022. */
  38023. addEntry(entry: T): void;
  38024. /**
  38025. * Add an array of elements to this block
  38026. * @param entries defines the array of elements to add
  38027. */
  38028. addEntries(entries: T[]): void;
  38029. /**
  38030. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  38031. * @param frustumPlanes defines the frustum planes to test
  38032. * @param selection defines the array to store current content if selection is positive
  38033. * @param allowDuplicate defines if the selection array can contains duplicated entries
  38034. */
  38035. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  38036. /**
  38037. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  38038. * @param sphereCenter defines the bounding sphere center
  38039. * @param sphereRadius defines the bounding sphere radius
  38040. * @param selection defines the array to store current content if selection is positive
  38041. * @param allowDuplicate defines if the selection array can contains duplicated entries
  38042. */
  38043. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  38044. /**
  38045. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  38046. * @param ray defines the ray to test with
  38047. * @param selection defines the array to store current content if selection is positive
  38048. */
  38049. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  38050. /**
  38051. * Subdivide the content into child blocks (this block will then be empty)
  38052. */
  38053. createInnerBlocks(): void;
  38054. }
  38055. }
  38056. declare module BABYLON {
  38057. interface Scene {
  38058. /**
  38059. * @hidden
  38060. * Backing Filed
  38061. */
  38062. /**
  38063. * Gets the octree used to boost mesh selection (picking)
  38064. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  38065. */
  38066. selectionOctree: Octree<AbstractMesh>;
  38067. /**
  38068. * Creates or updates the octree used to boost selection (picking)
  38069. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  38070. * @param maxCapacity defines the maximum capacity per leaf
  38071. * @param maxDepth defines the maximum depth of the octree
  38072. * @returns an octree of AbstractMesh
  38073. */
  38074. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  38075. }
  38076. interface AbstractMesh {
  38077. /**
  38078. * @hidden
  38079. * Backing Field
  38080. */
  38081. /**
  38082. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  38083. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  38084. * @param maxCapacity defines the maximum size of each block (64 by default)
  38085. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  38086. * @returns the new octree
  38087. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  38088. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  38089. */
  38090. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  38091. }
  38092. /**
  38093. * Defines the octree scene component responsible to manage any octrees
  38094. * in a given scene.
  38095. */
  38096. class OctreeSceneComponent {
  38097. /**
  38098. * The component name helpfull to identify the component in the list of scene components.
  38099. */
  38100. readonly name: string;
  38101. /**
  38102. * The scene the component belongs to.
  38103. */
  38104. scene: Scene;
  38105. /**
  38106. * Indicates if the meshes have been checked to make sure they are isEnabled()
  38107. */
  38108. readonly checksIsEnabled: boolean;
  38109. /**
  38110. * Creates a new instance of the component for the given scene
  38111. * @param scene Defines the scene to register the component in
  38112. */
  38113. constructor(scene: Scene);
  38114. /**
  38115. * Registers the component in a given scene
  38116. */
  38117. register(): void;
  38118. /**
  38119. * Return the list of active meshes
  38120. * @returns the list of active meshes
  38121. */
  38122. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  38123. /**
  38124. * Return the list of active sub meshes
  38125. * @param mesh The mesh to get the candidates sub meshes from
  38126. * @returns the list of active sub meshes
  38127. */
  38128. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  38129. private _tempRay;
  38130. /**
  38131. * Return the list of sub meshes intersecting with a given local ray
  38132. * @param mesh defines the mesh to find the submesh for
  38133. * @param localRay defines the ray in local space
  38134. * @returns the list of intersecting sub meshes
  38135. */
  38136. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  38137. /**
  38138. * Return the list of sub meshes colliding with a collider
  38139. * @param mesh defines the mesh to find the submesh for
  38140. * @param collider defines the collider to evaluate the collision against
  38141. * @returns the list of colliding sub meshes
  38142. */
  38143. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  38144. /**
  38145. * Rebuilds the elements related to this component in case of
  38146. * context lost for instance.
  38147. */
  38148. rebuild(): void;
  38149. /**
  38150. * Disposes the component and the associated ressources.
  38151. */
  38152. dispose(): void;
  38153. }
  38154. }
  38155. declare module BABYLON {
  38156. interface Engine {
  38157. /**
  38158. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  38159. * @return the new query
  38160. */
  38161. createQuery(): WebGLQuery;
  38162. /**
  38163. * Delete and release a webGL query
  38164. * @param query defines the query to delete
  38165. * @return the current engine
  38166. */
  38167. deleteQuery(query: WebGLQuery): Engine;
  38168. /**
  38169. * Check if a given query has resolved and got its value
  38170. * @param query defines the query to check
  38171. * @returns true if the query got its value
  38172. */
  38173. isQueryResultAvailable(query: WebGLQuery): boolean;
  38174. /**
  38175. * Gets the value of a given query
  38176. * @param query defines the query to check
  38177. * @returns the value of the query
  38178. */
  38179. getQueryResult(query: WebGLQuery): number;
  38180. /**
  38181. * Initiates an occlusion query
  38182. * @param algorithmType defines the algorithm to use
  38183. * @param query defines the query to use
  38184. * @returns the current engine
  38185. * @see http://doc.babylonjs.com/features/occlusionquery
  38186. */
  38187. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  38188. /**
  38189. * Ends an occlusion query
  38190. * @see http://doc.babylonjs.com/features/occlusionquery
  38191. * @param algorithmType defines the algorithm to use
  38192. * @returns the current engine
  38193. */
  38194. endOcclusionQuery(algorithmType: number): Engine;
  38195. /**
  38196. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  38197. * Please note that only one query can be issued at a time
  38198. * @returns a time token used to track the time span
  38199. */
  38200. startTimeQuery(): Nullable<_TimeToken>;
  38201. /**
  38202. * Ends a time query
  38203. * @param token defines the token used to measure the time span
  38204. * @returns the time spent (in ns)
  38205. */
  38206. endTimeQuery(token: _TimeToken): int;
  38207. /** @hidden */
  38208. /** @hidden */
  38209. /** @hidden */
  38210. /** @hidden */
  38211. /** @hidden */
  38212. /** @hidden */
  38213. }
  38214. }
  38215. declare module BABYLON {
  38216. interface Engine {
  38217. /**
  38218. * Creates a webGL transform feedback object
  38219. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  38220. * @returns the webGL transform feedback object
  38221. */
  38222. createTransformFeedback(): WebGLTransformFeedback;
  38223. /**
  38224. * Delete a webGL transform feedback object
  38225. * @param value defines the webGL transform feedback object to delete
  38226. */
  38227. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  38228. /**
  38229. * Bind a webGL transform feedback object to the webgl context
  38230. * @param value defines the webGL transform feedback object to bind
  38231. */
  38232. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  38233. /**
  38234. * Begins a transform feedback operation
  38235. * @param usePoints defines if points or triangles must be used
  38236. */
  38237. beginTransformFeedback(usePoints: boolean): void;
  38238. /**
  38239. * Ends a transform feedback operation
  38240. */
  38241. endTransformFeedback(): void;
  38242. /**
  38243. * Specify the varyings to use with transform feedback
  38244. * @param program defines the associated webGL program
  38245. * @param value defines the list of strings representing the varying names
  38246. */
  38247. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  38248. /**
  38249. * Bind a webGL buffer for a transform feedback operation
  38250. * @param value defines the webGL buffer to bind
  38251. */
  38252. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  38253. }
  38254. }
  38255. declare module BABYLON {
  38256. /**
  38257. * Google Daydream controller
  38258. */
  38259. class DaydreamController extends WebVRController {
  38260. /**
  38261. * Base Url for the controller model.
  38262. */
  38263. static MODEL_BASE_URL: string;
  38264. /**
  38265. * File name for the controller model.
  38266. */
  38267. static MODEL_FILENAME: string;
  38268. /**
  38269. * Gamepad Id prefix used to identify Daydream Controller.
  38270. */
  38271. static readonly GAMEPAD_ID_PREFIX: string;
  38272. /**
  38273. * Creates a new DaydreamController from a gamepad
  38274. * @param vrGamepad the gamepad that the controller should be created from
  38275. */
  38276. constructor(vrGamepad: any);
  38277. /**
  38278. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  38279. * @param scene scene in which to add meshes
  38280. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  38281. */
  38282. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  38283. /**
  38284. * Called once for each button that changed state since the last frame
  38285. * @param buttonIdx Which button index changed
  38286. * @param state New state of the button
  38287. * @param changes Which properties on the state changed since last frame
  38288. */
  38289. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  38290. }
  38291. }
  38292. declare module BABYLON {
  38293. /**
  38294. * Gear VR Controller
  38295. */
  38296. class GearVRController extends WebVRController {
  38297. /**
  38298. * Base Url for the controller model.
  38299. */
  38300. static MODEL_BASE_URL: string;
  38301. /**
  38302. * File name for the controller model.
  38303. */
  38304. static MODEL_FILENAME: string;
  38305. /**
  38306. * Gamepad Id prefix used to identify this controller.
  38307. */
  38308. static readonly GAMEPAD_ID_PREFIX: string;
  38309. private readonly _buttonIndexToObservableNameMap;
  38310. /**
  38311. * Creates a new GearVRController from a gamepad
  38312. * @param vrGamepad the gamepad that the controller should be created from
  38313. */
  38314. constructor(vrGamepad: any);
  38315. /**
  38316. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  38317. * @param scene scene in which to add meshes
  38318. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  38319. */
  38320. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  38321. /**
  38322. * Called once for each button that changed state since the last frame
  38323. * @param buttonIdx Which button index changed
  38324. * @param state New state of the button
  38325. * @param changes Which properties on the state changed since last frame
  38326. */
  38327. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  38328. }
  38329. }
  38330. declare module BABYLON {
  38331. /**
  38332. * Generic Controller
  38333. */
  38334. class GenericController extends WebVRController {
  38335. /**
  38336. * Base Url for the controller model.
  38337. */
  38338. static readonly MODEL_BASE_URL: string;
  38339. /**
  38340. * File name for the controller model.
  38341. */
  38342. static readonly MODEL_FILENAME: string;
  38343. /**
  38344. * Creates a new GenericController from a gamepad
  38345. * @param vrGamepad the gamepad that the controller should be created from
  38346. */
  38347. constructor(vrGamepad: any);
  38348. /**
  38349. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  38350. * @param scene scene in which to add meshes
  38351. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  38352. */
  38353. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  38354. /**
  38355. * Called once for each button that changed state since the last frame
  38356. * @param buttonIdx Which button index changed
  38357. * @param state New state of the button
  38358. * @param changes Which properties on the state changed since last frame
  38359. */
  38360. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  38361. }
  38362. }
  38363. declare module BABYLON {
  38364. /**
  38365. * Oculus Touch Controller
  38366. */
  38367. class OculusTouchController extends WebVRController {
  38368. /**
  38369. * Base Url for the controller model.
  38370. */
  38371. static MODEL_BASE_URL: string;
  38372. /**
  38373. * File name for the left controller model.
  38374. */
  38375. static MODEL_LEFT_FILENAME: string;
  38376. /**
  38377. * File name for the right controller model.
  38378. */
  38379. static MODEL_RIGHT_FILENAME: string;
  38380. /**
  38381. * Fired when the secondary trigger on this controller is modified
  38382. */
  38383. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  38384. /**
  38385. * Fired when the thumb rest on this controller is modified
  38386. */
  38387. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  38388. /**
  38389. * Creates a new OculusTouchController from a gamepad
  38390. * @param vrGamepad the gamepad that the controller should be created from
  38391. */
  38392. constructor(vrGamepad: any);
  38393. /**
  38394. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  38395. * @param scene scene in which to add meshes
  38396. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  38397. */
  38398. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  38399. /**
  38400. * Fired when the A button on this controller is modified
  38401. */
  38402. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  38403. /**
  38404. * Fired when the B button on this controller is modified
  38405. */
  38406. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  38407. /**
  38408. * Fired when the X button on this controller is modified
  38409. */
  38410. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  38411. /**
  38412. * Fired when the Y button on this controller is modified
  38413. */
  38414. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  38415. /**
  38416. * Called once for each button that changed state since the last frame
  38417. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  38418. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  38419. * 2) secondary trigger (same)
  38420. * 3) A (right) X (left), touch, pressed = value
  38421. * 4) B / Y
  38422. * 5) thumb rest
  38423. * @param buttonIdx Which button index changed
  38424. * @param state New state of the button
  38425. * @param changes Which properties on the state changed since last frame
  38426. */
  38427. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  38428. }
  38429. }
  38430. declare module BABYLON {
  38431. /**
  38432. * Defines the types of pose enabled controllers that are supported
  38433. */
  38434. enum PoseEnabledControllerType {
  38435. /**
  38436. * HTC Vive
  38437. */
  38438. VIVE = 0,
  38439. /**
  38440. * Oculus Rift
  38441. */
  38442. OCULUS = 1,
  38443. /**
  38444. * Windows mixed reality
  38445. */
  38446. WINDOWS = 2,
  38447. /**
  38448. * Samsung gear VR
  38449. */
  38450. GEAR_VR = 3,
  38451. /**
  38452. * Google Daydream
  38453. */
  38454. DAYDREAM = 4,
  38455. /**
  38456. * Generic
  38457. */
  38458. GENERIC = 5
  38459. }
  38460. /**
  38461. * Defines the MutableGamepadButton interface for the state of a gamepad button
  38462. */
  38463. interface MutableGamepadButton {
  38464. /**
  38465. * Value of the button/trigger
  38466. */
  38467. value: number;
  38468. /**
  38469. * If the button/trigger is currently touched
  38470. */
  38471. touched: boolean;
  38472. /**
  38473. * If the button/trigger is currently pressed
  38474. */
  38475. pressed: boolean;
  38476. }
  38477. /**
  38478. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  38479. * @hidden
  38480. */
  38481. interface ExtendedGamepadButton extends GamepadButton {
  38482. /**
  38483. * If the button/trigger is currently pressed
  38484. */
  38485. readonly pressed: boolean;
  38486. /**
  38487. * If the button/trigger is currently touched
  38488. */
  38489. readonly touched: boolean;
  38490. /**
  38491. * Value of the button/trigger
  38492. */
  38493. readonly value: number;
  38494. }
  38495. /**
  38496. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  38497. */
  38498. class PoseEnabledControllerHelper {
  38499. /**
  38500. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  38501. * @param vrGamepad the gamepad to initialized
  38502. * @returns a vr controller of the type the gamepad identified as
  38503. */
  38504. static InitiateController(vrGamepad: any): OculusTouchController | WindowsMotionController | ViveController | GearVRController | DaydreamController | GenericController;
  38505. }
  38506. /**
  38507. * Defines the PoseEnabledController object that contains state of a vr capable controller
  38508. */
  38509. class PoseEnabledController extends Gamepad implements PoseControlled {
  38510. private _deviceRoomPosition;
  38511. private _deviceRoomRotationQuaternion;
  38512. /**
  38513. * The device position in babylon space
  38514. */
  38515. devicePosition: Vector3;
  38516. /**
  38517. * The device rotation in babylon space
  38518. */
  38519. deviceRotationQuaternion: Quaternion;
  38520. /**
  38521. * The scale factor of the device in babylon space
  38522. */
  38523. deviceScaleFactor: number;
  38524. /**
  38525. * (Likely devicePosition should be used instead) The device position in its room space
  38526. */
  38527. position: Vector3;
  38528. /**
  38529. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  38530. */
  38531. rotationQuaternion: Quaternion;
  38532. /**
  38533. * The type of controller (Eg. Windows mixed reality)
  38534. */
  38535. controllerType: PoseEnabledControllerType;
  38536. protected _calculatedPosition: Vector3;
  38537. private _calculatedRotation;
  38538. /**
  38539. * The raw pose from the device
  38540. */
  38541. rawPose: DevicePose;
  38542. private _trackPosition;
  38543. private _maxRotationDistFromHeadset;
  38544. private _draggedRoomRotation;
  38545. /**
  38546. * @hidden
  38547. */
  38548. /**
  38549. * Internal, the mesh attached to the controller
  38550. * @hidden
  38551. */
  38552. private _poseControlledCamera;
  38553. private _leftHandSystemQuaternion;
  38554. /**
  38555. * Internal, matrix used to convert room space to babylon space
  38556. * @hidden
  38557. */
  38558. /**
  38559. * Node to be used when casting a ray from the controller
  38560. * @hidden
  38561. */
  38562. /**
  38563. * Name of the child mesh that can be used to cast a ray from the controller
  38564. */
  38565. static readonly POINTING_POSE: string;
  38566. /**
  38567. * Creates a new PoseEnabledController from a gamepad
  38568. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  38569. */
  38570. constructor(browserGamepad: any);
  38571. private _workingMatrix;
  38572. /**
  38573. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  38574. */
  38575. update(): void;
  38576. /**
  38577. * Updates only the pose device and mesh without doing any button event checking
  38578. */
  38579. protected _updatePoseAndMesh(): void;
  38580. /**
  38581. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  38582. * @param poseData raw pose fromthe device
  38583. */
  38584. updateFromDevice(poseData: DevicePose): void;
  38585. /**
  38586. * @hidden
  38587. */
  38588. /**
  38589. * Attaches a mesh to the controller
  38590. * @param mesh the mesh to be attached
  38591. */
  38592. attachToMesh(mesh: AbstractMesh): void;
  38593. /**
  38594. * Attaches the controllers mesh to a camera
  38595. * @param camera the camera the mesh should be attached to
  38596. */
  38597. attachToPoseControlledCamera(camera: TargetCamera): void;
  38598. /**
  38599. * Disposes of the controller
  38600. */
  38601. dispose(): void;
  38602. /**
  38603. * The mesh that is attached to the controller
  38604. */
  38605. readonly mesh: Nullable<AbstractMesh>;
  38606. /**
  38607. * Gets the ray of the controller in the direction the controller is pointing
  38608. * @param length the length the resulting ray should be
  38609. * @returns a ray in the direction the controller is pointing
  38610. */
  38611. getForwardRay(length?: number): Ray;
  38612. }
  38613. }
  38614. declare module BABYLON {
  38615. /**
  38616. * Vive Controller
  38617. */
  38618. class ViveController extends WebVRController {
  38619. /**
  38620. * Base Url for the controller model.
  38621. */
  38622. static MODEL_BASE_URL: string;
  38623. /**
  38624. * File name for the controller model.
  38625. */
  38626. static MODEL_FILENAME: string;
  38627. /**
  38628. * Creates a new ViveController from a gamepad
  38629. * @param vrGamepad the gamepad that the controller should be created from
  38630. */
  38631. constructor(vrGamepad: any);
  38632. /**
  38633. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  38634. * @param scene scene in which to add meshes
  38635. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  38636. */
  38637. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  38638. /**
  38639. * Fired when the left button on this controller is modified
  38640. */
  38641. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  38642. /**
  38643. * Fired when the right button on this controller is modified
  38644. */
  38645. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  38646. /**
  38647. * Fired when the menu button on this controller is modified
  38648. */
  38649. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  38650. /**
  38651. * Called once for each button that changed state since the last frame
  38652. * Vive mapping:
  38653. * 0: touchpad
  38654. * 1: trigger
  38655. * 2: left AND right buttons
  38656. * 3: menu button
  38657. * @param buttonIdx Which button index changed
  38658. * @param state New state of the button
  38659. * @param changes Which properties on the state changed since last frame
  38660. */
  38661. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  38662. }
  38663. }
  38664. declare module BABYLON {
  38665. /**
  38666. * Defines the WebVRController object that represents controllers tracked in 3D space
  38667. */
  38668. abstract class WebVRController extends PoseEnabledController {
  38669. /**
  38670. * Internal, the default controller model for the controller
  38671. */
  38672. protected _defaultModel: AbstractMesh;
  38673. /**
  38674. * Fired when the trigger state has changed
  38675. */
  38676. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  38677. /**
  38678. * Fired when the main button state has changed
  38679. */
  38680. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  38681. /**
  38682. * Fired when the secondary button state has changed
  38683. */
  38684. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  38685. /**
  38686. * Fired when the pad state has changed
  38687. */
  38688. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  38689. /**
  38690. * Fired when controllers stick values have changed
  38691. */
  38692. onPadValuesChangedObservable: Observable<StickValues>;
  38693. /**
  38694. * Array of button availible on the controller
  38695. */
  38696. protected _buttons: Array<MutableGamepadButton>;
  38697. private _onButtonStateChange;
  38698. /**
  38699. * Fired when a controller button's state has changed
  38700. * @param callback the callback containing the button that was modified
  38701. */
  38702. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  38703. /**
  38704. * X and Y axis corrisponding to the controllers joystick
  38705. */
  38706. pad: StickValues;
  38707. /**
  38708. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  38709. */
  38710. hand: string;
  38711. /**
  38712. * The default controller model for the controller
  38713. */
  38714. readonly defaultModel: AbstractMesh;
  38715. /**
  38716. * Creates a new WebVRController from a gamepad
  38717. * @param vrGamepad the gamepad that the WebVRController should be created from
  38718. */
  38719. constructor(vrGamepad: any);
  38720. /**
  38721. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  38722. */
  38723. update(): void;
  38724. /**
  38725. * Function to be called when a button is modified
  38726. */
  38727. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  38728. /**
  38729. * Loads a mesh and attaches it to the controller
  38730. * @param scene the scene the mesh should be added to
  38731. * @param meshLoaded callback for when the mesh has been loaded
  38732. */
  38733. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  38734. private _setButtonValue;
  38735. private _changes;
  38736. private _checkChanges;
  38737. /**
  38738. * Disposes of th webVRCOntroller
  38739. */
  38740. dispose(): void;
  38741. }
  38742. }
  38743. declare module BABYLON {
  38744. /**
  38745. * Defines the WindowsMotionController object that the state of the windows motion controller
  38746. */
  38747. class WindowsMotionController extends WebVRController {
  38748. /**
  38749. * The base url used to load the left and right controller models
  38750. */
  38751. static MODEL_BASE_URL: string;
  38752. /**
  38753. * The name of the left controller model file
  38754. */
  38755. static MODEL_LEFT_FILENAME: string;
  38756. /**
  38757. * The name of the right controller model file
  38758. */
  38759. static MODEL_RIGHT_FILENAME: string;
  38760. /**
  38761. * The controller name prefix for this controller type
  38762. */
  38763. static readonly GAMEPAD_ID_PREFIX: string;
  38764. /**
  38765. * The controller id pattern for this controller type
  38766. */
  38767. private static readonly GAMEPAD_ID_PATTERN;
  38768. private _loadedMeshInfo;
  38769. private readonly _mapping;
  38770. /**
  38771. * Fired when the trackpad on this controller is clicked
  38772. */
  38773. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  38774. /**
  38775. * Fired when the trackpad on this controller is modified
  38776. */
  38777. onTrackpadValuesChangedObservable: Observable<StickValues>;
  38778. /**
  38779. * The current x and y values of this controller's trackpad
  38780. */
  38781. trackpad: StickValues;
  38782. /**
  38783. * Creates a new WindowsMotionController from a gamepad
  38784. * @param vrGamepad the gamepad that the controller should be created from
  38785. */
  38786. constructor(vrGamepad: any);
  38787. /**
  38788. * Fired when the trigger on this controller is modified
  38789. */
  38790. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  38791. /**
  38792. * Fired when the menu button on this controller is modified
  38793. */
  38794. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  38795. /**
  38796. * Fired when the grip button on this controller is modified
  38797. */
  38798. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  38799. /**
  38800. * Fired when the thumbstick button on this controller is modified
  38801. */
  38802. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  38803. /**
  38804. * Fired when the touchpad button on this controller is modified
  38805. */
  38806. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  38807. /**
  38808. * Fired when the touchpad values on this controller are modified
  38809. */
  38810. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  38811. private _updateTrackpad;
  38812. /**
  38813. * Called once per frame by the engine.
  38814. */
  38815. update(): void;
  38816. /**
  38817. * Called once for each button that changed state since the last frame
  38818. * @param buttonIdx Which button index changed
  38819. * @param state New state of the button
  38820. * @param changes Which properties on the state changed since last frame
  38821. */
  38822. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  38823. /**
  38824. * Moves the buttons on the controller mesh based on their current state
  38825. * @param buttonName the name of the button to move
  38826. * @param buttonValue the value of the button which determines the buttons new position
  38827. */
  38828. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  38829. /**
  38830. * Moves the axis on the controller mesh based on its current state
  38831. * @param axis the index of the axis
  38832. * @param axisValue the value of the axis which determines the meshes new position
  38833. * @hidden
  38834. */
  38835. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  38836. /**
  38837. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  38838. * @param scene scene in which to add meshes
  38839. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  38840. */
  38841. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  38842. /**
  38843. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  38844. * can be transformed by button presses and axes values, based on this._mapping.
  38845. *
  38846. * @param scene scene in which the meshes exist
  38847. * @param meshes list of meshes that make up the controller model to process
  38848. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  38849. */
  38850. private processModel;
  38851. private createMeshInfo;
  38852. /**
  38853. * Gets the ray of the controller in the direction the controller is pointing
  38854. * @param length the length the resulting ray should be
  38855. * @returns a ray in the direction the controller is pointing
  38856. */
  38857. getForwardRay(length?: number): Ray;
  38858. /**
  38859. * Disposes of the controller
  38860. */
  38861. dispose(): void;
  38862. }
  38863. }
  38864. declare module BABYLON {
  38865. /**
  38866. * Interface to implement to create a shadow generator compatible with BJS.
  38867. */
  38868. interface IShadowGenerator {
  38869. /**
  38870. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  38871. * @returns The render target texture if present otherwise, null
  38872. */
  38873. getShadowMap(): Nullable<RenderTargetTexture>;
  38874. /**
  38875. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  38876. * @returns The render target texture if the shadow map is present otherwise, null
  38877. */
  38878. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  38879. /**
  38880. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  38881. * @param subMesh The submesh we want to render in the shadow map
  38882. * @param useInstances Defines wether will draw in the map using instances
  38883. * @returns true if ready otherwise, false
  38884. */
  38885. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  38886. /**
  38887. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  38888. * @param defines Defines of the material we want to update
  38889. * @param lightIndex Index of the light in the enabled light list of the material
  38890. */
  38891. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  38892. /**
  38893. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  38894. * defined in the generator but impacting the effect).
  38895. * It implies the unifroms available on the materials are the standard BJS ones.
  38896. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  38897. * @param effect The effect we are binfing the information for
  38898. */
  38899. bindShadowLight(lightIndex: string, effect: Effect): void;
  38900. /**
  38901. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  38902. * (eq to shadow prjection matrix * light transform matrix)
  38903. * @returns The transform matrix used to create the shadow map
  38904. */
  38905. getTransformMatrix(): Matrix;
  38906. /**
  38907. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  38908. * Cube and 2D textures for instance.
  38909. */
  38910. recreateShadowMap(): void;
  38911. /**
  38912. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  38913. * @param onCompiled Callback triggered at the and of the effects compilation
  38914. * @param options Sets of optional options forcing the compilation with different modes
  38915. */
  38916. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  38917. useInstances: boolean;
  38918. }>): void;
  38919. /**
  38920. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  38921. * @param options Sets of optional options forcing the compilation with different modes
  38922. * @returns A promise that resolves when the compilation completes
  38923. */
  38924. forceCompilationAsync(options?: Partial<{
  38925. useInstances: boolean;
  38926. }>): Promise<void>;
  38927. /**
  38928. * Serializes the shadow generator setup to a json object.
  38929. * @returns The serialized JSON object
  38930. */
  38931. serialize(): any;
  38932. /**
  38933. * Disposes the Shadow map and related Textures and effects.
  38934. */
  38935. dispose(): void;
  38936. }
  38937. /**
  38938. * Default implementation IShadowGenerator.
  38939. * This is the main object responsible of generating shadows in the framework.
  38940. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  38941. */
  38942. class ShadowGenerator implements IShadowGenerator {
  38943. /**
  38944. * Shadow generator mode None: no filtering applied.
  38945. */
  38946. static readonly FILTER_NONE: number;
  38947. /**
  38948. * Shadow generator mode ESM: Exponential Shadow Mapping.
  38949. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  38950. */
  38951. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  38952. /**
  38953. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  38954. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  38955. */
  38956. static readonly FILTER_POISSONSAMPLING: number;
  38957. /**
  38958. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  38959. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  38960. */
  38961. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  38962. /**
  38963. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  38964. * edge artifacts on steep falloff.
  38965. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  38966. */
  38967. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  38968. /**
  38969. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  38970. * edge artifacts on steep falloff.
  38971. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  38972. */
  38973. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  38974. /**
  38975. * Shadow generator mode PCF: Percentage Closer Filtering
  38976. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  38977. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  38978. */
  38979. static readonly FILTER_PCF: number;
  38980. /**
  38981. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  38982. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  38983. * Contact Hardening
  38984. */
  38985. static readonly FILTER_PCSS: number;
  38986. /**
  38987. * Reserved for PCF and PCSS
  38988. * Highest Quality.
  38989. *
  38990. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  38991. *
  38992. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  38993. */
  38994. static readonly QUALITY_HIGH: number;
  38995. /**
  38996. * Reserved for PCF and PCSS
  38997. * Good tradeoff for quality/perf cross devices
  38998. *
  38999. * Execute PCF on a 3*3 kernel.
  39000. *
  39001. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  39002. */
  39003. static readonly QUALITY_MEDIUM: number;
  39004. /**
  39005. * Reserved for PCF and PCSS
  39006. * The lowest quality but the fastest.
  39007. *
  39008. * Execute PCF on a 1*1 kernel.
  39009. *
  39010. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  39011. */
  39012. static readonly QUALITY_LOW: number;
  39013. private _bias;
  39014. /**
  39015. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  39016. */
  39017. /**
  39018. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  39019. */
  39020. bias: number;
  39021. private _normalBias;
  39022. /**
  39023. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  39024. */
  39025. /**
  39026. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  39027. */
  39028. normalBias: number;
  39029. private _blurBoxOffset;
  39030. /**
  39031. * Gets the blur box offset: offset applied during the blur pass.
  39032. * Only usefull if useKernelBlur = false
  39033. */
  39034. /**
  39035. * Sets the blur box offset: offset applied during the blur pass.
  39036. * Only usefull if useKernelBlur = false
  39037. */
  39038. blurBoxOffset: number;
  39039. private _blurScale;
  39040. /**
  39041. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  39042. * 2 means half of the size.
  39043. */
  39044. /**
  39045. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  39046. * 2 means half of the size.
  39047. */
  39048. blurScale: number;
  39049. private _blurKernel;
  39050. /**
  39051. * Gets the blur kernel: kernel size of the blur pass.
  39052. * Only usefull if useKernelBlur = true
  39053. */
  39054. /**
  39055. * Sets the blur kernel: kernel size of the blur pass.
  39056. * Only usefull if useKernelBlur = true
  39057. */
  39058. blurKernel: number;
  39059. private _useKernelBlur;
  39060. /**
  39061. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  39062. * Only usefull in filtered mode (useBlurExponentialShadowMap...)
  39063. */
  39064. /**
  39065. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  39066. * Only usefull in filtered mode (useBlurExponentialShadowMap...)
  39067. */
  39068. useKernelBlur: boolean;
  39069. private _depthScale;
  39070. /**
  39071. * Gets the depth scale used in ESM mode.
  39072. */
  39073. /**
  39074. * Sets the depth scale used in ESM mode.
  39075. * This can override the scale stored on the light.
  39076. */
  39077. depthScale: number;
  39078. private _filter;
  39079. /**
  39080. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  39081. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  39082. */
  39083. /**
  39084. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  39085. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  39086. */
  39087. filter: number;
  39088. /**
  39089. * Gets if the current filter is set to Poisson Sampling.
  39090. */
  39091. /**
  39092. * Sets the current filter to Poisson Sampling.
  39093. */
  39094. usePoissonSampling: boolean;
  39095. /**
  39096. * Gets if the current filter is set to VSM.
  39097. * DEPRECATED. Should use useExponentialShadowMap instead.
  39098. */
  39099. /**
  39100. * Sets the current filter is to VSM.
  39101. * DEPRECATED. Should use useExponentialShadowMap instead.
  39102. */
  39103. useVarianceShadowMap: boolean;
  39104. /**
  39105. * Gets if the current filter is set to blurred VSM.
  39106. * DEPRECATED. Should use useBlurExponentialShadowMap instead.
  39107. */
  39108. /**
  39109. * Sets the current filter is to blurred VSM.
  39110. * DEPRECATED. Should use useBlurExponentialShadowMap instead.
  39111. */
  39112. useBlurVarianceShadowMap: boolean;
  39113. /**
  39114. * Gets if the current filter is set to ESM.
  39115. */
  39116. /**
  39117. * Sets the current filter is to ESM.
  39118. */
  39119. useExponentialShadowMap: boolean;
  39120. /**
  39121. * Gets if the current filter is set to filtered ESM.
  39122. */
  39123. /**
  39124. * Gets if the current filter is set to filtered ESM.
  39125. */
  39126. useBlurExponentialShadowMap: boolean;
  39127. /**
  39128. * Gets if the current filter is set to "close ESM" (using the inverse of the
  39129. * exponential to prevent steep falloff artifacts).
  39130. */
  39131. /**
  39132. * Sets the current filter to "close ESM" (using the inverse of the
  39133. * exponential to prevent steep falloff artifacts).
  39134. */
  39135. useCloseExponentialShadowMap: boolean;
  39136. /**
  39137. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  39138. * exponential to prevent steep falloff artifacts).
  39139. */
  39140. /**
  39141. * Sets the current filter to filtered "close ESM" (using the inverse of the
  39142. * exponential to prevent steep falloff artifacts).
  39143. */
  39144. useBlurCloseExponentialShadowMap: boolean;
  39145. /**
  39146. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  39147. */
  39148. /**
  39149. * Sets the current filter to "PCF" (percentage closer filtering).
  39150. */
  39151. usePercentageCloserFiltering: boolean;
  39152. private _filteringQuality;
  39153. /**
  39154. * Gets the PCF or PCSS Quality.
  39155. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  39156. */
  39157. /**
  39158. * Sets the PCF or PCSS Quality.
  39159. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  39160. */
  39161. filteringQuality: number;
  39162. /**
  39163. * Gets if the current filter is set to "PCSS" (contact hardening).
  39164. */
  39165. /**
  39166. * Sets the current filter to "PCSS" (contact hardening).
  39167. */
  39168. useContactHardeningShadow: boolean;
  39169. private _contactHardeningLightSizeUVRatio;
  39170. /**
  39171. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  39172. * Using a ratio helps keeping shape stability independently of the map size.
  39173. *
  39174. * It does not account for the light projection as it was having too much
  39175. * instability during the light setup or during light position changes.
  39176. *
  39177. * Only valid if useContactHardeningShadow is true.
  39178. */
  39179. /**
  39180. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  39181. * Using a ratio helps keeping shape stability independently of the map size.
  39182. *
  39183. * It does not account for the light projection as it was having too much
  39184. * instability during the light setup or during light position changes.
  39185. *
  39186. * Only valid if useContactHardeningShadow is true.
  39187. */
  39188. contactHardeningLightSizeUVRatio: number;
  39189. private _darkness;
  39190. /**
  39191. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  39192. * 0 means strongest and 1 would means no shadow.
  39193. * @returns the darkness.
  39194. */
  39195. getDarkness(): number;
  39196. /**
  39197. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  39198. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  39199. * @returns the shadow generator allowing fluent coding.
  39200. */
  39201. setDarkness(darkness: number): ShadowGenerator;
  39202. private _transparencyShadow;
  39203. /**
  39204. * Sets the ability to have transparent shadow (boolean).
  39205. * @param transparent True if transparent else False
  39206. * @returns the shadow generator allowing fluent coding
  39207. */
  39208. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  39209. private _shadowMap;
  39210. private _shadowMap2;
  39211. /**
  39212. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  39213. * @returns The render target texture if present otherwise, null
  39214. */
  39215. getShadowMap(): Nullable<RenderTargetTexture>;
  39216. /**
  39217. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  39218. * @returns The render target texture if the shadow map is present otherwise, null
  39219. */
  39220. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  39221. /**
  39222. * Helper function to add a mesh and its descendants to the list of shadow casters.
  39223. * @param mesh Mesh to add
  39224. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  39225. * @returns the Shadow Generator itself
  39226. */
  39227. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  39228. /**
  39229. * Helper function to remove a mesh and its descendants from the list of shadow casters
  39230. * @param mesh Mesh to remove
  39231. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  39232. * @returns the Shadow Generator itself
  39233. */
  39234. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  39235. /**
  39236. * Controls the extent to which the shadows fade out at the edge of the frustum
  39237. * Used only by directionals and spots
  39238. */
  39239. frustumEdgeFalloff: number;
  39240. private _light;
  39241. /**
  39242. * Returns the associated light object.
  39243. * @returns the light generating the shadow
  39244. */
  39245. getLight(): IShadowLight;
  39246. /**
  39247. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  39248. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  39249. * It might on the other hand introduce peter panning.
  39250. */
  39251. forceBackFacesOnly: boolean;
  39252. private _scene;
  39253. private _lightDirection;
  39254. private _effect;
  39255. private _viewMatrix;
  39256. private _projectionMatrix;
  39257. private _transformMatrix;
  39258. private _cachedPosition;
  39259. private _cachedDirection;
  39260. private _cachedDefines;
  39261. private _currentRenderID;
  39262. private _boxBlurPostprocess;
  39263. private _kernelBlurXPostprocess;
  39264. private _kernelBlurYPostprocess;
  39265. private _blurPostProcesses;
  39266. private _mapSize;
  39267. private _currentFaceIndex;
  39268. private _currentFaceIndexCache;
  39269. private _textureType;
  39270. private _defaultTextureMatrix;
  39271. /**
  39272. * Creates a ShadowGenerator object.
  39273. * A ShadowGenerator is the required tool to use the shadows.
  39274. * Each light casting shadows needs to use its own ShadowGenerator.
  39275. * Documentation : http://doc.babylonjs.com/tutorials/shadows
  39276. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  39277. * @param light The light object generating the shadows.
  39278. * @param useFullFloatFirst 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.
  39279. */
  39280. constructor(mapSize: number, light: IShadowLight, useFullFloatFirst?: boolean);
  39281. private _initializeGenerator;
  39282. private _initializeShadowMap;
  39283. private _initializeBlurRTTAndPostProcesses;
  39284. private _renderForShadowMap;
  39285. private _renderSubMeshForShadowMap;
  39286. private _applyFilterValues;
  39287. /**
  39288. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  39289. * @param onCompiled Callback triggered at the and of the effects compilation
  39290. * @param options Sets of optional options forcing the compilation with different modes
  39291. */
  39292. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  39293. useInstances: boolean;
  39294. }>): void;
  39295. /**
  39296. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  39297. * @param options Sets of optional options forcing the compilation with different modes
  39298. * @returns A promise that resolves when the compilation completes
  39299. */
  39300. forceCompilationAsync(options?: Partial<{
  39301. useInstances: boolean;
  39302. }>): Promise<void>;
  39303. /**
  39304. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  39305. * @param subMesh The submesh we want to render in the shadow map
  39306. * @param useInstances Defines wether will draw in the map using instances
  39307. * @returns true if ready otherwise, false
  39308. */
  39309. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  39310. /**
  39311. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  39312. * @param defines Defines of the material we want to update
  39313. * @param lightIndex Index of the light in the enabled light list of the material
  39314. */
  39315. prepareDefines(defines: any, lightIndex: number): void;
  39316. /**
  39317. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  39318. * defined in the generator but impacting the effect).
  39319. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  39320. * @param effect The effect we are binfing the information for
  39321. */
  39322. bindShadowLight(lightIndex: string, effect: Effect): void;
  39323. /**
  39324. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  39325. * (eq to shadow prjection matrix * light transform matrix)
  39326. * @returns The transform matrix used to create the shadow map
  39327. */
  39328. getTransformMatrix(): Matrix;
  39329. /**
  39330. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  39331. * Cube and 2D textures for instance.
  39332. */
  39333. recreateShadowMap(): void;
  39334. private _disposeBlurPostProcesses;
  39335. private _disposeRTTandPostProcesses;
  39336. /**
  39337. * Disposes the ShadowGenerator.
  39338. * Returns nothing.
  39339. */
  39340. dispose(): void;
  39341. /**
  39342. * Serializes the shadow generator setup to a json object.
  39343. * @returns The serialized JSON object
  39344. */
  39345. serialize(): any;
  39346. /**
  39347. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  39348. * @param parsedShadowGenerator The JSON object to parse
  39349. * @param scene The scene to create the shadow map for
  39350. * @returns The parsed shadow generator
  39351. */
  39352. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  39353. }
  39354. }
  39355. declare module BABYLON {
  39356. /**
  39357. * Defines the shadow generator component responsible to manage any shadow generators
  39358. * in a given scene.
  39359. */
  39360. class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  39361. /**
  39362. * The component name helpfull to identify the component in the list of scene components.
  39363. */
  39364. readonly name: string;
  39365. /**
  39366. * The scene the component belongs to.
  39367. */
  39368. scene: Scene;
  39369. /**
  39370. * Creates a new instance of the component for the given scene
  39371. * @param scene Defines the scene to register the component in
  39372. */
  39373. constructor(scene: Scene);
  39374. /**
  39375. * Registers the component in a given scene
  39376. */
  39377. register(): void;
  39378. /**
  39379. * Rebuilds the elements related to this component in case of
  39380. * context lost for instance.
  39381. */
  39382. rebuild(): void;
  39383. /**
  39384. * Serializes the component data to the specified json object
  39385. * @param serializationObject The object to serialize to
  39386. */
  39387. serialize(serializationObject: any): void;
  39388. /**
  39389. * Adds all the element from the container to the scene
  39390. * @param container the container holding the elements
  39391. */
  39392. addFromContainer(container: AbstractScene): void;
  39393. /**
  39394. * Removes all the elements in the container from the scene
  39395. * @param container contains the elements to remove
  39396. */
  39397. removeFromContainer(container: AbstractScene): void;
  39398. /**
  39399. * Rebuilds the elements related to this component in case of
  39400. * context lost for instance.
  39401. */
  39402. dispose(): void;
  39403. private _gatherRenderTargets;
  39404. }
  39405. }
  39406. declare module BABYLON {
  39407. }
  39408. declare module BABYLON {
  39409. /**
  39410. * Background material used to create an efficient environement around your scene.
  39411. */
  39412. class BackgroundMaterial extends PushMaterial {
  39413. /**
  39414. * Standard reflectance value at parallel view angle.
  39415. */
  39416. static StandardReflectance0: number;
  39417. /**
  39418. * Standard reflectance value at grazing angle.
  39419. */
  39420. static StandardReflectance90: number;
  39421. protected _primaryColor: Color3;
  39422. /**
  39423. * Key light Color (multiply against the environement texture)
  39424. */
  39425. primaryColor: Color3;
  39426. protected __perceptualColor: Nullable<Color3>;
  39427. /**
  39428. * Experimental Internal Use Only.
  39429. *
  39430. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  39431. * This acts as a helper to set the primary color to a more "human friendly" value.
  39432. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  39433. * output color as close as possible from the chosen value.
  39434. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  39435. * part of lighting setup.)
  39436. */
  39437. protected _primaryColorShadowLevel: float;
  39438. /**
  39439. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  39440. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  39441. */
  39442. primaryColorShadowLevel: float;
  39443. protected _primaryColorHighlightLevel: float;
  39444. /**
  39445. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  39446. * The primary color is used at the level chosen to define what the white area would look.
  39447. */
  39448. primaryColorHighlightLevel: float;
  39449. protected _reflectionTexture: Nullable<BaseTexture>;
  39450. /**
  39451. * Reflection Texture used in the material.
  39452. * Should be author in a specific way for the best result (refer to the documentation).
  39453. */
  39454. reflectionTexture: Nullable<BaseTexture>;
  39455. protected _reflectionBlur: float;
  39456. /**
  39457. * Reflection Texture level of blur.
  39458. *
  39459. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  39460. * texture twice.
  39461. */
  39462. reflectionBlur: float;
  39463. protected _diffuseTexture: Nullable<BaseTexture>;
  39464. /**
  39465. * Diffuse Texture used in the material.
  39466. * Should be author in a specific way for the best result (refer to the documentation).
  39467. */
  39468. diffuseTexture: Nullable<BaseTexture>;
  39469. protected _shadowLights: Nullable<IShadowLight[]>;
  39470. /**
  39471. * Specify the list of lights casting shadow on the material.
  39472. * All scene shadow lights will be included if null.
  39473. */
  39474. shadowLights: Nullable<IShadowLight[]>;
  39475. protected _shadowLevel: float;
  39476. /**
  39477. * Helps adjusting the shadow to a softer level if required.
  39478. * 0 means black shadows and 1 means no shadows.
  39479. */
  39480. shadowLevel: float;
  39481. protected _sceneCenter: Vector3;
  39482. /**
  39483. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  39484. * It is usually zero but might be interesting to modify according to your setup.
  39485. */
  39486. sceneCenter: Vector3;
  39487. protected _opacityFresnel: boolean;
  39488. /**
  39489. * This helps specifying that the material is falling off to the sky box at grazing angle.
  39490. * This helps ensuring a nice transition when the camera goes under the ground.
  39491. */
  39492. opacityFresnel: boolean;
  39493. protected _reflectionFresnel: boolean;
  39494. /**
  39495. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  39496. * This helps adding a mirror texture on the ground.
  39497. */
  39498. reflectionFresnel: boolean;
  39499. protected _reflectionFalloffDistance: number;
  39500. /**
  39501. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  39502. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  39503. */
  39504. reflectionFalloffDistance: number;
  39505. protected _reflectionAmount: number;
  39506. /**
  39507. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  39508. */
  39509. reflectionAmount: number;
  39510. protected _reflectionReflectance0: number;
  39511. /**
  39512. * This specifies the weight of the reflection at grazing angle.
  39513. */
  39514. reflectionReflectance0: number;
  39515. protected _reflectionReflectance90: number;
  39516. /**
  39517. * This specifies the weight of the reflection at a perpendicular point of view.
  39518. */
  39519. reflectionReflectance90: number;
  39520. /**
  39521. * Sets the reflection reflectance fresnel values according to the default standard
  39522. * empirically know to work well :-)
  39523. */
  39524. reflectionStandardFresnelWeight: number;
  39525. protected _useRGBColor: boolean;
  39526. /**
  39527. * Helps to directly use the maps channels instead of their level.
  39528. */
  39529. useRGBColor: boolean;
  39530. protected _enableNoise: boolean;
  39531. /**
  39532. * This helps reducing the banding effect that could occur on the background.
  39533. */
  39534. enableNoise: boolean;
  39535. /**
  39536. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  39537. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  39538. * Recommended to be keep at 1.0 except for special cases.
  39539. */
  39540. fovMultiplier: number;
  39541. private _fovMultiplier;
  39542. /**
  39543. * Enable the FOV adjustment feature controlled by fovMultiplier.
  39544. */
  39545. useEquirectangularFOV: boolean;
  39546. private _maxSimultaneousLights;
  39547. /**
  39548. * Number of Simultaneous lights allowed on the material.
  39549. */
  39550. maxSimultaneousLights: int;
  39551. /**
  39552. * Default configuration related to image processing available in the Background Material.
  39553. */
  39554. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39555. /**
  39556. * Keep track of the image processing observer to allow dispose and replace.
  39557. */
  39558. private _imageProcessingObserver;
  39559. /**
  39560. * Attaches a new image processing configuration to the PBR Material.
  39561. * @param configuration (if null the scene configuration will be use)
  39562. */
  39563. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  39564. /**
  39565. * Gets the image processing configuration used either in this material.
  39566. */
  39567. /**
  39568. * Sets the Default image processing configuration used either in the this material.
  39569. *
  39570. * If sets to null, the scene one is in use.
  39571. */
  39572. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  39573. /**
  39574. * Gets wether the color curves effect is enabled.
  39575. */
  39576. /**
  39577. * Sets wether the color curves effect is enabled.
  39578. */
  39579. cameraColorCurvesEnabled: boolean;
  39580. /**
  39581. * Gets wether the color grading effect is enabled.
  39582. */
  39583. /**
  39584. * Gets wether the color grading effect is enabled.
  39585. */
  39586. cameraColorGradingEnabled: boolean;
  39587. /**
  39588. * Gets wether tonemapping is enabled or not.
  39589. */
  39590. /**
  39591. * Sets wether tonemapping is enabled or not
  39592. */
  39593. cameraToneMappingEnabled: boolean;
  39594. /**
  39595. * The camera exposure used on this material.
  39596. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  39597. * This corresponds to a photographic exposure.
  39598. */
  39599. /**
  39600. * The camera exposure used on this material.
  39601. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  39602. * This corresponds to a photographic exposure.
  39603. */
  39604. cameraExposure: float;
  39605. /**
  39606. * Gets The camera contrast used on this material.
  39607. */
  39608. /**
  39609. * Sets The camera contrast used on this material.
  39610. */
  39611. cameraContrast: float;
  39612. /**
  39613. * Gets the Color Grading 2D Lookup Texture.
  39614. */
  39615. /**
  39616. * Sets the Color Grading 2D Lookup Texture.
  39617. */
  39618. cameraColorGradingTexture: Nullable<BaseTexture>;
  39619. /**
  39620. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  39621. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  39622. * 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;
  39623. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  39624. */
  39625. /**
  39626. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  39627. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  39628. * 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;
  39629. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  39630. */
  39631. cameraColorCurves: Nullable<ColorCurves>;
  39632. /**
  39633. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  39634. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  39635. */
  39636. switchToBGR: boolean;
  39637. private _renderTargets;
  39638. private _reflectionControls;
  39639. private _white;
  39640. private _primaryShadowColor;
  39641. private _primaryHighlightColor;
  39642. /**
  39643. * Instantiates a Background Material in the given scene
  39644. * @param name The friendly name of the material
  39645. * @param scene The scene to add the material to
  39646. */
  39647. constructor(name: string, scene: Scene);
  39648. /**
  39649. * Gets a boolean indicating that current material needs to register RTT
  39650. */
  39651. readonly hasRenderTargetTextures: boolean;
  39652. /**
  39653. * The entire material has been created in order to prevent overdraw.
  39654. * @returns false
  39655. */
  39656. needAlphaTesting(): boolean;
  39657. /**
  39658. * The entire material has been created in order to prevent overdraw.
  39659. * @returns true if blending is enable
  39660. */
  39661. needAlphaBlending(): boolean;
  39662. /**
  39663. * Checks wether the material is ready to be rendered for a given mesh.
  39664. * @param mesh The mesh to render
  39665. * @param subMesh The submesh to check against
  39666. * @param useInstances Specify wether or not the material is used with instances
  39667. * @returns true if all the dependencies are ready (Textures, Effects...)
  39668. */
  39669. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  39670. /**
  39671. * Compute the primary color according to the chosen perceptual color.
  39672. */
  39673. private _computePrimaryColorFromPerceptualColor;
  39674. /**
  39675. * Compute the highlights and shadow colors according to their chosen levels.
  39676. */
  39677. private _computePrimaryColors;
  39678. /**
  39679. * Build the uniform buffer used in the material.
  39680. */
  39681. buildUniformLayout(): void;
  39682. /**
  39683. * Unbind the material.
  39684. */
  39685. unbind(): void;
  39686. /**
  39687. * Bind only the world matrix to the material.
  39688. * @param world The world matrix to bind.
  39689. */
  39690. bindOnlyWorldMatrix(world: Matrix): void;
  39691. /**
  39692. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  39693. * @param world The world matrix to bind.
  39694. * @param subMesh The submesh to bind for.
  39695. */
  39696. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  39697. /**
  39698. * Dispose the material.
  39699. * @param forceDisposeEffect Force disposal of the associated effect.
  39700. * @param forceDisposeTextures Force disposal of the associated textures.
  39701. */
  39702. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  39703. /**
  39704. * Clones the material.
  39705. * @param name The cloned name.
  39706. * @returns The cloned material.
  39707. */
  39708. clone(name: string): BackgroundMaterial;
  39709. /**
  39710. * Serializes the current material to its JSON representation.
  39711. * @returns The JSON representation.
  39712. */
  39713. serialize(): any;
  39714. /**
  39715. * Gets the class name of the material
  39716. * @returns "BackgroundMaterial"
  39717. */
  39718. getClassName(): string;
  39719. /**
  39720. * Parse a JSON input to create back a background material.
  39721. * @param source The JSON data to parse
  39722. * @param scene The scene to create the parsed material in
  39723. * @param rootUrl The root url of the assets the material depends upon
  39724. * @returns the instantiated BackgroundMaterial.
  39725. */
  39726. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  39727. }
  39728. }
  39729. declare module BABYLON {
  39730. /**
  39731. * The Physically based material base class of BJS.
  39732. *
  39733. * This offers the main features of a standard PBR material.
  39734. * For more information, please refer to the documentation :
  39735. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  39736. */
  39737. abstract class PBRBaseMaterial extends PushMaterial {
  39738. /**
  39739. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  39740. */
  39741. static readonly LIGHTFALLOFF_PHYSICAL: number;
  39742. /**
  39743. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  39744. * to enhance interoperability with other engines.
  39745. */
  39746. static readonly LIGHTFALLOFF_GLTF: number;
  39747. /**
  39748. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  39749. * to enhance interoperability with other materials.
  39750. */
  39751. static readonly LIGHTFALLOFF_STANDARD: number;
  39752. /**
  39753. * Intensity of the direct lights e.g. the four lights available in your scene.
  39754. * This impacts both the direct diffuse and specular highlights.
  39755. */
  39756. protected _directIntensity: number;
  39757. /**
  39758. * Intensity of the emissive part of the material.
  39759. * This helps controlling the emissive effect without modifying the emissive color.
  39760. */
  39761. protected _emissiveIntensity: number;
  39762. /**
  39763. * Intensity of the environment e.g. how much the environment will light the object
  39764. * either through harmonics for rough material or through the refelction for shiny ones.
  39765. */
  39766. protected _environmentIntensity: number;
  39767. /**
  39768. * This is a special control allowing the reduction of the specular highlights coming from the
  39769. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  39770. */
  39771. protected _specularIntensity: number;
  39772. /**
  39773. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  39774. */
  39775. private _lightingInfos;
  39776. /**
  39777. * Debug Control allowing disabling the bump map on this material.
  39778. */
  39779. protected _disableBumpMap: boolean;
  39780. /**
  39781. * AKA Diffuse Texture in standard nomenclature.
  39782. */
  39783. protected _albedoTexture: BaseTexture;
  39784. /**
  39785. * AKA Occlusion Texture in other nomenclature.
  39786. */
  39787. protected _ambientTexture: BaseTexture;
  39788. /**
  39789. * AKA Occlusion Texture Intensity in other nomenclature.
  39790. */
  39791. protected _ambientTextureStrength: number;
  39792. /**
  39793. * Defines how much the AO map is occluding the analytical lights (point spot...).
  39794. * 1 means it completely occludes it
  39795. * 0 mean it has no impact
  39796. */
  39797. protected _ambientTextureImpactOnAnalyticalLights: number;
  39798. /**
  39799. * Stores the alpha values in a texture.
  39800. */
  39801. protected _opacityTexture: BaseTexture;
  39802. /**
  39803. * Stores the reflection values in a texture.
  39804. */
  39805. protected _reflectionTexture: BaseTexture;
  39806. /**
  39807. * Stores the refraction values in a texture.
  39808. */
  39809. protected _refractionTexture: BaseTexture;
  39810. /**
  39811. * Stores the emissive values in a texture.
  39812. */
  39813. protected _emissiveTexture: BaseTexture;
  39814. /**
  39815. * AKA Specular texture in other nomenclature.
  39816. */
  39817. protected _reflectivityTexture: BaseTexture;
  39818. /**
  39819. * Used to switch from specular/glossiness to metallic/roughness workflow.
  39820. */
  39821. protected _metallicTexture: BaseTexture;
  39822. /**
  39823. * Specifies the metallic scalar of the metallic/roughness workflow.
  39824. * Can also be used to scale the metalness values of the metallic texture.
  39825. */
  39826. protected _metallic: Nullable<number>;
  39827. /**
  39828. * Specifies the roughness scalar of the metallic/roughness workflow.
  39829. * Can also be used to scale the roughness values of the metallic texture.
  39830. */
  39831. protected _roughness: Nullable<number>;
  39832. /**
  39833. * Used to enable roughness/glossiness fetch from a separate chanel depending on the current mode.
  39834. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  39835. */
  39836. protected _microSurfaceTexture: BaseTexture;
  39837. /**
  39838. * Stores surface normal data used to displace a mesh in a texture.
  39839. */
  39840. protected _bumpTexture: BaseTexture;
  39841. /**
  39842. * Stores the pre-calculated light information of a mesh in a texture.
  39843. */
  39844. protected _lightmapTexture: BaseTexture;
  39845. /**
  39846. * The color of a material in ambient lighting.
  39847. */
  39848. protected _ambientColor: Color3;
  39849. /**
  39850. * AKA Diffuse Color in other nomenclature.
  39851. */
  39852. protected _albedoColor: Color3;
  39853. /**
  39854. * AKA Specular Color in other nomenclature.
  39855. */
  39856. protected _reflectivityColor: Color3;
  39857. /**
  39858. * The color applied when light is reflected from a material.
  39859. */
  39860. protected _reflectionColor: Color3;
  39861. /**
  39862. * The color applied when light is emitted from a material.
  39863. */
  39864. protected _emissiveColor: Color3;
  39865. /**
  39866. * AKA Glossiness in other nomenclature.
  39867. */
  39868. protected _microSurface: number;
  39869. /**
  39870. * source material index of refraction (IOR)' / 'destination material IOR.
  39871. */
  39872. protected _indexOfRefraction: number;
  39873. /**
  39874. * Controls if refraction needs to be inverted on Y. This could be usefull for procedural texture.
  39875. */
  39876. protected _invertRefractionY: boolean;
  39877. /**
  39878. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  39879. * Materials half opaque for instance using refraction could benefit from this control.
  39880. */
  39881. protected _linkRefractionWithTransparency: boolean;
  39882. /**
  39883. * Specifies that the material will use the light map as a show map.
  39884. */
  39885. protected _useLightmapAsShadowmap: boolean;
  39886. /**
  39887. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  39888. * makes the reflect vector face the model (under horizon).
  39889. */
  39890. protected _useHorizonOcclusion: boolean;
  39891. /**
  39892. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  39893. * too much the area relying on ambient texture to define their ambient occlusion.
  39894. */
  39895. protected _useRadianceOcclusion: boolean;
  39896. /**
  39897. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  39898. */
  39899. protected _useAlphaFromAlbedoTexture: boolean;
  39900. /**
  39901. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  39902. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  39903. */
  39904. protected _useSpecularOverAlpha: boolean;
  39905. /**
  39906. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  39907. */
  39908. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  39909. /**
  39910. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  39911. */
  39912. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  39913. /**
  39914. * Specifies if the metallic texture contains the roughness information in its green channel.
  39915. */
  39916. protected _useRoughnessFromMetallicTextureGreen: boolean;
  39917. /**
  39918. * Specifies if the metallic texture contains the metallness information in its blue channel.
  39919. */
  39920. protected _useMetallnessFromMetallicTextureBlue: boolean;
  39921. /**
  39922. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  39923. */
  39924. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  39925. /**
  39926. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  39927. */
  39928. protected _useAmbientInGrayScale: boolean;
  39929. /**
  39930. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  39931. * The material will try to infer what glossiness each pixel should be.
  39932. */
  39933. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  39934. /**
  39935. * Defines the falloff type used in this material.
  39936. * It by default is Physical.
  39937. */
  39938. protected _lightFalloff: number;
  39939. /**
  39940. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  39941. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  39942. */
  39943. protected _useRadianceOverAlpha: boolean;
  39944. /**
  39945. * Allows using an object space normal map (instead of tangent space).
  39946. */
  39947. protected _useObjectSpaceNormalMap: boolean;
  39948. /**
  39949. * Allows using the bump map in parallax mode.
  39950. */
  39951. protected _useParallax: boolean;
  39952. /**
  39953. * Allows using the bump map in parallax occlusion mode.
  39954. */
  39955. protected _useParallaxOcclusion: boolean;
  39956. /**
  39957. * Controls the scale bias of the parallax mode.
  39958. */
  39959. protected _parallaxScaleBias: number;
  39960. /**
  39961. * If sets to true, disables all the lights affecting the material.
  39962. */
  39963. protected _disableLighting: boolean;
  39964. /**
  39965. * Number of Simultaneous lights allowed on the material.
  39966. */
  39967. protected _maxSimultaneousLights: number;
  39968. /**
  39969. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  39970. */
  39971. protected _invertNormalMapX: boolean;
  39972. /**
  39973. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  39974. */
  39975. protected _invertNormalMapY: boolean;
  39976. /**
  39977. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  39978. */
  39979. protected _twoSidedLighting: boolean;
  39980. /**
  39981. * Defines the alpha limits in alpha test mode.
  39982. */
  39983. protected _alphaCutOff: number;
  39984. /**
  39985. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  39986. */
  39987. protected _forceAlphaTest: boolean;
  39988. /**
  39989. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  39990. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  39991. */
  39992. protected _useAlphaFresnel: boolean;
  39993. /**
  39994. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  39995. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  39996. */
  39997. protected _useLinearAlphaFresnel: boolean;
  39998. /**
  39999. * The transparency mode of the material.
  40000. */
  40001. protected _transparencyMode: Nullable<number>;
  40002. /**
  40003. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  40004. * from cos thetav and roughness:
  40005. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  40006. */
  40007. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  40008. /**
  40009. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  40010. */
  40011. protected _forceIrradianceInFragment: boolean;
  40012. /**
  40013. * Force normal to face away from face.
  40014. */
  40015. protected _forceNormalForward: boolean;
  40016. /**
  40017. * Enables specular anti aliasing in the PBR shader.
  40018. * It will both interacts on the Geometry for analytical and IBL lighting.
  40019. * It also prefilter the roughness map based on the bump values.
  40020. */
  40021. protected _enableSpecularAntiAliasing: boolean;
  40022. /**
  40023. * Default configuration related to image processing available in the PBR Material.
  40024. */
  40025. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  40026. /**
  40027. * Keep track of the image processing observer to allow dispose and replace.
  40028. */
  40029. private _imageProcessingObserver;
  40030. /**
  40031. * Attaches a new image processing configuration to the PBR Material.
  40032. * @param configuration
  40033. */
  40034. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  40035. /**
  40036. * Stores the available render targets.
  40037. */
  40038. private _renderTargets;
  40039. /**
  40040. * Sets the global ambient color for the material used in lighting calculations.
  40041. */
  40042. private _globalAmbientColor;
  40043. /**
  40044. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  40045. */
  40046. private _useLogarithmicDepth;
  40047. /**
  40048. * If set to true, no lighting calculations will be applied.
  40049. */
  40050. private _unlit;
  40051. /**
  40052. * Instantiates a new PBRMaterial instance.
  40053. *
  40054. * @param name The material name
  40055. * @param scene The scene the material will be use in.
  40056. */
  40057. constructor(name: string, scene: Scene);
  40058. /**
  40059. * Gets a boolean indicating that current material needs to register RTT
  40060. */
  40061. readonly hasRenderTargetTextures: boolean;
  40062. /**
  40063. * Gets the name of the material class.
  40064. */
  40065. getClassName(): string;
  40066. /**
  40067. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  40068. */
  40069. /**
  40070. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  40071. */
  40072. useLogarithmicDepth: boolean;
  40073. /**
  40074. * Gets the current transparency mode.
  40075. */
  40076. /**
  40077. * Sets the transparency mode of the material.
  40078. *
  40079. * | Value | Type | Description |
  40080. * | ----- | ----------------------------------- | ----------- |
  40081. * | 0 | OPAQUE | |
  40082. * | 1 | ALPHATEST | |
  40083. * | 2 | ALPHABLEND | |
  40084. * | 3 | ALPHATESTANDBLEND | |
  40085. *
  40086. */
  40087. transparencyMode: Nullable<number>;
  40088. /**
  40089. * Returns true if alpha blending should be disabled.
  40090. */
  40091. private readonly _disableAlphaBlending;
  40092. /**
  40093. * Specifies whether or not this material should be rendered in alpha blend mode.
  40094. */
  40095. needAlphaBlending(): boolean;
  40096. /**
  40097. * Specifies if the mesh will require alpha blending.
  40098. * @param mesh - BJS mesh.
  40099. */
  40100. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  40101. /**
  40102. * Specifies whether or not this material should be rendered in alpha test mode.
  40103. */
  40104. needAlphaTesting(): boolean;
  40105. /**
  40106. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  40107. */
  40108. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  40109. /**
  40110. * Gets the texture used for the alpha test.
  40111. */
  40112. getAlphaTestTexture(): BaseTexture;
  40113. /**
  40114. * Stores the reflectivity values based on metallic roughness workflow.
  40115. */
  40116. private static _scaledReflectivity;
  40117. /**
  40118. * Specifies that the submesh is ready to be used.
  40119. * @param mesh - BJS mesh.
  40120. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  40121. * @param useInstances - Specifies that instances should be used.
  40122. * @returns - boolean indicating that the submesh is ready or not.
  40123. */
  40124. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  40125. /**
  40126. * Specifies if the material uses metallic roughness workflow.
  40127. * @returns boolean specifiying if the material uses metallic roughness workflow.
  40128. */
  40129. isMetallicWorkflow(): boolean;
  40130. private _prepareEffect;
  40131. private _prepareDefines;
  40132. /**
  40133. * Force shader compilation
  40134. */
  40135. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  40136. clipPlane: boolean;
  40137. }>): void;
  40138. /**
  40139. * Initializes the uniform buffer layout for the shader.
  40140. */
  40141. buildUniformLayout(): void;
  40142. /**
  40143. * Unbinds the textures.
  40144. */
  40145. unbind(): void;
  40146. /**
  40147. * Binds the submesh data.
  40148. * @param world - The world matrix.
  40149. * @param mesh - The BJS mesh.
  40150. * @param subMesh - A submesh of the BJS mesh.
  40151. */
  40152. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  40153. /**
  40154. * Returns the animatable textures.
  40155. * @returns - Array of animatable textures.
  40156. */
  40157. getAnimatables(): IAnimatable[];
  40158. /**
  40159. * Returns the texture used for reflections.
  40160. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  40161. */
  40162. private _getReflectionTexture;
  40163. /**
  40164. * Returns the texture used for refraction or null if none is used.
  40165. * @returns - Refection texture if present. If no refraction texture and refraction
  40166. * is linked with transparency, returns environment texture. Otherwise, returns null.
  40167. */
  40168. private _getRefractionTexture;
  40169. /**
  40170. * Disposes the resources of the material.
  40171. * @param forceDisposeEffect - Forces the disposal of effects.
  40172. * @param forceDisposeTextures - Forces the disposal of all textures.
  40173. */
  40174. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  40175. }
  40176. }
  40177. declare module BABYLON {
  40178. /**
  40179. * The Physically based simple base material of BJS.
  40180. *
  40181. * This enables better naming and convention enforcements on top of the pbrMaterial.
  40182. * It is used as the base class for both the specGloss and metalRough conventions.
  40183. */
  40184. abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  40185. /**
  40186. * Number of Simultaneous lights allowed on the material.
  40187. */
  40188. maxSimultaneousLights: number;
  40189. /**
  40190. * If sets to true, disables all the lights affecting the material.
  40191. */
  40192. disableLighting: boolean;
  40193. /**
  40194. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  40195. */
  40196. environmentTexture: BaseTexture;
  40197. /**
  40198. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  40199. */
  40200. invertNormalMapX: boolean;
  40201. /**
  40202. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  40203. */
  40204. invertNormalMapY: boolean;
  40205. /**
  40206. * Normal map used in the model.
  40207. */
  40208. normalTexture: BaseTexture;
  40209. /**
  40210. * Emissivie color used to self-illuminate the model.
  40211. */
  40212. emissiveColor: Color3;
  40213. /**
  40214. * Emissivie texture used to self-illuminate the model.
  40215. */
  40216. emissiveTexture: BaseTexture;
  40217. /**
  40218. * Occlusion Channel Strenght.
  40219. */
  40220. occlusionStrength: number;
  40221. /**
  40222. * Occlusion Texture of the material (adding extra occlusion effects).
  40223. */
  40224. occlusionTexture: BaseTexture;
  40225. /**
  40226. * Defines the alpha limits in alpha test mode.
  40227. */
  40228. alphaCutOff: number;
  40229. /**
  40230. * Gets the current double sided mode.
  40231. */
  40232. /**
  40233. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  40234. */
  40235. doubleSided: boolean;
  40236. lightmapTexture: BaseTexture;
  40237. useLightmapAsShadowmap: boolean;
  40238. /**
  40239. * Return the active textures of the material.
  40240. */
  40241. getActiveTextures(): BaseTexture[];
  40242. hasTexture(texture: BaseTexture): boolean;
  40243. /**
  40244. * Instantiates a new PBRMaterial instance.
  40245. *
  40246. * @param name The material name
  40247. * @param scene The scene the material will be use in.
  40248. */
  40249. constructor(name: string, scene: Scene);
  40250. getClassName(): string;
  40251. }
  40252. }
  40253. declare module BABYLON {
  40254. /**
  40255. * The Physically based material of BJS.
  40256. *
  40257. * This offers the main features of a standard PBR material.
  40258. * For more information, please refer to the documentation :
  40259. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  40260. */
  40261. class PBRMaterial extends PBRBaseMaterial {
  40262. /**
  40263. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  40264. */
  40265. static readonly PBRMATERIAL_OPAQUE: number;
  40266. /**
  40267. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  40268. */
  40269. static readonly PBRMATERIAL_ALPHATEST: number;
  40270. /**
  40271. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  40272. */
  40273. static readonly PBRMATERIAL_ALPHABLEND: number;
  40274. /**
  40275. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  40276. * They are also discarded below the alpha cutoff threshold to improve performances.
  40277. */
  40278. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  40279. /**
  40280. * Defines the default value of how much AO map is occluding the analytical lights
  40281. * (point spot...).
  40282. */
  40283. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  40284. /**
  40285. * Intensity of the direct lights e.g. the four lights available in your scene.
  40286. * This impacts both the direct diffuse and specular highlights.
  40287. */
  40288. directIntensity: number;
  40289. /**
  40290. * Intensity of the emissive part of the material.
  40291. * This helps controlling the emissive effect without modifying the emissive color.
  40292. */
  40293. emissiveIntensity: number;
  40294. /**
  40295. * Intensity of the environment e.g. how much the environment will light the object
  40296. * either through harmonics for rough material or through the refelction for shiny ones.
  40297. */
  40298. environmentIntensity: number;
  40299. /**
  40300. * This is a special control allowing the reduction of the specular highlights coming from the
  40301. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  40302. */
  40303. specularIntensity: number;
  40304. /**
  40305. * Debug Control allowing disabling the bump map on this material.
  40306. */
  40307. disableBumpMap: boolean;
  40308. /**
  40309. * AKA Diffuse Texture in standard nomenclature.
  40310. */
  40311. albedoTexture: BaseTexture;
  40312. /**
  40313. * AKA Occlusion Texture in other nomenclature.
  40314. */
  40315. ambientTexture: BaseTexture;
  40316. /**
  40317. * AKA Occlusion Texture Intensity in other nomenclature.
  40318. */
  40319. ambientTextureStrength: number;
  40320. /**
  40321. * Defines how much the AO map is occluding the analytical lights (point spot...).
  40322. * 1 means it completely occludes it
  40323. * 0 mean it has no impact
  40324. */
  40325. ambientTextureImpactOnAnalyticalLights: number;
  40326. /**
  40327. * Stores the alpha values in a texture.
  40328. */
  40329. opacityTexture: BaseTexture;
  40330. /**
  40331. * Stores the reflection values in a texture.
  40332. */
  40333. reflectionTexture: Nullable<BaseTexture>;
  40334. /**
  40335. * Stores the emissive values in a texture.
  40336. */
  40337. emissiveTexture: BaseTexture;
  40338. /**
  40339. * AKA Specular texture in other nomenclature.
  40340. */
  40341. reflectivityTexture: BaseTexture;
  40342. /**
  40343. * Used to switch from specular/glossiness to metallic/roughness workflow.
  40344. */
  40345. metallicTexture: BaseTexture;
  40346. /**
  40347. * Specifies the metallic scalar of the metallic/roughness workflow.
  40348. * Can also be used to scale the metalness values of the metallic texture.
  40349. */
  40350. metallic: Nullable<number>;
  40351. /**
  40352. * Specifies the roughness scalar of the metallic/roughness workflow.
  40353. * Can also be used to scale the roughness values of the metallic texture.
  40354. */
  40355. roughness: Nullable<number>;
  40356. /**
  40357. * Used to enable roughness/glossiness fetch from a separate chanel depending on the current mode.
  40358. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  40359. */
  40360. microSurfaceTexture: BaseTexture;
  40361. /**
  40362. * Stores surface normal data used to displace a mesh in a texture.
  40363. */
  40364. bumpTexture: BaseTexture;
  40365. /**
  40366. * Stores the pre-calculated light information of a mesh in a texture.
  40367. */
  40368. lightmapTexture: BaseTexture;
  40369. /**
  40370. * Stores the refracted light information in a texture.
  40371. */
  40372. refractionTexture: BaseTexture;
  40373. /**
  40374. * The color of a material in ambient lighting.
  40375. */
  40376. ambientColor: Color3;
  40377. /**
  40378. * AKA Diffuse Color in other nomenclature.
  40379. */
  40380. albedoColor: Color3;
  40381. /**
  40382. * AKA Specular Color in other nomenclature.
  40383. */
  40384. reflectivityColor: Color3;
  40385. /**
  40386. * The color reflected from the material.
  40387. */
  40388. reflectionColor: Color3;
  40389. /**
  40390. * The color emitted from the material.
  40391. */
  40392. emissiveColor: Color3;
  40393. /**
  40394. * AKA Glossiness in other nomenclature.
  40395. */
  40396. microSurface: number;
  40397. /**
  40398. * source material index of refraction (IOR)' / 'destination material IOR.
  40399. */
  40400. indexOfRefraction: number;
  40401. /**
  40402. * Controls if refraction needs to be inverted on Y. This could be usefull for procedural texture.
  40403. */
  40404. invertRefractionY: boolean;
  40405. /**
  40406. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  40407. * Materials half opaque for instance using refraction could benefit from this control.
  40408. */
  40409. linkRefractionWithTransparency: boolean;
  40410. useLightmapAsShadowmap: boolean;
  40411. /**
  40412. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  40413. */
  40414. useAlphaFromAlbedoTexture: boolean;
  40415. /**
  40416. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  40417. */
  40418. forceAlphaTest: boolean;
  40419. /**
  40420. * Defines the alpha limits in alpha test mode.
  40421. */
  40422. alphaCutOff: number;
  40423. /**
  40424. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  40425. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  40426. */
  40427. useSpecularOverAlpha: boolean;
  40428. /**
  40429. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  40430. */
  40431. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  40432. /**
  40433. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  40434. */
  40435. useRoughnessFromMetallicTextureAlpha: boolean;
  40436. /**
  40437. * Specifies if the metallic texture contains the roughness information in its green channel.
  40438. */
  40439. useRoughnessFromMetallicTextureGreen: boolean;
  40440. /**
  40441. * Specifies if the metallic texture contains the metallness information in its blue channel.
  40442. */
  40443. useMetallnessFromMetallicTextureBlue: boolean;
  40444. /**
  40445. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  40446. */
  40447. useAmbientOcclusionFromMetallicTextureRed: boolean;
  40448. /**
  40449. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  40450. */
  40451. useAmbientInGrayScale: boolean;
  40452. /**
  40453. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  40454. * The material will try to infer what glossiness each pixel should be.
  40455. */
  40456. useAutoMicroSurfaceFromReflectivityMap: boolean;
  40457. /**
  40458. * BJS is using an harcoded light falloff based on a manually sets up range.
  40459. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  40460. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  40461. */
  40462. /**
  40463. * BJS is using an harcoded light falloff based on a manually sets up range.
  40464. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  40465. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  40466. */
  40467. usePhysicalLightFalloff: boolean;
  40468. /**
  40469. * In order to support the falloff compatibility with gltf, a special mode has been added
  40470. * to reproduce the gltf light falloff.
  40471. */
  40472. /**
  40473. * In order to support the falloff compatibility with gltf, a special mode has been added
  40474. * to reproduce the gltf light falloff.
  40475. */
  40476. useGLTFLightFalloff: boolean;
  40477. /**
  40478. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  40479. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  40480. */
  40481. useRadianceOverAlpha: boolean;
  40482. /**
  40483. * Allows using an object space normal map (instead of tangent space).
  40484. */
  40485. useObjectSpaceNormalMap: boolean;
  40486. /**
  40487. * Allows using the bump map in parallax mode.
  40488. */
  40489. useParallax: boolean;
  40490. /**
  40491. * Allows using the bump map in parallax occlusion mode.
  40492. */
  40493. useParallaxOcclusion: boolean;
  40494. /**
  40495. * Controls the scale bias of the parallax mode.
  40496. */
  40497. parallaxScaleBias: number;
  40498. /**
  40499. * If sets to true, disables all the lights affecting the material.
  40500. */
  40501. disableLighting: boolean;
  40502. /**
  40503. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  40504. */
  40505. forceIrradianceInFragment: boolean;
  40506. /**
  40507. * Number of Simultaneous lights allowed on the material.
  40508. */
  40509. maxSimultaneousLights: number;
  40510. /**
  40511. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  40512. */
  40513. invertNormalMapX: boolean;
  40514. /**
  40515. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  40516. */
  40517. invertNormalMapY: boolean;
  40518. /**
  40519. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  40520. */
  40521. twoSidedLighting: boolean;
  40522. /**
  40523. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  40524. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  40525. */
  40526. useAlphaFresnel: boolean;
  40527. /**
  40528. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  40529. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  40530. */
  40531. useLinearAlphaFresnel: boolean;
  40532. /**
  40533. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  40534. * And/Or occlude the blended part.
  40535. */
  40536. environmentBRDFTexture: Nullable<BaseTexture>;
  40537. /**
  40538. * Force normal to face away from face.
  40539. */
  40540. forceNormalForward: boolean;
  40541. /**
  40542. * Enables specular anti aliasing in the PBR shader.
  40543. * It will both interacts on the Geometry for analytical and IBL lighting.
  40544. * It also prefilter the roughness map based on the bump values.
  40545. */
  40546. enableSpecularAntiAliasing: boolean;
  40547. /**
  40548. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  40549. * makes the reflect vector face the model (under horizon).
  40550. */
  40551. useHorizonOcclusion: boolean;
  40552. /**
  40553. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  40554. * too much the area relying on ambient texture to define their ambient occlusion.
  40555. */
  40556. useRadianceOcclusion: boolean;
  40557. /**
  40558. * If set to true, no lighting calculations will be applied.
  40559. */
  40560. unlit: boolean;
  40561. /**
  40562. * Gets the image processing configuration used either in this material.
  40563. */
  40564. /**
  40565. * Sets the Default image processing configuration used either in the this material.
  40566. *
  40567. * If sets to null, the scene one is in use.
  40568. */
  40569. imageProcessingConfiguration: ImageProcessingConfiguration;
  40570. /**
  40571. * Gets wether the color curves effect is enabled.
  40572. */
  40573. /**
  40574. * Sets wether the color curves effect is enabled.
  40575. */
  40576. cameraColorCurvesEnabled: boolean;
  40577. /**
  40578. * Gets wether the color grading effect is enabled.
  40579. */
  40580. /**
  40581. * Gets wether the color grading effect is enabled.
  40582. */
  40583. cameraColorGradingEnabled: boolean;
  40584. /**
  40585. * Gets wether tonemapping is enabled or not.
  40586. */
  40587. /**
  40588. * Sets wether tonemapping is enabled or not
  40589. */
  40590. cameraToneMappingEnabled: boolean;
  40591. /**
  40592. * The camera exposure used on this material.
  40593. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  40594. * This corresponds to a photographic exposure.
  40595. */
  40596. /**
  40597. * The camera exposure used on this material.
  40598. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  40599. * This corresponds to a photographic exposure.
  40600. */
  40601. cameraExposure: number;
  40602. /**
  40603. * Gets The camera contrast used on this material.
  40604. */
  40605. /**
  40606. * Sets The camera contrast used on this material.
  40607. */
  40608. cameraContrast: number;
  40609. /**
  40610. * Gets the Color Grading 2D Lookup Texture.
  40611. */
  40612. /**
  40613. * Sets the Color Grading 2D Lookup Texture.
  40614. */
  40615. cameraColorGradingTexture: Nullable<BaseTexture>;
  40616. /**
  40617. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  40618. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  40619. * 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;
  40620. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  40621. */
  40622. /**
  40623. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  40624. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  40625. * 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;
  40626. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  40627. */
  40628. cameraColorCurves: Nullable<ColorCurves>;
  40629. /**
  40630. * Instantiates a new PBRMaterial instance.
  40631. *
  40632. * @param name The material name
  40633. * @param scene The scene the material will be use in.
  40634. */
  40635. constructor(name: string, scene: Scene);
  40636. /**
  40637. * Returns the name of this material class.
  40638. */
  40639. getClassName(): string;
  40640. /**
  40641. * Returns an array of the actively used textures.
  40642. * @returns - Array of BaseTextures
  40643. */
  40644. getActiveTextures(): BaseTexture[];
  40645. /**
  40646. * Checks to see if a texture is used in the material.
  40647. * @param texture - Base texture to use.
  40648. * @returns - Boolean specifying if a texture is used in the material.
  40649. */
  40650. hasTexture(texture: BaseTexture): boolean;
  40651. /**
  40652. * Makes a duplicate of the current material.
  40653. * @param name - name to use for the new material.
  40654. */
  40655. clone(name: string): PBRMaterial;
  40656. /**
  40657. * Serializes this PBR Material.
  40658. * @returns - An object with the serialized material.
  40659. */
  40660. serialize(): any;
  40661. /**
  40662. * Parses a PBR Material from a serialized object.
  40663. * @param source - Serialized object.
  40664. * @param scene - BJS scene instance.
  40665. * @param rootUrl - url for the scene object
  40666. * @returns - PBRMaterial
  40667. */
  40668. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  40669. }
  40670. }
  40671. declare module BABYLON {
  40672. /**
  40673. * The PBR material of BJS following the metal roughness convention.
  40674. *
  40675. * This fits to the PBR convention in the GLTF definition:
  40676. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  40677. */
  40678. class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  40679. /**
  40680. * The base color has two different interpretations depending on the value of metalness.
  40681. * When the material is a metal, the base color is the specific measured reflectance value
  40682. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  40683. * of the material.
  40684. */
  40685. baseColor: Color3;
  40686. /**
  40687. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  40688. * well as opacity information in the alpha channel.
  40689. */
  40690. baseTexture: BaseTexture;
  40691. /**
  40692. * Specifies the metallic scalar value of the material.
  40693. * Can also be used to scale the metalness values of the metallic texture.
  40694. */
  40695. metallic: number;
  40696. /**
  40697. * Specifies the roughness scalar value of the material.
  40698. * Can also be used to scale the roughness values of the metallic texture.
  40699. */
  40700. roughness: number;
  40701. /**
  40702. * Texture containing both the metallic value in the B channel and the
  40703. * roughness value in the G channel to keep better precision.
  40704. */
  40705. metallicRoughnessTexture: BaseTexture;
  40706. /**
  40707. * Instantiates a new PBRMetalRoughnessMaterial instance.
  40708. *
  40709. * @param name The material name
  40710. * @param scene The scene the material will be use in.
  40711. */
  40712. constructor(name: string, scene: Scene);
  40713. /**
  40714. * Return the currrent class name of the material.
  40715. */
  40716. getClassName(): string;
  40717. /**
  40718. * Return the active textures of the material.
  40719. */
  40720. getActiveTextures(): BaseTexture[];
  40721. /**
  40722. * Checks to see if a texture is used in the material.
  40723. * @param texture - Base texture to use.
  40724. * @returns - Boolean specifying if a texture is used in the material.
  40725. */
  40726. hasTexture(texture: BaseTexture): boolean;
  40727. /**
  40728. * Makes a duplicate of the current material.
  40729. * @param name - name to use for the new material.
  40730. */
  40731. clone(name: string): PBRMetallicRoughnessMaterial;
  40732. /**
  40733. * Serialize the material to a parsable JSON object.
  40734. */
  40735. serialize(): any;
  40736. /**
  40737. * Parses a JSON object correponding to the serialize function.
  40738. */
  40739. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  40740. }
  40741. }
  40742. declare module BABYLON {
  40743. /**
  40744. * The PBR material of BJS following the specular glossiness convention.
  40745. *
  40746. * This fits to the PBR convention in the GLTF definition:
  40747. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  40748. */
  40749. class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  40750. /**
  40751. * Specifies the diffuse color of the material.
  40752. */
  40753. diffuseColor: Color3;
  40754. /**
  40755. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  40756. * channel.
  40757. */
  40758. diffuseTexture: BaseTexture;
  40759. /**
  40760. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  40761. */
  40762. specularColor: Color3;
  40763. /**
  40764. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  40765. */
  40766. glossiness: number;
  40767. /**
  40768. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  40769. */
  40770. specularGlossinessTexture: BaseTexture;
  40771. /**
  40772. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  40773. *
  40774. * @param name The material name
  40775. * @param scene The scene the material will be use in.
  40776. */
  40777. constructor(name: string, scene: Scene);
  40778. /**
  40779. * Return the currrent class name of the material.
  40780. */
  40781. getClassName(): string;
  40782. /**
  40783. * Return the active textures of the material.
  40784. */
  40785. getActiveTextures(): BaseTexture[];
  40786. /**
  40787. * Checks to see if a texture is used in the material.
  40788. * @param texture - Base texture to use.
  40789. * @returns - Boolean specifying if a texture is used in the material.
  40790. */
  40791. hasTexture(texture: BaseTexture): boolean;
  40792. /**
  40793. * Makes a duplicate of the current material.
  40794. * @param name - name to use for the new material.
  40795. */
  40796. clone(name: string): PBRSpecularGlossinessMaterial;
  40797. /**
  40798. * Serialize the material to a parsable JSON object.
  40799. */
  40800. serialize(): any;
  40801. /**
  40802. * Parses a JSON object correponding to the serialize function.
  40803. */
  40804. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  40805. }
  40806. }
  40807. declare module BABYLON {
  40808. class BaseTexture {
  40809. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  40810. name: string;
  40811. private _hasAlpha;
  40812. hasAlpha: boolean;
  40813. getAlphaFromRGB: boolean;
  40814. level: number;
  40815. coordinatesIndex: number;
  40816. private _coordinatesMode;
  40817. /**
  40818. * How a texture is mapped.
  40819. *
  40820. * | Value | Type | Description |
  40821. * | ----- | ----------------------------------- | ----------- |
  40822. * | 0 | EXPLICIT_MODE | |
  40823. * | 1 | SPHERICAL_MODE | |
  40824. * | 2 | PLANAR_MODE | |
  40825. * | 3 | CUBIC_MODE | |
  40826. * | 4 | PROJECTION_MODE | |
  40827. * | 5 | SKYBOX_MODE | |
  40828. * | 6 | INVCUBIC_MODE | |
  40829. * | 7 | EQUIRECTANGULAR_MODE | |
  40830. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  40831. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  40832. */
  40833. coordinatesMode: number;
  40834. /**
  40835. * | Value | Type | Description |
  40836. * | ----- | ------------------ | ----------- |
  40837. * | 0 | CLAMP_ADDRESSMODE | |
  40838. * | 1 | WRAP_ADDRESSMODE | |
  40839. * | 2 | MIRROR_ADDRESSMODE | |
  40840. */
  40841. wrapU: number;
  40842. /**
  40843. * | Value | Type | Description |
  40844. * | ----- | ------------------ | ----------- |
  40845. * | 0 | CLAMP_ADDRESSMODE | |
  40846. * | 1 | WRAP_ADDRESSMODE | |
  40847. * | 2 | MIRROR_ADDRESSMODE | |
  40848. */
  40849. wrapV: number;
  40850. /**
  40851. * | Value | Type | Description |
  40852. * | ----- | ------------------ | ----------- |
  40853. * | 0 | CLAMP_ADDRESSMODE | |
  40854. * | 1 | WRAP_ADDRESSMODE | |
  40855. * | 2 | MIRROR_ADDRESSMODE | |
  40856. */
  40857. wrapR: number;
  40858. anisotropicFilteringLevel: number;
  40859. isCube: boolean;
  40860. is3D: boolean;
  40861. gammaSpace: boolean;
  40862. /**
  40863. * Gets whether or not the texture contains RGBD data.
  40864. */
  40865. readonly isRGBD: boolean;
  40866. invertZ: boolean;
  40867. lodLevelInAlpha: boolean;
  40868. lodGenerationOffset: number;
  40869. lodGenerationScale: number;
  40870. isRenderTarget: boolean;
  40871. readonly uid: string;
  40872. toString(): string;
  40873. getClassName(): string;
  40874. animations: Animation[];
  40875. /**
  40876. * An event triggered when the texture is disposed.
  40877. */
  40878. onDisposeObservable: Observable<BaseTexture>;
  40879. private _onDisposeObserver;
  40880. onDispose: () => void;
  40881. delayLoadState: number;
  40882. private _scene;
  40883. /** @hidden */
  40884. private _uid;
  40885. readonly isBlocking: boolean;
  40886. constructor(scene: Nullable<Scene>);
  40887. getScene(): Nullable<Scene>;
  40888. getTextureMatrix(): Matrix;
  40889. getReflectionTextureMatrix(): Matrix;
  40890. getInternalTexture(): Nullable<InternalTexture>;
  40891. isReadyOrNotBlocking(): boolean;
  40892. isReady(): boolean;
  40893. private _cachedSize;
  40894. getSize(): ISize;
  40895. getBaseSize(): ISize;
  40896. scale(ratio: number): void;
  40897. readonly canRescale: boolean;
  40898. /** @hidden */
  40899. /** @hidden */
  40900. delayLoad(): void;
  40901. clone(): Nullable<BaseTexture>;
  40902. readonly textureType: number;
  40903. readonly textureFormat: number;
  40904. /**
  40905. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  40906. * This will returns an RGBA array buffer containing either in values (0-255) or
  40907. * float values (0-1) depending of the underlying buffer type.
  40908. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  40909. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  40910. * @param buffer defines a user defined buffer to fill with data (can be null)
  40911. * @returns The Array buffer containing the pixels data.
  40912. */
  40913. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  40914. releaseInternalTexture(): void;
  40915. sphericalPolynomial: Nullable<SphericalPolynomial>;
  40916. protected readonly _lodTextureHigh: Nullable<BaseTexture>;
  40917. protected readonly _lodTextureMid: Nullable<BaseTexture>;
  40918. protected readonly _lodTextureLow: Nullable<BaseTexture>;
  40919. dispose(): void;
  40920. serialize(): any;
  40921. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  40922. }
  40923. }
  40924. declare module BABYLON {
  40925. /**
  40926. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  40927. * It can help converting any input color in a desired output one. This can then be used to create effects
  40928. * from sepia, black and white to sixties or futuristic rendering...
  40929. *
  40930. * The only supported format is currently 3dl.
  40931. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table/
  40932. */
  40933. class ColorGradingTexture extends BaseTexture {
  40934. /**
  40935. * The current texture matrix. (will always be identity in color grading texture)
  40936. */
  40937. private _textureMatrix;
  40938. /**
  40939. * The texture URL.
  40940. */
  40941. url: string;
  40942. /**
  40943. * Empty line regex stored for GC.
  40944. */
  40945. private static _noneEmptyLineRegex;
  40946. private _engine;
  40947. /**
  40948. * Instantiates a ColorGradingTexture from the following parameters.
  40949. *
  40950. * @param url The location of the color gradind data (currently only supporting 3dl)
  40951. * @param scene The scene the texture will be used in
  40952. */
  40953. constructor(url: string, scene: Scene);
  40954. /**
  40955. * Returns the texture matrix used in most of the material.
  40956. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  40957. */
  40958. getTextureMatrix(): Matrix;
  40959. /**
  40960. * Occurs when the file being loaded is a .3dl LUT file.
  40961. */
  40962. private load3dlTexture;
  40963. /**
  40964. * Starts the loading process of the texture.
  40965. */
  40966. private loadTexture;
  40967. /**
  40968. * Clones the color gradind texture.
  40969. */
  40970. clone(): ColorGradingTexture;
  40971. /**
  40972. * Called during delayed load for textures.
  40973. */
  40974. delayLoad(): void;
  40975. /**
  40976. * Parses a color grading texture serialized by Babylon.
  40977. * @param parsedTexture The texture information being parsedTexture
  40978. * @param scene The scene to load the texture in
  40979. * @param rootUrl The root url of the data assets to load
  40980. * @return A color gradind texture
  40981. */
  40982. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<ColorGradingTexture>;
  40983. /**
  40984. * Serializes the LUT texture to json format.
  40985. */
  40986. serialize(): any;
  40987. }
  40988. }
  40989. declare module BABYLON {
  40990. class CubeTexture extends BaseTexture {
  40991. url: string;
  40992. /**
  40993. * Gets or sets the center of the bounding box associated with the cube texture
  40994. * It must define where the camera used to render the texture was set
  40995. */
  40996. boundingBoxPosition: Vector3;
  40997. private _boundingBoxSize;
  40998. /**
  40999. * Gets or sets the size of the bounding box associated with the cube texture
  41000. * When defined, the cubemap will switch to local mode
  41001. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  41002. * @example https://www.babylonjs-playground.com/#RNASML
  41003. */
  41004. boundingBoxSize: Vector3;
  41005. protected _rotationY: number;
  41006. /**
  41007. * Sets texture matrix rotation angle around Y axis in radians.
  41008. */
  41009. /**
  41010. * Gets texture matrix rotation angle around Y axis radians.
  41011. */
  41012. rotationY: number;
  41013. private _noMipmap;
  41014. private _files;
  41015. private _extensions;
  41016. private _textureMatrix;
  41017. private _format;
  41018. private _createPolynomials;
  41019. /** @hidden */
  41020. protected readonly _prefiltered: boolean;
  41021. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  41022. /**
  41023. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  41024. * @param url defines the url of the prefiltered texture
  41025. * @param scene defines the scene the texture is attached to
  41026. * @param forcedExtension defines the extension of the file if different from the url
  41027. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  41028. * @return the prefiltered texture
  41029. */
  41030. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  41031. /**
  41032. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  41033. * as prefiltered data.
  41034. * @param rootUrl defines the url of the texture or the root name of the six images
  41035. * @param scene defines the scene the texture is attached to
  41036. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  41037. * @param noMipmap defines if mipmaps should be created or not
  41038. * @param files defines the six files to load for the different faces
  41039. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  41040. * @param onError defines a callback triggered in case of error during load
  41041. * @param format defines the internal format to use for the texture once loaded
  41042. * @param prefiltered defines whether or not the texture is created from prefiltered data
  41043. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  41044. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  41045. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  41046. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  41047. * @return the cube texture
  41048. */
  41049. 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);
  41050. delayLoad(): void;
  41051. getReflectionTextureMatrix(): Matrix;
  41052. setReflectionTextureMatrix(value: Matrix): void;
  41053. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  41054. clone(): CubeTexture;
  41055. }
  41056. }
  41057. declare module BABYLON {
  41058. /**
  41059. * A class extending {BABYLON.Texture} allowing drawing on a texture
  41060. * @see http://doc.babylonjs.com/how_to/dynamictexture
  41061. */
  41062. class DynamicTexture extends Texture {
  41063. private _generateMipMaps;
  41064. private _canvas;
  41065. private _context;
  41066. private _engine;
  41067. /**
  41068. * Creates a {BABYLON.DynamicTexture}
  41069. * @param name defines the name of the texture
  41070. * @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
  41071. * @param scene defines the scene where you want the texture
  41072. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  41073. * @param samplingMode defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  41074. * @param format defines the texture format to use (default is BABYLON.Engine.TEXTUREFORMAT_RGBA)
  41075. */
  41076. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  41077. /**
  41078. * Gets the current state of canRescale
  41079. */
  41080. readonly canRescale: boolean;
  41081. private _recreate;
  41082. /**
  41083. * Scales the texture
  41084. * @param ratio the scale factor to apply to both width and height
  41085. */
  41086. scale(ratio: number): void;
  41087. /**
  41088. * Resizes the texture
  41089. * @param width the new width
  41090. * @param height the new height
  41091. */
  41092. scaleTo(width: number, height: number): void;
  41093. /**
  41094. * Gets the context of the canvas used by the texture
  41095. * @returns the canvas context of the dynamic texture
  41096. */
  41097. getContext(): CanvasRenderingContext2D;
  41098. /**
  41099. * Clears the texture
  41100. */
  41101. clear(): void;
  41102. /**
  41103. * Updates the texture
  41104. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  41105. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  41106. */
  41107. update(invertY?: boolean, premulAlpha?: boolean): void;
  41108. /**
  41109. * Draws text onto the texture
  41110. * @param text defines the text to be drawn
  41111. * @param x defines the placement of the text from the left
  41112. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  41113. * @param font defines the font to be used with font-style, font-size, font-name
  41114. * @param color defines the color used for the text
  41115. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  41116. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  41117. * @param update defines whether texture is immediately update (default is true)
  41118. */
  41119. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  41120. /**
  41121. * Clones the texture
  41122. * @returns the clone of the texture.
  41123. */
  41124. clone(): DynamicTexture;
  41125. /**
  41126. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  41127. * @returns a serialized dynamic texture object
  41128. */
  41129. serialize(): any;
  41130. /** @hidden */
  41131. }
  41132. }
  41133. declare module BABYLON {
  41134. /**
  41135. * This represents a texture coming from an HDR input.
  41136. *
  41137. * The only supported format is currently panorama picture stored in RGBE format.
  41138. * Example of such files can be found on HDRLib: http://hdrlib.com/
  41139. */
  41140. class HDRCubeTexture extends BaseTexture {
  41141. private static _facesMapping;
  41142. private _generateHarmonics;
  41143. private _noMipmap;
  41144. private _textureMatrix;
  41145. private _size;
  41146. private _onLoad;
  41147. private _onError;
  41148. /**
  41149. * The texture URL.
  41150. */
  41151. url: string;
  41152. /**
  41153. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  41154. */
  41155. coordinatesMode: number;
  41156. protected _isBlocking: boolean;
  41157. /**
  41158. * Sets wether or not the texture is blocking during loading.
  41159. */
  41160. /**
  41161. * Gets wether or not the texture is blocking during loading.
  41162. */
  41163. isBlocking: boolean;
  41164. protected _rotationY: number;
  41165. /**
  41166. * Sets texture matrix rotation angle around Y axis in radians.
  41167. */
  41168. /**
  41169. * Gets texture matrix rotation angle around Y axis radians.
  41170. */
  41171. rotationY: number;
  41172. /**
  41173. * Gets or sets the center of the bounding box associated with the cube texture
  41174. * It must define where the camera used to render the texture was set
  41175. */
  41176. boundingBoxPosition: Vector3;
  41177. private _boundingBoxSize;
  41178. /**
  41179. * Gets or sets the size of the bounding box associated with the cube texture
  41180. * When defined, the cubemap will switch to local mode
  41181. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  41182. * @example https://www.babylonjs-playground.com/#RNASML
  41183. */
  41184. boundingBoxSize: Vector3;
  41185. /**
  41186. * Instantiates an HDRTexture from the following parameters.
  41187. *
  41188. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  41189. * @param scene The scene the texture will be used in
  41190. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  41191. * @param noMipmap Forces to not generate the mipmap if true
  41192. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  41193. * @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)
  41194. * @param reserved Reserved flag for internal use.
  41195. */
  41196. 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>);
  41197. /**
  41198. * Occurs when the file is raw .hdr file.
  41199. */
  41200. private loadTexture;
  41201. clone(): HDRCubeTexture;
  41202. delayLoad(): void;
  41203. getReflectionTextureMatrix(): Matrix;
  41204. setReflectionTextureMatrix(value: Matrix): void;
  41205. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  41206. serialize(): any;
  41207. }
  41208. }
  41209. declare module BABYLON {
  41210. /**
  41211. * Class used to store data associated with WebGL texture data for the engine
  41212. * This class should not be used directly
  41213. */
  41214. class InternalTexture implements IInternalTextureTracker {
  41215. /**
  41216. * The source of the texture data is unknown
  41217. */
  41218. static DATASOURCE_UNKNOWN: number;
  41219. /**
  41220. * Texture data comes from an URL
  41221. */
  41222. static DATASOURCE_URL: number;
  41223. /**
  41224. * Texture data is only used for temporary storage
  41225. */
  41226. static DATASOURCE_TEMP: number;
  41227. /**
  41228. * Texture data comes from raw data (ArrayBuffer)
  41229. */
  41230. static DATASOURCE_RAW: number;
  41231. /**
  41232. * Texture content is dynamic (video or dynamic texture)
  41233. */
  41234. static DATASOURCE_DYNAMIC: number;
  41235. /**
  41236. * Texture content is generated by rendering to it
  41237. */
  41238. static DATASOURCE_RENDERTARGET: number;
  41239. /**
  41240. * Texture content is part of a multi render target process
  41241. */
  41242. static DATASOURCE_MULTIRENDERTARGET: number;
  41243. /**
  41244. * Texture data comes from a cube data file
  41245. */
  41246. static DATASOURCE_CUBE: number;
  41247. /**
  41248. * Texture data comes from a raw cube data
  41249. */
  41250. static DATASOURCE_CUBERAW: number;
  41251. /**
  41252. * Texture data come from a prefiltered cube data file
  41253. */
  41254. static DATASOURCE_CUBEPREFILTERED: number;
  41255. /**
  41256. * Texture content is raw 3D data
  41257. */
  41258. static DATASOURCE_RAW3D: number;
  41259. /**
  41260. * Texture content is a depth texture
  41261. */
  41262. static DATASOURCE_DEPTHTEXTURE: number;
  41263. /**
  41264. * Texture data comes from a raw cube data encoded with RGBD
  41265. */
  41266. static DATASOURCE_CUBERAW_RGBD: number;
  41267. /**
  41268. * Defines if the texture is ready
  41269. */
  41270. isReady: boolean;
  41271. /**
  41272. * Defines if the texture is a cube texture
  41273. */
  41274. isCube: boolean;
  41275. /**
  41276. * Defines if the texture contains 3D data
  41277. */
  41278. is3D: boolean;
  41279. /**
  41280. * Gets the URL used to load this texture
  41281. */
  41282. url: string;
  41283. /**
  41284. * Gets the sampling mode of the texture
  41285. */
  41286. samplingMode: number;
  41287. /**
  41288. * Gets a boolean indicating if the texture needs mipmaps generation
  41289. */
  41290. generateMipMaps: boolean;
  41291. /**
  41292. * Gets the number of samples used by the texture (WebGL2+ only)
  41293. */
  41294. samples: number;
  41295. /**
  41296. * Gets the type of the texture
  41297. */
  41298. type: number;
  41299. /**
  41300. * Gets the format of the texture
  41301. */
  41302. format: number;
  41303. /**
  41304. * Observable called when the texture is loaded
  41305. */
  41306. onLoadedObservable: Observable<InternalTexture>;
  41307. /**
  41308. * Gets the width of the texture
  41309. */
  41310. width: number;
  41311. /**
  41312. * Gets the height of the texture
  41313. */
  41314. height: number;
  41315. /**
  41316. * Gets the depth of the texture
  41317. */
  41318. depth: number;
  41319. /**
  41320. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  41321. */
  41322. baseWidth: number;
  41323. /**
  41324. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  41325. */
  41326. baseHeight: number;
  41327. /**
  41328. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  41329. */
  41330. baseDepth: number;
  41331. /**
  41332. * Gets a boolean indicating if the texture is inverted on Y axis
  41333. */
  41334. invertY: boolean;
  41335. /**
  41336. * Gets or set the previous tracker in the list
  41337. */
  41338. previous: Nullable<IInternalTextureTracker>;
  41339. /**
  41340. * Gets or set the next tracker in the list
  41341. */
  41342. next: Nullable<IInternalTextureTracker>;
  41343. /** @hidden */
  41344. /** @hidden */
  41345. /** @hidden */
  41346. /** @hidden */
  41347. /** @hidden */
  41348. /** @hidden */
  41349. /** @hidden */
  41350. /** @hidden */
  41351. /** @hidden */
  41352. /** @hidden */
  41353. /** @hidden */
  41354. /** @hidden */
  41355. /** @hidden */
  41356. /** @hidden */
  41357. /** @hidden */
  41358. /** @hidden */
  41359. /** @hidden */
  41360. /** @hidden */
  41361. /** @hidden */
  41362. /** @hidden */
  41363. /** @hidden */
  41364. /** @hidden */
  41365. /** @hidden */
  41366. /** @hidden */
  41367. /** @hidden */
  41368. /** @hidden */
  41369. /** @hidden */
  41370. /** @hidden */
  41371. /** @hidden */
  41372. /** @hidden */
  41373. /** @hidden */
  41374. /** @hidden */
  41375. /** @hidden */
  41376. /** @hidden */
  41377. /** @hidden */
  41378. /** @hidden */
  41379. private _engine;
  41380. /**
  41381. * Gets the Engine the texture belongs to.
  41382. * @returns The babylon engine
  41383. */
  41384. getEngine(): Engine;
  41385. /**
  41386. * Gets the data source type of the texture (can be one of the BABYLON.InternalTexture.DATASOURCE_XXXX)
  41387. */
  41388. readonly dataSource: number;
  41389. /**
  41390. * Creates a new InternalTexture
  41391. * @param engine defines the engine to use
  41392. * @param dataSource defines the type of data that will be used
  41393. */
  41394. constructor(engine: Engine, dataSource: number);
  41395. /**
  41396. * Increments the number of references (ie. the number of {BABYLON.Texture} that point to it)
  41397. */
  41398. incrementReferences(): void;
  41399. /**
  41400. * Change the size of the texture (not the size of the content)
  41401. * @param width defines the new width
  41402. * @param height defines the new height
  41403. * @param depth defines the new depth (1 by default)
  41404. */
  41405. updateSize(width: int, height: int, depth?: int): void;
  41406. /** @hidden */
  41407. /** @hidden */
  41408. /**
  41409. * Dispose the current allocated resources
  41410. */
  41411. dispose(): void;
  41412. }
  41413. }
  41414. declare module BABYLON {
  41415. /**
  41416. * This represents the required contract to create a new type of texture loader.
  41417. */
  41418. interface IInternalTextureLoader {
  41419. /**
  41420. * Defines wether the loader supports cascade loading the different faces.
  41421. */
  41422. supportCascades: boolean;
  41423. /**
  41424. * This returns if the loader support the current file information.
  41425. * @param extension defines the file extension of the file being loaded
  41426. * @param textureFormatInUse defines the current compressed format in use iun the engine
  41427. * @param fallback defines the fallback internal texture if any
  41428. * @param isBase64 defines whether the texture is encoded as a base64
  41429. * @param isBuffer defines whether the texture data are stored as a buffer
  41430. * @returns true if the loader can load the specified file
  41431. */
  41432. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  41433. /**
  41434. * Transform the url before loading if required.
  41435. * @param rootUrl the url of the texture
  41436. * @param textureFormatInUse defines the current compressed format in use iun the engine
  41437. * @returns the transformed texture
  41438. */
  41439. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  41440. /**
  41441. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  41442. * @param rootUrl the url of the texture
  41443. * @param textureFormatInUse defines the current compressed format in use iun the engine
  41444. * @returns the fallback texture
  41445. */
  41446. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  41447. /**
  41448. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  41449. * @param data contains the texture data
  41450. * @param texture defines the BabylonJS internal texture
  41451. * @param createPolynomials will be true if polynomials have been requested
  41452. * @param onLoad defines the callback to trigger once the texture is ready
  41453. * @param onError defines the callback to trigger in case of error
  41454. */
  41455. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  41456. /**
  41457. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  41458. * @param data contains the texture data
  41459. * @param texture defines the BabylonJS internal texture
  41460. * @param callback defines the method to call once ready to upload
  41461. */
  41462. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  41463. }
  41464. }
  41465. declare module BABYLON {
  41466. /**
  41467. * Internal interface used to track {BABYLON.InternalTexture} already bound to the GL context
  41468. */
  41469. interface IInternalTextureTracker {
  41470. /**
  41471. * Gets or set the previous tracker in the list
  41472. */
  41473. previous: Nullable<IInternalTextureTracker>;
  41474. /**
  41475. * Gets or set the next tracker in the list
  41476. */
  41477. next: Nullable<IInternalTextureTracker>;
  41478. }
  41479. /**
  41480. * Internal class used by the engine to get list of {BABYLON.InternalTexture} already bound to the GL context
  41481. */
  41482. class DummyInternalTextureTracker {
  41483. /**
  41484. * Gets or set the previous tracker in the list
  41485. */
  41486. previous: Nullable<IInternalTextureTracker>;
  41487. /**
  41488. * Gets or set the next tracker in the list
  41489. */
  41490. next: Nullable<IInternalTextureTracker>;
  41491. }
  41492. }
  41493. declare module BABYLON {
  41494. class MirrorTexture extends RenderTargetTexture {
  41495. private scene;
  41496. mirrorPlane: Plane;
  41497. private _transformMatrix;
  41498. private _mirrorMatrix;
  41499. private _savedViewMatrix;
  41500. private _blurX;
  41501. private _blurY;
  41502. private _adaptiveBlurKernel;
  41503. private _blurKernelX;
  41504. private _blurKernelY;
  41505. private _blurRatio;
  41506. blurRatio: number;
  41507. adaptiveBlurKernel: number;
  41508. blurKernel: number;
  41509. blurKernelX: number;
  41510. blurKernelY: number;
  41511. private _autoComputeBlurKernel;
  41512. protected _onRatioRescale(): void;
  41513. private _updateGammaSpace;
  41514. private _imageProcessingConfigChangeObserver;
  41515. constructor(name: string, size: number | {
  41516. width: number;
  41517. height: number;
  41518. } | {
  41519. ratio: number;
  41520. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  41521. private _preparePostProcesses;
  41522. clone(): MirrorTexture;
  41523. serialize(): any;
  41524. dispose(): void;
  41525. }
  41526. }
  41527. declare module BABYLON {
  41528. interface IMultiRenderTargetOptions {
  41529. generateMipMaps?: boolean;
  41530. types?: number[];
  41531. samplingModes?: number[];
  41532. generateDepthBuffer?: boolean;
  41533. generateStencilBuffer?: boolean;
  41534. generateDepthTexture?: boolean;
  41535. textureCount?: number;
  41536. doNotChangeAspectRatio?: boolean;
  41537. defaultType?: number;
  41538. }
  41539. class MultiRenderTarget extends RenderTargetTexture {
  41540. private _internalTextures;
  41541. private _textures;
  41542. readonly isSupported: boolean;
  41543. private _multiRenderTargetOptions;
  41544. readonly textures: Texture[];
  41545. readonly depthTexture: Texture;
  41546. wrapU: number;
  41547. wrapV: number;
  41548. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  41549. /** @hidden */
  41550. private _createInternalTextures;
  41551. private _createTextures;
  41552. samples: number;
  41553. resize(size: any): void;
  41554. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  41555. dispose(): void;
  41556. releaseInternalTextures(): void;
  41557. }
  41558. }
  41559. declare module BABYLON {
  41560. /**
  41561. * Raw cube texture where the raw buffers are passed in
  41562. */
  41563. class RawCubeTexture extends CubeTexture {
  41564. /**
  41565. * Creates a cube texture where the raw buffers are passed in.
  41566. * @param scene defines the scene the texture is attached to
  41567. * @param data defines the array of data to use to create each face
  41568. * @param size defines the size of the textures
  41569. * @param format defines the format of the data
  41570. * @param type defines the type of the data (like BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT)
  41571. * @param generateMipMaps defines if the engine should generate the mip levels
  41572. * @param invertY defines if data must be stored with Y axis inverted
  41573. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  41574. * @param compression defines the compression used (null by default)
  41575. */
  41576. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  41577. /**
  41578. * Updates the raw cube texture.
  41579. * @param data defines the data to store
  41580. * @param format defines the data format
  41581. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  41582. * @param invertY defines if data must be stored with Y axis inverted
  41583. * @param compression defines the compression used (null by default)
  41584. * @param level defines which level of the texture to update
  41585. */
  41586. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  41587. /**
  41588. * Updates a raw cube texture with RGBD encoded data.
  41589. * @param data defines the array of data [mipmap][face] to use to create each face
  41590. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  41591. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  41592. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  41593. * @returns a promsie that resolves when the operation is complete
  41594. */
  41595. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  41596. /**
  41597. * Clones the raw cube texture.
  41598. * @return a new cube texture
  41599. */
  41600. clone(): CubeTexture;
  41601. /** @hidden */
  41602. private static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  41603. }
  41604. }
  41605. declare module BABYLON {
  41606. class RawTexture extends Texture {
  41607. format: number;
  41608. private _engine;
  41609. constructor(data: ArrayBufferView, width: number, height: number, format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  41610. update(data: ArrayBufferView): void;
  41611. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  41612. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  41613. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  41614. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  41615. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  41616. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  41617. }
  41618. }
  41619. declare module BABYLON {
  41620. /**
  41621. * Class used to store 3D textures containing user data
  41622. */
  41623. class RawTexture3D extends Texture {
  41624. /** Gets or sets the texture format to use */
  41625. format: number;
  41626. private _engine;
  41627. /**
  41628. * Create a new RawTexture3D
  41629. * @param data defines the data of the texture
  41630. * @param width defines the width of the texture
  41631. * @param height defines the height of the texture
  41632. * @param depth defines the depth of the texture
  41633. * @param format defines the texture format to use
  41634. * @param scene defines the hosting scene
  41635. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  41636. * @param invertY defines if texture must be stored with Y axis inverted
  41637. * @param samplingMode defines the sampling mode to use (BABYLON.Texture.TRILINEAR_SAMPLINGMODE by default)
  41638. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  41639. */
  41640. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  41641. /** Gets or sets the texture format to use */
  41642. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  41643. /**
  41644. * Update the texture with new data
  41645. * @param data defines the data to store in the texture
  41646. */
  41647. update(data: ArrayBufferView): void;
  41648. }
  41649. }
  41650. declare module BABYLON {
  41651. /**
  41652. * Creates a refraction texture used by refraction channel of the standard material.
  41653. * @param name the texture name
  41654. * @param size size of the underlying texture
  41655. * @param scene root scene
  41656. */
  41657. class RefractionTexture extends RenderTargetTexture {
  41658. refractionPlane: Plane;
  41659. depth: number;
  41660. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  41661. clone(): RefractionTexture;
  41662. serialize(): any;
  41663. }
  41664. }
  41665. declare module BABYLON {
  41666. class RenderTargetTexture extends Texture {
  41667. isCube: boolean;
  41668. private static _REFRESHRATE_RENDER_ONCE: number;
  41669. private static _REFRESHRATE_RENDER_ONEVERYFRAME: number;
  41670. private static _REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  41671. static readonly REFRESHRATE_RENDER_ONCE: number;
  41672. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  41673. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  41674. /**
  41675. * Use this predicate to dynamically define the list of mesh you want to render.
  41676. * If set, the renderList property will be overwritten.
  41677. */
  41678. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  41679. private _renderList;
  41680. /**
  41681. * Use this list to define the list of mesh you want to render.
  41682. */
  41683. renderList: Nullable<Array<AbstractMesh>>;
  41684. private _hookArray;
  41685. renderParticles: boolean;
  41686. renderSprites: boolean;
  41687. coordinatesMode: number;
  41688. activeCamera: Nullable<Camera>;
  41689. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  41690. useCameraPostProcesses: boolean;
  41691. ignoreCameraViewport: boolean;
  41692. private _postProcessManager;
  41693. private _postProcesses;
  41694. private _resizeObserver;
  41695. /**
  41696. * An event triggered when the texture is unbind.
  41697. */
  41698. onBeforeBindObservable: Observable<RenderTargetTexture>;
  41699. /**
  41700. * An event triggered when the texture is unbind.
  41701. */
  41702. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  41703. private _onAfterUnbindObserver;
  41704. onAfterUnbind: () => void;
  41705. /**
  41706. * An event triggered before rendering the texture
  41707. */
  41708. onBeforeRenderObservable: Observable<number>;
  41709. private _onBeforeRenderObserver;
  41710. onBeforeRender: (faceIndex: number) => void;
  41711. /**
  41712. * An event triggered after rendering the texture
  41713. */
  41714. onAfterRenderObservable: Observable<number>;
  41715. private _onAfterRenderObserver;
  41716. onAfterRender: (faceIndex: number) => void;
  41717. /**
  41718. * An event triggered after the texture clear
  41719. */
  41720. onClearObservable: Observable<Engine>;
  41721. private _onClearObserver;
  41722. onClear: (Engine: Engine) => void;
  41723. clearColor: Color4;
  41724. protected _size: number | {
  41725. width: number;
  41726. height: number;
  41727. };
  41728. protected _initialSizeParameter: number | {
  41729. width: number;
  41730. height: number;
  41731. } | {
  41732. ratio: number;
  41733. };
  41734. protected _sizeRatio: Nullable<number>;
  41735. /** @hidden */
  41736. protected _renderingManager: RenderingManager;
  41737. /** @hidden */
  41738. protected _doNotChangeAspectRatio: boolean;
  41739. protected _currentRefreshId: number;
  41740. protected _refreshRate: number;
  41741. protected _textureMatrix: Matrix;
  41742. protected _samples: number;
  41743. protected _renderTargetOptions: RenderTargetCreationOptions;
  41744. readonly renderTargetOptions: RenderTargetCreationOptions;
  41745. protected _engine: Engine;
  41746. protected _onRatioRescale(): void;
  41747. /**
  41748. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  41749. * It must define where the camera used to render the texture is set
  41750. */
  41751. boundingBoxPosition: Vector3;
  41752. private _boundingBoxSize;
  41753. /**
  41754. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  41755. * When defined, the cubemap will switch to local mode
  41756. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  41757. * @example https://www.babylonjs-playground.com/#RNASML
  41758. */
  41759. boundingBoxSize: Vector3;
  41760. /**
  41761. * In case the RTT has been created with a depth texture, get the associated
  41762. * depth texture.
  41763. * Otherwise, return null.
  41764. */
  41765. depthStencilTexture: Nullable<InternalTexture>;
  41766. /**
  41767. * Instantiate a render target texture. This is mainly to render of screen the scene to for instance apply post processse
  41768. * or used a shadow, depth texture...
  41769. * @param name The friendly name of the texture
  41770. * @param size The size of the RTT (number if square, or {with: number, height:number} or {ratio:} to define a ratio from the main scene)
  41771. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  41772. * @param generateMipMaps True if mip maps need to be generated after render.
  41773. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  41774. * @param type The type of the buffer in the RTT (int, half float, float...)
  41775. * @param isCube True if a cube texture needs to be created
  41776. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  41777. * @param generateDepthBuffer True to generate a depth buffer
  41778. * @param generateStencilBuffer True to generate a stencil buffer
  41779. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  41780. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  41781. */
  41782. constructor(name: string, size: number | {
  41783. width: number;
  41784. height: number;
  41785. } | {
  41786. ratio: number;
  41787. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number);
  41788. /**
  41789. * Creates a depth stencil texture.
  41790. * This is only available in WebGL 2 or with the depth texture extension available.
  41791. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  41792. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  41793. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  41794. */
  41795. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  41796. private _processSizeParameter;
  41797. samples: number;
  41798. resetRefreshCounter(): void;
  41799. refreshRate: number;
  41800. addPostProcess(postProcess: PostProcess): void;
  41801. clearPostProcesses(dispose?: boolean): void;
  41802. removePostProcess(postProcess: PostProcess): void;
  41803. /** @hidden */
  41804. getRenderSize(): number;
  41805. getRenderWidth(): number;
  41806. getRenderHeight(): number;
  41807. readonly canRescale: boolean;
  41808. scale(ratio: number): void;
  41809. getReflectionTextureMatrix(): Matrix;
  41810. resize(size: number | {
  41811. width: number;
  41812. height: number;
  41813. } | {
  41814. ratio: number;
  41815. }): void;
  41816. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  41817. private _bestReflectionRenderTargetDimension;
  41818. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  41819. private renderToTarget;
  41820. /**
  41821. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  41822. * This allowed control for front to back rendering or reversly depending of the special needs.
  41823. *
  41824. * @param renderingGroupId The rendering group id corresponding to its index
  41825. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  41826. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  41827. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  41828. */
  41829. 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;
  41830. /**
  41831. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  41832. *
  41833. * @param renderingGroupId The rendering group id corresponding to its index
  41834. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  41835. */
  41836. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  41837. clone(): RenderTargetTexture;
  41838. serialize(): any;
  41839. disposeFramebufferObjects(): void;
  41840. dispose(): void;
  41841. /** @hidden */
  41842. /**
  41843. * Clear the info related to rendering groups preventing retention point in material dispose.
  41844. */
  41845. freeRenderingGroups(): void;
  41846. }
  41847. }
  41848. declare module BABYLON {
  41849. class Texture extends BaseTexture {
  41850. static NEAREST_SAMPLINGMODE: number;
  41851. static NEAREST_NEAREST_MIPLINEAR: number;
  41852. static BILINEAR_SAMPLINGMODE: number;
  41853. static LINEAR_LINEAR_MIPNEAREST: number;
  41854. static TRILINEAR_SAMPLINGMODE: number;
  41855. static LINEAR_LINEAR_MIPLINEAR: number;
  41856. static NEAREST_NEAREST_MIPNEAREST: number;
  41857. static NEAREST_LINEAR_MIPNEAREST: number;
  41858. static NEAREST_LINEAR_MIPLINEAR: number;
  41859. static NEAREST_LINEAR: number;
  41860. static NEAREST_NEAREST: number;
  41861. static LINEAR_NEAREST_MIPNEAREST: number;
  41862. static LINEAR_NEAREST_MIPLINEAR: number;
  41863. static LINEAR_LINEAR: number;
  41864. static LINEAR_NEAREST: number;
  41865. static EXPLICIT_MODE: number;
  41866. static SPHERICAL_MODE: number;
  41867. static PLANAR_MODE: number;
  41868. static CUBIC_MODE: number;
  41869. static PROJECTION_MODE: number;
  41870. static SKYBOX_MODE: number;
  41871. static INVCUBIC_MODE: number;
  41872. static EQUIRECTANGULAR_MODE: number;
  41873. static FIXED_EQUIRECTANGULAR_MODE: number;
  41874. static FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  41875. static readonly CLAMP_ADDRESSMODE: number;
  41876. static readonly WRAP_ADDRESSMODE: number;
  41877. static readonly MIRROR_ADDRESSMODE: number;
  41878. /**
  41879. * 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
  41880. */
  41881. static UseSerializedUrlIfAny: boolean;
  41882. url: Nullable<string>;
  41883. uOffset: number;
  41884. vOffset: number;
  41885. uScale: number;
  41886. vScale: number;
  41887. uAng: number;
  41888. vAng: number;
  41889. wAng: number;
  41890. /**
  41891. * Defines the center of rotation (U)
  41892. */
  41893. uRotationCenter: number;
  41894. /**
  41895. * Defines the center of rotation (V)
  41896. */
  41897. vRotationCenter: number;
  41898. /**
  41899. * Defines the center of rotation (W)
  41900. */
  41901. wRotationCenter: number;
  41902. readonly noMipmap: boolean;
  41903. private _noMipmap;
  41904. /** @hidden */
  41905. private _rowGenerationMatrix;
  41906. private _cachedTextureMatrix;
  41907. private _projectionModeMatrix;
  41908. private _t0;
  41909. private _t1;
  41910. private _t2;
  41911. private _cachedUOffset;
  41912. private _cachedVOffset;
  41913. private _cachedUScale;
  41914. private _cachedVScale;
  41915. private _cachedUAng;
  41916. private _cachedVAng;
  41917. private _cachedWAng;
  41918. private _cachedProjectionMatrixId;
  41919. private _cachedCoordinatesMode;
  41920. /** @hidden */
  41921. /** @hidden */
  41922. private _deleteBuffer;
  41923. protected _format: Nullable<number>;
  41924. private _delayedOnLoad;
  41925. private _delayedOnError;
  41926. protected _onLoadObservable: Nullable<Observable<Texture>>;
  41927. protected _isBlocking: boolean;
  41928. isBlocking: boolean;
  41929. readonly samplingMode: number;
  41930. 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);
  41931. /**
  41932. * Update the url (and optional buffer) of this texture if url was null during construction.
  41933. * @param url the url of the texture
  41934. * @param buffer the buffer of the texture (defaults to null)
  41935. */
  41936. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>): void;
  41937. delayLoad(): void;
  41938. /**
  41939. * Default is Trilinear mode.
  41940. *
  41941. * | Value | Type | Description |
  41942. * | ----- | ------------------ | ----------- |
  41943. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  41944. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  41945. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  41946. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  41947. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  41948. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  41949. * | 7 | NEAREST_LINEAR | |
  41950. * | 8 | NEAREST_NEAREST | |
  41951. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  41952. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  41953. * | 11 | LINEAR_LINEAR | |
  41954. * | 12 | LINEAR_NEAREST | |
  41955. *
  41956. * > _mag_: magnification filter (close to the viewer)
  41957. * > _min_: minification filter (far from the viewer)
  41958. * > _mip_: filter used between mip map levels
  41959. *
  41960. */
  41961. updateSamplingMode(samplingMode: number): void;
  41962. private _prepareRowForTextureGeneration;
  41963. getTextureMatrix(): Matrix;
  41964. getReflectionTextureMatrix(): Matrix;
  41965. clone(): Texture;
  41966. readonly onLoadObservable: Observable<Texture>;
  41967. serialize(): any;
  41968. getClassName(): string;
  41969. dispose(): void;
  41970. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  41971. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  41972. 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;
  41973. }
  41974. }
  41975. declare module BABYLON {
  41976. /**
  41977. * Settings for finer control over video usage
  41978. */
  41979. interface VideoTextureSettings {
  41980. /**
  41981. * Applies `autoplay` to video, if specified
  41982. */
  41983. autoPlay?: boolean;
  41984. /**
  41985. * Applies `loop` to video, if specified
  41986. */
  41987. loop?: boolean;
  41988. /**
  41989. * Automatically updates internal texture from video at every frame in the render loop
  41990. */
  41991. autoUpdateTexture: boolean;
  41992. /**
  41993. * Image src displayed during the video loading or until the user interacts with the video.
  41994. */
  41995. poster?: string;
  41996. }
  41997. class VideoTexture extends Texture {
  41998. /**
  41999. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  42000. */
  42001. readonly autoUpdateTexture: boolean;
  42002. /**
  42003. * The video instance used by the texture internally
  42004. */
  42005. readonly video: HTMLVideoElement;
  42006. private _onUserActionRequestedObservable;
  42007. readonly onUserActionRequestedObservable: Observable<Texture>;
  42008. private _generateMipMaps;
  42009. private _engine;
  42010. private _stillImageCaptured;
  42011. private _poster;
  42012. /**
  42013. * Creates a video texture.
  42014. * Sample : https://doc.babylonjs.com/how_to/video_texture
  42015. * @param {string | null} name optional name, will detect from video source, if not defined
  42016. * @param {(string | string[] | HTMLVideoElement)} src can be used to provide an url, array of urls or an already setup HTML video element.
  42017. * @param {BABYLON.Scene} scene is obviously the current scene.
  42018. * @param {boolean} generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  42019. * @param {boolean} invertY is false by default but can be used to invert video on Y axis
  42020. * @param {number} samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  42021. * @param {VideoTextureSettings} [settings] allows finer control over video usage
  42022. */
  42023. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  42024. private _getName;
  42025. private _getVideo;
  42026. private _createInternalTexture;
  42027. private reset;
  42028. /**
  42029. * @hidden Internal method to initiate `update`.
  42030. */
  42031. /**
  42032. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  42033. */
  42034. update(): void;
  42035. /**
  42036. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  42037. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  42038. */
  42039. updateTexture(isVisible: boolean): void;
  42040. protected _updateInternalTexture: (e?: Event | undefined) => void;
  42041. /**
  42042. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  42043. * @param url New url.
  42044. */
  42045. updateURL(url: string): void;
  42046. dispose(): void;
  42047. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  42048. minWidth: number;
  42049. maxWidth: number;
  42050. minHeight: number;
  42051. maxHeight: number;
  42052. deviceId: string;
  42053. }): void;
  42054. }
  42055. }
  42056. declare var DracoDecoderModule: any;
  42057. declare var WebAssembly: any;
  42058. declare module BABYLON {
  42059. /**
  42060. * Configuration for Draco compression
  42061. */
  42062. interface IDracoCompressionConfiguration {
  42063. /**
  42064. * Configuration for the decoder.
  42065. */
  42066. decoder?: {
  42067. /**
  42068. * The url to the WebAssembly module.
  42069. */
  42070. wasmUrl?: string;
  42071. /**
  42072. * The url to the WebAssembly binary.
  42073. */
  42074. wasmBinaryUrl?: string;
  42075. /**
  42076. * The url to the fallback JavaScript module.
  42077. */
  42078. fallbackUrl?: string;
  42079. };
  42080. }
  42081. /**
  42082. * Draco compression (https://google.github.io/draco/)
  42083. *
  42084. * This class wraps the Draco module.
  42085. *
  42086. * **Encoder**
  42087. *
  42088. * The encoder is not currently implemented.
  42089. *
  42090. * **Decoder**
  42091. *
  42092. * 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.
  42093. *
  42094. * To update the configuration, use the following code:
  42095. * ```javascript
  42096. * BABYLON.DracoCompression.Configuration = {
  42097. * decoder: {
  42098. * wasmUrl: "<url to the WebAssembly library>",
  42099. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  42100. * fallbackUrl: "<url to the fallback JavaScript library>",
  42101. * }
  42102. * };
  42103. * ```
  42104. *
  42105. * 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.
  42106. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  42107. * Use `BABYLON.DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  42108. *
  42109. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  42110. * ```javascript
  42111. * var dracoCompression = new BABYLON.DracoCompression();
  42112. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  42113. * [BABYLON.VertexBuffer.PositionKind]: 0
  42114. * });
  42115. * ```
  42116. *
  42117. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  42118. */
  42119. class DracoCompression implements IDisposable {
  42120. private static _DecoderModulePromise;
  42121. /**
  42122. * The configuration. Defaults to the following urls:
  42123. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  42124. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  42125. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  42126. */
  42127. static Configuration: IDracoCompressionConfiguration;
  42128. /**
  42129. * Returns true if the decoder is available.
  42130. */
  42131. static readonly DecoderAvailable: boolean;
  42132. /**
  42133. * Constructor
  42134. */
  42135. constructor();
  42136. /**
  42137. * Stop all async operations and release resources.
  42138. */
  42139. dispose(): void;
  42140. /**
  42141. * Decode Draco compressed mesh data to vertex data.
  42142. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  42143. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  42144. * @returns A promise that resolves with the decoded vertex data
  42145. */
  42146. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes: {
  42147. [kind: string]: number;
  42148. }): Promise<VertexData>;
  42149. private static _GetDecoderModule;
  42150. private static _LoadScriptAsync;
  42151. private static _LoadFileAsync;
  42152. }
  42153. }
  42154. declare module BABYLON {
  42155. /**
  42156. * Particle emitter emitting particles from the inside of a box.
  42157. * It emits the particles randomly between 2 given directions.
  42158. */
  42159. class BoxParticleEmitter implements IParticleEmitterType {
  42160. /**
  42161. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  42162. */
  42163. direction1: Vector3;
  42164. /**
  42165. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  42166. */
  42167. direction2: Vector3;
  42168. /**
  42169. * 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.
  42170. */
  42171. minEmitBox: Vector3;
  42172. /**
  42173. * 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.
  42174. */
  42175. maxEmitBox: Vector3;
  42176. /**
  42177. * Creates a new instance BoxParticleEmitter
  42178. */
  42179. constructor();
  42180. /**
  42181. * Called by the particle System when the direction is computed for the created particle.
  42182. * @param worldMatrix is the world matrix of the particle system
  42183. * @param directionToUpdate is the direction vector to update with the result
  42184. * @param particle is the particle we are computed the direction for
  42185. */
  42186. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  42187. /**
  42188. * Called by the particle System when the position is computed for the created particle.
  42189. * @param worldMatrix is the world matrix of the particle system
  42190. * @param positionToUpdate is the position vector to update with the result
  42191. * @param particle is the particle we are computed the position for
  42192. */
  42193. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  42194. /**
  42195. * Clones the current emitter and returns a copy of it
  42196. * @returns the new emitter
  42197. */
  42198. clone(): BoxParticleEmitter;
  42199. /**
  42200. * Called by the GPUParticleSystem to setup the update shader
  42201. * @param effect defines the update shader
  42202. */
  42203. applyToShader(effect: Effect): void;
  42204. /**
  42205. * Returns a string to use to update the GPU particles update shader
  42206. * @returns a string containng the defines string
  42207. */
  42208. getEffectDefines(): string;
  42209. /**
  42210. * Returns the string "BoxParticleEmitter"
  42211. * @returns a string containing the class name
  42212. */
  42213. getClassName(): string;
  42214. /**
  42215. * Serializes the particle system to a JSON object.
  42216. * @returns the JSON object
  42217. */
  42218. serialize(): any;
  42219. /**
  42220. * Parse properties from a JSON object
  42221. * @param serializationObject defines the JSON object
  42222. */
  42223. parse(serializationObject: any): void;
  42224. }
  42225. }
  42226. declare module BABYLON {
  42227. /**
  42228. * Particle emitter emitting particles from the inside of a cone.
  42229. * It emits the particles alongside the cone volume from the base to the particle.
  42230. * The emission direction might be randomized.
  42231. */
  42232. class ConeParticleEmitter implements IParticleEmitterType {
  42233. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  42234. directionRandomizer: number;
  42235. private _radius;
  42236. private _angle;
  42237. private _height;
  42238. /**
  42239. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  42240. */
  42241. radiusRange: number;
  42242. /**
  42243. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  42244. */
  42245. heightRange: number;
  42246. /**
  42247. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  42248. */
  42249. emitFromSpawnPointOnly: boolean;
  42250. /**
  42251. * Gets or sets the radius of the emission cone
  42252. */
  42253. radius: number;
  42254. /**
  42255. * Gets or sets the angle of the emission cone
  42256. */
  42257. angle: number;
  42258. private _buildHeight;
  42259. /**
  42260. * Creates a new instance ConeParticleEmitter
  42261. * @param radius the radius of the emission cone (1 by default)
  42262. * @param angles the cone base angle (PI by default)
  42263. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  42264. */
  42265. constructor(radius?: number, angle?: number,
  42266. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  42267. directionRandomizer?: number);
  42268. /**
  42269. * Called by the particle System when the direction is computed for the created particle.
  42270. * @param worldMatrix is the world matrix of the particle system
  42271. * @param directionToUpdate is the direction vector to update with the result
  42272. * @param particle is the particle we are computed the direction for
  42273. */
  42274. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  42275. /**
  42276. * Called by the particle System when the position is computed for the created particle.
  42277. * @param worldMatrix is the world matrix of the particle system
  42278. * @param positionToUpdate is the position vector to update with the result
  42279. * @param particle is the particle we are computed the position for
  42280. */
  42281. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  42282. /**
  42283. * Clones the current emitter and returns a copy of it
  42284. * @returns the new emitter
  42285. */
  42286. clone(): ConeParticleEmitter;
  42287. /**
  42288. * Called by the GPUParticleSystem to setup the update shader
  42289. * @param effect defines the update shader
  42290. */
  42291. applyToShader(effect: Effect): void;
  42292. /**
  42293. * Returns a string to use to update the GPU particles update shader
  42294. * @returns a string containng the defines string
  42295. */
  42296. getEffectDefines(): string;
  42297. /**
  42298. * Returns the string "ConeParticleEmitter"
  42299. * @returns a string containing the class name
  42300. */
  42301. getClassName(): string;
  42302. /**
  42303. * Serializes the particle system to a JSON object.
  42304. * @returns the JSON object
  42305. */
  42306. serialize(): any;
  42307. /**
  42308. * Parse properties from a JSON object
  42309. * @param serializationObject defines the JSON object
  42310. */
  42311. parse(serializationObject: any): void;
  42312. }
  42313. }
  42314. declare module BABYLON {
  42315. /**
  42316. * Particle emitter emitting particles from the inside of a cylinder.
  42317. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  42318. */
  42319. class CylinderParticleEmitter implements IParticleEmitterType {
  42320. /**
  42321. * The radius of the emission cylinder.
  42322. */
  42323. radius: number;
  42324. /**
  42325. * The height of the emission cylinder.
  42326. */
  42327. height: number;
  42328. /**
  42329. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  42330. */
  42331. radiusRange: number;
  42332. /**
  42333. * How much to randomize the particle direction [0-1].
  42334. */
  42335. directionRandomizer: number;
  42336. /**
  42337. * Creates a new instance CylinderParticleEmitter
  42338. * @param radius the radius of the emission cylinder (1 by default)
  42339. * @param height the height of the emission cylinder (1 by default)
  42340. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  42341. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  42342. */
  42343. constructor(
  42344. /**
  42345. * The radius of the emission cylinder.
  42346. */
  42347. radius?: number,
  42348. /**
  42349. * The height of the emission cylinder.
  42350. */
  42351. height?: number,
  42352. /**
  42353. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  42354. */
  42355. radiusRange?: number,
  42356. /**
  42357. * How much to randomize the particle direction [0-1].
  42358. */
  42359. directionRandomizer?: number);
  42360. /**
  42361. * Called by the particle System when the direction is computed for the created particle.
  42362. * @param worldMatrix is the world matrix of the particle system
  42363. * @param directionToUpdate is the direction vector to update with the result
  42364. * @param particle is the particle we are computed the direction for
  42365. */
  42366. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  42367. /**
  42368. * Called by the particle System when the position is computed for the created particle.
  42369. * @param worldMatrix is the world matrix of the particle system
  42370. * @param positionToUpdate is the position vector to update with the result
  42371. * @param particle is the particle we are computed the position for
  42372. */
  42373. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  42374. /**
  42375. * Clones the current emitter and returns a copy of it
  42376. * @returns the new emitter
  42377. */
  42378. clone(): CylinderParticleEmitter;
  42379. /**
  42380. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  42381. * @param effect defines the update shader
  42382. */
  42383. applyToShader(effect: Effect): void;
  42384. /**
  42385. * Returns a string to use to update the GPU particles update shader
  42386. * @returns a string containng the defines string
  42387. */
  42388. getEffectDefines(): string;
  42389. /**
  42390. * Returns the string "CylinderParticleEmitter"
  42391. * @returns a string containing the class name
  42392. */
  42393. getClassName(): string;
  42394. /**
  42395. * Serializes the particle system to a JSON object.
  42396. * @returns the JSON object
  42397. */
  42398. serialize(): any;
  42399. /**
  42400. * Parse properties from a JSON object
  42401. * @param serializationObject defines the JSON object
  42402. */
  42403. parse(serializationObject: any): void;
  42404. }
  42405. /**
  42406. * Particle emitter emitting particles from the inside of a cylinder.
  42407. * It emits the particles randomly between two vectors.
  42408. */
  42409. class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  42410. /**
  42411. * The min limit of the emission direction.
  42412. */
  42413. direction1: Vector3;
  42414. /**
  42415. * The max limit of the emission direction.
  42416. */
  42417. direction2: Vector3;
  42418. /**
  42419. * Creates a new instance CylinderDirectedParticleEmitter
  42420. * @param radius the radius of the emission cylinder (1 by default)
  42421. * @param height the height of the emission cylinder (1 by default)
  42422. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  42423. * @param direction1 the min limit of the emission direction (up vector by default)
  42424. * @param direction2 the max limit of the emission direction (up vector by default)
  42425. */
  42426. constructor(radius?: number, height?: number, radiusRange?: number,
  42427. /**
  42428. * The min limit of the emission direction.
  42429. */
  42430. direction1?: Vector3,
  42431. /**
  42432. * The max limit of the emission direction.
  42433. */
  42434. direction2?: Vector3);
  42435. /**
  42436. * Called by the particle System when the direction is computed for the created particle.
  42437. * @param worldMatrix is the world matrix of the particle system
  42438. * @param directionToUpdate is the direction vector to update with the result
  42439. * @param particle is the particle we are computed the direction for
  42440. */
  42441. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  42442. /**
  42443. * Clones the current emitter and returns a copy of it
  42444. * @returns the new emitter
  42445. */
  42446. clone(): CylinderDirectedParticleEmitter;
  42447. /**
  42448. * Called by the GPUParticleSystem to setup the update shader
  42449. * @param effect defines the update shader
  42450. */
  42451. applyToShader(effect: Effect): void;
  42452. /**
  42453. * Returns a string to use to update the GPU particles update shader
  42454. * @returns a string containng the defines string
  42455. */
  42456. getEffectDefines(): string;
  42457. /**
  42458. * Returns the string "CylinderDirectedParticleEmitter"
  42459. * @returns a string containing the class name
  42460. */
  42461. getClassName(): string;
  42462. /**
  42463. * Serializes the particle system to a JSON object.
  42464. * @returns the JSON object
  42465. */
  42466. serialize(): any;
  42467. /**
  42468. * Parse properties from a JSON object
  42469. * @param serializationObject defines the JSON object
  42470. */
  42471. parse(serializationObject: any): void;
  42472. }
  42473. }
  42474. declare module BABYLON {
  42475. /**
  42476. * Particle emitter emitting particles from the inside of a hemisphere.
  42477. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  42478. */
  42479. class HemisphericParticleEmitter implements IParticleEmitterType {
  42480. /**
  42481. * The radius of the emission hemisphere.
  42482. */
  42483. radius: number;
  42484. /**
  42485. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  42486. */
  42487. radiusRange: number;
  42488. /**
  42489. * How much to randomize the particle direction [0-1].
  42490. */
  42491. directionRandomizer: number;
  42492. /**
  42493. * Creates a new instance HemisphericParticleEmitter
  42494. * @param radius the radius of the emission hemisphere (1 by default)
  42495. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  42496. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  42497. */
  42498. constructor(
  42499. /**
  42500. * The radius of the emission hemisphere.
  42501. */
  42502. radius?: number,
  42503. /**
  42504. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  42505. */
  42506. radiusRange?: number,
  42507. /**
  42508. * How much to randomize the particle direction [0-1].
  42509. */
  42510. directionRandomizer?: number);
  42511. /**
  42512. * Called by the particle System when the direction is computed for the created particle.
  42513. * @param worldMatrix is the world matrix of the particle system
  42514. * @param directionToUpdate is the direction vector to update with the result
  42515. * @param particle is the particle we are computed the direction for
  42516. */
  42517. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  42518. /**
  42519. * Called by the particle System when the position is computed for the created particle.
  42520. * @param worldMatrix is the world matrix of the particle system
  42521. * @param positionToUpdate is the position vector to update with the result
  42522. * @param particle is the particle we are computed the position for
  42523. */
  42524. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  42525. /**
  42526. * Clones the current emitter and returns a copy of it
  42527. * @returns the new emitter
  42528. */
  42529. clone(): HemisphericParticleEmitter;
  42530. /**
  42531. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  42532. * @param effect defines the update shader
  42533. */
  42534. applyToShader(effect: Effect): void;
  42535. /**
  42536. * Returns a string to use to update the GPU particles update shader
  42537. * @returns a string containng the defines string
  42538. */
  42539. getEffectDefines(): string;
  42540. /**
  42541. * Returns the string "HemisphericParticleEmitter"
  42542. * @returns a string containing the class name
  42543. */
  42544. getClassName(): string;
  42545. /**
  42546. * Serializes the particle system to a JSON object.
  42547. * @returns the JSON object
  42548. */
  42549. serialize(): any;
  42550. /**
  42551. * Parse properties from a JSON object
  42552. * @param serializationObject defines the JSON object
  42553. */
  42554. parse(serializationObject: any): void;
  42555. }
  42556. }
  42557. declare module BABYLON {
  42558. /**
  42559. * Particle emitter represents a volume emitting particles.
  42560. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  42561. */
  42562. interface IParticleEmitterType {
  42563. /**
  42564. * Called by the particle System when the direction is computed for the created particle.
  42565. * @param worldMatrix is the world matrix of the particle system
  42566. * @param directionToUpdate is the direction vector to update with the result
  42567. * @param particle is the particle we are computed the direction for
  42568. */
  42569. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  42570. /**
  42571. * Called by the particle System when the position is computed for the created particle.
  42572. * @param worldMatrix is the world matrix of the particle system
  42573. * @param positionToUpdate is the position vector to update with the result
  42574. * @param particle is the particle we are computed the position for
  42575. */
  42576. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  42577. /**
  42578. * Clones the current emitter and returns a copy of it
  42579. * @returns the new emitter
  42580. */
  42581. clone(): IParticleEmitterType;
  42582. /**
  42583. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  42584. * @param effect defines the update shader
  42585. */
  42586. applyToShader(effect: Effect): void;
  42587. /**
  42588. * Returns a string to use to update the GPU particles update shader
  42589. * @returns the effect defines string
  42590. */
  42591. getEffectDefines(): string;
  42592. /**
  42593. * Returns a string representing the class name
  42594. * @returns a string containing the class name
  42595. */
  42596. getClassName(): string;
  42597. /**
  42598. * Serializes the particle system to a JSON object.
  42599. * @returns the JSON object
  42600. */
  42601. serialize(): any;
  42602. /**
  42603. * Parse properties from a JSON object
  42604. * @param serializationObject defines the JSON object
  42605. */
  42606. parse(serializationObject: any): void;
  42607. }
  42608. }
  42609. declare module BABYLON {
  42610. /**
  42611. * Particle emitter emitting particles from a point.
  42612. * It emits the particles randomly between 2 given directions.
  42613. */
  42614. class PointParticleEmitter implements IParticleEmitterType {
  42615. /**
  42616. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  42617. */
  42618. direction1: Vector3;
  42619. /**
  42620. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  42621. */
  42622. direction2: Vector3;
  42623. /**
  42624. * Creates a new instance PointParticleEmitter
  42625. */
  42626. constructor();
  42627. /**
  42628. * Called by the particle System when the direction is computed for the created particle.
  42629. * @param worldMatrix is the world matrix of the particle system
  42630. * @param directionToUpdate is the direction vector to update with the result
  42631. * @param particle is the particle we are computed the direction for
  42632. */
  42633. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  42634. /**
  42635. * Called by the particle System when the position is computed for the created particle.
  42636. * @param worldMatrix is the world matrix of the particle system
  42637. * @param positionToUpdate is the position vector to update with the result
  42638. * @param particle is the particle we are computed the position for
  42639. */
  42640. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  42641. /**
  42642. * Clones the current emitter and returns a copy of it
  42643. * @returns the new emitter
  42644. */
  42645. clone(): PointParticleEmitter;
  42646. /**
  42647. * Called by the GPUParticleSystem to setup the update shader
  42648. * @param effect defines the update shader
  42649. */
  42650. applyToShader(effect: Effect): void;
  42651. /**
  42652. * Returns a string to use to update the GPU particles update shader
  42653. * @returns a string containng the defines string
  42654. */
  42655. getEffectDefines(): string;
  42656. /**
  42657. * Returns the string "PointParticleEmitter"
  42658. * @returns a string containing the class name
  42659. */
  42660. getClassName(): string;
  42661. /**
  42662. * Serializes the particle system to a JSON object.
  42663. * @returns the JSON object
  42664. */
  42665. serialize(): any;
  42666. /**
  42667. * Parse properties from a JSON object
  42668. * @param serializationObject defines the JSON object
  42669. */
  42670. parse(serializationObject: any): void;
  42671. }
  42672. }
  42673. declare module BABYLON {
  42674. /**
  42675. * Particle emitter emitting particles from the inside of a sphere.
  42676. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  42677. */
  42678. class SphereParticleEmitter implements IParticleEmitterType {
  42679. /**
  42680. * The radius of the emission sphere.
  42681. */
  42682. radius: number;
  42683. /**
  42684. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  42685. */
  42686. radiusRange: number;
  42687. /**
  42688. * How much to randomize the particle direction [0-1].
  42689. */
  42690. directionRandomizer: number;
  42691. /**
  42692. * Creates a new instance SphereParticleEmitter
  42693. * @param radius the radius of the emission sphere (1 by default)
  42694. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  42695. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  42696. */
  42697. constructor(
  42698. /**
  42699. * The radius of the emission sphere.
  42700. */
  42701. radius?: number,
  42702. /**
  42703. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  42704. */
  42705. radiusRange?: number,
  42706. /**
  42707. * How much to randomize the particle direction [0-1].
  42708. */
  42709. directionRandomizer?: number);
  42710. /**
  42711. * Called by the particle System when the direction is computed for the created particle.
  42712. * @param worldMatrix is the world matrix of the particle system
  42713. * @param directionToUpdate is the direction vector to update with the result
  42714. * @param particle is the particle we are computed the direction for
  42715. */
  42716. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  42717. /**
  42718. * Called by the particle System when the position is computed for the created particle.
  42719. * @param worldMatrix is the world matrix of the particle system
  42720. * @param positionToUpdate is the position vector to update with the result
  42721. * @param particle is the particle we are computed the position for
  42722. */
  42723. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  42724. /**
  42725. * Clones the current emitter and returns a copy of it
  42726. * @returns the new emitter
  42727. */
  42728. clone(): SphereParticleEmitter;
  42729. /**
  42730. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  42731. * @param effect defines the update shader
  42732. */
  42733. applyToShader(effect: Effect): void;
  42734. /**
  42735. * Returns a string to use to update the GPU particles update shader
  42736. * @returns a string containng the defines string
  42737. */
  42738. getEffectDefines(): string;
  42739. /**
  42740. * Returns the string "SphereParticleEmitter"
  42741. * @returns a string containing the class name
  42742. */
  42743. getClassName(): string;
  42744. /**
  42745. * Serializes the particle system to a JSON object.
  42746. * @returns the JSON object
  42747. */
  42748. serialize(): any;
  42749. /**
  42750. * Parse properties from a JSON object
  42751. * @param serializationObject defines the JSON object
  42752. */
  42753. parse(serializationObject: any): void;
  42754. }
  42755. /**
  42756. * Particle emitter emitting particles from the inside of a sphere.
  42757. * It emits the particles randomly between two vectors.
  42758. */
  42759. class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  42760. /**
  42761. * The min limit of the emission direction.
  42762. */
  42763. direction1: Vector3;
  42764. /**
  42765. * The max limit of the emission direction.
  42766. */
  42767. direction2: Vector3;
  42768. /**
  42769. * Creates a new instance SphereDirectedParticleEmitter
  42770. * @param radius the radius of the emission sphere (1 by default)
  42771. * @param direction1 the min limit of the emission direction (up vector by default)
  42772. * @param direction2 the max limit of the emission direction (up vector by default)
  42773. */
  42774. constructor(radius?: number,
  42775. /**
  42776. * The min limit of the emission direction.
  42777. */
  42778. direction1?: Vector3,
  42779. /**
  42780. * The max limit of the emission direction.
  42781. */
  42782. direction2?: Vector3);
  42783. /**
  42784. * Called by the particle System when the direction is computed for the created particle.
  42785. * @param worldMatrix is the world matrix of the particle system
  42786. * @param directionToUpdate is the direction vector to update with the result
  42787. * @param particle is the particle we are computed the direction for
  42788. */
  42789. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  42790. /**
  42791. * Clones the current emitter and returns a copy of it
  42792. * @returns the new emitter
  42793. */
  42794. clone(): SphereDirectedParticleEmitter;
  42795. /**
  42796. * Called by the GPUParticleSystem to setup the update shader
  42797. * @param effect defines the update shader
  42798. */
  42799. applyToShader(effect: Effect): void;
  42800. /**
  42801. * Returns a string to use to update the GPU particles update shader
  42802. * @returns a string containng the defines string
  42803. */
  42804. getEffectDefines(): string;
  42805. /**
  42806. * Returns the string "SphereDirectedParticleEmitter"
  42807. * @returns a string containing the class name
  42808. */
  42809. getClassName(): string;
  42810. /**
  42811. * Serializes the particle system to a JSON object.
  42812. * @returns the JSON object
  42813. */
  42814. serialize(): any;
  42815. /**
  42816. * Parse properties from a JSON object
  42817. * @param serializationObject defines the JSON object
  42818. */
  42819. parse(serializationObject: any): void;
  42820. }
  42821. }
  42822. declare module BABYLON {
  42823. /** @hidden */
  42824. class CannonJSPlugin implements IPhysicsEnginePlugin {
  42825. private _useDeltaForWorldStep;
  42826. world: any;
  42827. name: string;
  42828. private _physicsMaterials;
  42829. private _fixedTimeStep;
  42830. BJSCANNON: any;
  42831. constructor(_useDeltaForWorldStep?: boolean, iterations?: number);
  42832. setGravity(gravity: Vector3): void;
  42833. setTimeStep(timeStep: number): void;
  42834. getTimeStep(): number;
  42835. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  42836. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  42837. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  42838. generatePhysicsBody(impostor: PhysicsImpostor): void;
  42839. private _processChildMeshes;
  42840. removePhysicsBody(impostor: PhysicsImpostor): void;
  42841. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  42842. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  42843. private _addMaterial;
  42844. private _checkWithEpsilon;
  42845. private _createShape;
  42846. private _createHeightmap;
  42847. private _minus90X;
  42848. private _plus90X;
  42849. private _tmpPosition;
  42850. private _tmpDeltaPosition;
  42851. private _tmpUnityRotation;
  42852. private _updatePhysicsBodyTransformation;
  42853. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  42854. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  42855. isSupported(): boolean;
  42856. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  42857. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  42858. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  42859. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  42860. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  42861. getBodyMass(impostor: PhysicsImpostor): number;
  42862. getBodyFriction(impostor: PhysicsImpostor): number;
  42863. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  42864. getBodyRestitution(impostor: PhysicsImpostor): number;
  42865. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  42866. sleepBody(impostor: PhysicsImpostor): void;
  42867. wakeUpBody(impostor: PhysicsImpostor): void;
  42868. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  42869. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  42870. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  42871. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  42872. getRadius(impostor: PhysicsImpostor): number;
  42873. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  42874. dispose(): void;
  42875. private _extendNamespace;
  42876. }
  42877. }
  42878. declare module BABYLON {
  42879. /** @hidden */
  42880. class OimoJSPlugin implements IPhysicsEnginePlugin {
  42881. world: any;
  42882. name: string;
  42883. BJSOIMO: any;
  42884. constructor(iterations?: number);
  42885. setGravity(gravity: Vector3): void;
  42886. setTimeStep(timeStep: number): void;
  42887. getTimeStep(): number;
  42888. private _tmpImpostorsArray;
  42889. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  42890. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  42891. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  42892. generatePhysicsBody(impostor: PhysicsImpostor): void;
  42893. private _tmpPositionVector;
  42894. removePhysicsBody(impostor: PhysicsImpostor): void;
  42895. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  42896. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  42897. isSupported(): boolean;
  42898. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  42899. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  42900. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  42901. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  42902. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  42903. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  42904. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  42905. getBodyMass(impostor: PhysicsImpostor): number;
  42906. getBodyFriction(impostor: PhysicsImpostor): number;
  42907. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  42908. getBodyRestitution(impostor: PhysicsImpostor): number;
  42909. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  42910. sleepBody(impostor: PhysicsImpostor): void;
  42911. wakeUpBody(impostor: PhysicsImpostor): void;
  42912. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  42913. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  42914. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  42915. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  42916. getRadius(impostor: PhysicsImpostor): number;
  42917. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  42918. dispose(): void;
  42919. }
  42920. }
  42921. declare module BABYLON {
  42922. /**
  42923. * This represents a set of one or more post processes in Babylon.
  42924. * A post process can be used to apply a shader to a texture after it is rendered.
  42925. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  42926. */
  42927. class PostProcessRenderEffect {
  42928. private _postProcesses;
  42929. private _getPostProcesses;
  42930. private _singleInstance;
  42931. private _cameras;
  42932. private _indicesForCamera;
  42933. /**
  42934. * Name of the effect
  42935. * @hidden
  42936. */
  42937. /**
  42938. * Instantiates a post process render effect.
  42939. * A post process can be used to apply a shader to a texture after it is rendered.
  42940. * @param engine The engine the effect is tied to
  42941. * @param name The name of the effect
  42942. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  42943. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  42944. */
  42945. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  42946. /**
  42947. * Checks if all the post processes in the effect are supported.
  42948. */
  42949. readonly isSupported: boolean;
  42950. /**
  42951. * Updates the current state of the effect
  42952. * @hidden
  42953. */
  42954. /**
  42955. * Attaches the effect on cameras
  42956. * @param cameras The camera to attach to.
  42957. * @hidden
  42958. */
  42959. /**
  42960. * Attaches the effect on cameras
  42961. * @param cameras The camera to attach to.
  42962. * @hidden
  42963. */
  42964. /**
  42965. * Detatches the effect on cameras
  42966. * @param cameras The camera to detatch from.
  42967. * @hidden
  42968. */
  42969. /**
  42970. * Detatches the effect on cameras
  42971. * @param cameras The camera to detatch from.
  42972. * @hidden
  42973. */
  42974. /**
  42975. * Enables the effect on given cameras
  42976. * @param cameras The camera to enable.
  42977. * @hidden
  42978. */
  42979. /**
  42980. * Enables the effect on given cameras
  42981. * @param cameras The camera to enable.
  42982. * @hidden
  42983. */
  42984. /**
  42985. * Disables the effect on the given cameras
  42986. * @param cameras The camera to disable.
  42987. * @hidden
  42988. */
  42989. /**
  42990. * Disables the effect on the given cameras
  42991. * @param cameras The camera to disable.
  42992. * @hidden
  42993. */
  42994. /**
  42995. * Gets a list of the post processes contained in the effect.
  42996. * @param camera The camera to get the post processes on.
  42997. * @returns The list of the post processes in the effect.
  42998. */
  42999. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  43000. }
  43001. }
  43002. declare module BABYLON {
  43003. class PostProcessRenderPipeline {
  43004. private engine;
  43005. private _renderEffects;
  43006. private _renderEffectsForIsolatedPass;
  43007. protected _cameras: Camera[];
  43008. /** @hidden */
  43009. constructor(engine: Engine, name: string);
  43010. getClassName(): string;
  43011. readonly isSupported: boolean;
  43012. addEffect(renderEffect: PostProcessRenderEffect): void;
  43013. /** @hidden */
  43014. /** @hidden */
  43015. /** @hidden */
  43016. /** @hidden */
  43017. /** @hidden */
  43018. /** @hidden */
  43019. /** @hidden */
  43020. /** @hidden */
  43021. /** @hidden */
  43022. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  43023. dispose(): void;
  43024. }
  43025. }
  43026. declare module BABYLON {
  43027. class PostProcessRenderPipelineManager {
  43028. private _renderPipelines;
  43029. constructor();
  43030. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  43031. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: Camera, unique?: boolean): void;
  43032. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: Camera[], unique?: boolean): void;
  43033. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: Camera): void;
  43034. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: Camera[]): void;
  43035. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera): void;
  43036. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera[]): void;
  43037. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera): void;
  43038. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera[]): void;
  43039. update(): void;
  43040. /** @hidden */
  43041. dispose(): void;
  43042. }
  43043. }
  43044. declare module BABYLON {
  43045. interface Scene {
  43046. /** @hidden (Backing field) */
  43047. /**
  43048. * Gets the postprocess render pipeline manager
  43049. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  43050. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  43051. */
  43052. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  43053. }
  43054. /**
  43055. * Defines the Render Pipeline scene component responsible to rendering pipelines
  43056. */
  43057. class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  43058. /**
  43059. * The component name helpfull to identify the component in the list of scene components.
  43060. */
  43061. readonly name: string;
  43062. /**
  43063. * The scene the component belongs to.
  43064. */
  43065. scene: Scene;
  43066. /**
  43067. * Creates a new instance of the component for the given scene
  43068. * @param scene Defines the scene to register the component in
  43069. */
  43070. constructor(scene: Scene);
  43071. /**
  43072. * Registers the component in a given scene
  43073. */
  43074. register(): void;
  43075. /**
  43076. * Rebuilds the elements related to this component in case of
  43077. * context lost for instance.
  43078. */
  43079. rebuild(): void;
  43080. /**
  43081. * Disposes the component and the associated ressources
  43082. */
  43083. dispose(): void;
  43084. private _gatherRenderTargets;
  43085. }
  43086. }
  43087. declare module BABYLON {
  43088. /**
  43089. * Helper class dealing with the extraction of spherical polynomial dataArray
  43090. * from a cube map.
  43091. */
  43092. class CubeMapToSphericalPolynomialTools {
  43093. private static FileFaces;
  43094. /**
  43095. * Converts a texture to the according Spherical Polynomial data.
  43096. * This extracts the first 3 orders only as they are the only one used in the lighting.
  43097. *
  43098. * @param texture The texture to extract the information from.
  43099. * @return The Spherical Polynomial data.
  43100. */
  43101. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  43102. /**
  43103. * Converts a cubemap to the according Spherical Polynomial data.
  43104. * This extracts the first 3 orders only as they are the only one used in the lighting.
  43105. *
  43106. * @param cubeInfo The Cube map to extract the information from.
  43107. * @return The Spherical Polynomial data.
  43108. */
  43109. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  43110. }
  43111. }
  43112. declare module BABYLON {
  43113. /**
  43114. * Header information of HDR texture files.
  43115. */
  43116. interface HDRInfo {
  43117. /**
  43118. * The height of the texture in pixels.
  43119. */
  43120. height: number;
  43121. /**
  43122. * The width of the texture in pixels.
  43123. */
  43124. width: number;
  43125. /**
  43126. * The index of the beginning of the data in the binary file.
  43127. */
  43128. dataPosition: number;
  43129. }
  43130. /**
  43131. * This groups tools to convert HDR texture to native colors array.
  43132. */
  43133. class HDRTools {
  43134. private static Ldexp;
  43135. private static Rgbe2float;
  43136. private static readStringLine;
  43137. /**
  43138. * Reads header information from an RGBE texture stored in a native array.
  43139. * More information on this format are available here:
  43140. * https://en.wikipedia.org/wiki/RGBE_image_format
  43141. *
  43142. * @param uint8array The binary file stored in native array.
  43143. * @return The header information.
  43144. */
  43145. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  43146. /**
  43147. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  43148. * This RGBE texture needs to store the information as a panorama.
  43149. *
  43150. * More information on this format are available here:
  43151. * https://en.wikipedia.org/wiki/RGBE_image_format
  43152. *
  43153. * @param buffer The binary file stored in an array buffer.
  43154. * @param size The expected size of the extracted cubemap.
  43155. * @return The Cube Map information.
  43156. */
  43157. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  43158. /**
  43159. * Returns the pixels data extracted from an RGBE texture.
  43160. * This pixels will be stored left to right up to down in the R G B order in one array.
  43161. *
  43162. * More information on this format are available here:
  43163. * https://en.wikipedia.org/wiki/RGBE_image_format
  43164. *
  43165. * @param uint8array The binary file stored in an array buffer.
  43166. * @param hdrInfo The header information of the file.
  43167. * @return The pixels data in RGB right to left up to down order.
  43168. */
  43169. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  43170. private static RGBE_ReadPixels_RLE;
  43171. }
  43172. }
  43173. declare module BABYLON {
  43174. /**
  43175. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  43176. */
  43177. interface CubeMapInfo {
  43178. /**
  43179. * The pixel array for the front face.
  43180. * This is stored in format, left to right, up to down format.
  43181. */
  43182. front: Nullable<ArrayBufferView>;
  43183. /**
  43184. * The pixel array for the back face.
  43185. * This is stored in format, left to right, up to down format.
  43186. */
  43187. back: Nullable<ArrayBufferView>;
  43188. /**
  43189. * The pixel array for the left face.
  43190. * This is stored in format, left to right, up to down format.
  43191. */
  43192. left: Nullable<ArrayBufferView>;
  43193. /**
  43194. * The pixel array for the right face.
  43195. * This is stored in format, left to right, up to down format.
  43196. */
  43197. right: Nullable<ArrayBufferView>;
  43198. /**
  43199. * The pixel array for the up face.
  43200. * This is stored in format, left to right, up to down format.
  43201. */
  43202. up: Nullable<ArrayBufferView>;
  43203. /**
  43204. * The pixel array for the down face.
  43205. * This is stored in format, left to right, up to down format.
  43206. */
  43207. down: Nullable<ArrayBufferView>;
  43208. /**
  43209. * The size of the cubemap stored.
  43210. *
  43211. * Each faces will be size * size pixels.
  43212. */
  43213. size: number;
  43214. /**
  43215. * The format of the texture.
  43216. *
  43217. * RGBA, RGB.
  43218. */
  43219. format: number;
  43220. /**
  43221. * The type of the texture data.
  43222. *
  43223. * UNSIGNED_INT, FLOAT.
  43224. */
  43225. type: number;
  43226. /**
  43227. * Specifies whether the texture is in gamma space.
  43228. */
  43229. gammaSpace: boolean;
  43230. }
  43231. /**
  43232. * Helper class usefull to convert panorama picture to their cubemap representation in 6 faces.
  43233. */
  43234. class PanoramaToCubeMapTools {
  43235. private static FACE_FRONT;
  43236. private static FACE_BACK;
  43237. private static FACE_RIGHT;
  43238. private static FACE_LEFT;
  43239. private static FACE_DOWN;
  43240. private static FACE_UP;
  43241. /**
  43242. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  43243. *
  43244. * @param float32Array The source data.
  43245. * @param inputWidth The width of the input panorama.
  43246. * @param inputhHeight The height of the input panorama.
  43247. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  43248. * @return The cubemap data
  43249. */
  43250. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  43251. private static CreateCubemapTexture;
  43252. private static CalcProjectionSpherical;
  43253. }
  43254. }
  43255. declare module BABYLON {
  43256. }
  43257. declare module BABYLON {
  43258. }
  43259. declare module BABYLON {
  43260. }
  43261. declare module BABYLON {
  43262. }
  43263. declare module BABYLON {
  43264. class CustomProceduralTexture extends ProceduralTexture {
  43265. private _animate;
  43266. private _time;
  43267. private _config;
  43268. private _texturePath;
  43269. constructor(name: string, texturePath: any, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  43270. private loadJson;
  43271. isReady(): boolean;
  43272. render(useCameraPostProcess?: boolean): void;
  43273. updateTextures(): void;
  43274. updateShaderUniforms(): void;
  43275. animate: boolean;
  43276. }
  43277. }
  43278. declare module BABYLON {
  43279. /**
  43280. * Class used to generate noise procedural textures
  43281. */
  43282. class NoiseProceduralTexture extends ProceduralTexture {
  43283. private _time;
  43284. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  43285. brightness: number;
  43286. /** Defines the number of octaves to process */
  43287. octaves: number;
  43288. /** Defines the level of persistence (0.8 by default) */
  43289. persistence: number;
  43290. /** Gets or sets animation speed factor (default is 1) */
  43291. animationSpeedFactor: number;
  43292. /**
  43293. * Creates a new NoiseProceduralTexture
  43294. * @param name defines the name fo the texture
  43295. * @param size defines the size of the texture (default is 256)
  43296. * @param scene defines the hosting scene
  43297. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  43298. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  43299. */
  43300. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  43301. private _updateShaderUniforms;
  43302. protected _getDefines(): string;
  43303. /** Generate the current state of the procedural texture */
  43304. render(useCameraPostProcess?: boolean): void;
  43305. /**
  43306. * Serializes this noise procedural texture
  43307. * @returns a serialized noise procedural texture object
  43308. */
  43309. serialize(): any;
  43310. /**
  43311. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  43312. * @param parsedTexture defines parsed texture data
  43313. * @param scene defines the current scene
  43314. * @param rootUrl defines the root URL containing noise procedural texture information
  43315. * @returns a parsed NoiseProceduralTexture
  43316. */
  43317. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): NoiseProceduralTexture;
  43318. }
  43319. }
  43320. declare module BABYLON {
  43321. class ProceduralTexture extends Texture {
  43322. isCube: boolean;
  43323. private _size;
  43324. /** @hidden */
  43325. isEnabled: boolean;
  43326. private _currentRefreshId;
  43327. private _refreshRate;
  43328. /**
  43329. * Callback called when the texture is generated
  43330. */
  43331. onGenerated: () => void;
  43332. /**
  43333. * Event raised when the texture is generated
  43334. */
  43335. onGeneratedObservable: Observable<ProceduralTexture>;
  43336. private _vertexBuffers;
  43337. private _indexBuffer;
  43338. /** get the internal effect */
  43339. private _uniforms;
  43340. private _samplers;
  43341. private _fragment;
  43342. /** @hidden */
  43343. ;
  43344. private _floats;
  43345. private _ints;
  43346. private _floatsArrays;
  43347. private _colors3;
  43348. private _colors4;
  43349. private _vectors2;
  43350. private _vectors3;
  43351. private _matrices;
  43352. private _fallbackTexture;
  43353. private _fallbackTextureUsed;
  43354. private _engine;
  43355. private _cachedDefines;
  43356. private _contentUpdateId;
  43357. private _contentData;
  43358. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  43359. /**
  43360. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  43361. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  43362. */
  43363. getContent(): Nullable<ArrayBufferView>;
  43364. private _createIndexBuffer;
  43365. /** @hidden */
  43366. reset(): void;
  43367. protected _getDefines(): string;
  43368. isReady(): boolean;
  43369. resetRefreshCounter(): void;
  43370. setFragment(fragment: any): void;
  43371. refreshRate: number;
  43372. /** @hidden */
  43373. getRenderSize(): number;
  43374. resize(size: number, generateMipMaps: boolean): void;
  43375. private _checkUniform;
  43376. setTexture(name: string, texture: Texture): ProceduralTexture;
  43377. setFloat(name: string, value: number): ProceduralTexture;
  43378. /**
  43379. * Set the value of an uniform to an integer value
  43380. * @param name defines the name of the uniform
  43381. * @param value defines the value to set
  43382. * @returns the current procedural texture
  43383. */
  43384. setInt(name: string, value: number): ProceduralTexture;
  43385. setFloats(name: string, value: number[]): ProceduralTexture;
  43386. setColor3(name: string, value: Color3): ProceduralTexture;
  43387. setColor4(name: string, value: Color4): ProceduralTexture;
  43388. setVector2(name: string, value: Vector2): ProceduralTexture;
  43389. setVector3(name: string, value: Vector3): ProceduralTexture;
  43390. setMatrix(name: string, value: Matrix): ProceduralTexture;
  43391. render(useCameraPostProcess?: boolean): void;
  43392. clone(): ProceduralTexture;
  43393. dispose(): void;
  43394. }
  43395. }
  43396. declare module BABYLON {
  43397. interface AbstractScene {
  43398. /**
  43399. * The list of procedural textures added to the scene
  43400. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  43401. */
  43402. proceduralTextures: Array<ProceduralTexture>;
  43403. }
  43404. /**
  43405. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  43406. * in a given scene.
  43407. */
  43408. class ProceduralTextureSceneComponent implements ISceneComponent {
  43409. /**
  43410. * The component name helpfull to identify the component in the list of scene components.
  43411. */
  43412. readonly name: string;
  43413. /**
  43414. * The scene the component belongs to.
  43415. */
  43416. scene: Scene;
  43417. /**
  43418. * Creates a new instance of the component for the given scene
  43419. * @param scene Defines the scene to register the component in
  43420. */
  43421. constructor(scene: Scene);
  43422. /**
  43423. * Registers the component in a given scene
  43424. */
  43425. register(): void;
  43426. /**
  43427. * Rebuilds the elements related to this component in case of
  43428. * context lost for instance.
  43429. */
  43430. rebuild(): void;
  43431. /**
  43432. * Disposes the component and the associated ressources.
  43433. */
  43434. dispose(): void;
  43435. private _beforeClear;
  43436. }
  43437. }
  43438. declare module BABYLON {
  43439. /**
  43440. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  43441. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  43442. */
  43443. class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  43444. private _scene;
  43445. private _camerasToBeAttached;
  43446. /**
  43447. * ID of the sharpen post process,
  43448. */
  43449. private readonly SharpenPostProcessId;
  43450. /**
  43451. * ID of the image processing post process;
  43452. */
  43453. readonly ImageProcessingPostProcessId: string;
  43454. /**
  43455. * ID of the Fast Approximate Anti-Aliasing post process;
  43456. */
  43457. readonly FxaaPostProcessId: string;
  43458. /**
  43459. * ID of the chromatic aberration post process,
  43460. */
  43461. private readonly ChromaticAberrationPostProcessId;
  43462. /**
  43463. * ID of the grain post process
  43464. */
  43465. private readonly GrainPostProcessId;
  43466. /**
  43467. * Sharpen post process which will apply a sharpen convolution to enhance edges
  43468. */
  43469. sharpen: SharpenPostProcess;
  43470. private _sharpenEffect;
  43471. private bloom;
  43472. /**
  43473. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  43474. */
  43475. depthOfField: DepthOfFieldEffect;
  43476. /**
  43477. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  43478. */
  43479. fxaa: FxaaPostProcess;
  43480. /**
  43481. * Image post processing pass used to perform operations such as tone mapping or color grading.
  43482. */
  43483. imageProcessing: ImageProcessingPostProcess;
  43484. /**
  43485. * Chromatic aberration post process which will shift rgb colors in the image
  43486. */
  43487. chromaticAberration: ChromaticAberrationPostProcess;
  43488. private _chromaticAberrationEffect;
  43489. /**
  43490. * Grain post process which add noise to the image
  43491. */
  43492. grain: GrainPostProcess;
  43493. private _grainEffect;
  43494. /**
  43495. * Glow post process which adds a glow to emmisive areas of the image
  43496. */
  43497. private _glowLayer;
  43498. /**
  43499. * Animations which can be used to tweak settings over a period of time
  43500. */
  43501. animations: Animation[];
  43502. private _imageProcessingConfigurationObserver;
  43503. private _sharpenEnabled;
  43504. private _bloomEnabled;
  43505. private _depthOfFieldEnabled;
  43506. private _depthOfFieldBlurLevel;
  43507. private _fxaaEnabled;
  43508. private _imageProcessingEnabled;
  43509. private _defaultPipelineTextureType;
  43510. private _bloomScale;
  43511. private _chromaticAberrationEnabled;
  43512. private _grainEnabled;
  43513. private _buildAllowed;
  43514. /**
  43515. * Enable or disable the sharpen process from the pipeline
  43516. */
  43517. sharpenEnabled: boolean;
  43518. private _resizeObserver;
  43519. private _hardwareScaleLevel;
  43520. private _bloomKernel;
  43521. /**
  43522. * Specifies the size of the bloom blur kernel, relative to the final output size
  43523. */
  43524. bloomKernel: number;
  43525. /**
  43526. * Specifies the weight of the bloom in the final rendering
  43527. */
  43528. private _bloomWeight;
  43529. /**
  43530. * Specifies the luma threshold for the area that will be blurred by the bloom
  43531. */
  43532. private _bloomThreshold;
  43533. private _hdr;
  43534. /**
  43535. * The strength of the bloom.
  43536. */
  43537. bloomWeight: number;
  43538. /**
  43539. * The strength of the bloom.
  43540. */
  43541. bloomThreshold: number;
  43542. /**
  43543. * The scale of the bloom, lower value will provide better performance.
  43544. */
  43545. bloomScale: number;
  43546. /**
  43547. * Enable or disable the bloom from the pipeline
  43548. */
  43549. bloomEnabled: boolean;
  43550. private _rebuildBloom;
  43551. /**
  43552. * If the depth of field is enabled.
  43553. */
  43554. depthOfFieldEnabled: boolean;
  43555. /**
  43556. * Blur level of the depth of field effect. (Higher blur will effect performance)
  43557. */
  43558. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  43559. /**
  43560. * If the anti aliasing is enabled.
  43561. */
  43562. fxaaEnabled: boolean;
  43563. private _samples;
  43564. /**
  43565. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  43566. */
  43567. samples: number;
  43568. /**
  43569. * If image processing is enabled.
  43570. */
  43571. imageProcessingEnabled: boolean;
  43572. /**
  43573. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  43574. */
  43575. glowLayerEnabled: boolean;
  43576. /**
  43577. * Enable or disable the chromaticAberration process from the pipeline
  43578. */
  43579. chromaticAberrationEnabled: boolean;
  43580. /**
  43581. * Enable or disable the grain process from the pipeline
  43582. */
  43583. grainEnabled: boolean;
  43584. /**
  43585. * @constructor
  43586. * @param {string} name - The rendering pipeline name (default: "")
  43587. * @param {boolean} hdr - If high dynamic range textures should be used (default: true)
  43588. * @param {BABYLON.Scene} scene - The scene linked to this pipeline (default: the last created scene)
  43589. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  43590. * @param {boolean} automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  43591. */
  43592. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  43593. /**
  43594. * Force the compilation of the entire pipeline.
  43595. */
  43596. prepare(): void;
  43597. private _hasCleared;
  43598. private _prevPostProcess;
  43599. private _prevPrevPostProcess;
  43600. private _setAutoClearAndTextureSharing;
  43601. private _depthOfFieldSceneObserver;
  43602. private _buildPipeline;
  43603. private _disposePostProcesses;
  43604. /**
  43605. * Adds a camera to the pipeline
  43606. * @param camera the camera to be added
  43607. */
  43608. addCamera(camera: Camera): void;
  43609. /**
  43610. * Removes a camera from the pipeline
  43611. * @param camera the camera to remove
  43612. */
  43613. removeCamera(camera: Camera): void;
  43614. /**
  43615. * Dispose of the pipeline and stop all post processes
  43616. */
  43617. dispose(): void;
  43618. /**
  43619. * Serialize the rendering pipeline (Used when exporting)
  43620. * @returns the serialized object
  43621. */
  43622. serialize(): any;
  43623. /**
  43624. * Parse the serialized pipeline
  43625. * @param source Source pipeline.
  43626. * @param scene The scene to load the pipeline to.
  43627. * @param rootUrl The URL of the serialized pipeline.
  43628. * @returns An instantiated pipeline from the serialized object.
  43629. */
  43630. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  43631. }
  43632. }
  43633. declare module BABYLON {
  43634. class LensRenderingPipeline extends PostProcessRenderPipeline {
  43635. /**
  43636. * The chromatic aberration PostProcess id in the pipeline
  43637. */
  43638. LensChromaticAberrationEffect: string;
  43639. /**
  43640. * The highlights enhancing PostProcess id in the pipeline
  43641. */
  43642. HighlightsEnhancingEffect: string;
  43643. /**
  43644. * The depth-of-field PostProcess id in the pipeline
  43645. */
  43646. LensDepthOfFieldEffect: string;
  43647. private _scene;
  43648. private _depthTexture;
  43649. private _grainTexture;
  43650. private _chromaticAberrationPostProcess;
  43651. private _highlightsPostProcess;
  43652. private _depthOfFieldPostProcess;
  43653. private _edgeBlur;
  43654. private _grainAmount;
  43655. private _chromaticAberration;
  43656. private _distortion;
  43657. private _highlightsGain;
  43658. private _highlightsThreshold;
  43659. private _dofDistance;
  43660. private _dofAperture;
  43661. private _dofDarken;
  43662. private _dofPentagon;
  43663. private _blurNoise;
  43664. /**
  43665. * @constructor
  43666. *
  43667. * Effect parameters are as follow:
  43668. * {
  43669. * chromatic_aberration: number; // from 0 to x (1 for realism)
  43670. * edge_blur: number; // from 0 to x (1 for realism)
  43671. * distortion: number; // from 0 to x (1 for realism)
  43672. * grain_amount: number; // from 0 to 1
  43673. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  43674. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  43675. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  43676. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  43677. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  43678. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  43679. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  43680. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  43681. * }
  43682. * Note: if an effect parameter is unset, effect is disabled
  43683. *
  43684. * @param {string} name - The rendering pipeline name
  43685. * @param {object} parameters - An object containing all parameters (see above)
  43686. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  43687. * @param {number} 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)
  43688. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  43689. */
  43690. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  43691. setEdgeBlur(amount: number): void;
  43692. disableEdgeBlur(): void;
  43693. setGrainAmount(amount: number): void;
  43694. disableGrain(): void;
  43695. setChromaticAberration(amount: number): void;
  43696. disableChromaticAberration(): void;
  43697. setEdgeDistortion(amount: number): void;
  43698. disableEdgeDistortion(): void;
  43699. setFocusDistance(amount: number): void;
  43700. disableDepthOfField(): void;
  43701. setAperture(amount: number): void;
  43702. setDarkenOutOfFocus(amount: number): void;
  43703. enablePentagonBokeh(): void;
  43704. disablePentagonBokeh(): void;
  43705. enableNoiseBlur(): void;
  43706. disableNoiseBlur(): void;
  43707. setHighlightsGain(amount: number): void;
  43708. setHighlightsThreshold(amount: number): void;
  43709. disableHighlights(): void;
  43710. /**
  43711. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  43712. */
  43713. dispose(disableDepthRender?: boolean): void;
  43714. private _createChromaticAberrationPostProcess;
  43715. private _createHighlightsPostProcess;
  43716. private _createDepthOfFieldPostProcess;
  43717. private _createGrainTexture;
  43718. }
  43719. }
  43720. declare module BABYLON {
  43721. class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  43722. /**
  43723. * The PassPostProcess id in the pipeline that contains the original scene color
  43724. */
  43725. SSAOOriginalSceneColorEffect: string;
  43726. /**
  43727. * The SSAO PostProcess id in the pipeline
  43728. */
  43729. SSAORenderEffect: string;
  43730. /**
  43731. * The horizontal blur PostProcess id in the pipeline
  43732. */
  43733. SSAOBlurHRenderEffect: string;
  43734. /**
  43735. * The vertical blur PostProcess id in the pipeline
  43736. */
  43737. SSAOBlurVRenderEffect: string;
  43738. /**
  43739. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  43740. */
  43741. SSAOCombineRenderEffect: string;
  43742. /**
  43743. * The output strength of the SSAO post-process. Default value is 1.0.
  43744. */
  43745. totalStrength: number;
  43746. /**
  43747. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  43748. */
  43749. maxZ: number;
  43750. /**
  43751. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  43752. */
  43753. minZAspect: number;
  43754. private _samples;
  43755. /**
  43756. * Number of samples used for the SSAO calculations. Default value is 8
  43757. */
  43758. samples: number;
  43759. private _textureSamples;
  43760. /**
  43761. * Number of samples to use for antialiasing
  43762. */
  43763. textureSamples: number;
  43764. /**
  43765. * Ratio object used for SSAO ratio and blur ratio
  43766. */
  43767. private _ratio;
  43768. /**
  43769. * Dynamically generated sphere sampler.
  43770. */
  43771. private _sampleSphere;
  43772. /**
  43773. * Blur filter offsets
  43774. */
  43775. private _samplerOffsets;
  43776. /**
  43777. * Are we using bilateral blur ?
  43778. */
  43779. private _expensiveBlur;
  43780. expensiveBlur: boolean;
  43781. /**
  43782. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  43783. */
  43784. radius: number;
  43785. /**
  43786. * The base color of the SSAO post-process
  43787. * The final result is "base + ssao" between [0, 1]
  43788. */
  43789. base: number;
  43790. /**
  43791. * Support test.
  43792. */
  43793. static readonly IsSupported: boolean;
  43794. private _scene;
  43795. private _depthTexture;
  43796. private _normalTexture;
  43797. private _randomTexture;
  43798. private _originalColorPostProcess;
  43799. private _ssaoPostProcess;
  43800. private _blurHPostProcess;
  43801. private _blurVPostProcess;
  43802. private _ssaoCombinePostProcess;
  43803. private _firstUpdate;
  43804. /**
  43805. * @constructor
  43806. * @param {string} name - The rendering pipeline name
  43807. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  43808. * @param {any} 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 }
  43809. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  43810. */
  43811. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  43812. /**
  43813. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  43814. */
  43815. dispose(disableGeometryBufferRenderer?: boolean): void;
  43816. private _createBlurPostProcess;
  43817. /** @hidden */
  43818. private _bits;
  43819. private _radicalInverse_VdC;
  43820. private _hammersley;
  43821. private _hemisphereSample_uniform;
  43822. private _generateHemisphere;
  43823. private _createSSAOPostProcess;
  43824. private _createSSAOCombinePostProcess;
  43825. private _createRandomTexture;
  43826. /**
  43827. * Serialize the rendering pipeline (Used when exporting)
  43828. * @returns the serialized object
  43829. */
  43830. serialize(): any;
  43831. /**
  43832. * Parse the serialized pipeline
  43833. * @param source Source pipeline.
  43834. * @param scene The scene to load the pipeline to.
  43835. * @param rootUrl The URL of the serialized pipeline.
  43836. * @returns An instantiated pipeline from the serialized object.
  43837. */
  43838. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  43839. }
  43840. }
  43841. declare module BABYLON {
  43842. class SSAORenderingPipeline extends PostProcessRenderPipeline {
  43843. /**
  43844. * The PassPostProcess id in the pipeline that contains the original scene color
  43845. */
  43846. SSAOOriginalSceneColorEffect: string;
  43847. /**
  43848. * The SSAO PostProcess id in the pipeline
  43849. */
  43850. SSAORenderEffect: string;
  43851. /**
  43852. * The horizontal blur PostProcess id in the pipeline
  43853. */
  43854. SSAOBlurHRenderEffect: string;
  43855. /**
  43856. * The vertical blur PostProcess id in the pipeline
  43857. */
  43858. SSAOBlurVRenderEffect: string;
  43859. /**
  43860. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  43861. */
  43862. SSAOCombineRenderEffect: string;
  43863. /**
  43864. * The output strength of the SSAO post-process. Default value is 1.0.
  43865. */
  43866. totalStrength: number;
  43867. /**
  43868. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  43869. */
  43870. radius: number;
  43871. /**
  43872. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  43873. * Must not be equal to fallOff and superior to fallOff.
  43874. * Default value is 0.975
  43875. */
  43876. area: number;
  43877. /**
  43878. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  43879. * Must not be equal to area and inferior to area.
  43880. * Default value is 0.0
  43881. */
  43882. fallOff: number;
  43883. /**
  43884. * The base color of the SSAO post-process
  43885. * The final result is "base + ssao" between [0, 1]
  43886. */
  43887. base: number;
  43888. private _scene;
  43889. private _depthTexture;
  43890. private _randomTexture;
  43891. private _originalColorPostProcess;
  43892. private _ssaoPostProcess;
  43893. private _blurHPostProcess;
  43894. private _blurVPostProcess;
  43895. private _ssaoCombinePostProcess;
  43896. private _firstUpdate;
  43897. /**
  43898. * @constructor
  43899. * @param {string} name - The rendering pipeline name
  43900. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  43901. * @param {any} 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 }
  43902. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  43903. */
  43904. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  43905. /**
  43906. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  43907. */
  43908. dispose(disableDepthRender?: boolean): void;
  43909. private _createBlurPostProcess;
  43910. /** @hidden */
  43911. private _createSSAOPostProcess;
  43912. private _createSSAOCombinePostProcess;
  43913. private _createRandomTexture;
  43914. }
  43915. }
  43916. declare module BABYLON {
  43917. class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  43918. /**
  43919. * Public members
  43920. */
  43921. /**
  43922. * Post-process which contains the original scene color before the pipeline applies all the effects
  43923. */
  43924. originalPostProcess: Nullable<PostProcess>;
  43925. /**
  43926. * Post-process used to down scale an image x4
  43927. */
  43928. downSampleX4PostProcess: Nullable<PostProcess>;
  43929. /**
  43930. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  43931. */
  43932. brightPassPostProcess: Nullable<PostProcess>;
  43933. /**
  43934. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  43935. */
  43936. blurHPostProcesses: PostProcess[];
  43937. /**
  43938. * Post-process array storing all the vertical blur post-processes used by the pipeline
  43939. */
  43940. blurVPostProcesses: PostProcess[];
  43941. /**
  43942. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  43943. */
  43944. textureAdderPostProcess: Nullable<PostProcess>;
  43945. /**
  43946. * Post-process used to create volumetric lighting effect
  43947. */
  43948. volumetricLightPostProcess: Nullable<PostProcess>;
  43949. /**
  43950. * Post-process used to smooth the previous volumetric light post-process on the X axis
  43951. */
  43952. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  43953. /**
  43954. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  43955. */
  43956. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  43957. /**
  43958. * Post-process used to merge the volumetric light effect and the real scene color
  43959. */
  43960. volumetricLightMergePostProces: Nullable<PostProcess>;
  43961. /**
  43962. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  43963. */
  43964. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  43965. /**
  43966. * Base post-process used to calculate the average luminance of the final image for HDR
  43967. */
  43968. luminancePostProcess: Nullable<PostProcess>;
  43969. /**
  43970. * Post-processes used to create down sample post-processes in order to get
  43971. * the average luminance of the final image for HDR
  43972. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  43973. */
  43974. luminanceDownSamplePostProcesses: PostProcess[];
  43975. /**
  43976. * Post-process used to create a HDR effect (light adaptation)
  43977. */
  43978. hdrPostProcess: Nullable<PostProcess>;
  43979. /**
  43980. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  43981. */
  43982. textureAdderFinalPostProcess: Nullable<PostProcess>;
  43983. /**
  43984. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  43985. */
  43986. lensFlareFinalPostProcess: Nullable<PostProcess>;
  43987. /**
  43988. * Post-process used to merge the final HDR post-process and the real scene color
  43989. */
  43990. hdrFinalPostProcess: Nullable<PostProcess>;
  43991. /**
  43992. * Post-process used to create a lens flare effect
  43993. */
  43994. lensFlarePostProcess: Nullable<PostProcess>;
  43995. /**
  43996. * Post-process that merges the result of the lens flare post-process and the real scene color
  43997. */
  43998. lensFlareComposePostProcess: Nullable<PostProcess>;
  43999. /**
  44000. * Post-process used to create a motion blur effect
  44001. */
  44002. motionBlurPostProcess: Nullable<PostProcess>;
  44003. /**
  44004. * Post-process used to create a depth of field effect
  44005. */
  44006. depthOfFieldPostProcess: Nullable<PostProcess>;
  44007. /**
  44008. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  44009. */
  44010. fxaaPostProcess: Nullable<FxaaPostProcess>;
  44011. /**
  44012. * Represents the brightness threshold in order to configure the illuminated surfaces
  44013. */
  44014. brightThreshold: number;
  44015. /**
  44016. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  44017. */
  44018. blurWidth: number;
  44019. /**
  44020. * Sets if the blur for highlighted surfaces must be only horizontal
  44021. */
  44022. horizontalBlur: boolean;
  44023. /**
  44024. * Sets the overall exposure used by the pipeline
  44025. */
  44026. exposure: number;
  44027. /**
  44028. * Texture used typically to simulate "dirty" on camera lens
  44029. */
  44030. lensTexture: Nullable<Texture>;
  44031. /**
  44032. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  44033. */
  44034. volumetricLightCoefficient: number;
  44035. /**
  44036. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  44037. */
  44038. volumetricLightPower: number;
  44039. /**
  44040. * Used the set the blur intensity to smooth the volumetric lights
  44041. */
  44042. volumetricLightBlurScale: number;
  44043. /**
  44044. * Light (spot or directional) used to generate the volumetric lights rays
  44045. * The source light must have a shadow generate so the pipeline can get its
  44046. * depth map
  44047. */
  44048. sourceLight: Nullable<SpotLight | DirectionalLight>;
  44049. /**
  44050. * For eye adaptation, represents the minimum luminance the eye can see
  44051. */
  44052. hdrMinimumLuminance: number;
  44053. /**
  44054. * For eye adaptation, represents the decrease luminance speed
  44055. */
  44056. hdrDecreaseRate: number;
  44057. /**
  44058. * For eye adaptation, represents the increase luminance speed
  44059. */
  44060. hdrIncreaseRate: number;
  44061. /**
  44062. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  44063. */
  44064. lensColorTexture: Nullable<Texture>;
  44065. /**
  44066. * The overall strengh for the lens flare effect
  44067. */
  44068. lensFlareStrength: number;
  44069. /**
  44070. * Dispersion coefficient for lens flare ghosts
  44071. */
  44072. lensFlareGhostDispersal: number;
  44073. /**
  44074. * Main lens flare halo width
  44075. */
  44076. lensFlareHaloWidth: number;
  44077. /**
  44078. * Based on the lens distortion effect, defines how much the lens flare result
  44079. * is distorted
  44080. */
  44081. lensFlareDistortionStrength: number;
  44082. /**
  44083. * Lens star texture must be used to simulate rays on the flares and is available
  44084. * in the documentation
  44085. */
  44086. lensStarTexture: Nullable<Texture>;
  44087. /**
  44088. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  44089. * flare effect by taking account of the dirt texture
  44090. */
  44091. lensFlareDirtTexture: Nullable<Texture>;
  44092. /**
  44093. * Represents the focal length for the depth of field effect
  44094. */
  44095. depthOfFieldDistance: number;
  44096. /**
  44097. * Represents the blur intensity for the blurred part of the depth of field effect
  44098. */
  44099. depthOfFieldBlurWidth: number;
  44100. /**
  44101. * For motion blur, defines how much the image is blurred by the movement
  44102. */
  44103. motionStrength: number;
  44104. /**
  44105. * List of animations for the pipeline (IAnimatable implementation)
  44106. */
  44107. animations: Animation[];
  44108. /**
  44109. * Private members
  44110. */
  44111. private _scene;
  44112. private _currentDepthOfFieldSource;
  44113. private _basePostProcess;
  44114. private _hdrCurrentLuminance;
  44115. private _floatTextureType;
  44116. private _ratio;
  44117. private _bloomEnabled;
  44118. private _depthOfFieldEnabled;
  44119. private _vlsEnabled;
  44120. private _lensFlareEnabled;
  44121. private _hdrEnabled;
  44122. private _motionBlurEnabled;
  44123. private _fxaaEnabled;
  44124. private _motionBlurSamples;
  44125. private _volumetricLightStepsCount;
  44126. private _samples;
  44127. /**
  44128. * Specifies if the bloom pipeline is enabled
  44129. */
  44130. BloomEnabled: boolean;
  44131. /**
  44132. * Specifies if the depth of field pipeline is enabed
  44133. */
  44134. DepthOfFieldEnabled: boolean;
  44135. /**
  44136. * Specifies if the lens flare pipeline is enabed
  44137. */
  44138. LensFlareEnabled: boolean;
  44139. /**
  44140. * Specifies if the HDR pipeline is enabled
  44141. */
  44142. HDREnabled: boolean;
  44143. /**
  44144. * Specifies if the volumetric lights scattering effect is enabled
  44145. */
  44146. VLSEnabled: boolean;
  44147. /**
  44148. * Specifies if the motion blur effect is enabled
  44149. */
  44150. MotionBlurEnabled: boolean;
  44151. /**
  44152. * Specifies if anti-aliasing is enabled
  44153. */
  44154. fxaaEnabled: boolean;
  44155. /**
  44156. * Specifies the number of steps used to calculate the volumetric lights
  44157. * Typically in interval [50, 200]
  44158. */
  44159. volumetricLightStepsCount: number;
  44160. /**
  44161. * Specifies the number of samples used for the motion blur effect
  44162. * Typically in interval [16, 64]
  44163. */
  44164. motionBlurSamples: number;
  44165. /**
  44166. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  44167. */
  44168. samples: number;
  44169. /**
  44170. * @constructor
  44171. * @param {string} name - The rendering pipeline name
  44172. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  44173. * @param {any} 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)
  44174. * @param {BABYLON.PostProcess} originalPostProcess - the custom original color post-process. Must be "reusable". Can be null.
  44175. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  44176. */
  44177. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  44178. private _buildPipeline;
  44179. private _createDownSampleX4PostProcess;
  44180. private _createBrightPassPostProcess;
  44181. private _createBlurPostProcesses;
  44182. private _createTextureAdderPostProcess;
  44183. private _createVolumetricLightPostProcess;
  44184. private _createLuminancePostProcesses;
  44185. private _createHdrPostProcess;
  44186. private _createLensFlarePostProcess;
  44187. private _createDepthOfFieldPostProcess;
  44188. private _createMotionBlurPostProcess;
  44189. private _getDepthTexture;
  44190. private _disposePostProcesses;
  44191. /**
  44192. * Dispose of the pipeline and stop all post processes
  44193. */
  44194. dispose(): void;
  44195. /**
  44196. * Serialize the rendering pipeline (Used when exporting)
  44197. * @returns the serialized object
  44198. */
  44199. serialize(): any;
  44200. /**
  44201. * Parse the serialized pipeline
  44202. * @param source Source pipeline.
  44203. * @param scene The scene to load the pipeline to.
  44204. * @param rootUrl The URL of the serialized pipeline.
  44205. * @returns An instantiated pipeline from the serialized object.
  44206. */
  44207. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  44208. static LuminanceSteps: number;
  44209. }
  44210. }
  44211. /*BabylonJS GUI*/
  44212. // Dependencies for this module:
  44213. // ../../../../Tools/gulp/babylonjs
  44214. declare module BABYLON.GUI {
  44215. }
  44216. declare module BABYLON.GUI {
  44217. }
  44218. declare module BABYLON.GUI {
  44219. }
  44220. declare module BABYLON.GUI {
  44221. }
  44222. declare module BABYLON.GUI {
  44223. /**
  44224. * Interface used to define a control that can receive focus
  44225. */
  44226. export interface IFocusableControl {
  44227. /**
  44228. * Function called when the control receives the focus
  44229. */
  44230. onFocus(): void;
  44231. /**
  44232. * Function called when the control loses the focus
  44233. */
  44234. onBlur(): void;
  44235. /**
  44236. * Function called to let the control handle keyboard events
  44237. * @param evt defines the current keyboard event
  44238. */
  44239. processKeyboard(evt: KeyboardEvent): void;
  44240. /**
  44241. * Function called to get the list of controls that should not steal the focus from this control
  44242. * @returns an array of controls
  44243. */
  44244. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  44245. }
  44246. /**
  44247. * Class used to create texture to support 2D GUI elements
  44248. * @see http://doc.babylonjs.com/how_to/gui
  44249. */
  44250. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  44251. /** @hidden */
  44252. /** @hidden */
  44253. /** @hidden */ ;
  44254. /** @hidden */ ;
  44255. /** @hidden */ ;
  44256. /** @hidden */
  44257. /** @hidden */
  44258. /** @hidden */
  44259. /**
  44260. * Gets or sets a boolean defining if alpha is stored as premultiplied
  44261. */
  44262. premulAlpha: boolean;
  44263. /**
  44264. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  44265. * Useful when you want more antialiasing
  44266. */
  44267. renderScale: number;
  44268. /** Gets or sets the background color */
  44269. background: string;
  44270. /**
  44271. * Gets or sets the ideal width used to design controls.
  44272. * The GUI will then rescale everything accordingly
  44273. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  44274. */
  44275. idealWidth: number;
  44276. /**
  44277. * Gets or sets the ideal height used to design controls.
  44278. * The GUI will then rescale everything accordingly
  44279. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  44280. */
  44281. idealHeight: number;
  44282. /**
  44283. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  44284. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  44285. */
  44286. useSmallestIdeal: boolean;
  44287. /**
  44288. * Gets or sets a boolean indicating if adaptive scaling must be used
  44289. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  44290. */
  44291. renderAtIdealSize: boolean;
  44292. /**
  44293. * Gets the underlying layer used to render the texture when in fullscreen mode
  44294. */
  44295. readonly layer: BABYLON.Nullable<BABYLON.Layer>;
  44296. /**
  44297. * Gets the root container control
  44298. */
  44299. readonly rootContainer: Container;
  44300. /**
  44301. * Gets or sets the current focused control
  44302. */
  44303. focusedControl: BABYLON.Nullable<IFocusableControl>;
  44304. /**
  44305. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  44306. */
  44307. isForeground: boolean;
  44308. /**
  44309. * Creates a new AdvancedDynamicTexture
  44310. * @param name defines the name of the texture
  44311. * @param width defines the width of the texture
  44312. * @param height defines the height of the texture
  44313. * @param scene defines the hosting scene
  44314. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  44315. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  44316. */
  44317. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  44318. /**
  44319. * Function used to execute a function on all controls
  44320. * @param func defines the function to execute
  44321. * @param container defines the container where controls belong. If null the root container will be used
  44322. */
  44323. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  44324. /**
  44325. * Marks the texture as dirty forcing a complete update
  44326. */
  44327. markAsDirty(): void;
  44328. /**
  44329. * Helper function used to create a new style
  44330. * @returns a new style
  44331. * @see http://doc.babylonjs.com/how_to/gui#styles
  44332. */
  44333. createStyle(): Style;
  44334. /**
  44335. * Adds a new control to the root container
  44336. * @param control defines the control to add
  44337. * @returns the current texture
  44338. */
  44339. addControl(control: Control): AdvancedDynamicTexture;
  44340. /**
  44341. * Removes a control from the root container
  44342. * @param control defines the control to remove
  44343. * @returns the current texture
  44344. */
  44345. removeControl(control: Control): AdvancedDynamicTexture;
  44346. /**
  44347. * Release all resources
  44348. */
  44349. dispose(): void;
  44350. /** @hidden */
  44351. /**
  44352. * Get screen coordinates for a vector3
  44353. * @param position defines the position to project
  44354. * @param worldMatrix defines the world matrix to use
  44355. * @returns the projected position
  44356. */
  44357. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  44358. /** @hidden */
  44359. /** @hidden */ , control: Control): void;
  44360. /** @hidden */
  44361. /** Attach to all scene events required to support pointer events */
  44362. attach(): void;
  44363. /**
  44364. * Connect the texture to a hosting mesh to enable interactions
  44365. * @param mesh defines the mesh to attach to
  44366. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  44367. */
  44368. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  44369. /**
  44370. * Move the focus to a specific control
  44371. * @param control defines the control which will receive the focus
  44372. */
  44373. moveFocusToControl(control: IFocusableControl): void;
  44374. /**
  44375. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  44376. * @param mesh defines the mesh which will receive the texture
  44377. * @param width defines the texture width (1024 by default)
  44378. * @param height defines the texture height (1024 by default)
  44379. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  44380. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  44381. * @returns a new AdvancedDynamicTexture
  44382. */
  44383. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  44384. /**
  44385. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  44386. * In this mode the texture will rely on a layer for its rendering.
  44387. * This allows it to be treated like any other layer.
  44388. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  44389. * LayerMask is set through advancedTexture.layer.layerMask
  44390. * @param name defines name for the texture
  44391. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  44392. * @param scene defines the hsoting scene
  44393. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  44394. * @returns a new AdvancedDynamicTexture
  44395. */
  44396. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  44397. }
  44398. }
  44399. declare module BABYLON.GUI {
  44400. /**
  44401. * Class used to transport BABYLON.Vector2 information for pointer events
  44402. */
  44403. export class Vector2WithInfo extends BABYLON.Vector2 {
  44404. /** defines the current mouse button index */
  44405. buttonIndex: number;
  44406. /**
  44407. * Creates a new Vector2WithInfo
  44408. * @param source defines the vector2 data to transport
  44409. * @param buttonIndex defines the current mouse button index
  44410. */
  44411. constructor(source: BABYLON.Vector2,
  44412. /** defines the current mouse button index */
  44413. buttonIndex?: number);
  44414. }
  44415. /** Class used to provide 2D matrix features */
  44416. export class Matrix2D {
  44417. /** Gets the internal array of 6 floats used to store matrix data */
  44418. m: Float32Array;
  44419. /**
  44420. * Creates a new matrix
  44421. * @param m00 defines value for (0, 0)
  44422. * @param m01 defines value for (0, 1)
  44423. * @param m10 defines value for (1, 0)
  44424. * @param m11 defines value for (1, 1)
  44425. * @param m20 defines value for (2, 0)
  44426. * @param m21 defines value for (2, 1)
  44427. */
  44428. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  44429. /**
  44430. * Fills the matrix from direct values
  44431. * @param m00 defines value for (0, 0)
  44432. * @param m01 defines value for (0, 1)
  44433. * @param m10 defines value for (1, 0)
  44434. * @param m11 defines value for (1, 1)
  44435. * @param m20 defines value for (2, 0)
  44436. * @param m21 defines value for (2, 1)
  44437. * @returns the current modified matrix
  44438. */
  44439. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  44440. /**
  44441. * Gets matrix determinant
  44442. * @returns the determinant
  44443. */
  44444. determinant(): number;
  44445. /**
  44446. * Inverses the matrix and stores it in a target matrix
  44447. * @param result defines the target matrix
  44448. * @returns the current matrix
  44449. */
  44450. invertToRef(result: Matrix2D): Matrix2D;
  44451. /**
  44452. * Multiplies the current matrix with another one
  44453. * @param other defines the second operand
  44454. * @param result defines the target matrix
  44455. * @returns the current matrix
  44456. */
  44457. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  44458. /**
  44459. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  44460. * @param x defines the x coordinate to transform
  44461. * @param y defines the x coordinate to transform
  44462. * @param result defines the target vector2
  44463. * @returns the current matrix
  44464. */
  44465. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  44466. /**
  44467. * Creates an identity matrix
  44468. * @returns a new matrix
  44469. */
  44470. static Identity(): Matrix2D;
  44471. /**
  44472. * Creates a translation matrix and stores it in a target matrix
  44473. * @param x defines the x coordinate of the translation
  44474. * @param y defines the y coordinate of the translation
  44475. * @param result defines the target matrix
  44476. */
  44477. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  44478. /**
  44479. * Creates a scaling matrix and stores it in a target matrix
  44480. * @param x defines the x coordinate of the scaling
  44481. * @param y defines the y coordinate of the scaling
  44482. * @param result defines the target matrix
  44483. */
  44484. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  44485. /**
  44486. * Creates a rotation matrix and stores it in a target matrix
  44487. * @param angle defines the rotation angle
  44488. * @param result defines the target matrix
  44489. */
  44490. static RotationToRef(angle: number, result: Matrix2D): void;
  44491. /**
  44492. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  44493. * @param tx defines the x coordinate of the translation
  44494. * @param ty defines the y coordinate of the translation
  44495. * @param angle defines the rotation angle
  44496. * @param scaleX defines the x coordinate of the scaling
  44497. * @param scaleY defines the y coordinate of the scaling
  44498. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  44499. * @param result defines the target matrix
  44500. */
  44501. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  44502. }
  44503. }
  44504. declare module BABYLON.GUI {
  44505. /**
  44506. * Class used to store 2D control sizes
  44507. */
  44508. export class Measure {
  44509. /** defines left coordinate */
  44510. left: number;
  44511. /** defines top coordinate */
  44512. top: number;
  44513. /** defines width dimension */
  44514. width: number;
  44515. /** defines height dimension */
  44516. height: number;
  44517. /**
  44518. * Creates a new measure
  44519. * @param left defines left coordinate
  44520. * @param top defines top coordinate
  44521. * @param width defines width dimension
  44522. * @param height defines height dimension
  44523. */
  44524. constructor(
  44525. /** defines left coordinate */
  44526. left: number,
  44527. /** defines top coordinate */
  44528. top: number,
  44529. /** defines width dimension */
  44530. width: number,
  44531. /** defines height dimension */
  44532. height: number);
  44533. /**
  44534. * Copy from another measure
  44535. * @param other defines the other measure to copy from
  44536. */
  44537. copyFrom(other: Measure): void;
  44538. /**
  44539. * Check equality between this measure and another one
  44540. * @param other defines the other measures
  44541. * @returns true if both measures are equals
  44542. */
  44543. isEqualsTo(other: Measure): boolean;
  44544. /**
  44545. * Creates an empty measure
  44546. * @returns a new measure
  44547. */
  44548. static Empty(): Measure;
  44549. }
  44550. }
  44551. declare module BABYLON.GUI {
  44552. /**
  44553. * Class used to store a point for a MultiLine object.
  44554. * The point can be pure 2D coordinates, a mesh or a control
  44555. */
  44556. export class MultiLinePoint {
  44557. /** @hidden */
  44558. /**
  44559. * Creates a new MultiLinePoint
  44560. * @param multiLine defines the source MultiLine object
  44561. */
  44562. constructor(multiLine: MultiLine);
  44563. /** Gets or sets x coordinate */
  44564. x: string | number;
  44565. /** Gets or sets y coordinate */
  44566. y: string | number;
  44567. /** Gets or sets the control associated with this point */
  44568. control: BABYLON.Nullable<Control>;
  44569. /** Gets or sets the mesh associated with this point */
  44570. mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  44571. /**
  44572. * Gets a translation vector
  44573. * @returns the translation vector
  44574. */
  44575. translate(): BABYLON.Vector2;
  44576. /** Release associated resources */
  44577. dispose(): void;
  44578. }
  44579. }
  44580. declare module BABYLON.GUI {
  44581. /**
  44582. * Define a style used by control to automatically setup properties based on a template.
  44583. * Only support font related properties so far
  44584. */
  44585. export class Style implements BABYLON.IDisposable {
  44586. /** @hidden */
  44587. /** @hidden */
  44588. /**
  44589. * BABYLON.Observable raised when the style values are changed
  44590. */
  44591. onChangedObservable: BABYLON.Observable<Style>;
  44592. /**
  44593. * Creates a new style object
  44594. * @param host defines the AdvancedDynamicTexture which hosts this style
  44595. */
  44596. constructor(host: AdvancedDynamicTexture);
  44597. /**
  44598. * Gets or sets the font size
  44599. */
  44600. fontSize: string | number;
  44601. /**
  44602. * Gets or sets the font family
  44603. */
  44604. fontFamily: string;
  44605. /**
  44606. * Gets or sets the font style
  44607. */
  44608. fontStyle: string;
  44609. /** Gets or sets font weight */
  44610. fontWeight: string;
  44611. /** Dispose all associated resources */
  44612. dispose(): void;
  44613. }
  44614. }
  44615. declare module BABYLON.GUI {
  44616. /**
  44617. * Class used to specific a value and its associated unit
  44618. */
  44619. export class ValueAndUnit {
  44620. /** defines the unit to store */
  44621. unit: number;
  44622. /** defines a boolean indicating if the value can be negative */
  44623. negativeValueAllowed: boolean;
  44624. /**
  44625. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  44626. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  44627. */
  44628. ignoreAdaptiveScaling: boolean;
  44629. /**
  44630. * Creates a new ValueAndUnit
  44631. * @param value defines the value to store
  44632. * @param unit defines the unit to store
  44633. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  44634. */
  44635. constructor(value: number,
  44636. /** defines the unit to store */
  44637. unit?: number,
  44638. /** defines a boolean indicating if the value can be negative */
  44639. negativeValueAllowed?: boolean);
  44640. /** Gets a boolean indicating if the value is a percentage */
  44641. readonly isPercentage: boolean;
  44642. /** Gets a boolean indicating if the value is store as pixel */
  44643. readonly isPixel: boolean;
  44644. /** Gets direct internal value */
  44645. readonly internalValue: number;
  44646. /**
  44647. * Gets value as pixel
  44648. * @param host defines the root host
  44649. * @param refValue defines the reference value for percentages
  44650. * @returns the value as pixel
  44651. */
  44652. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  44653. /**
  44654. * Gets the value accordingly to its unit
  44655. * @param host defines the root host
  44656. * @returns the value
  44657. */
  44658. getValue(host: AdvancedDynamicTexture): number;
  44659. /**
  44660. * Gets a string representation of the value
  44661. * @param host defines the root host
  44662. * @returns a string
  44663. */
  44664. toString(host: AdvancedDynamicTexture): string;
  44665. /**
  44666. * Store a value parsed from a string
  44667. * @param source defines the source string
  44668. * @returns true if the value was successfully parsed
  44669. */
  44670. fromString(source: string | number): boolean;
  44671. /** UNITMODE_PERCENTAGE */
  44672. static readonly UNITMODE_PERCENTAGE: number;
  44673. /** UNITMODE_PIXEL */
  44674. static readonly UNITMODE_PIXEL: number;
  44675. }
  44676. }
  44677. declare module BABYLON.GUI {
  44678. }
  44679. declare module BABYLON.GUI {
  44680. }
  44681. declare module BABYLON.GUI {
  44682. /**
  44683. * Class used to manage 3D user interface
  44684. * @see http://doc.babylonjs.com/how_to/gui3d
  44685. */
  44686. export class GUI3DManager implements BABYLON.IDisposable {
  44687. /** @hidden */
  44688. /** @hidden */ ;
  44689. /** @hidden */ ;
  44690. /**
  44691. * BABYLON.Observable raised when the point picked by the pointer events changed
  44692. */
  44693. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  44694. /** @hidden */ ;
  44695. /** Gets the hosting scene */
  44696. readonly scene: BABYLON.Scene;
  44697. /** Gets associated utility layer */
  44698. readonly utilityLayer: BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  44699. /**
  44700. * Creates a new GUI3DManager
  44701. * @param scene
  44702. */
  44703. constructor(scene?: BABYLON.Scene);
  44704. /**
  44705. * Gets the root container
  44706. */
  44707. readonly rootContainer: Container3D;
  44708. /**
  44709. * Gets a boolean indicating if the given control is in the root child list
  44710. * @param control defines the control to check
  44711. * @returns true if the control is in the root child list
  44712. */
  44713. containsControl(control: Control3D): boolean;
  44714. /**
  44715. * Adds a control to the root child list
  44716. * @param control defines the control to add
  44717. * @returns the current manager
  44718. */
  44719. addControl(control: Control3D): GUI3DManager;
  44720. /**
  44721. * Removes a control from the root child list
  44722. * @param control defines the control to remove
  44723. * @returns the current container
  44724. */
  44725. removeControl(control: Control3D): GUI3DManager;
  44726. /**
  44727. * Releases all associated resources
  44728. */
  44729. dispose(): void;
  44730. }
  44731. }
  44732. declare module BABYLON.GUI {
  44733. /**
  44734. * Class used to transport BABYLON.Vector3 information for pointer events
  44735. */
  44736. export class Vector3WithInfo extends BABYLON.Vector3 {
  44737. /** defines the current mouse button index */
  44738. buttonIndex: number;
  44739. /**
  44740. * Creates a new Vector3WithInfo
  44741. * @param source defines the vector3 data to transport
  44742. * @param buttonIndex defines the current mouse button index
  44743. */
  44744. constructor(source: BABYLON.Vector3,
  44745. /** defines the current mouse button index */
  44746. buttonIndex?: number);
  44747. }
  44748. }
  44749. declare module BABYLON.GUI {
  44750. /**
  44751. * Class used to create 2D buttons
  44752. */
  44753. export class Button extends Rectangle {
  44754. name?: string | undefined;
  44755. /**
  44756. * Function called to generate a pointer enter animation
  44757. */
  44758. pointerEnterAnimation: () => void;
  44759. /**
  44760. * Function called to generate a pointer out animation
  44761. */
  44762. pointerOutAnimation: () => void;
  44763. /**
  44764. * Function called to generate a pointer down animation
  44765. */
  44766. pointerDownAnimation: () => void;
  44767. /**
  44768. * Function called to generate a pointer up animation
  44769. */
  44770. pointerUpAnimation: () => void;
  44771. /**
  44772. * Creates a new Button
  44773. * @param name defines the name of the button
  44774. */
  44775. constructor(name?: string | undefined);
  44776. protected _getTypeName(): string;
  44777. /** @hidden */
  44778. /** @hidden */
  44779. /** @hidden */
  44780. /** @hidden */
  44781. /** @hidden */
  44782. /**
  44783. * Creates a new button made with an image and a text
  44784. * @param name defines the name of the button
  44785. * @param text defines the text of the button
  44786. * @param imageUrl defines the url of the image
  44787. * @returns a new Button
  44788. */
  44789. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  44790. /**
  44791. * Creates a new button made with an image
  44792. * @param name defines the name of the button
  44793. * @param imageUrl defines the url of the image
  44794. * @returns a new Button
  44795. */
  44796. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  44797. /**
  44798. * Creates a new button made with a text
  44799. * @param name defines the name of the button
  44800. * @param text defines the text of the button
  44801. * @returns a new Button
  44802. */
  44803. static CreateSimpleButton(name: string, text: string): Button;
  44804. /**
  44805. * Creates a new button made with an image and a centered text
  44806. * @param name defines the name of the button
  44807. * @param text defines the text of the button
  44808. * @param imageUrl defines the url of the image
  44809. * @returns a new Button
  44810. */
  44811. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  44812. }
  44813. }
  44814. declare module BABYLON.GUI {
  44815. /**
  44816. * Class used to represent a 2D checkbox
  44817. */
  44818. export class Checkbox extends Control {
  44819. name?: string | undefined;
  44820. /** Gets or sets border thickness */
  44821. thickness: number;
  44822. /**
  44823. * BABYLON.Observable raised when isChecked property changes
  44824. */
  44825. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  44826. /** Gets or sets a value indicating the ratio between overall size and check size */
  44827. checkSizeRatio: number;
  44828. /** Gets or sets background color */
  44829. background: string;
  44830. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  44831. isChecked: boolean;
  44832. /**
  44833. * Creates a new CheckBox
  44834. * @param name defines the control name
  44835. */
  44836. constructor(name?: string | undefined);
  44837. protected _getTypeName(): string;
  44838. /** @hidden */
  44839. /** @hidden */
  44840. /**
  44841. * Utility function to easily create a checkbox with a header
  44842. * @param title defines the label to use for the header
  44843. * @param onValueChanged defines the callback to call when value changes
  44844. * @returns a StackPanel containing the checkbox and a textBlock
  44845. */
  44846. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  44847. }
  44848. }
  44849. declare module BABYLON.GUI {
  44850. /** Class used to create color pickers */
  44851. export class ColorPicker extends Control {
  44852. name?: string | undefined;
  44853. /**
  44854. * BABYLON.Observable raised when the value changes
  44855. */
  44856. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  44857. /** Gets or sets the color of the color picker */
  44858. value: BABYLON.Color3;
  44859. /** Gets or sets control width */
  44860. width: string | number;
  44861. /** Gets or sets control height */
  44862. height: string | number;
  44863. /** Gets or sets control size */
  44864. size: string | number;
  44865. /**
  44866. * Creates a new ColorPicker
  44867. * @param name defines the control name
  44868. */
  44869. constructor(name?: string | undefined);
  44870. protected _getTypeName(): string;
  44871. /** @hidden */
  44872. }
  44873. }
  44874. declare module BABYLON.GUI {
  44875. /**
  44876. * Root class for 2D containers
  44877. * @see http://doc.babylonjs.com/how_to/gui#containers
  44878. */
  44879. export class Container extends Control {
  44880. name?: string | undefined;
  44881. /** @hidden */
  44882. protected _children: Control[];
  44883. /** @hidden */
  44884. protected _measureForChildren: Measure;
  44885. /** @hidden */
  44886. protected _background: string;
  44887. /** @hidden */
  44888. protected _adaptWidthToChildren: boolean;
  44889. /** @hidden */
  44890. protected _adaptHeightToChildren: boolean;
  44891. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  44892. adaptHeightToChildren: boolean;
  44893. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  44894. adaptWidthToChildren: boolean;
  44895. /** Gets or sets background color */
  44896. background: string;
  44897. /** Gets the list of children */
  44898. readonly children: Control[];
  44899. /**
  44900. * Creates a new Container
  44901. * @param name defines the name of the container
  44902. */
  44903. constructor(name?: string | undefined);
  44904. protected _getTypeName(): string;
  44905. /**
  44906. * Gets a child using its name
  44907. * @param name defines the child name to look for
  44908. * @returns the child control if found
  44909. */
  44910. getChildByName(name: string): BABYLON.Nullable<Control>;
  44911. /**
  44912. * Gets a child using its type and its name
  44913. * @param name defines the child name to look for
  44914. * @param type defines the child type to look for
  44915. * @returns the child control if found
  44916. */
  44917. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  44918. /**
  44919. * Search for a specific control in children
  44920. * @param control defines the control to look for
  44921. * @returns true if the control is in child list
  44922. */
  44923. containsControl(control: Control): boolean;
  44924. /**
  44925. * Adds a new control to the current container
  44926. * @param control defines the control to add
  44927. * @returns the current container
  44928. */
  44929. addControl(control: BABYLON.Nullable<Control>): Container;
  44930. /**
  44931. * Removes all controls from the current container
  44932. * @returns the current container
  44933. */
  44934. clearControls(): Container;
  44935. /**
  44936. * Removes a control from the current container
  44937. * @param control defines the control to remove
  44938. * @returns the current container
  44939. */
  44940. removeControl(control: Control): Container;
  44941. /** @hidden */
  44942. /** @hidden */
  44943. /** @hidden */
  44944. /** @hidden */
  44945. protected _localDraw(context: CanvasRenderingContext2D): void;
  44946. /** @hidden */
  44947. /** @hidden */
  44948. /** @hidden */
  44949. /** @hidden */
  44950. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  44951. /** @hidden */
  44952. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  44953. /** Releases associated resources */
  44954. dispose(): void;
  44955. }
  44956. }
  44957. declare module BABYLON.GUI {
  44958. /**
  44959. * Root class used for all 2D controls
  44960. * @see http://doc.babylonjs.com/how_to/gui#controls
  44961. */
  44962. export class Control {
  44963. /** defines the name of the control */
  44964. name?: string | undefined;
  44965. /** @hidden */
  44966. /** @hidden */
  44967. /** Gets or sets the control parent */
  44968. parent: BABYLON.Nullable<Container>;
  44969. /** @hidden */
  44970. /** @hidden */
  44971. /** @hidden */
  44972. /** @hidden */
  44973. protected _fontOffset: {
  44974. ascent: number;
  44975. height: number;
  44976. descent: number;
  44977. };
  44978. /** @hidden */
  44979. protected _horizontalAlignment: number;
  44980. /** @hidden */
  44981. protected _verticalAlignment: number;
  44982. /** @hidden */
  44983. /** @hidden */
  44984. protected _cachedParentMeasure: Measure;
  44985. /** @hidden */
  44986. /** @hidden */
  44987. /** @hidden */
  44988. protected _invertTransformMatrix: Matrix2D;
  44989. /** @hidden */
  44990. protected _transformedPosition: BABYLON.Vector2;
  44991. /** @hidden */
  44992. protected _isEnabled: boolean;
  44993. protected _disabledColor: string;
  44994. /** @hidden */
  44995. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  44996. isHitTestVisible: boolean;
  44997. /** Gets or sets a boolean indicating if the control can block pointer events */
  44998. isPointerBlocker: boolean;
  44999. /** Gets or sets a boolean indicating if the control can be focusable */
  45000. isFocusInvisible: boolean;
  45001. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  45002. shadowOffsetX: number;
  45003. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  45004. shadowOffsetY: number;
  45005. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  45006. shadowBlur: number;
  45007. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  45008. shadowColor: string;
  45009. /** Gets or sets the cursor to use when the control is hovered */
  45010. hoverCursor: string;
  45011. /** @hidden */
  45012. protected _linkOffsetX: ValueAndUnit;
  45013. /** @hidden */
  45014. protected _linkOffsetY: ValueAndUnit;
  45015. /** Gets the control type name */
  45016. readonly typeName: string;
  45017. /**
  45018. * An event triggered when the pointer move over the control.
  45019. */
  45020. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  45021. /**
  45022. * An event triggered when the pointer move out of the control.
  45023. */
  45024. onPointerOutObservable: BABYLON.Observable<Control>;
  45025. /**
  45026. * An event triggered when the pointer taps the control
  45027. */
  45028. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  45029. /**
  45030. * An event triggered when pointer up
  45031. */
  45032. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  45033. /**
  45034. * An event triggered when a control is clicked on
  45035. */
  45036. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  45037. /**
  45038. * An event triggered when pointer enters the control
  45039. */
  45040. onPointerEnterObservable: BABYLON.Observable<Control>;
  45041. /**
  45042. * An event triggered when the control is marked as dirty
  45043. */
  45044. onDirtyObservable: BABYLON.Observable<Control>;
  45045. /**
  45046. * An event triggered after the control is drawn
  45047. */
  45048. onAfterDrawObservable: BABYLON.Observable<Control>;
  45049. /** Gets or set information about font offsets (used to render and align text) */
  45050. fontOffset: {
  45051. ascent: number;
  45052. height: number;
  45053. descent: number;
  45054. };
  45055. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  45056. alpha: number;
  45057. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  45058. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  45059. */
  45060. scaleX: number;
  45061. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  45062. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  45063. */
  45064. scaleY: number;
  45065. /** Gets or sets the rotation angle (0 by default)
  45066. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  45067. */
  45068. rotation: number;
  45069. /** Gets or sets the transformation center on Y axis (0 by default)
  45070. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  45071. */
  45072. transformCenterY: number;
  45073. /** Gets or sets the transformation center on X axis (0 by default)
  45074. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  45075. */
  45076. transformCenterX: number;
  45077. /**
  45078. * Gets or sets the horizontal alignment
  45079. * @see http://doc.babylonjs.com/how_to/gui#alignments
  45080. */
  45081. horizontalAlignment: number;
  45082. /**
  45083. * Gets or sets the vertical alignment
  45084. * @see http://doc.babylonjs.com/how_to/gui#alignments
  45085. */
  45086. verticalAlignment: number;
  45087. /**
  45088. * Gets or sets control width
  45089. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  45090. */
  45091. width: string | number;
  45092. /**
  45093. * Gets control width in pixel
  45094. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  45095. */
  45096. readonly widthInPixels: number;
  45097. /**
  45098. * Gets or sets control height
  45099. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  45100. */
  45101. height: string | number;
  45102. /**
  45103. * Gets control height in pixel
  45104. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  45105. */
  45106. readonly heightInPixels: number;
  45107. /** Gets or set font family */
  45108. fontFamily: string;
  45109. /** Gets or sets font style */
  45110. fontStyle: string;
  45111. /** Gets or sets font weight */
  45112. fontWeight: string;
  45113. /**
  45114. * Gets or sets style
  45115. * @see http://doc.babylonjs.com/how_to/gui#styles
  45116. */
  45117. style: BABYLON.Nullable<Style>;
  45118. /** @hidden */ protected readonly _isFontSizeInPercentage: boolean;
  45119. /** Gets font size in pixels */
  45120. readonly fontSizeInPixels: number;
  45121. /** Gets or sets font size */
  45122. fontSize: string | number;
  45123. /** Gets or sets foreground color */
  45124. color: string;
  45125. /** Gets or sets z index which is used to reorder controls on the z axis */
  45126. zIndex: number;
  45127. /** Gets or sets a boolean indicating if the control can be rendered */
  45128. notRenderable: boolean;
  45129. /** Gets or sets a boolean indicating if the control is visible */
  45130. isVisible: boolean;
  45131. /** Gets a boolean indicating that the control needs to update its rendering */
  45132. readonly isDirty: boolean;
  45133. /**
  45134. * Gets or sets a value indicating the padding to use on the left of the control
  45135. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  45136. */
  45137. paddingLeft: string | number;
  45138. /**
  45139. * Gets a value indicating the padding in pixels to use on the left of the control
  45140. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  45141. */
  45142. readonly paddingLeftInPixels: number;
  45143. /**
  45144. * Gets or sets a value indicating the padding to use on the right of the control
  45145. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  45146. */
  45147. paddingRight: string | number;
  45148. /**
  45149. * Gets a value indicating the padding in pixels to use on the right of the control
  45150. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  45151. */
  45152. readonly paddingRightInPixels: number;
  45153. /**
  45154. * Gets or sets a value indicating the padding to use on the top of the control
  45155. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  45156. */
  45157. paddingTop: string | number;
  45158. /**
  45159. * Gets a value indicating the padding in pixels to use on the top of the control
  45160. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  45161. */
  45162. readonly paddingTopInPixels: number;
  45163. /**
  45164. * Gets or sets a value indicating the padding to use on the bottom of the control
  45165. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  45166. */
  45167. paddingBottom: string | number;
  45168. /**
  45169. * Gets a value indicating the padding in pixels to use on the bottom of the control
  45170. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  45171. */
  45172. readonly paddingBottomInPixels: number;
  45173. /**
  45174. * Gets or sets a value indicating the left coordinate of the control
  45175. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  45176. */
  45177. left: string | number;
  45178. /**
  45179. * Gets a value indicating the left coordinate in pixels of the control
  45180. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  45181. */
  45182. readonly leftInPixels: number;
  45183. /**
  45184. * Gets or sets a value indicating the top coordinate of the control
  45185. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  45186. */
  45187. top: string | number;
  45188. /**
  45189. * Gets a value indicating the top coordinate in pixels of the control
  45190. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  45191. */
  45192. readonly topInPixels: number;
  45193. /**
  45194. * Gets or sets a value indicating the offset on X axis to the linked mesh
  45195. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  45196. */
  45197. linkOffsetX: string | number;
  45198. /**
  45199. * Gets a value indicating the offset in pixels on X axis to the linked mesh
  45200. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  45201. */
  45202. readonly linkOffsetXInPixels: number;
  45203. /**
  45204. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  45205. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  45206. */
  45207. linkOffsetY: string | number;
  45208. /**
  45209. * Gets a value indicating the offset in pixels on Y axis to the linked mesh
  45210. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  45211. */
  45212. readonly linkOffsetYInPixels: number;
  45213. /** Gets the center coordinate on X axis */
  45214. readonly centerX: number;
  45215. /** Gets the center coordinate on Y axis */
  45216. readonly centerY: number;
  45217. /** Gets or sets if control is Enabled*/
  45218. isEnabled: boolean;
  45219. /** Gets or sets background color of control if it's disabled*/
  45220. disabledColor: string;
  45221. /**
  45222. * Creates a new control
  45223. * @param name defines the name of the control
  45224. */
  45225. constructor(
  45226. /** defines the name of the control */
  45227. name?: string | undefined);
  45228. /** @hidden */
  45229. protected _getTypeName(): string;
  45230. /** @hidden */
  45231. /**
  45232. * Determines if a container is an ascendant of the current control
  45233. * @param container defines the container to look for
  45234. * @returns true if the container is one of the ascendant of the control
  45235. */
  45236. isAscendant(container: Control): boolean;
  45237. /**
  45238. * Gets coordinates in local control space
  45239. * @param globalCoordinates defines the coordinates to transform
  45240. * @returns the new coordinates in local space
  45241. */
  45242. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  45243. /**
  45244. * Gets coordinates in local control space
  45245. * @param globalCoordinates defines the coordinates to transform
  45246. * @param result defines the target vector2 where to store the result
  45247. * @returns the current control
  45248. */
  45249. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  45250. /**
  45251. * Gets coordinates in parent local control space
  45252. * @param globalCoordinates defines the coordinates to transform
  45253. * @returns the new coordinates in parent local space
  45254. */
  45255. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  45256. /**
  45257. * Move the current control to a vector3 position projected onto the screen.
  45258. * @param position defines the target position
  45259. * @param scene defines the hosting scene
  45260. */
  45261. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  45262. /**
  45263. * Link current control with a target mesh
  45264. * @param mesh defines the mesh to link with
  45265. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  45266. */
  45267. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  45268. /** @hidden */
  45269. /** @hidden */
  45270. /** @hidden */
  45271. /** @hidden */
  45272. /** @hidden */
  45273. /** @hidden */
  45274. protected _transform(context: CanvasRenderingContext2D): void;
  45275. /** @hidden */
  45276. protected _applyStates(context: CanvasRenderingContext2D): void;
  45277. /** @hidden */
  45278. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  45279. /** @hidden */
  45280. protected _clip(context: CanvasRenderingContext2D): void;
  45281. /** @hidden */
  45282. /** @hidden */
  45283. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  45284. /** @hidden */
  45285. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  45286. /** @hidden */
  45287. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  45288. /** @hidden */
  45289. /**
  45290. * Tests if a given coordinates belong to the current control
  45291. * @param x defines x coordinate to test
  45292. * @param y defines y coordinate to test
  45293. * @returns true if the coordinates are inside the control
  45294. */
  45295. contains(x: number, y: number): boolean;
  45296. /** @hidden */
  45297. /** @hidden */
  45298. /** @hidden */
  45299. /** @hidden */
  45300. /** @hidden */
  45301. /** @hidden */
  45302. /** @hidden */
  45303. /** @hidden */
  45304. /** Releases associated resources */
  45305. dispose(): void;
  45306. /** HORIZONTAL_ALIGNMENT_LEFT */
  45307. static readonly HORIZONTAL_ALIGNMENT_LEFT: number;
  45308. /** HORIZONTAL_ALIGNMENT_RIGHT */
  45309. static readonly HORIZONTAL_ALIGNMENT_RIGHT: number;
  45310. /** HORIZONTAL_ALIGNMENT_CENTER */
  45311. static readonly HORIZONTAL_ALIGNMENT_CENTER: number;
  45312. /** VERTICAL_ALIGNMENT_TOP */
  45313. static readonly VERTICAL_ALIGNMENT_TOP: number;
  45314. /** VERTICAL_ALIGNMENT_BOTTOM */
  45315. static readonly VERTICAL_ALIGNMENT_BOTTOM: number;
  45316. /** VERTICAL_ALIGNMENT_CENTER */
  45317. static readonly VERTICAL_ALIGNMENT_CENTER: number;
  45318. /** @hidden */ private static _GetFontOffset(font: string): {
  45319. ascent: number;
  45320. height: number;
  45321. descent: number;
  45322. };
  45323. /**
  45324. * Creates a stack panel that can be used to render headers
  45325. * @param control defines the control to associate with the header
  45326. * @param text defines the text of the header
  45327. * @param size defines the size of the header
  45328. * @param options defines options used to configure the header
  45329. * @returns a new StackPanel
  45330. * @ignore
  45331. * @hidden
  45332. */
  45333. static AddHeader: (control: Control, text: string, size: string | number, options: {
  45334. isHorizontal: boolean;
  45335. controlFirst: boolean;
  45336. }) => any;
  45337. /** @hidden */
  45338. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  45339. }
  45340. }
  45341. declare module BABYLON.GUI {
  45342. /** Class used to create 2D ellipse containers */
  45343. export class Ellipse extends Container {
  45344. name?: string | undefined;
  45345. /** Gets or sets border thickness */
  45346. thickness: number;
  45347. /**
  45348. * Creates a new Ellipse
  45349. * @param name defines the control name
  45350. */
  45351. constructor(name?: string | undefined);
  45352. protected _getTypeName(): string;
  45353. protected _localDraw(context: CanvasRenderingContext2D): void;
  45354. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  45355. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  45356. }
  45357. }
  45358. declare module BABYLON.GUI {
  45359. /**
  45360. * Class used to create a 2D grid container
  45361. */
  45362. export class Grid extends Container {
  45363. name?: string | undefined;
  45364. /** Gets the list of children */
  45365. readonly children: Control[];
  45366. /**
  45367. * Adds a new row to the grid
  45368. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  45369. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  45370. * @returns the current grid
  45371. */
  45372. addRowDefinition(height: number, isPixel?: boolean): Grid;
  45373. /**
  45374. * Adds a new column to the grid
  45375. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  45376. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  45377. * @returns the current grid
  45378. */
  45379. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  45380. /**
  45381. * Update a row definition
  45382. * @param index defines the index of the row to update
  45383. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  45384. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  45385. * @returns the current grid
  45386. */
  45387. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  45388. /**
  45389. * Update a column definition
  45390. * @param index defines the index of the column to update
  45391. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  45392. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  45393. * @returns the current grid
  45394. */
  45395. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  45396. /**
  45397. * Remove a column definition at specified index
  45398. * @param index defines the index of the column to remove
  45399. * @returns the current grid
  45400. */
  45401. removeColumnDefinition(index: number): Grid;
  45402. /**
  45403. * Remove a row definition at specified index
  45404. * @param index defines the index of the row to remove
  45405. * @returns the current grid
  45406. */
  45407. removeRowDefinition(index: number): Grid;
  45408. /**
  45409. * Adds a new control to the current grid
  45410. * @param control defines the control to add
  45411. * @param row defines the row where to add the control (0 by default)
  45412. * @param column defines the column where to add the control (0 by default)
  45413. * @returns the current grid
  45414. */
  45415. addControl(control: Control, row?: number, column?: number): Grid;
  45416. /**
  45417. * Removes a control from the current container
  45418. * @param control defines the control to remove
  45419. * @returns the current container
  45420. */
  45421. removeControl(control: Control): Container;
  45422. /**
  45423. * Creates a new Grid
  45424. * @param name defines control name
  45425. */
  45426. constructor(name?: string | undefined);
  45427. protected _getTypeName(): string;
  45428. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  45429. /** Releases associated resources */
  45430. dispose(): void;
  45431. }
  45432. }
  45433. declare module BABYLON.GUI {
  45434. /**
  45435. * Class used to create 2D images
  45436. */
  45437. export class Image extends Control {
  45438. name?: string | undefined;
  45439. /**
  45440. * Gets or sets the left coordinate in the source image
  45441. */
  45442. sourceLeft: number;
  45443. /**
  45444. * Gets or sets the top coordinate in the source image
  45445. */
  45446. sourceTop: number;
  45447. /**
  45448. * Gets or sets the width to capture in the source image
  45449. */
  45450. sourceWidth: number;
  45451. /**
  45452. * Gets or sets the height to capture in the source image
  45453. */
  45454. sourceHeight: number;
  45455. /**
  45456. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  45457. * @see http://doc.babylonjs.com/how_to/gui#image
  45458. */
  45459. autoScale: boolean;
  45460. /** Gets or sets the streching mode used by the image */
  45461. stretch: number;
  45462. /**
  45463. * Gets or sets the internal DOM image used to render the control
  45464. */
  45465. domImage: HTMLImageElement;
  45466. /**
  45467. * Gets or sets image source url
  45468. */
  45469. source: BABYLON.Nullable<string>;
  45470. /**
  45471. * Gets or sets the cell width to use when animation sheet is enabled
  45472. * @see http://doc.babylonjs.com/how_to/gui#image
  45473. */
  45474. cellWidth: number;
  45475. /**
  45476. * Gets or sets the cell height to use when animation sheet is enabled
  45477. * @see http://doc.babylonjs.com/how_to/gui#image
  45478. */
  45479. cellHeight: number;
  45480. /**
  45481. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  45482. * @see http://doc.babylonjs.com/how_to/gui#image
  45483. */
  45484. cellId: number;
  45485. /**
  45486. * Creates a new Image
  45487. * @param name defines the control name
  45488. * @param url defines the image url
  45489. */
  45490. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  45491. protected _getTypeName(): string;
  45492. /** Force the control to synchronize with its content */
  45493. synchronizeSizeWithContent(): void;
  45494. /** STRETCH_NONE */
  45495. static readonly STRETCH_NONE: number;
  45496. /** STRETCH_FILL */
  45497. static readonly STRETCH_FILL: number;
  45498. /** STRETCH_UNIFORM */
  45499. static readonly STRETCH_UNIFORM: number;
  45500. /** STRETCH_EXTEND */
  45501. static readonly STRETCH_EXTEND: number;
  45502. }
  45503. }
  45504. declare module BABYLON.GUI {
  45505. /**
  45506. * Class used to create input text control
  45507. */
  45508. export class InputText extends Control implements IFocusableControl {
  45509. name?: string | undefined;
  45510. /** @hidden */
  45511. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  45512. promptMessage: string;
  45513. /** BABYLON.Observable raised when the text changes */
  45514. onTextChangedObservable: BABYLON.Observable<InputText>;
  45515. /** BABYLON.Observable raised just before an entered character is to be added */
  45516. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  45517. /** BABYLON.Observable raised when the control gets the focus */
  45518. onFocusObservable: BABYLON.Observable<InputText>;
  45519. /** BABYLON.Observable raised when the control loses the focus */
  45520. onBlurObservable: BABYLON.Observable<InputText>;
  45521. /** Gets or sets the maximum width allowed by the control */
  45522. maxWidth: string | number;
  45523. /** Gets the maximum width allowed by the control in pixels */
  45524. readonly maxWidthInPixels: number;
  45525. /** Gets or sets control margin */
  45526. margin: string;
  45527. /** Gets control margin in pixels */
  45528. readonly marginInPixels: number;
  45529. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  45530. autoStretchWidth: boolean;
  45531. /** Gets or sets border thickness */
  45532. thickness: number;
  45533. /** Gets or sets the background color when focused */
  45534. focusedBackground: string;
  45535. /** Gets or sets the background color */
  45536. background: string;
  45537. /** Gets or sets the placeholder color */
  45538. placeholderColor: string;
  45539. /** Gets or sets the text displayed when the control is empty */
  45540. placeholderText: string;
  45541. /** Gets or sets the dead key flag */
  45542. deadKey: boolean;
  45543. /** Gets or sets if the current key should be added */
  45544. addKey: boolean;
  45545. /** Gets or sets the value of the current key being entered */
  45546. currentKey: string;
  45547. /** Gets or sets the text displayed in the control */
  45548. text: string;
  45549. /** Gets or sets control width */
  45550. width: string | number;
  45551. /**
  45552. * Creates a new InputText
  45553. * @param name defines the control name
  45554. * @param text defines the text of the control
  45555. */
  45556. constructor(name?: string | undefined, text?: string);
  45557. /** @hidden */
  45558. onBlur(): void;
  45559. /** @hidden */
  45560. onFocus(): void;
  45561. protected _getTypeName(): string;
  45562. /**
  45563. * Function called to get the list of controls that should not steal the focus from this control
  45564. * @returns an array of controls
  45565. */
  45566. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  45567. /** @hidden */
  45568. processKey(keyCode: number, key?: string): void;
  45569. /** @hidden */
  45570. processKeyboard(evt: KeyboardEvent): void;
  45571. protected _beforeRenderText(text: string): string;
  45572. dispose(): void;
  45573. }
  45574. }
  45575. declare module BABYLON.GUI {
  45576. /**
  45577. * Class used to create a password control
  45578. */
  45579. export class InputPassword extends InputText {
  45580. protected _beforeRenderText(text: string): string;
  45581. }
  45582. }
  45583. declare module BABYLON.GUI {
  45584. /** Class used to render 2D lines */
  45585. export class Line extends Control {
  45586. name?: string | undefined;
  45587. /** Gets or sets the dash pattern */
  45588. dash: Array<number>;
  45589. /** Gets or sets the control connected with the line end */
  45590. connectedControl: Control;
  45591. /** Gets or sets start coordinates on X axis */
  45592. x1: string | number;
  45593. /** Gets or sets start coordinates on Y axis */
  45594. y1: string | number;
  45595. /** Gets or sets end coordinates on X axis */
  45596. x2: string | number;
  45597. /** Gets or sets end coordinates on Y axis */
  45598. y2: string | number;
  45599. /** Gets or sets line width */
  45600. lineWidth: number;
  45601. /** Gets or sets horizontal alignment */
  45602. horizontalAlignment: number;
  45603. /** Gets or sets vertical alignment */
  45604. verticalAlignment: number;
  45605. /**
  45606. * Creates a new Line
  45607. * @param name defines the control name
  45608. */
  45609. constructor(name?: string | undefined);
  45610. protected _getTypeName(): string;
  45611. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  45612. /**
  45613. * Move one end of the line given 3D cartesian coordinates.
  45614. * @param position Targeted world position
  45615. * @param scene BABYLON.Scene
  45616. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  45617. */
  45618. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  45619. /**
  45620. * Move one end of the line to a position in screen absolute space.
  45621. * @param projectedPosition Position in screen absolute space (X, Y)
  45622. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  45623. */
  45624. }
  45625. }
  45626. declare module BABYLON.GUI {
  45627. /**
  45628. * Class used to create multi line control
  45629. */
  45630. export class MultiLine extends Control {
  45631. name?: string | undefined;
  45632. /**
  45633. * Creates a new MultiLine
  45634. * @param name defines the control name
  45635. */
  45636. constructor(name?: string | undefined);
  45637. /** Gets or sets dash pattern */
  45638. dash: Array<number>;
  45639. /**
  45640. * Gets point stored at specified index
  45641. * @param index defines the index to look for
  45642. * @returns the requested point if found
  45643. */
  45644. getAt(index: number): MultiLinePoint;
  45645. /** Function called when a point is updated */
  45646. onPointUpdate: () => void;
  45647. /**
  45648. * Adds new points to the point collection
  45649. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  45650. * @returns the list of created MultiLinePoint
  45651. */
  45652. add(...items: (AbstractMesh | Control | {
  45653. x: string | number;
  45654. y: string | number;
  45655. })[]): MultiLinePoint[];
  45656. /**
  45657. * Adds a new point to the point collection
  45658. * @param item defines the item (mesh, control or 2d coordiantes) to add
  45659. * @returns the created MultiLinePoint
  45660. */
  45661. push(item?: (AbstractMesh | Control | {
  45662. x: string | number;
  45663. y: string | number;
  45664. })): MultiLinePoint;
  45665. /**
  45666. * Remove a specific value or point from the active point collection
  45667. * @param value defines the value or point to remove
  45668. */
  45669. remove(value: number | MultiLinePoint): void;
  45670. /** Gets or sets line width */
  45671. lineWidth: number;
  45672. horizontalAlignment: number;
  45673. verticalAlignment: number;
  45674. protected _getTypeName(): string;
  45675. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  45676. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  45677. dispose(): void;
  45678. }
  45679. }
  45680. declare module BABYLON.GUI {
  45681. /**
  45682. * Class used to create radio button controls
  45683. */
  45684. export class RadioButton extends Control {
  45685. name?: string | undefined;
  45686. /** Gets or sets border thickness */
  45687. thickness: number;
  45688. /** Gets or sets group name */
  45689. group: string;
  45690. /** BABYLON.Observable raised when isChecked is changed */
  45691. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  45692. /** Gets or sets a value indicating the ratio between overall size and check size */
  45693. checkSizeRatio: number;
  45694. /** Gets or sets background color */
  45695. background: string;
  45696. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  45697. isChecked: boolean;
  45698. /**
  45699. * Creates a new RadioButton
  45700. * @param name defines the control name
  45701. */
  45702. constructor(name?: string | undefined);
  45703. protected _getTypeName(): string;
  45704. /**
  45705. * Utility function to easily create a radio button with a header
  45706. * @param title defines the label to use for the header
  45707. * @param group defines the group to use for the radio button
  45708. * @param isChecked defines the initial state of the radio button
  45709. * @param onValueChanged defines the callback to call when value changes
  45710. * @returns a StackPanel containing the radio button and a textBlock
  45711. */
  45712. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  45713. }
  45714. }
  45715. declare module BABYLON.GUI {
  45716. /**
  45717. * Class used to create a 2D stack panel container
  45718. */
  45719. export class StackPanel extends Container {
  45720. name?: string | undefined;
  45721. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  45722. isVertical: boolean;
  45723. /** Gets or sets panel width */
  45724. width: string | number;
  45725. /** Gets or sets panel height */
  45726. height: string | number;
  45727. /**
  45728. * Creates a new StackPanel
  45729. * @param name defines control name
  45730. */
  45731. constructor(name?: string | undefined);
  45732. protected _getTypeName(): string;
  45733. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  45734. }
  45735. }
  45736. declare module BABYLON.GUI {
  45737. /** Class used to create a RadioGroup
  45738. * which contains groups of radio buttons
  45739. */
  45740. export class SelectorGroup {
  45741. /** name of SelectorGroup */
  45742. name: string;
  45743. /**
  45744. * Creates a new SelectorGroup
  45745. * @param name of group, used as a group heading
  45746. */
  45747. constructor(
  45748. /** name of SelectorGroup */
  45749. name: string);
  45750. /** Gets the groupPanel of the SelectorGroup */
  45751. readonly groupPanel: StackPanel;
  45752. /** Gets the selectors array */
  45753. readonly selectors: StackPanel[];
  45754. /** Gets and sets the group header */
  45755. header: string;
  45756. /** @hidden*/
  45757. /** Removes the selector at the given position
  45758. * @param selectorNb the position of the selector within the group
  45759. */
  45760. removeSelector(selectorNb: number): void;
  45761. }
  45762. /** Class used to create a CheckboxGroup
  45763. * which contains groups of checkbox buttons
  45764. */
  45765. export class CheckboxGroup extends SelectorGroup {
  45766. /** Adds a checkbox as a control
  45767. * @param text is the label for the selector
  45768. * @param func is the function called when the Selector is checked
  45769. * @param checked is true when Selector is checked
  45770. */
  45771. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  45772. /** @hidden */
  45773. /** @hidden */
  45774. /** @hidden */
  45775. /** @hidden */
  45776. }
  45777. /** Class used to create a RadioGroup
  45778. * which contains groups of radio buttons
  45779. */
  45780. export class RadioGroup extends SelectorGroup {
  45781. /** Adds a radio button as a control
  45782. * @param label is the label for the selector
  45783. * @param func is the function called when the Selector is checked
  45784. * @param checked is true when Selector is checked
  45785. */
  45786. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  45787. /** @hidden */
  45788. /** @hidden */
  45789. /** @hidden */
  45790. /** @hidden */
  45791. }
  45792. /** Class used to create a SliderGroup
  45793. * which contains groups of slider buttons
  45794. */
  45795. export class SliderGroup extends SelectorGroup {
  45796. /**
  45797. * Adds a slider to the SelectorGroup
  45798. * @param label is the label for the SliderBar
  45799. * @param func is the function called when the Slider moves
  45800. * @param unit is a string describing the units used, eg degrees or metres
  45801. * @param min is the minimum value for the Slider
  45802. * @param max is the maximum value for the Slider
  45803. * @param value is the start value for the Slider between min and max
  45804. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  45805. */
  45806. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  45807. /** @hidden */
  45808. /** @hidden */
  45809. /** @hidden */
  45810. /** @hidden */
  45811. }
  45812. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  45813. * @see http://doc.babylonjs.com/how_to/selector
  45814. */
  45815. export class SelectionPanel extends Rectangle {
  45816. /** name of SelectionPanel */
  45817. name: string;
  45818. /** an array of SelectionGroups */
  45819. groups: SelectorGroup[];
  45820. /**
  45821. * Creates a new SelectionPanel
  45822. * @param name of SelectionPanel
  45823. * @param groups is an array of SelectionGroups
  45824. */
  45825. constructor(
  45826. /** name of SelectionPanel */
  45827. name: string,
  45828. /** an array of SelectionGroups */
  45829. groups?: SelectorGroup[]);
  45830. protected _getTypeName(): string;
  45831. /** Gets or sets the headerColor */
  45832. headerColor: string;
  45833. /** Gets or sets the button color */
  45834. buttonColor: string;
  45835. /** Gets or sets the label color */
  45836. labelColor: string;
  45837. /** Gets or sets the button background */
  45838. buttonBackground: string;
  45839. /** Gets or sets the color of separator bar */
  45840. barColor: string;
  45841. /** Gets or sets the height of separator bar */
  45842. barHeight: string;
  45843. /** Gets or sets the height of spacers*/
  45844. spacerHeight: string;
  45845. /** Add a group to the selection panel
  45846. * @param group is the selector group to add
  45847. */
  45848. addGroup(group: SelectorGroup): void;
  45849. /** Remove the group from the given position
  45850. * @param groupNb is the position of the group in the list
  45851. */
  45852. removeGroup(groupNb: number): void;
  45853. /** Change a group header label
  45854. * @param label is the new group header label
  45855. * @param groupNb is the number of the group to relabel
  45856. * */
  45857. setHeaderName(label: string, groupNb: number): void;
  45858. /** Change selector label to the one given
  45859. * @param label is the new selector label
  45860. * @param groupNb is the number of the groupcontaining the selector
  45861. * @param selectorNb is the number of the selector within a group to relabel
  45862. * */
  45863. relabel(label: string, groupNb: number, selectorNb: number): void;
  45864. /** For a given group position remove the selector at the given position
  45865. * @param groupNb is the number of the group to remove the selector from
  45866. * @param selectorNb is the number of the selector within the group
  45867. */
  45868. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  45869. /** For a given group position of correct type add a checkbox button
  45870. * @param groupNb is the number of the group to remove the selector from
  45871. * @param label is the label for the selector
  45872. * @param func is the function called when the Selector is checked
  45873. * @param checked is true when Selector is checked
  45874. */
  45875. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  45876. /** For a given group position of correct type add a radio button
  45877. * @param groupNb is the number of the group to remove the selector from
  45878. * @param label is the label for the selector
  45879. * @param func is the function called when the Selector is checked
  45880. * @param checked is true when Selector is checked
  45881. */
  45882. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  45883. /**
  45884. * For a given slider group add a slider
  45885. * @param groupNb is the number of the group to add the slider to
  45886. * @param label is the label for the Slider
  45887. * @param func is the function called when the Slider moves
  45888. * @param unit is a string describing the units used, eg degrees or metres
  45889. * @param min is the minimum value for the Slider
  45890. * @param max is the maximum value for the Slider
  45891. * @param value is the start value for the Slider between min and max
  45892. * @param onVal is the function used to format the value displayed, eg radians to degrees
  45893. */
  45894. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  45895. }
  45896. }
  45897. declare module BABYLON.GUI {
  45898. /**
  45899. * Enum that determines the text-wrapping mode to use.
  45900. */
  45901. export enum TextWrapping {
  45902. /**
  45903. * Clip the text when it's larger than Control.width; this is the default mode.
  45904. */
  45905. Clip = 0,
  45906. /**
  45907. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  45908. */
  45909. WordWrap = 1,
  45910. /**
  45911. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  45912. */
  45913. Ellipsis = 2
  45914. }
  45915. /**
  45916. * Class used to create text block control
  45917. */
  45918. export class TextBlock extends Control {
  45919. /**
  45920. * Defines the name of the control
  45921. */
  45922. name?: string | undefined;
  45923. /**
  45924. * An event triggered after the text is changed
  45925. */
  45926. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  45927. /**
  45928. * An event triggered after the text was broken up into lines
  45929. */
  45930. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  45931. /**
  45932. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  45933. */
  45934. readonly lines: any[];
  45935. /**
  45936. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  45937. */
  45938. resizeToFit: boolean;
  45939. /**
  45940. * Gets or sets a boolean indicating if text must be wrapped
  45941. */
  45942. textWrapping: TextWrapping | boolean;
  45943. /**
  45944. * Gets or sets text to display
  45945. */
  45946. text: string;
  45947. /**
  45948. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  45949. */
  45950. textHorizontalAlignment: number;
  45951. /**
  45952. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  45953. */
  45954. textVerticalAlignment: number;
  45955. /**
  45956. * Gets or sets line spacing value
  45957. */
  45958. lineSpacing: string | number;
  45959. /**
  45960. * Gets or sets outlineWidth of the text to display
  45961. */
  45962. outlineWidth: number;
  45963. /**
  45964. * Gets or sets outlineColor of the text to display
  45965. */
  45966. outlineColor: string;
  45967. /**
  45968. * Creates a new TextBlock object
  45969. * @param name defines the name of the control
  45970. * @param text defines the text to display (emptry string by default)
  45971. */
  45972. constructor(
  45973. /**
  45974. * Defines the name of the control
  45975. */
  45976. name?: string | undefined, text?: string);
  45977. protected _getTypeName(): string;
  45978. /** @hidden */
  45979. protected _applyStates(context: CanvasRenderingContext2D): void;
  45980. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  45981. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  45982. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  45983. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  45984. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  45985. protected _renderLines(context: CanvasRenderingContext2D): void;
  45986. /**
  45987. * Given a width constraint applied on the text block, find the expected height
  45988. * @returns expected height
  45989. */
  45990. computeExpectedHeight(): number;
  45991. dispose(): void;
  45992. }
  45993. }
  45994. declare module BABYLON.GUI {
  45995. /**
  45996. * Class used to store key control properties
  45997. */
  45998. export class KeyPropertySet {
  45999. /** Width */
  46000. width?: string;
  46001. /** Height */
  46002. height?: string;
  46003. /** Left padding */
  46004. paddingLeft?: string;
  46005. /** Right padding */
  46006. paddingRight?: string;
  46007. /** Top padding */
  46008. paddingTop?: string;
  46009. /** Bottom padding */
  46010. paddingBottom?: string;
  46011. /** Foreground color */
  46012. color?: string;
  46013. /** Background color */
  46014. background?: string;
  46015. }
  46016. /**
  46017. * Class used to create virtual keyboard
  46018. */
  46019. export class VirtualKeyboard extends StackPanel {
  46020. /** BABYLON.Observable raised when a key is pressed */
  46021. onKeyPressObservable: BABYLON.Observable<string>;
  46022. /** Gets or sets default key button width */
  46023. defaultButtonWidth: string;
  46024. /** Gets or sets default key button height */
  46025. defaultButtonHeight: string;
  46026. /** Gets or sets default key button left padding */
  46027. defaultButtonPaddingLeft: string;
  46028. /** Gets or sets default key button right padding */
  46029. defaultButtonPaddingRight: string;
  46030. /** Gets or sets default key button top padding */
  46031. defaultButtonPaddingTop: string;
  46032. /** Gets or sets default key button bottom padding */
  46033. defaultButtonPaddingBottom: string;
  46034. /** Gets or sets default key button foreground color */
  46035. defaultButtonColor: string;
  46036. /** Gets or sets default key button background color */
  46037. defaultButtonBackground: string;
  46038. /** Gets or sets shift button foreground color */
  46039. shiftButtonColor: string;
  46040. /** Gets or sets shift button thickness*/
  46041. selectedShiftThickness: number;
  46042. /** Gets shift key state */
  46043. shiftState: number;
  46044. protected _getTypeName(): string;
  46045. /**
  46046. * Adds a new row of keys
  46047. * @param keys defines the list of keys to add
  46048. * @param propertySets defines the associated property sets
  46049. */
  46050. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  46051. /**
  46052. * Set the shift key to a specific state
  46053. * @param shiftState defines the new shift state
  46054. */
  46055. applyShiftState(shiftState: number): void;
  46056. /** Gets the input text control currently attached to the keyboard */
  46057. readonly connectedInputText: BABYLON.Nullable<InputText>;
  46058. /**
  46059. * Connects the keyboard with an input text control
  46060. *
  46061. * @param input defines the target control
  46062. */
  46063. connect(input: InputText): void;
  46064. /**
  46065. * Disconnects the keyboard from connected InputText controls
  46066. *
  46067. * @param input optionally defines a target control, otherwise all are disconnected
  46068. */
  46069. disconnect(input?: InputText): void;
  46070. /**
  46071. * Release all resources
  46072. */
  46073. dispose(): void;
  46074. /**
  46075. * Creates a new keyboard using a default layout
  46076. *
  46077. * @param name defines control name
  46078. * @returns a new VirtualKeyboard
  46079. */
  46080. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  46081. }
  46082. }
  46083. declare module BABYLON.GUI {
  46084. /**
  46085. * Class used to create slider controls
  46086. */
  46087. export class Slider extends Control {
  46088. name?: string | undefined;
  46089. /** BABYLON.Observable raised when the sldier value changes */
  46090. onValueChangedObservable: BABYLON.Observable<number>;
  46091. /** Gets or sets border color */
  46092. borderColor: string;
  46093. /** Gets or sets background color */
  46094. background: string;
  46095. /** Gets or sets main bar offset */
  46096. barOffset: string | number;
  46097. /** Gets main bar offset in pixels*/
  46098. readonly barOffsetInPixels: number;
  46099. /** Gets or sets thumb width */
  46100. thumbWidth: string | number;
  46101. /** Gets thumb width in pixels */
  46102. readonly thumbWidthInPixels: number;
  46103. /** Gets or sets minimum value */
  46104. minimum: number;
  46105. /** Gets or sets maximum value */
  46106. maximum: number;
  46107. /** Gets or sets current value */
  46108. value: number;
  46109. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  46110. isVertical: boolean;
  46111. /** Gets or sets a boolean indicating if the thumb should be round or square */
  46112. isThumbCircle: boolean;
  46113. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  46114. isThumbClamped: boolean;
  46115. /**
  46116. * Creates a new Slider
  46117. * @param name defines the control name
  46118. */
  46119. constructor(name?: string | undefined);
  46120. protected _getTypeName(): string;
  46121. protected _getThumbThickness(type: string, backgroundLength: number): number;
  46122. }
  46123. }
  46124. declare module BABYLON.GUI {
  46125. /** Class used to create rectangle container */
  46126. export class Rectangle extends Container {
  46127. name?: string | undefined;
  46128. /** Gets or sets border thickness */
  46129. thickness: number;
  46130. /** Gets or sets the corner radius angle */
  46131. cornerRadius: number;
  46132. /**
  46133. * Creates a new Rectangle
  46134. * @param name defines the control name
  46135. */
  46136. constructor(name?: string | undefined);
  46137. protected _getTypeName(): string;
  46138. protected _localDraw(context: CanvasRenderingContext2D): void;
  46139. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  46140. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  46141. }
  46142. }
  46143. declare module BABYLON.GUI {
  46144. /** Class used to render a grid */
  46145. export class DisplayGrid extends Control {
  46146. name?: string | undefined;
  46147. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  46148. displayMinorLines: boolean;
  46149. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  46150. displayMajorLines: boolean;
  46151. /** Gets or sets background color (Black by default) */
  46152. background: string;
  46153. /** Gets or sets the width of each cell (20 by default) */
  46154. cellWidth: number;
  46155. /** Gets or sets the height of each cell (20 by default) */
  46156. cellHeight: number;
  46157. /** Gets or sets the tickness of minor lines (1 by default) */
  46158. minorLineTickness: number;
  46159. /** Gets or sets the color of minor lines (DarkGray by default) */
  46160. minorLineColor: string;
  46161. /** Gets or sets the tickness of major lines (2 by default) */
  46162. majorLineTickness: number;
  46163. /** Gets or sets the color of major lines (White by default) */
  46164. majorLineColor: string;
  46165. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  46166. majorLineFrequency: number;
  46167. /**
  46168. * Creates a new GridDisplayRectangle
  46169. * @param name defines the control name
  46170. */
  46171. constructor(name?: string | undefined);
  46172. protected _getTypeName(): string;
  46173. }
  46174. }
  46175. declare module BABYLON.GUI {
  46176. /**
  46177. * Forcing an export so that this code will execute
  46178. * @hidden
  46179. */
  46180. const name = "Statics";
  46181. }
  46182. declare module BABYLON.GUI {
  46183. /**
  46184. * Class used as a root to all buttons
  46185. */
  46186. export class AbstractButton3D extends Control3D {
  46187. /**
  46188. * Creates a new button
  46189. * @param name defines the control name
  46190. */
  46191. constructor(name?: string);
  46192. protected _getTypeName(): string;
  46193. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  46194. }
  46195. }
  46196. declare module BABYLON.GUI {
  46197. /**
  46198. * Class used to create a button in 3D
  46199. */
  46200. export class Button3D extends AbstractButton3D {
  46201. /** @hidden */
  46202. protected _currentMaterial: BABYLON.Material;
  46203. /**
  46204. * Gets or sets the texture resolution used to render content (512 by default)
  46205. */
  46206. contentResolution: BABYLON.int;
  46207. /**
  46208. * Gets or sets the texture scale ratio used to render content (2 by default)
  46209. */
  46210. contentScaleRatio: number;
  46211. protected _disposeFacadeTexture(): void;
  46212. protected _resetContent(): void;
  46213. /**
  46214. * Creates a new button
  46215. * @param name defines the control name
  46216. */
  46217. constructor(name?: string);
  46218. /**
  46219. * Gets or sets the GUI 2D content used to display the button's facade
  46220. */
  46221. content: Control;
  46222. /**
  46223. * Apply the facade texture (created from the content property).
  46224. * This function can be overloaded by child classes
  46225. * @param facadeTexture defines the AdvancedDynamicTexture to use
  46226. */
  46227. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  46228. protected _getTypeName(): string;
  46229. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  46230. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  46231. /**
  46232. * Releases all associated resources
  46233. */
  46234. dispose(): void;
  46235. }
  46236. }
  46237. declare module BABYLON.GUI {
  46238. /**
  46239. * Class used to create containers for controls
  46240. */
  46241. export class Container3D extends Control3D {
  46242. /**
  46243. * Gets the list of child controls
  46244. */
  46245. protected _children: Control3D[];
  46246. /**
  46247. * Gets the list of child controls
  46248. */
  46249. readonly children: Array<Control3D>;
  46250. /**
  46251. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  46252. * This is helpful to optimize layout operation when adding multiple children in a row
  46253. */
  46254. blockLayout: boolean;
  46255. /**
  46256. * Creates a new container
  46257. * @param name defines the container name
  46258. */
  46259. constructor(name?: string);
  46260. /**
  46261. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  46262. * @returns the current container
  46263. */
  46264. updateLayout(): Container3D;
  46265. /**
  46266. * Gets a boolean indicating if the given control is in the children of this control
  46267. * @param control defines the control to check
  46268. * @returns true if the control is in the child list
  46269. */
  46270. containsControl(control: Control3D): boolean;
  46271. /**
  46272. * Adds a control to the children of this control
  46273. * @param control defines the control to add
  46274. * @returns the current container
  46275. */
  46276. addControl(control: Control3D): Container3D;
  46277. /**
  46278. * This function will be called everytime a new control is added
  46279. */
  46280. protected _arrangeChildren(): void;
  46281. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  46282. /**
  46283. * Removes a control from the children of this control
  46284. * @param control defines the control to remove
  46285. * @returns the current container
  46286. */
  46287. removeControl(control: Control3D): Container3D;
  46288. protected _getTypeName(): string;
  46289. /**
  46290. * Releases all associated resources
  46291. */
  46292. dispose(): void;
  46293. /** Control rotation will remain unchanged */
  46294. static readonly UNSET_ORIENTATION: number;
  46295. /** Control will rotate to make it look at sphere central axis */
  46296. static readonly FACEORIGIN_ORIENTATION: number;
  46297. /** Control will rotate to make it look back at sphere central axis */
  46298. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  46299. /** Control will rotate to look at z axis (0, 0, 1) */
  46300. static readonly FACEFORWARD_ORIENTATION: number;
  46301. /** Control will rotate to look at negative z axis (0, 0, -1) */
  46302. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  46303. }
  46304. }
  46305. declare module BABYLON.GUI {
  46306. /**
  46307. * Class used as base class for controls
  46308. */
  46309. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  46310. /** Defines the control name */
  46311. name?: string | undefined;
  46312. /** @hidden */
  46313. /** Gets or sets the control position in world space */
  46314. position: BABYLON.Vector3;
  46315. /** Gets or sets the control scaling in world space */
  46316. scaling: BABYLON.Vector3;
  46317. /** Callback used to start pointer enter animation */
  46318. pointerEnterAnimation: () => void;
  46319. /** Callback used to start pointer out animation */
  46320. pointerOutAnimation: () => void;
  46321. /** Callback used to start pointer down animation */
  46322. pointerDownAnimation: () => void;
  46323. /** Callback used to start pointer up animation */
  46324. pointerUpAnimation: () => void;
  46325. /**
  46326. * An event triggered when the pointer move over the control
  46327. */
  46328. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  46329. /**
  46330. * An event triggered when the pointer move out of the control
  46331. */
  46332. onPointerOutObservable: BABYLON.Observable<Control3D>;
  46333. /**
  46334. * An event triggered when the pointer taps the control
  46335. */
  46336. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  46337. /**
  46338. * An event triggered when pointer is up
  46339. */
  46340. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  46341. /**
  46342. * An event triggered when a control is clicked on (with a mouse)
  46343. */
  46344. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  46345. /**
  46346. * An event triggered when pointer enters the control
  46347. */
  46348. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  46349. /**
  46350. * Gets or sets the parent container
  46351. */
  46352. parent: BABYLON.Nullable<Container3D>;
  46353. /**
  46354. * Gets the list of attached behaviors
  46355. * @see http://doc.babylonjs.com/features/behaviour
  46356. */
  46357. readonly behaviors: BABYLON.Behavior<Control3D>[];
  46358. /**
  46359. * Attach a behavior to the control
  46360. * @see http://doc.babylonjs.com/features/behaviour
  46361. * @param behavior defines the behavior to attach
  46362. * @returns the current control
  46363. */
  46364. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  46365. /**
  46366. * Remove an attached behavior
  46367. * @see http://doc.babylonjs.com/features/behaviour
  46368. * @param behavior defines the behavior to attach
  46369. * @returns the current control
  46370. */
  46371. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  46372. /**
  46373. * Gets an attached behavior by name
  46374. * @param name defines the name of the behavior to look for
  46375. * @see http://doc.babylonjs.com/features/behaviour
  46376. * @returns null if behavior was not found else the requested behavior
  46377. */
  46378. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  46379. /** Gets or sets a boolean indicating if the control is visible */
  46380. isVisible: boolean;
  46381. /**
  46382. * Creates a new control
  46383. * @param name defines the control name
  46384. */
  46385. constructor(
  46386. /** Defines the control name */
  46387. name?: string | undefined);
  46388. /**
  46389. * Gets a string representing the class name
  46390. */
  46391. readonly typeName: string;
  46392. protected _getTypeName(): string;
  46393. /**
  46394. * Gets the transform node used by this control
  46395. */
  46396. readonly node: BABYLON.Nullable<BABYLON.TransformNode>;
  46397. /**
  46398. * Gets the mesh used to render this control
  46399. */
  46400. readonly mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  46401. /**
  46402. * Link the control as child of the given node
  46403. * @param node defines the node to link to. Use null to unlink the control
  46404. * @returns the current control
  46405. */
  46406. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  46407. /** @hidden **/
  46408. /**
  46409. * Node creation.
  46410. * Can be overriden by children
  46411. * @param scene defines the scene where the node must be attached
  46412. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  46413. */
  46414. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  46415. /**
  46416. * Affect a material to the given mesh
  46417. * @param mesh defines the mesh which will represent the control
  46418. */
  46419. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  46420. /** @hidden */
  46421. /** @hidden */
  46422. /** @hidden */
  46423. /** @hidden */
  46424. /** @hidden */
  46425. /** @hidden */
  46426. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  46427. /** @hidden */
  46428. /** @hidden */
  46429. /**
  46430. * Releases all associated resources
  46431. */
  46432. dispose(): void;
  46433. }
  46434. }
  46435. declare module BABYLON.GUI {
  46436. /**
  46437. * Class used to create a container panel deployed on the surface of a cylinder
  46438. */
  46439. export class CylinderPanel extends VolumeBasedPanel {
  46440. /**
  46441. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  46442. */
  46443. radius: BABYLON.float;
  46444. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  46445. }
  46446. }
  46447. declare module BABYLON.GUI {
  46448. /**
  46449. * Class used to create a holographic button in 3D
  46450. */
  46451. export class HolographicButton extends Button3D {
  46452. /**
  46453. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  46454. */
  46455. tooltipText: BABYLON.Nullable<string>;
  46456. /**
  46457. * Gets or sets text for the button
  46458. */
  46459. text: string;
  46460. /**
  46461. * Gets or sets the image url for the button
  46462. */
  46463. imageUrl: string;
  46464. /**
  46465. * Gets the back material used by this button
  46466. */
  46467. readonly backMaterial: FluentMaterial;
  46468. /**
  46469. * Gets the front material used by this button
  46470. */
  46471. readonly frontMaterial: FluentMaterial;
  46472. /**
  46473. * Gets the plate material used by this button
  46474. */
  46475. readonly plateMaterial: BABYLON.StandardMaterial;
  46476. /**
  46477. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  46478. */
  46479. readonly shareMaterials: boolean;
  46480. /**
  46481. * Creates a new button
  46482. * @param name defines the control name
  46483. */
  46484. constructor(name?: string, shareMaterials?: boolean);
  46485. protected _getTypeName(): string;
  46486. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  46487. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  46488. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  46489. /**
  46490. * Releases all associated resources
  46491. */
  46492. dispose(): void;
  46493. }
  46494. }
  46495. declare module BABYLON.GUI {
  46496. /**
  46497. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  46498. */
  46499. export class MeshButton3D extends Button3D {
  46500. /** @hidden */
  46501. protected _currentMesh: BABYLON.Mesh;
  46502. /**
  46503. * Creates a new 3D button based on a mesh
  46504. * @param mesh mesh to become a 3D button
  46505. * @param name defines the control name
  46506. */
  46507. constructor(mesh: BABYLON.Mesh, name?: string);
  46508. protected _getTypeName(): string;
  46509. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  46510. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  46511. }
  46512. }
  46513. declare module BABYLON.GUI {
  46514. /**
  46515. * Class used to create a container panel deployed on the surface of a plane
  46516. */
  46517. export class PlanePanel extends VolumeBasedPanel {
  46518. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  46519. }
  46520. }
  46521. declare module BABYLON.GUI {
  46522. /**
  46523. * Class used to create a container panel where items get randomized planar mapping
  46524. */
  46525. export class ScatterPanel extends VolumeBasedPanel {
  46526. /**
  46527. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  46528. */
  46529. iteration: BABYLON.float;
  46530. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  46531. protected _finalProcessing(): void;
  46532. }
  46533. }
  46534. declare module BABYLON.GUI {
  46535. /**
  46536. * Class used to create a container panel deployed on the surface of a sphere
  46537. */
  46538. export class SpherePanel extends VolumeBasedPanel {
  46539. /**
  46540. * Gets or sets the radius of the sphere where to project controls (5 by default)
  46541. */
  46542. radius: BABYLON.float;
  46543. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  46544. }
  46545. }
  46546. declare module BABYLON.GUI {
  46547. /**
  46548. * Class used to create a stack panel in 3D on XY plane
  46549. */
  46550. export class StackPanel3D extends Container3D {
  46551. /**
  46552. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  46553. */
  46554. isVertical: boolean;
  46555. /**
  46556. * Gets or sets the distance between elements
  46557. */
  46558. margin: number;
  46559. /**
  46560. * Creates new StackPanel
  46561. * @param isVertical
  46562. */
  46563. constructor(isVertical?: boolean);
  46564. protected _arrangeChildren(): void;
  46565. }
  46566. }
  46567. declare module BABYLON.GUI {
  46568. /**
  46569. * Abstract class used to create a container panel deployed on the surface of a volume
  46570. */
  46571. export abstract class VolumeBasedPanel extends Container3D {
  46572. protected _cellWidth: number;
  46573. protected _cellHeight: number;
  46574. /**
  46575. * Gets or sets the distance between elements
  46576. */
  46577. margin: number;
  46578. /**
  46579. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  46580. * | Value | Type | Description |
  46581. * | ----- | ----------------------------------- | ----------- |
  46582. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  46583. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  46584. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  46585. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  46586. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  46587. */
  46588. orientation: number;
  46589. /**
  46590. * Gets or sets the number of columns requested (10 by default).
  46591. * The panel will automatically compute the number of rows based on number of child controls.
  46592. */
  46593. columns: BABYLON.int;
  46594. /**
  46595. * Gets or sets a the number of rows requested.
  46596. * The panel will automatically compute the number of columns based on number of child controls.
  46597. */
  46598. rows: BABYLON.int;
  46599. /**
  46600. * Creates new VolumeBasedPanel
  46601. */
  46602. constructor();
  46603. protected _arrangeChildren(): void;
  46604. /** Child classes must implement this function to provide correct control positioning */
  46605. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  46606. /** Child classes can implement this function to provide additional processing */
  46607. protected _finalProcessing(): void;
  46608. }
  46609. }
  46610. declare module BABYLON.GUI {
  46611. /** @hidden */
  46612. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  46613. INNERGLOW: boolean;
  46614. BORDER: boolean;
  46615. HOVERLIGHT: boolean;
  46616. TEXTURE: boolean;
  46617. constructor();
  46618. }
  46619. /**
  46620. * Class used to render controls with fluent desgin
  46621. */
  46622. export class FluentMaterial extends BABYLON.PushMaterial {
  46623. /**
  46624. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  46625. */
  46626. innerGlowColorIntensity: number;
  46627. /**
  46628. * Gets or sets the inner glow color (white by default)
  46629. */
  46630. innerGlowColor: BABYLON.Color3;
  46631. /**
  46632. * Gets or sets alpha value (default is 1.0)
  46633. */
  46634. alpha: number;
  46635. /**
  46636. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  46637. */
  46638. albedoColor: BABYLON.Color3;
  46639. /**
  46640. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  46641. */
  46642. renderBorders: boolean;
  46643. /**
  46644. * Gets or sets border width (default is 0.5)
  46645. */
  46646. borderWidth: number;
  46647. /**
  46648. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  46649. */
  46650. edgeSmoothingValue: number;
  46651. /**
  46652. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  46653. */
  46654. borderMinValue: number;
  46655. /**
  46656. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  46657. */
  46658. renderHoverLight: boolean;
  46659. /**
  46660. * Gets or sets the radius used to render the hover light (default is 1.0)
  46661. */
  46662. hoverRadius: number;
  46663. /**
  46664. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  46665. */
  46666. hoverColor: BABYLON.Color4;
  46667. /**
  46668. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  46669. */
  46670. hoverPosition: BABYLON.Vector3;
  46671. /** Gets or sets the texture to use for albedo color */
  46672. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  46673. /**
  46674. * Creates a new Fluent material
  46675. * @param name defines the name of the material
  46676. * @param scene defines the hosting scene
  46677. */
  46678. constructor(name: string, scene: BABYLON.Scene);
  46679. needAlphaBlending(): boolean;
  46680. needAlphaTesting(): boolean;
  46681. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  46682. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  46683. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  46684. getActiveTextures(): BABYLON.BaseTexture[];
  46685. hasTexture(texture: BABYLON.BaseTexture): boolean;
  46686. dispose(forceDisposeEffect?: boolean): void;
  46687. clone(name: string): FluentMaterial;
  46688. serialize(): any;
  46689. getClassName(): string;
  46690. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  46691. }
  46692. }
  46693. declare module BABYLON {
  46694. /**
  46695. * Mode that determines the coordinate system to use.
  46696. */
  46697. enum GLTFLoaderCoordinateSystemMode {
  46698. /**
  46699. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  46700. */
  46701. AUTO = 0,
  46702. /**
  46703. * Sets the useRightHandedSystem flag on the scene.
  46704. */
  46705. FORCE_RIGHT_HANDED = 1
  46706. }
  46707. /**
  46708. * Mode that determines what animations will start.
  46709. */
  46710. enum GLTFLoaderAnimationStartMode {
  46711. /**
  46712. * No animation will start.
  46713. */
  46714. NONE = 0,
  46715. /**
  46716. * The first animation will start.
  46717. */
  46718. FIRST = 1,
  46719. /**
  46720. * All animations will start.
  46721. */
  46722. ALL = 2
  46723. }
  46724. /**
  46725. * Interface that contains the data for the glTF asset.
  46726. */
  46727. interface IGLTFLoaderData {
  46728. /**
  46729. * Object that represents the glTF JSON.
  46730. */
  46731. json: Object;
  46732. /**
  46733. * The BIN chunk of a binary glTF.
  46734. */
  46735. bin: Nullable<ArrayBufferView>;
  46736. }
  46737. /**
  46738. * Interface for extending the loader.
  46739. */
  46740. interface IGLTFLoaderExtension {
  46741. /**
  46742. * The name of this extension.
  46743. */
  46744. readonly name: string;
  46745. /**
  46746. * Defines whether this extension is enabled.
  46747. */
  46748. enabled: boolean;
  46749. }
  46750. /**
  46751. * Loader state.
  46752. */
  46753. enum GLTFLoaderState {
  46754. /**
  46755. * The asset is loading.
  46756. */
  46757. LOADING = 0,
  46758. /**
  46759. * The asset is ready for rendering.
  46760. */
  46761. READY = 1,
  46762. /**
  46763. * The asset is completely loaded.
  46764. */
  46765. COMPLETE = 2
  46766. }
  46767. /** @hidden */
  46768. interface IGLTFLoader extends IDisposable {
  46769. readonly state: Nullable<GLTFLoaderState>;
  46770. importMeshAsync: (meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<{
  46771. meshes: AbstractMesh[];
  46772. particleSystems: IParticleSystem[];
  46773. skeletons: Skeleton[];
  46774. animationGroups: AnimationGroup[];
  46775. }>;
  46776. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  46777. }
  46778. /**
  46779. * File loader for loading glTF files into a scene.
  46780. */
  46781. class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  46782. /** @hidden */
  46783. private static _CreateGLTFLoaderV1: (parent: GLTFFileLoader) => IGLTFLoader;
  46784. /** @hidden */
  46785. private static _CreateGLTFLoaderV2: (parent: GLTFFileLoader) => IGLTFLoader;
  46786. /**
  46787. * Raised when the asset has been parsed
  46788. */
  46789. onParsedObservable: Observable<IGLTFLoaderData>;
  46790. private _onParsedObserver;
  46791. /**
  46792. * Raised when the asset has been parsed
  46793. */
  46794. onParsed: (loaderData: IGLTFLoaderData) => void;
  46795. /**
  46796. * 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.
  46797. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  46798. * Defaults to true.
  46799. * @hidden
  46800. */
  46801. static IncrementalLoading: boolean;
  46802. /**
  46803. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  46804. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  46805. * @hidden
  46806. */
  46807. static HomogeneousCoordinates: boolean;
  46808. /**
  46809. * The coordinate system mode. Defaults to AUTO.
  46810. */
  46811. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  46812. /**
  46813. * The animation start mode. Defaults to FIRST.
  46814. */
  46815. animationStartMode: GLTFLoaderAnimationStartMode;
  46816. /**
  46817. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  46818. */
  46819. compileMaterials: boolean;
  46820. /**
  46821. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  46822. */
  46823. useClipPlane: boolean;
  46824. /**
  46825. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  46826. */
  46827. compileShadowGenerators: boolean;
  46828. /**
  46829. * Defines if the Alpha blended materials are only applied as coverage.
  46830. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  46831. * If true, no extra effects are applied to transparent pixels.
  46832. */
  46833. transparencyAsCoverage: boolean;
  46834. /**
  46835. * Function called before loading a url referenced by the asset.
  46836. */
  46837. preprocessUrlAsync: (url: string) => Promise<string>;
  46838. /**
  46839. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  46840. */
  46841. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  46842. private _onMeshLoadedObserver;
  46843. /**
  46844. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  46845. */
  46846. onMeshLoaded: (mesh: AbstractMesh) => void;
  46847. /**
  46848. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  46849. */
  46850. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  46851. private _onTextureLoadedObserver;
  46852. /**
  46853. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  46854. */
  46855. onTextureLoaded: (texture: BaseTexture) => void;
  46856. /**
  46857. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  46858. */
  46859. readonly onMaterialLoadedObservable: Observable<Material>;
  46860. private _onMaterialLoadedObserver;
  46861. /**
  46862. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  46863. */
  46864. onMaterialLoaded: (material: Material) => void;
  46865. /**
  46866. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  46867. */
  46868. readonly onCameraLoadedObservable: Observable<Camera>;
  46869. private _onCameraLoadedObserver;
  46870. /**
  46871. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  46872. */
  46873. onCameraLoaded: (camera: Camera) => void;
  46874. /**
  46875. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  46876. * For assets with LODs, raised when all of the LODs are complete.
  46877. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  46878. */
  46879. readonly onCompleteObservable: Observable<void>;
  46880. private _onCompleteObserver;
  46881. /**
  46882. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  46883. * For assets with LODs, raised when all of the LODs are complete.
  46884. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  46885. */
  46886. onComplete: () => void;
  46887. /**
  46888. * Observable raised when an error occurs.
  46889. */
  46890. readonly onErrorObservable: Observable<any>;
  46891. private _onErrorObserver;
  46892. /**
  46893. * Callback raised when an error occurs.
  46894. */
  46895. onError: (reason: any) => void;
  46896. /**
  46897. * Observable raised after the loader is disposed.
  46898. */
  46899. readonly onDisposeObservable: Observable<void>;
  46900. private _onDisposeObserver;
  46901. /**
  46902. * Callback raised after the loader is disposed.
  46903. */
  46904. onDispose: () => void;
  46905. /**
  46906. * Observable raised after a loader extension is created.
  46907. * Set additional options for a loader extension in this event.
  46908. */
  46909. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  46910. private _onExtensionLoadedObserver;
  46911. /**
  46912. * Callback raised after a loader extension is created.
  46913. */
  46914. onExtensionLoaded: (extension: IGLTFLoaderExtension) => void;
  46915. /**
  46916. * Defines if the loader logging is enabled.
  46917. */
  46918. loggingEnabled: boolean;
  46919. /**
  46920. * Defines if the loader should capture performance counters.
  46921. */
  46922. capturePerformanceCounters: boolean;
  46923. /**
  46924. * Defines if the loader should validate the asset.
  46925. */
  46926. validate: boolean;
  46927. /**
  46928. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  46929. */
  46930. readonly onValidatedObservable: Observable<IGLTFValidationResults>;
  46931. private _onValidatedObserver;
  46932. /**
  46933. * Callback raised after a loader extension is created.
  46934. */
  46935. onValidated: (results: IGLTFValidationResults) => void;
  46936. private _loader;
  46937. /**
  46938. * Name of the loader ("gltf")
  46939. */
  46940. name: string;
  46941. /**
  46942. * Supported file extensions of the loader (.gltf, .glb)
  46943. */
  46944. extensions: ISceneLoaderPluginExtensions;
  46945. /**
  46946. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  46947. */
  46948. dispose(): void;
  46949. /** @hidden */
  46950. /**
  46951. * Imports one or more meshes from the loaded glTF data and adds them to the scene
  46952. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  46953. * @param scene the scene the meshes should be added to
  46954. * @param data the glTF data to load
  46955. * @param rootUrl root url to load from
  46956. * @param onProgress event that fires when loading progress has occured
  46957. * @param fileName Defines the name of the file to load
  46958. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  46959. */
  46960. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  46961. meshes: AbstractMesh[];
  46962. particleSystems: IParticleSystem[];
  46963. skeletons: Skeleton[];
  46964. animationGroups: AnimationGroup[];
  46965. }>;
  46966. /**
  46967. * Imports all objects from the loaded glTF data and adds them to the scene
  46968. * @param scene the scene the objects should be added to
  46969. * @param data the glTF data to load
  46970. * @param rootUrl root url to load from
  46971. * @param onProgress event that fires when loading progress has occured
  46972. * @param fileName Defines the name of the file to load
  46973. * @returns a promise which completes when objects have been loaded to the scene
  46974. */
  46975. loadAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  46976. /**
  46977. * Load into an asset container.
  46978. * @param scene The scene to load into
  46979. * @param data The data to import
  46980. * @param rootUrl The root url for scene and resources
  46981. * @param onProgress The callback when the load progresses
  46982. * @param fileName Defines the name of the file to load
  46983. * @returns The loaded asset container
  46984. */
  46985. loadAssetContainerAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  46986. /**
  46987. * If the data string can be loaded directly.
  46988. * @param data string contianing the file data
  46989. * @returns if the data can be loaded directly
  46990. */
  46991. canDirectLoad(data: string): boolean;
  46992. /**
  46993. * Rewrites a url by combining a root url and response url.
  46994. */
  46995. rewriteRootURL: (rootUrl: string, responseURL?: string) => string;
  46996. /**
  46997. * Instantiates a glTF file loader plugin.
  46998. * @returns the created plugin
  46999. */
  47000. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  47001. /**
  47002. * The loader state or null if the loader is not active.
  47003. */
  47004. readonly loaderState: Nullable<GLTFLoaderState>;
  47005. /**
  47006. * Returns a promise that resolves when the asset is completely loaded.
  47007. * @returns a promise that resolves when the asset is completely loaded.
  47008. */
  47009. whenCompleteAsync(): Promise<void>;
  47010. private _parseAsync;
  47011. private _validateAsync;
  47012. private _getLoader;
  47013. private _unpackBinary;
  47014. private _unpackBinaryV1;
  47015. private _unpackBinaryV2;
  47016. private static _parseVersion;
  47017. private static _compareVersion;
  47018. private static _decodeBufferToText;
  47019. private static readonly _logSpaces;
  47020. private _logIndentLevel;
  47021. private _loggingEnabled;
  47022. /** @hidden */
  47023. /** @hidden */
  47024. /** @hidden */
  47025. private _logEnabled;
  47026. private _logDisabled;
  47027. private _capturePerformanceCounters;
  47028. /** @hidden */
  47029. /** @hidden */
  47030. private _startPerformanceCounterEnabled;
  47031. private _startPerformanceCounterDisabled;
  47032. private _endPerformanceCounterEnabled;
  47033. private _endPerformanceCounterDisabled;
  47034. }
  47035. }
  47036. declare module BABYLON.GLTF2.Loader {
  47037. /**
  47038. * Loader interface with an index field.
  47039. */
  47040. interface IArrayItem {
  47041. /**
  47042. * The index of this item in the array.
  47043. */
  47044. index: number;
  47045. }
  47046. /**
  47047. * Loader interface with additional members.
  47048. */
  47049. interface IAccessor extends GLTF2.IAccessor, IArrayItem {
  47050. /** @hidden */
  47051. /** @hidden */
  47052. }
  47053. /**
  47054. * Loader interface with additional members.
  47055. */
  47056. interface IAnimationChannel extends GLTF2.IAnimationChannel, IArrayItem {
  47057. }
  47058. /** @hidden */
  47059. interface _IAnimationSamplerData {
  47060. input: Float32Array;
  47061. interpolation: AnimationSamplerInterpolation;
  47062. output: Float32Array;
  47063. }
  47064. /**
  47065. * Loader interface with additional members.
  47066. */
  47067. interface IAnimationSampler extends GLTF2.IAnimationSampler, IArrayItem {
  47068. /** @hidden */
  47069. }
  47070. /**
  47071. * Loader interface with additional members.
  47072. */
  47073. interface IAnimation extends GLTF2.IAnimation, IArrayItem {
  47074. channels: IAnimationChannel[];
  47075. samplers: IAnimationSampler[];
  47076. /** @hidden */
  47077. }
  47078. /**
  47079. * Loader interface with additional members.
  47080. */
  47081. interface IBuffer extends GLTF2.IBuffer, IArrayItem {
  47082. /** @hidden */
  47083. }
  47084. /**
  47085. * Loader interface with additional members.
  47086. */
  47087. interface IBufferView extends GLTF2.IBufferView, IArrayItem {
  47088. /** @hidden */
  47089. /** @hidden */
  47090. }
  47091. /**
  47092. * Loader interface with additional members.
  47093. */
  47094. interface ICamera extends GLTF2.ICamera, IArrayItem {
  47095. }
  47096. /**
  47097. * Loader interface with additional members.
  47098. */
  47099. interface IImage extends GLTF2.IImage, IArrayItem {
  47100. /** @hidden */
  47101. }
  47102. /**
  47103. * Loader interface with additional members.
  47104. */
  47105. interface IMaterialNormalTextureInfo extends GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  47106. }
  47107. /**
  47108. * Loader interface with additional members.
  47109. */
  47110. interface IMaterialOcclusionTextureInfo extends GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  47111. }
  47112. /**
  47113. * Loader interface with additional members.
  47114. */
  47115. interface IMaterialPbrMetallicRoughness extends GLTF2.IMaterialPbrMetallicRoughness {
  47116. baseColorTexture?: ITextureInfo;
  47117. metallicRoughnessTexture?: ITextureInfo;
  47118. }
  47119. /**
  47120. * Loader interface with additional members.
  47121. */
  47122. interface IMaterial extends GLTF2.IMaterial, IArrayItem {
  47123. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  47124. normalTexture?: IMaterialNormalTextureInfo;
  47125. occlusionTexture?: IMaterialOcclusionTextureInfo;
  47126. emissiveTexture?: ITextureInfo;
  47127. /** @hidden */
  47128. ;
  47129. };
  47130. }
  47131. /**
  47132. * Loader interface with additional members.
  47133. */
  47134. interface IMesh extends GLTF2.IMesh, IArrayItem {
  47135. primitives: IMeshPrimitive[];
  47136. }
  47137. /**
  47138. * Loader interface with additional members.
  47139. */
  47140. interface IMeshPrimitive extends GLTF2.IMeshPrimitive, IArrayItem {
  47141. }
  47142. /**
  47143. * Loader interface with additional members.
  47144. */
  47145. interface INode extends GLTF2.INode, IArrayItem {
  47146. /**
  47147. * The parent glTF node.
  47148. */
  47149. parent?: INode;
  47150. /** @hidden */
  47151. /** @hidden */
  47152. /** @hidden */
  47153. /** @hidden */
  47154. }
  47155. /** @hidden */
  47156. interface _ISamplerData {
  47157. noMipMaps: boolean;
  47158. samplingMode: number;
  47159. wrapU: number;
  47160. wrapV: number;
  47161. }
  47162. /**
  47163. * Loader interface with additional members.
  47164. */
  47165. interface ISampler extends GLTF2.ISampler, IArrayItem {
  47166. /** @hidden */
  47167. }
  47168. /**
  47169. * Loader interface with additional members.
  47170. */
  47171. interface IScene extends GLTF2.IScene, IArrayItem {
  47172. }
  47173. /**
  47174. * Loader interface with additional members.
  47175. */
  47176. interface ISkin extends GLTF2.ISkin, IArrayItem {
  47177. /** @hidden */
  47178. /** @hidden */
  47179. }
  47180. /**
  47181. * Loader interface with additional members.
  47182. */
  47183. interface ITexture extends GLTF2.ITexture, IArrayItem {
  47184. }
  47185. /**
  47186. * Loader interface with additional members.
  47187. */
  47188. interface ITextureInfo extends GLTF2.ITextureInfo {
  47189. }
  47190. /**
  47191. * Loader interface with additional members.
  47192. */
  47193. interface IGLTF extends GLTF2.IGLTF {
  47194. accessors?: IAccessor[];
  47195. animations?: IAnimation[];
  47196. buffers?: IBuffer[];
  47197. bufferViews?: IBufferView[];
  47198. cameras?: ICamera[];
  47199. images?: IImage[];
  47200. materials?: IMaterial[];
  47201. meshes?: IMesh[];
  47202. nodes?: INode[];
  47203. samplers?: ISampler[];
  47204. scenes?: IScene[];
  47205. skins?: ISkin[];
  47206. textures?: ITexture[];
  47207. }
  47208. }
  47209. /**
  47210. * Defines the module for importing and exporting glTF 2.0 assets
  47211. */
  47212. declare module BABYLON.GLTF2 {
  47213. /**
  47214. * Helper class for working with arrays when loading the glTF asset
  47215. */
  47216. class ArrayItem {
  47217. /**
  47218. * Gets an item from the given array.
  47219. * @param context The context when loading the asset
  47220. * @param array The array to get the item from
  47221. * @param index The index to the array
  47222. * @returns The array item
  47223. */
  47224. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  47225. /**
  47226. * Assign an `index` field to each item of the given array.
  47227. * @param array The array of items
  47228. */
  47229. static Assign(array?: Loader.IArrayItem[]): void;
  47230. }
  47231. /**
  47232. * The glTF 2.0 loader
  47233. */
  47234. class GLTFLoader implements IGLTFLoader {
  47235. /** The glTF object parsed from the JSON. */
  47236. gltf: Loader.IGLTF;
  47237. /** The Babylon scene when loading the asset. */
  47238. babylonScene: Scene;
  47239. /** @hidden */
  47240. private _disposed;
  47241. private _parent;
  47242. private _state;
  47243. private _extensions;
  47244. private _rootUrl;
  47245. private _fileName;
  47246. private _uniqueRootUrl;
  47247. private _rootBabylonMesh;
  47248. private _defaultBabylonMaterialData;
  47249. private _progressCallback?;
  47250. private _requests;
  47251. private static readonly _DefaultSampler;
  47252. private static _ExtensionNames;
  47253. private static _ExtensionFactories;
  47254. /**
  47255. * Registers a loader extension.
  47256. * @param name The name of the loader extension.
  47257. * @param factory The factory function that creates the loader extension.
  47258. */
  47259. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  47260. /**
  47261. * Unregisters a loader extension.
  47262. * @param name The name of the loader extenion.
  47263. * @returns A boolean indicating whether the extension has been unregistered
  47264. */
  47265. static UnregisterExtension(name: string): boolean;
  47266. /**
  47267. * Gets the loader state.
  47268. */
  47269. readonly state: Nullable<GLTFLoaderState>;
  47270. /** @hidden */
  47271. constructor(parent: GLTFFileLoader);
  47272. /** @hidden */
  47273. dispose(): void;
  47274. /** @hidden */
  47275. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  47276. meshes: AbstractMesh[];
  47277. particleSystems: IParticleSystem[];
  47278. skeletons: Skeleton[];
  47279. animationGroups: AnimationGroup[];
  47280. }>;
  47281. /** @hidden */
  47282. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  47283. private _loadAsync;
  47284. private _loadData;
  47285. private _setupData;
  47286. private _loadExtensions;
  47287. private _checkExtensions;
  47288. private _setState;
  47289. private _createRootNode;
  47290. /**
  47291. * Loads a glTF scene.
  47292. * @param context The context when loading the asset
  47293. * @param scene The glTF scene property
  47294. * @returns A promise that resolves when the load is complete
  47295. */
  47296. loadSceneAsync(context: string, scene: Loader.IScene): Promise<void>;
  47297. private _forEachPrimitive;
  47298. private _getMeshes;
  47299. private _getSkeletons;
  47300. private _getAnimationGroups;
  47301. private _startAnimations;
  47302. /**
  47303. * Loads a glTF node.
  47304. * @param context The context when loading the asset
  47305. * @param node The glTF node property
  47306. * @param assign A function called synchronously after parsing the glTF properties
  47307. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  47308. */
  47309. loadNodeAsync(context: string, node: Loader.INode, assign?: (babylonMesh: Mesh) => void): Promise<Mesh>;
  47310. private _loadMeshAsync;
  47311. private _loadMeshPrimitiveAsync;
  47312. private _loadVertexDataAsync;
  47313. private _createMorphTargets;
  47314. private _loadMorphTargetsAsync;
  47315. private _loadMorphTargetVertexDataAsync;
  47316. private static _LoadTransform;
  47317. private _loadSkinAsync;
  47318. private _loadBones;
  47319. private _loadBone;
  47320. private _loadSkinInverseBindMatricesDataAsync;
  47321. private _updateBoneMatrices;
  47322. private _getNodeMatrix;
  47323. /**
  47324. * Loads a glTF camera.
  47325. * @param context The context when loading the asset
  47326. * @param camera The glTF camera property
  47327. * @param assign A function called synchronously after parsing the glTF properties
  47328. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  47329. */
  47330. loadCameraAsync(context: string, camera: Loader.ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  47331. private _loadAnimationsAsync;
  47332. /**
  47333. * Loads a glTF animation.
  47334. * @param context The context when loading the asset
  47335. * @param animation The glTF animation property
  47336. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  47337. */
  47338. loadAnimationAsync(context: string, animation: Loader.IAnimation): Promise<AnimationGroup>;
  47339. private _loadAnimationChannelAsync;
  47340. private _loadAnimationSamplerAsync;
  47341. private _loadBufferAsync;
  47342. /**
  47343. * Loads a glTF buffer view.
  47344. * @param context The context when loading the asset
  47345. * @param bufferView The glTF buffer view property
  47346. * @returns A promise that resolves with the loaded data when the load is complete
  47347. */
  47348. loadBufferViewAsync(context: string, bufferView: Loader.IBufferView): Promise<ArrayBufferView>;
  47349. private _loadIndicesAccessorAsync;
  47350. private _loadFloatAccessorAsync;
  47351. private _loadVertexBufferViewAsync;
  47352. private _loadVertexAccessorAsync;
  47353. private _loadMaterialMetallicRoughnessPropertiesAsync;
  47354. /** @hidden */
  47355. private _createDefaultMaterial;
  47356. /**
  47357. * Creates a Babylon material from a glTF material.
  47358. * @param context The context when loading the asset
  47359. * @param material The glTF material property
  47360. * @param babylonDrawMode The draw mode for the Babylon material
  47361. * @returns The Babylon material
  47362. */
  47363. createMaterial(context: string, material: Loader.IMaterial, babylonDrawMode: number): Material;
  47364. /**
  47365. * Loads properties from a glTF material into a Babylon material.
  47366. * @param context The context when loading the asset
  47367. * @param material The glTF material property
  47368. * @param babylonMaterial The Babylon material
  47369. * @returns A promise that resolves when the load is complete
  47370. */
  47371. loadMaterialPropertiesAsync(context: string, material: Loader.IMaterial, babylonMaterial: Material): Promise<void>;
  47372. /**
  47373. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  47374. * @param context The context when loading the asset
  47375. * @param material The glTF material property
  47376. * @param babylonMaterial The Babylon material
  47377. * @returns A promise that resolves when the load is complete
  47378. */
  47379. loadMaterialBasePropertiesAsync(context: string, material: Loader.IMaterial, babylonMaterial: Material): Promise<void>;
  47380. /**
  47381. * Loads the alpha properties from a glTF material into a Babylon material.
  47382. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  47383. * @param context The context when loading the asset
  47384. * @param material The glTF material property
  47385. * @param babylonMaterial The Babylon material
  47386. */
  47387. loadMaterialAlphaProperties(context: string, material: Loader.IMaterial, babylonMaterial: Material): void;
  47388. /**
  47389. * Loads a glTF texture info.
  47390. * @param context The context when loading the asset
  47391. * @param textureInfo The glTF texture info property
  47392. * @param assign A function called synchronously after parsing the glTF properties
  47393. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  47394. */
  47395. loadTextureInfoAsync(context: string, textureInfo: Loader.ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  47396. private _loadTextureAsync;
  47397. private _loadSampler;
  47398. /**
  47399. * Loads a glTF image.
  47400. * @param context The context when loading the asset
  47401. * @param image The glTF image property
  47402. * @returns A promise that resolves with the loaded data when the load is complete
  47403. */
  47404. loadImageAsync(context: string, image: Loader.IImage): Promise<ArrayBufferView>;
  47405. /**
  47406. * Loads a glTF uri.
  47407. * @param context The context when loading the asset
  47408. * @param uri The base64 or relative uri
  47409. * @returns A promise that resolves with the loaded data when the load is complete
  47410. */
  47411. loadUriAsync(context: string, uri: string): Promise<ArrayBufferView>;
  47412. private _onProgress;
  47413. private static _GetTextureWrapMode;
  47414. private static _GetTextureSamplingMode;
  47415. private static _GetTypedArray;
  47416. private static _GetNumComponents;
  47417. private static _ValidateUri;
  47418. private static _GetDrawMode;
  47419. private _compileMaterialsAsync;
  47420. private _compileShadowGeneratorsAsync;
  47421. private _forEachExtensions;
  47422. private _applyExtensions;
  47423. private _extensionsOnLoading;
  47424. private _extensionsOnReady;
  47425. private _extensionsLoadSceneAsync;
  47426. private _extensionsLoadNodeAsync;
  47427. private _extensionsLoadCameraAsync;
  47428. private _extensionsLoadVertexDataAsync;
  47429. private _extensionsLoadMaterialAsync;
  47430. private _extensionsCreateMaterial;
  47431. private _extensionsLoadMaterialPropertiesAsync;
  47432. private _extensionsLoadTextureInfoAsync;
  47433. private _extensionsLoadAnimationAsync;
  47434. private _extensionsLoadUriAsync;
  47435. /**
  47436. * Helper method called by a loader extension to load an glTF extension.
  47437. * @param context The context when loading the asset
  47438. * @param property The glTF property to load the extension from
  47439. * @param extensionName The name of the extension to load
  47440. * @param actionAsync The action to run
  47441. * @returns The promise returned by actionAsync or null if the extension does not exist
  47442. */
  47443. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  47444. /**
  47445. * Helper method called by a loader extension to load a glTF extra.
  47446. * @param context The context when loading the asset
  47447. * @param property The glTF property to load the extra from
  47448. * @param extensionName The name of the extension to load
  47449. * @param actionAsync The action to run
  47450. * @returns The promise returned by actionAsync or null if the extra does not exist
  47451. */
  47452. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  47453. /**
  47454. * Increments the indentation level and logs a message.
  47455. * @param message The message to log
  47456. */
  47457. logOpen(message: string): void;
  47458. /**
  47459. * Decrements the indentation level.
  47460. */
  47461. logClose(): void;
  47462. /**
  47463. * Logs a message
  47464. * @param message The message to log
  47465. */
  47466. log(message: string): void;
  47467. /**
  47468. * Starts a performance counter.
  47469. * @param counterName The name of the performance counter
  47470. */
  47471. startPerformanceCounter(counterName: string): void;
  47472. /**
  47473. * Ends a performance counter.
  47474. * @param counterName The name of the performance counter
  47475. */
  47476. endPerformanceCounter(counterName: string): void;
  47477. }
  47478. }
  47479. declare module BABYLON.GLTF2 {
  47480. /**
  47481. * Interface for a glTF loader extension.
  47482. */
  47483. interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  47484. /**
  47485. * Called after the loader state changes to LOADING.
  47486. */
  47487. onLoading?(): void;
  47488. /**
  47489. * Called after the loader state changes to READY.
  47490. */
  47491. onReady?(): void;
  47492. /**
  47493. * Define this method to modify the default behavior when loading scenes.
  47494. * @param context The context when loading the asset
  47495. * @param scene The glTF scene property
  47496. * @returns A promise that resolves when the load is complete or null if not handled
  47497. */
  47498. loadSceneAsync?(context: string, scene: Loader.IScene): Nullable<Promise<void>>;
  47499. /**
  47500. * Define this method to modify the default behavior when loading nodes.
  47501. * @param context The context when loading the asset
  47502. * @param node The glTF node property
  47503. * @param assign A function called synchronously after parsing the glTF properties
  47504. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete or null if not handled
  47505. */
  47506. loadNodeAsync?(context: string, node: Loader.INode, assign: (babylonMesh: Mesh) => void): Nullable<Promise<Mesh>>;
  47507. /**
  47508. * Define this method to modify the default behavior when loading cameras.
  47509. * @param context The context when loading the asset
  47510. * @param camera The glTF camera property
  47511. * @param assign A function called synchronously after parsing the glTF properties
  47512. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  47513. */
  47514. loadCameraAsync?(context: string, camera: Loader.ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  47515. /**
  47516. * @hidden Define this method to modify the default behavior when loading vertex data for mesh primitives.
  47517. * @param context The context when loading the asset
  47518. * @param primitive The glTF mesh primitive property
  47519. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  47520. */
  47521. /**
  47522. * @hidden Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  47523. * @param context The context when loading the asset
  47524. * @param material The glTF material property
  47525. * @param assign A function called synchronously after parsing the glTF properties
  47526. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  47527. */
  47528. /**
  47529. * Define this method to modify the default behavior when creating materials.
  47530. * @param context The context when loading the asset
  47531. * @param material The glTF material property
  47532. * @param babylonDrawMode The draw mode for the Babylon material
  47533. * @returns The Babylon material or null if not handled
  47534. */
  47535. createMaterial?(context: string, material: Loader.IMaterial, babylonDrawMode: number): Nullable<Material>;
  47536. /**
  47537. * Define this method to modify the default behavior when loading material properties.
  47538. * @param context The context when loading the asset
  47539. * @param material The glTF material property
  47540. * @param babylonMaterial The Babylon material
  47541. * @returns A promise that resolves when the load is complete or null if not handled
  47542. */
  47543. loadMaterialPropertiesAsync?(context: string, material: Loader.IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  47544. /**
  47545. * Define this method to modify the default behavior when loading texture infos.
  47546. * @param context The context when loading the asset
  47547. * @param textureInfo The glTF texture info property
  47548. * @param assign A function called synchronously after parsing the glTF properties
  47549. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  47550. */
  47551. loadTextureInfoAsync?(context: string, textureInfo: Loader.ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  47552. /**
  47553. * Define this method to modify the default behavior when loading animations.
  47554. * @param context The context when loading the asset
  47555. * @param animation The glTF animation property
  47556. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  47557. */
  47558. loadAnimationAsync?(context: string, animation: Loader.IAnimation): Nullable<Promise<AnimationGroup>>;
  47559. /**
  47560. * Define this method to modify the default behavior when loading uris.
  47561. * @param context The context when loading the asset
  47562. * @param uri The uri to load
  47563. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  47564. */
  47565. }
  47566. }
  47567. /**
  47568. * Defines the module for the built-in glTF 2.0 loader extensions.
  47569. */
  47570. declare module BABYLON.GLTF2.Loader.Extensions {
  47571. }
  47572. declare module BABYLON.GLTF2.Loader.Extensions {
  47573. /**
  47574. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  47575. */
  47576. class MSFT_lod implements IGLTFLoaderExtension {
  47577. /** The name of this extension. */
  47578. readonly name: string;
  47579. /** Defines whether this extension is enabled. */
  47580. enabled: boolean;
  47581. /**
  47582. * Maximum number of LODs to load, starting from the lowest LOD.
  47583. */
  47584. maxLODsToLoad: number;
  47585. /**
  47586. * Observable raised when all node LODs of one level are loaded.
  47587. * The event data is the index of the loaded LOD starting from zero.
  47588. * Dispose the loader to cancel the loading of the next level of LODs.
  47589. */
  47590. onNodeLODsLoadedObservable: Observable<number>;
  47591. /**
  47592. * Observable raised when all material LODs of one level are loaded.
  47593. * The event data is the index of the loaded LOD starting from zero.
  47594. * Dispose the loader to cancel the loading of the next level of LODs.
  47595. */
  47596. onMaterialLODsLoadedObservable: Observable<number>;
  47597. private _loader;
  47598. private _nodeIndexLOD;
  47599. private _nodeSignalLODs;
  47600. private _nodePromiseLODs;
  47601. private _materialIndexLOD;
  47602. private _materialSignalLODs;
  47603. private _materialPromiseLODs;
  47604. /** @hidden */
  47605. constructor(loader: GLTFLoader);
  47606. /** @hidden */
  47607. dispose(): void;
  47608. /** @hidden */
  47609. onReady(): void;
  47610. /** @hidden */
  47611. loadNodeAsync(context: string, node: INode, assign: (babylonMesh: Mesh) => void): Nullable<Promise<Mesh>>;
  47612. /** @hidden */
  47613. /** @hidden */
  47614. /**
  47615. * Gets an array of LOD properties from lowest to highest.
  47616. */
  47617. private _getLODs;
  47618. private _disposeUnusedMaterials;
  47619. }
  47620. }
  47621. declare module BABYLON.GLTF2.Loader.Extensions {
  47622. /** @hidden */
  47623. class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  47624. readonly name: string;
  47625. enabled: boolean;
  47626. private _loader;
  47627. constructor(loader: GLTFLoader);
  47628. dispose(): void;
  47629. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  47630. }
  47631. }
  47632. declare module BABYLON.GLTF2.Loader.Extensions {
  47633. /** @hidden */
  47634. class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  47635. readonly name: string;
  47636. enabled: boolean;
  47637. private _loader;
  47638. constructor(loader: GLTFLoader);
  47639. dispose(): void;
  47640. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  47641. }
  47642. }
  47643. declare module BABYLON.GLTF2.Loader.Extensions {
  47644. /**
  47645. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  47646. */
  47647. class MSFT_audio_emitter implements IGLTFLoaderExtension {
  47648. /** The name of this extension. */
  47649. readonly name: string;
  47650. /** Defines whether this extension is enabled. */
  47651. enabled: boolean;
  47652. private _loader;
  47653. private _clips;
  47654. private _emitters;
  47655. /** @hidden */
  47656. constructor(loader: GLTFLoader);
  47657. /** @hidden */
  47658. dispose(): void;
  47659. /** @hidden */
  47660. onLoading(): void;
  47661. /** @hidden */
  47662. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  47663. /** @hidden */
  47664. loadNodeAsync(context: string, node: INode, assign: (babylonMesh: Mesh) => void): Nullable<Promise<Mesh>>;
  47665. /** @hidden */
  47666. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  47667. private _loadClipAsync;
  47668. private _loadEmitterAsync;
  47669. private _getEventAction;
  47670. private _loadAnimationEventAsync;
  47671. }
  47672. }
  47673. declare module BABYLON.GLTF2.Loader.Extensions {
  47674. /**
  47675. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  47676. */
  47677. class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  47678. /** The name of this extension. */
  47679. readonly name: string;
  47680. /** Defines whether this extension is enabled. */
  47681. enabled: boolean;
  47682. private _loader;
  47683. private _dracoCompression?;
  47684. /** @hidden */
  47685. constructor(loader: GLTFLoader);
  47686. /** @hidden */
  47687. dispose(): void;
  47688. /** @hidden */
  47689. }
  47690. }
  47691. declare module BABYLON.GLTF2.Loader.Extensions {
  47692. /**
  47693. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  47694. */
  47695. class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  47696. /** The name of this extension. */
  47697. readonly name: string;
  47698. /** Defines whether this extension is enabled. */
  47699. enabled: boolean;
  47700. private _loader;
  47701. /** @hidden */
  47702. constructor(loader: GLTFLoader);
  47703. /** @hidden */
  47704. dispose(): void;
  47705. /** @hidden */
  47706. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  47707. private _loadSpecularGlossinessPropertiesAsync;
  47708. }
  47709. }
  47710. declare module BABYLON.GLTF2.Loader.Extensions {
  47711. /**
  47712. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  47713. */
  47714. class KHR_materials_unlit implements IGLTFLoaderExtension {
  47715. /** The name of this extension. */
  47716. readonly name: string;
  47717. /** Defines whether this extension is enabled. */
  47718. enabled: boolean;
  47719. private _loader;
  47720. /** @hidden */
  47721. constructor(loader: GLTFLoader);
  47722. /** @hidden */
  47723. dispose(): void;
  47724. /** @hidden */
  47725. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  47726. private _loadUnlitPropertiesAsync;
  47727. }
  47728. }
  47729. declare module BABYLON.GLTF2.Loader.Extensions {
  47730. /**
  47731. * [Specification](https://github.com/KhronosGroup/glTF/blob/1048d162a44dbcb05aefc1874bfd423cf60135a6/extensions/2.0/Khronos/KHR_lights_punctual/README.md) (Experimental)
  47732. */
  47733. class KHR_lights implements IGLTFLoaderExtension {
  47734. /** The name of this extension. */
  47735. readonly name: string;
  47736. /** Defines whether this extension is enabled. */
  47737. enabled: boolean;
  47738. private _loader;
  47739. private _lights?;
  47740. /** @hidden */
  47741. constructor(loader: GLTFLoader);
  47742. /** @hidden */
  47743. dispose(): void;
  47744. /** @hidden */
  47745. onLoading(): void;
  47746. /** @hidden */
  47747. loadNodeAsync(context: string, node: INode, assign: (babylonMesh: Mesh) => void): Nullable<Promise<Mesh>>;
  47748. }
  47749. }
  47750. declare module BABYLON.GLTF2.Loader.Extensions {
  47751. /**
  47752. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform/README.md)
  47753. */
  47754. class KHR_texture_transform implements IGLTFLoaderExtension {
  47755. /** The name of this extension. */
  47756. readonly name: string;
  47757. /** Defines whether this extension is enabled. */
  47758. enabled: boolean;
  47759. private _loader;
  47760. /** @hidden */
  47761. constructor(loader: GLTFLoader);
  47762. /** @hidden */
  47763. dispose(): void;
  47764. /** @hidden */
  47765. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  47766. }
  47767. }
  47768. declare module BABYLON.GLTF2.Loader.Extensions {
  47769. /**
  47770. * [Specification](https://github.com/KhronosGroup/glTF/blob/eb3e32332042e04691a5f35103f8c261e50d8f1e/extensions/2.0/Khronos/EXT_lights_image_based/README.md) (Experimental)
  47771. */
  47772. class EXT_lights_image_based implements IGLTFLoaderExtension {
  47773. /** The name of this extension. */
  47774. readonly name: string;
  47775. /** Defines whether this extension is enabled. */
  47776. enabled: boolean;
  47777. private _loader;
  47778. private _lights?;
  47779. /** @hidden */
  47780. constructor(loader: GLTFLoader);
  47781. /** @hidden */
  47782. dispose(): void;
  47783. /** @hidden */
  47784. onLoading(): void;
  47785. /** @hidden */
  47786. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  47787. private _loadLightAsync;
  47788. }
  47789. }
  47790. declare module BABYLON {
  47791. /**
  47792. * Holds a collection of exporter options and parameters
  47793. */
  47794. interface IExportOptions {
  47795. /**
  47796. * Function which indicates whether a babylon mesh should be exported or not
  47797. * @param transformNode source Babylon transform node. It is used to check whether it should be exported to glTF or not
  47798. * @returns boolean, which indicates whether the mesh should be exported (true) or not (false)
  47799. */
  47800. shouldExportTransformNode?(transformNode: TransformNode): boolean;
  47801. /**
  47802. * The sample rate to bake animation curves
  47803. */
  47804. animationSampleRate?: number;
  47805. /**
  47806. * Begin serialization without waiting for the scene to be ready
  47807. */
  47808. exportWithoutWaitingForScene?: boolean;
  47809. }
  47810. /**
  47811. * Class for generating glTF data from a Babylon scene.
  47812. */
  47813. class GLTF2Export {
  47814. /**
  47815. * Exports the geometry of the scene to .gltf file format asynchronously
  47816. * @param scene Babylon scene with scene hierarchy information
  47817. * @param filePrefix File prefix to use when generating the glTF file
  47818. * @param options Exporter options
  47819. * @returns Returns an object with a .gltf file and associates texture names
  47820. * as keys and their data and paths as values
  47821. */
  47822. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  47823. private static _PreExportAsync;
  47824. private static _PostExportAsync;
  47825. /**
  47826. * Exports the geometry of the scene to .glb file format asychronously
  47827. * @param scene Babylon scene with scene hierarchy information
  47828. * @param filePrefix File prefix to use when generating glb file
  47829. * @param options Exporter options
  47830. * @returns Returns an object with a .glb filename as key and data as value
  47831. */
  47832. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  47833. }
  47834. }
  47835. declare module BABYLON.GLTF2.Exporter {
  47836. /**
  47837. * Converts Babylon Scene into glTF 2.0.
  47838. * @hidden
  47839. */
  47840. class _Exporter {
  47841. /**
  47842. * Stores all generated buffer views, which represents views into the main glTF buffer data
  47843. */
  47844. /**
  47845. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  47846. */
  47847. /**
  47848. * Stores all the generated nodes, which contains transform and/or mesh information per node
  47849. */
  47850. private _nodes;
  47851. /**
  47852. * Stores the glTF asset information, which represents the glTF version and this file generator
  47853. */
  47854. private _asset;
  47855. /**
  47856. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  47857. */
  47858. private _scenes;
  47859. /**
  47860. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  47861. */
  47862. private _meshes;
  47863. /**
  47864. * Stores all the generated material information, which represents the appearance of each primitive
  47865. */
  47866. ;
  47867. /**
  47868. * Stores all the generated texture information, which is referenced by glTF materials
  47869. */
  47870. /**
  47871. * Stores all the generated image information, which is referenced by glTF textures
  47872. */
  47873. /**
  47874. * Stores all the texture samplers
  47875. */
  47876. /**
  47877. * Stores all the generated animation samplers, which is referenced by glTF animations
  47878. */
  47879. /**
  47880. * Stores the animations for glTF models
  47881. */
  47882. private _animations;
  47883. /**
  47884. * Stores the total amount of bytes stored in the glTF buffer
  47885. */
  47886. private _totalByteLength;
  47887. /**
  47888. * Stores a reference to the Babylon scene containing the source geometry and material information
  47889. */
  47890. private _babylonScene;
  47891. /**
  47892. * Stores a map of the image data, where the key is the file name and the value
  47893. * is the image data
  47894. */
  47895. ;
  47896. };
  47897. /**
  47898. * Stores a map of the unique id of a node to its index in the node array
  47899. */
  47900. private _nodeMap;
  47901. /**
  47902. * Specifies if the Babylon scene should be converted to right-handed on export
  47903. */
  47904. private _convertToRightHandedSystem;
  47905. /**
  47906. * Baked animation sample rate
  47907. */
  47908. private _animationSampleRate;
  47909. /**
  47910. * Callback which specifies if a transform node should be exported or not
  47911. */
  47912. private _shouldExportTransformNode;
  47913. private _localEngine;
  47914. private _extensions;
  47915. private _extensionsUsed;
  47916. private _extensionsRequired;
  47917. private static _ExtensionNames;
  47918. private static _ExtensionFactories;
  47919. private _applyExtensions;
  47920. /**
  47921. * Load glTF serializer extensions
  47922. */
  47923. private _loadExtensions;
  47924. /**
  47925. * Creates a glTF Exporter instance, which can accept optional exporter options
  47926. * @param babylonScene Babylon scene object
  47927. * @param options Options to modify the behavior of the exporter
  47928. */
  47929. constructor(babylonScene: Scene, options?: IExportOptions);
  47930. /**
  47931. * Registers a glTF exporter extension
  47932. * @param name Name of the extension to export
  47933. * @param factory The factory function that creates the exporter extension
  47934. */
  47935. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtension): void;
  47936. /**
  47937. * Un-registers an exporter extension
  47938. * @param name The name fo the exporter extension
  47939. * @returns A boolean indicating whether the extension has been un-registered
  47940. */
  47941. static UnregisterExtension(name: string): boolean;
  47942. /**
  47943. * Lazy load a local engine with premultiplied alpha set to false
  47944. */
  47945. private reorderIndicesBasedOnPrimitiveMode;
  47946. /**
  47947. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  47948. * clock-wise during export to glTF
  47949. * @param submesh BabylonJS submesh
  47950. * @param primitiveMode Primitive mode of the mesh
  47951. * @param sideOrientation the winding order of the submesh
  47952. * @param vertexBufferKind The type of vertex attribute
  47953. * @param meshAttributeArray The vertex attribute data
  47954. * @param byteOffset The offset to the binary data
  47955. * @param binaryWriter The binary data for the glTF file
  47956. */
  47957. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  47958. /**
  47959. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  47960. * clock-wise during export to glTF
  47961. * @param submesh BabylonJS submesh
  47962. * @param primitiveMode Primitive mode of the mesh
  47963. * @param sideOrientation the winding order of the submesh
  47964. * @param vertexBufferKind The type of vertex attribute
  47965. * @param meshAttributeArray The vertex attribute data
  47966. * @param byteOffset The offset to the binary data
  47967. * @param binaryWriter The binary data for the glTF file
  47968. */
  47969. private reorderTriangleFillMode;
  47970. /**
  47971. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  47972. * clock-wise during export to glTF
  47973. * @param submesh BabylonJS submesh
  47974. * @param primitiveMode Primitive mode of the mesh
  47975. * @param sideOrientation the winding order of the submesh
  47976. * @param vertexBufferKind The type of vertex attribute
  47977. * @param meshAttributeArray The vertex attribute data
  47978. * @param byteOffset The offset to the binary data
  47979. * @param binaryWriter The binary data for the glTF file
  47980. */
  47981. private reorderTriangleStripDrawMode;
  47982. /**
  47983. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  47984. * clock-wise during export to glTF
  47985. * @param submesh BabylonJS submesh
  47986. * @param primitiveMode Primitive mode of the mesh
  47987. * @param sideOrientation the winding order of the submesh
  47988. * @param vertexBufferKind The type of vertex attribute
  47989. * @param meshAttributeArray The vertex attribute data
  47990. * @param byteOffset The offset to the binary data
  47991. * @param binaryWriter The binary data for the glTF file
  47992. */
  47993. private reorderTriangleFanMode;
  47994. /**
  47995. * Writes the vertex attribute data to binary
  47996. * @param vertices The vertices to write to the binary writer
  47997. * @param byteOffset The offset into the binary writer to overwrite binary data
  47998. * @param vertexAttributeKind The vertex attribute type
  47999. * @param meshAttributeArray The vertex attribute data
  48000. * @param binaryWriter The writer containing the binary data
  48001. */
  48002. private writeVertexAttributeData;
  48003. /**
  48004. * Writes mesh attribute data to a data buffer
  48005. * Returns the bytelength of the data
  48006. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  48007. * @param meshAttributeArray Array containing the attribute data
  48008. * @param binaryWriter The buffer to write the binary data to
  48009. * @param indices Used to specify the order of the vertex data
  48010. */
  48011. writeAttributeData(vertexBufferKind: string, meshAttributeArray: FloatArray, byteStride: number, binaryWriter: _BinaryWriter): void;
  48012. /**
  48013. * Generates glTF json data
  48014. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  48015. * @param glTFPrefix Text to use when prefixing a glTF file
  48016. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  48017. * @returns json data as string
  48018. */
  48019. private generateJSON;
  48020. /**
  48021. * Generates data for .gltf and .bin files based on the glTF prefix string
  48022. * @param glTFPrefix Text to use when prefixing a glTF file
  48023. * @returns GLTFData with glTF file data
  48024. */
  48025. /**
  48026. * Creates a binary buffer for glTF
  48027. * @returns array buffer for binary data
  48028. */
  48029. private _generateBinaryAsync;
  48030. /**
  48031. * Pads the number to a multiple of 4
  48032. * @param num number to pad
  48033. * @returns padded number
  48034. */
  48035. private _getPadding;
  48036. /**
  48037. * Generates a glb file from the json and binary data
  48038. * Returns an object with the glb file name as the key and data as the value
  48039. * @param glTFPrefix
  48040. * @returns object with glb filename as key and data as value
  48041. */
  48042. /**
  48043. * Sets the TRS for each node
  48044. * @param node glTF Node for storing the transformation data
  48045. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  48046. */
  48047. private setNodeTransformation;
  48048. private getVertexBufferFromMesh;
  48049. /**
  48050. * Creates a bufferview based on the vertices type for the Babylon mesh
  48051. * @param kind Indicates the type of vertices data
  48052. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  48053. * @param binaryWriter The buffer to write the bufferview data to
  48054. */
  48055. private createBufferViewKind;
  48056. /**
  48057. * The primitive mode of the Babylon mesh
  48058. * @param babylonMesh The BabylonJS mesh
  48059. */
  48060. private getMeshPrimitiveMode;
  48061. /**
  48062. * Sets the primitive mode of the glTF mesh primitive
  48063. * @param meshPrimitive glTF mesh primitive
  48064. * @param primitiveMode The primitive mode
  48065. */
  48066. private setPrimitiveMode;
  48067. /**
  48068. * Sets the vertex attribute accessor based of the glTF mesh primitive
  48069. * @param meshPrimitive glTF mesh primitive
  48070. * @param attributeKind vertex attribute
  48071. * @returns boolean specifying if uv coordinates are present
  48072. */
  48073. private setAttributeKind;
  48074. /**
  48075. * Sets data for the primitive attributes of each submesh
  48076. * @param mesh glTF Mesh object to store the primitive attribute information
  48077. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  48078. * @param binaryWriter Buffer to write the attribute data to
  48079. */
  48080. private setPrimitiveAttributesAsync;
  48081. /**
  48082. * Creates a glTF scene based on the array of meshes
  48083. * Returns the the total byte offset
  48084. * @param babylonScene Babylon scene to get the mesh data from
  48085. * @param binaryWriter Buffer to write binary data to
  48086. */
  48087. private createSceneAsync;
  48088. /**
  48089. * Creates a mapping of Node unique id to node index and handles animations
  48090. * @param babylonScene Babylon Scene
  48091. * @param nodes Babylon transform nodes
  48092. * @param shouldExportTransformNode Callback specifying if a transform node should be exported
  48093. * @param binaryWriter Buffer to write binary data to
  48094. * @returns Node mapping of unique id to index
  48095. */
  48096. private createNodeMapAndAnimationsAsync;
  48097. /**
  48098. * Creates a glTF node from a Babylon mesh
  48099. * @param babylonMesh Source Babylon mesh
  48100. * @param binaryWriter Buffer for storing geometry data
  48101. * @returns glTF node
  48102. */
  48103. private createNodeAsync;
  48104. }
  48105. /**
  48106. * @hidden
  48107. *
  48108. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  48109. */
  48110. class _BinaryWriter {
  48111. /**
  48112. * Array buffer which stores all binary data
  48113. */
  48114. private _arrayBuffer;
  48115. /**
  48116. * View of the array buffer
  48117. */
  48118. private _dataView;
  48119. /**
  48120. * byte offset of data in array buffer
  48121. */
  48122. private _byteOffset;
  48123. /**
  48124. * Initialize binary writer with an initial byte length
  48125. * @param byteLength Initial byte length of the array buffer
  48126. */
  48127. constructor(byteLength: number);
  48128. /**
  48129. * Resize the array buffer to the specified byte length
  48130. * @param byteLength
  48131. */
  48132. private resizeBuffer;
  48133. /**
  48134. * Get an array buffer with the length of the byte offset
  48135. * @returns ArrayBuffer resized to the byte offset
  48136. */
  48137. getArrayBuffer(): ArrayBuffer;
  48138. /**
  48139. * Get the byte offset of the array buffer
  48140. * @returns byte offset
  48141. */
  48142. getByteOffset(): number;
  48143. /**
  48144. * Stores an UInt8 in the array buffer
  48145. * @param entry
  48146. * @param byteOffset If defined, specifies where to set the value as an offset.
  48147. */
  48148. setUInt8(entry: number, byteOffset?: number): void;
  48149. /**
  48150. * Gets an UInt32 in the array buffer
  48151. * @param entry
  48152. * @param byteOffset If defined, specifies where to set the value as an offset.
  48153. */
  48154. getUInt32(byteOffset: number): number;
  48155. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  48156. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  48157. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  48158. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  48159. /**
  48160. * Stores a Float32 in the array buffer
  48161. * @param entry
  48162. */
  48163. setFloat32(entry: number, byteOffset?: number): void;
  48164. /**
  48165. * Stores an UInt32 in the array buffer
  48166. * @param entry
  48167. * @param byteOffset If defined, specifies where to set the value as an offset.
  48168. */
  48169. setUInt32(entry: number, byteOffset?: number): void;
  48170. }
  48171. }
  48172. declare module BABYLON {
  48173. /**
  48174. * Class for holding and downloading glTF file data
  48175. */
  48176. class GLTFData {
  48177. /**
  48178. * Object which contains the file name as the key and its data as the value
  48179. */
  48180. glTFFiles: {
  48181. [fileName: string]: string | Blob;
  48182. };
  48183. /**
  48184. * Initializes the glTF file object
  48185. */
  48186. constructor();
  48187. /**
  48188. * Downloads the glTF data as files based on their names and data
  48189. */
  48190. downloadFiles(): void;
  48191. }
  48192. }
  48193. declare module BABYLON.GLTF2.Exporter {
  48194. /**
  48195. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  48196. * @hidden
  48197. */
  48198. class _GLTFMaterialExporter {
  48199. /**
  48200. * Represents the dielectric specular values for R, G and B
  48201. */
  48202. private static readonly _DielectricSpecular;
  48203. /**
  48204. * Allows the maximum specular power to be defined for material calculations
  48205. */
  48206. private static readonly _MaxSpecularPower;
  48207. /**
  48208. * Mapping to store textures
  48209. */
  48210. private _textureMap;
  48211. /**
  48212. * Numeric tolerance value
  48213. */
  48214. private static readonly _Epsilon;
  48215. /**
  48216. * Reference to the glTF Exporter
  48217. */
  48218. private _exporter;
  48219. constructor(exporter: _Exporter);
  48220. /**
  48221. * Specifies if two colors are approximately equal in value
  48222. * @param color1 first color to compare to
  48223. * @param color2 second color to compare to
  48224. * @param epsilon threshold value
  48225. */
  48226. private static FuzzyEquals;
  48227. /**
  48228. * Gets the materials from a Babylon scene and converts them to glTF materials
  48229. * @param scene babylonjs scene
  48230. * @param mimeType texture mime type
  48231. * @param images array of images
  48232. * @param textures array of textures
  48233. * @param materials array of materials
  48234. * @param imageData mapping of texture names to base64 textures
  48235. * @param hasTextureCoords specifies if texture coordinates are present on the material
  48236. */
  48237. /**
  48238. * Makes a copy of the glTF material without the texture parameters
  48239. * @param originalMaterial original glTF material
  48240. * @returns glTF material without texture parameters
  48241. */
  48242. /**
  48243. * Specifies if the material has any texture parameters present
  48244. * @param material glTF Material
  48245. * @returns boolean specifying if texture parameters are present
  48246. */
  48247. /**
  48248. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  48249. * @param babylonStandardMaterial
  48250. * @returns glTF Metallic Roughness Material representation
  48251. */
  48252. /**
  48253. * Computes the metallic factor
  48254. * @param diffuse diffused value
  48255. * @param specular specular value
  48256. * @param oneMinusSpecularStrength one minus the specular strength
  48257. * @returns metallic value
  48258. */
  48259. private static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  48260. /**
  48261. * Gets the glTF alpha mode from the Babylon Material
  48262. * @param babylonMaterial Babylon Material
  48263. * @returns The Babylon alpha mode value
  48264. */
  48265. /**
  48266. * Converts a Babylon Standard Material to a glTF Material
  48267. * @param babylonStandardMaterial BJS Standard Material
  48268. * @param mimeType mime type to use for the textures
  48269. * @param images array of glTF image interfaces
  48270. * @param textures array of glTF texture interfaces
  48271. * @param materials array of glTF material interfaces
  48272. * @param imageData map of image file name to data
  48273. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  48274. */
  48275. /**
  48276. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  48277. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  48278. * @param mimeType mime type to use for the textures
  48279. * @param images array of glTF image interfaces
  48280. * @param textures array of glTF texture interfaces
  48281. * @param materials array of glTF material interfaces
  48282. * @param imageData map of image file name to data
  48283. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  48284. */
  48285. /**
  48286. * Converts an image typed array buffer to a base64 image
  48287. * @param buffer typed array buffer
  48288. * @param width width of the image
  48289. * @param height height of the image
  48290. * @param mimeType mimetype of the image
  48291. * @returns base64 image string
  48292. */
  48293. private _createBase64FromCanvasAsync;
  48294. /**
  48295. * Generates a white texture based on the specified width and height
  48296. * @param width width of the texture in pixels
  48297. * @param height height of the texture in pixels
  48298. * @param scene babylonjs scene
  48299. * @returns white texture
  48300. */
  48301. private _createWhiteTexture;
  48302. /**
  48303. * 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
  48304. * @param texture1 first texture to resize
  48305. * @param texture2 second texture to resize
  48306. * @param scene babylonjs scene
  48307. * @returns resized textures or null
  48308. */
  48309. private _resizeTexturesToSameDimensions;
  48310. /**
  48311. * Converts an array of pixels to a Float32Array
  48312. * Throws an error if the pixel format is not supported
  48313. * @param pixels - array buffer containing pixel values
  48314. * @returns Float32 of pixels
  48315. */
  48316. private _convertPixelArrayToFloat32;
  48317. /**
  48318. * Convert Specular Glossiness Textures to Metallic Roughness
  48319. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  48320. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  48321. * @param diffuseTexture texture used to store diffuse information
  48322. * @param specularGlossinessTexture texture used to store specular and glossiness information
  48323. * @param factors specular glossiness material factors
  48324. * @param mimeType the mime type to use for the texture
  48325. * @returns pbr metallic roughness interface or null
  48326. */
  48327. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  48328. /**
  48329. * Converts specular glossiness material properties to metallic roughness
  48330. * @param specularGlossiness interface with specular glossiness material properties
  48331. * @returns interface with metallic roughness material properties
  48332. */
  48333. private _convertSpecularGlossinessToMetallicRoughness;
  48334. /**
  48335. * Calculates the surface reflectance, independent of lighting conditions
  48336. * @param color Color source to calculate brightness from
  48337. * @returns number representing the perceived brightness, or zero if color is undefined
  48338. */
  48339. private _getPerceivedBrightness;
  48340. /**
  48341. * Returns the maximum color component value
  48342. * @param color
  48343. * @returns maximum color component value, or zero if color is null or undefined
  48344. */
  48345. private _getMaxComponent;
  48346. /**
  48347. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  48348. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  48349. * @param mimeType mime type to use for the textures
  48350. * @param images array of glTF image interfaces
  48351. * @param textures array of glTF texture interfaces
  48352. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  48353. * @param imageData map of image file name to data
  48354. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  48355. * @returns glTF PBR Metallic Roughness factors
  48356. */
  48357. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  48358. private _getGLTFTextureSampler;
  48359. private _getGLTFTextureWrapMode;
  48360. private _getGLTFTextureWrapModesSampler;
  48361. /**
  48362. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  48363. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  48364. * @param mimeType mime type to use for the textures
  48365. * @param images array of glTF image interfaces
  48366. * @param textures array of glTF texture interfaces
  48367. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  48368. * @param imageData map of image file name to data
  48369. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  48370. * @returns glTF PBR Metallic Roughness factors
  48371. */
  48372. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  48373. /**
  48374. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  48375. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  48376. * @param mimeType mime type to use for the textures
  48377. * @param images array of glTF image interfaces
  48378. * @param textures array of glTF texture interfaces
  48379. * @param materials array of glTF material interfaces
  48380. * @param imageData map of image file name to data
  48381. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  48382. */
  48383. private setMetallicRoughnessPbrMaterial;
  48384. private getPixelsFromTexture;
  48385. /**
  48386. * Extracts a texture from a Babylon texture into file data and glTF data
  48387. * @param babylonTexture Babylon texture to extract
  48388. * @param mimeType Mime Type of the babylonTexture
  48389. * @return glTF texture info, or null if the texture format is not supported
  48390. */
  48391. /**
  48392. * Builds a texture from base64 string
  48393. * @param base64Texture base64 texture string
  48394. * @param baseTextureName Name to use for the texture
  48395. * @param mimeType image mime type for the texture
  48396. * @param images array of images
  48397. * @param textures array of textures
  48398. * @param imageData map of image data
  48399. * @returns glTF texture info, or null if the texture format is not supported
  48400. */
  48401. private _getTextureInfoFromBase64;
  48402. }
  48403. }
  48404. declare module BABYLON.GLTF2.Exporter {
  48405. /**
  48406. * @hidden
  48407. * Interface to store animation data.
  48408. */
  48409. interface _IAnimationData {
  48410. /**
  48411. * Keyframe data.
  48412. */
  48413. inputs: number[];
  48414. /**
  48415. * Value data.
  48416. */
  48417. outputs: number[][];
  48418. /**
  48419. * Animation interpolation data.
  48420. */
  48421. samplerInterpolation: AnimationSamplerInterpolation;
  48422. /**
  48423. * Minimum keyframe value.
  48424. */
  48425. inputsMin: number;
  48426. /**
  48427. * Maximum keyframe value.
  48428. */
  48429. inputsMax: number;
  48430. }
  48431. /**
  48432. * @hidden
  48433. */
  48434. interface _IAnimationInfo {
  48435. /**
  48436. * The target channel for the animation
  48437. */
  48438. animationChannelTargetPath: AnimationChannelTargetPath;
  48439. /**
  48440. * The glTF accessor type for the data.
  48441. */
  48442. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4;
  48443. /**
  48444. * Specifies if quaternions should be used.
  48445. */
  48446. useQuaternion: boolean;
  48447. }
  48448. /**
  48449. * @hidden
  48450. * Utility class for generating glTF animation data from BabylonJS.
  48451. */
  48452. class _GLTFAnimation {
  48453. /**
  48454. * @ignore
  48455. *
  48456. * Creates glTF channel animation from BabylonJS animation.
  48457. * @param babylonTransformNode - BabylonJS mesh.
  48458. * @param animation - animation.
  48459. * @param animationChannelTargetPath - The target animation channel.
  48460. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  48461. * @param useQuaternion - Specifies if quaternions are used.
  48462. * @returns nullable IAnimationData
  48463. */
  48464. private static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  48465. private static _DeduceAnimationInfo;
  48466. /**
  48467. * @ignore
  48468. * Create node animations from the transform node animations
  48469. * @param babylonTransformNode
  48470. * @param runtimeGLTFAnimation
  48471. * @param idleGLTFAnimations
  48472. * @param nodeMap
  48473. * @param nodes
  48474. * @param binaryWriter
  48475. * @param bufferViews
  48476. * @param accessors
  48477. * @param convertToRightHandedSystem
  48478. */
  48479. private static _CreateNodeAnimationFromTransformNodeAnimations(babylonTransformNode: TransformNode, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  48480. [key: number]: number;
  48481. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  48482. /**
  48483. * @ignore
  48484. * Create node animations from the animation groups
  48485. * @param babylonScene
  48486. * @param glTFAnimations
  48487. * @param nodeMap
  48488. * @param nodes
  48489. * @param binaryWriter
  48490. * @param bufferViews
  48491. * @param accessors
  48492. * @param convertToRightHandedSystem
  48493. */
  48494. private static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  48495. [key: number]: number;
  48496. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  48497. private static AddAnimation;
  48498. /**
  48499. * Create a baked animation
  48500. * @param babylonTransformNode BabylonJS mesh
  48501. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  48502. * @param animationChannelTargetPath animation target channel
  48503. * @param minFrame minimum animation frame
  48504. * @param maxFrame maximum animation frame
  48505. * @param fps frames per second of the animation
  48506. * @param inputs input key frames of the animation
  48507. * @param outputs output key frame data of the animation
  48508. * @param convertToRightHandedSystem converts the values to right-handed
  48509. * @param useQuaternion specifies if quaternions should be used
  48510. */
  48511. private static _CreateBakedAnimation;
  48512. private static _ConvertFactorToVector3OrQuaternion;
  48513. private static _SetInterpolatedValue;
  48514. /**
  48515. * Creates linear animation from the animation key frames
  48516. * @param babylonTransformNode BabylonJS mesh
  48517. * @param animation BabylonJS animation
  48518. * @param animationChannelTargetPath The target animation channel
  48519. * @param frameDelta The difference between the last and first frame of the animation
  48520. * @param inputs Array to store the key frame times
  48521. * @param outputs Array to store the key frame data
  48522. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  48523. * @param useQuaternion Specifies if quaternions are used in the animation
  48524. */
  48525. private static _CreateLinearOrStepAnimation;
  48526. /**
  48527. * Creates cubic spline animation from the animation key frames
  48528. * @param babylonTransformNode BabylonJS mesh
  48529. * @param animation BabylonJS animation
  48530. * @param animationChannelTargetPath The target animation channel
  48531. * @param frameDelta The difference between the last and first frame of the animation
  48532. * @param inputs Array to store the key frame times
  48533. * @param outputs Array to store the key frame data
  48534. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  48535. * @param useQuaternion Specifies if quaternions are used in the animation
  48536. */
  48537. private static _CreateCubicSplineAnimation;
  48538. private static _GetBasePositionRotationOrScale;
  48539. /**
  48540. * Adds a key frame value
  48541. * @param keyFrame
  48542. * @param animation
  48543. * @param outputs
  48544. * @param animationChannelTargetPath
  48545. * @param basePositionRotationOrScale
  48546. * @param convertToRightHandedSystem
  48547. * @param useQuaternion
  48548. */
  48549. private static _AddKeyframeValue;
  48550. /**
  48551. * Determine the interpolation based on the key frames
  48552. * @param keyFrames
  48553. * @param animationChannelTargetPath
  48554. * @param useQuaternion
  48555. */
  48556. private static _DeduceInterpolation;
  48557. /**
  48558. * Adds an input tangent or output tangent to the output data
  48559. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  48560. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  48561. * @param outputs The animation data by keyframe
  48562. * @param animationChannelTargetPath The target animation channel
  48563. * @param interpolation The interpolation type
  48564. * @param keyFrame The key frame with the animation data
  48565. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  48566. * @param useQuaternion Specifies if quaternions are used
  48567. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  48568. */
  48569. private static AddSplineTangent;
  48570. /**
  48571. * Get the minimum and maximum key frames' frame values
  48572. * @param keyFrames animation key frames
  48573. * @returns the minimum and maximum key frame value
  48574. */
  48575. private static calculateMinMaxKeyFrames;
  48576. }
  48577. }
  48578. declare module BABYLON.GLTF2.Exporter {
  48579. /**
  48580. * @hidden
  48581. */
  48582. class _GLTFUtilities {
  48583. /**
  48584. * Creates a buffer view based on the supplied arguments
  48585. * @param bufferIndex index value of the specified buffer
  48586. * @param byteOffset byte offset value
  48587. * @param byteLength byte length of the bufferView
  48588. * @param byteStride byte distance between conequential elements
  48589. * @param name name of the buffer view
  48590. * @returns bufferView for glTF
  48591. */
  48592. private static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  48593. /**
  48594. * Creates an accessor based on the supplied arguments
  48595. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  48596. * @param name The name of the accessor
  48597. * @param type The type of the accessor
  48598. * @param componentType The datatype of components in the attribute
  48599. * @param count The number of attributes referenced by this accessor
  48600. * @param byteOffset The offset relative to the start of the bufferView in bytes
  48601. * @param min Minimum value of each component in this attribute
  48602. * @param max Maximum value of each component in this attribute
  48603. * @returns accessor for glTF
  48604. */
  48605. private static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  48606. /**
  48607. * Calculates the minimum and maximum values of an array of position floats
  48608. * @param positions Positions array of a mesh
  48609. * @param vertexStart Starting vertex offset to calculate min and max values
  48610. * @param vertexCount Number of vertices to check for min and max values
  48611. * @returns min number array and max number array
  48612. */
  48613. private static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  48614. min: number[];
  48615. max: number[];
  48616. };
  48617. /**
  48618. * Converts a new right-handed Vector3
  48619. * @param vector vector3 array
  48620. * @returns right-handed Vector3
  48621. */
  48622. private static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  48623. /**
  48624. * Converts a Vector3 to right-handed
  48625. * @param vector Vector3 to convert to right-handed
  48626. */
  48627. private static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  48628. /**
  48629. * Converts a three element number array to right-handed
  48630. * @param vector number array to convert to right-handed
  48631. */
  48632. private static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  48633. /**
  48634. * Converts a new right-handed Vector3
  48635. * @param vector vector3 array
  48636. * @returns right-handed Vector3
  48637. */
  48638. private static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  48639. /**
  48640. * Converts a Vector3 to right-handed
  48641. * @param vector Vector3 to convert to right-handed
  48642. */
  48643. private static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  48644. /**
  48645. * Converts a three element number array to right-handed
  48646. * @param vector number array to convert to right-handed
  48647. */
  48648. private static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  48649. /**
  48650. * Converts a Vector4 to right-handed
  48651. * @param vector Vector4 to convert to right-handed
  48652. */
  48653. private static _GetRightHandedVector4FromRef(vector: Vector4): void;
  48654. /**
  48655. * Converts a Vector4 to right-handed
  48656. * @param vector Vector4 to convert to right-handed
  48657. */
  48658. private static _GetRightHandedArray4FromRef(vector: number[]): void;
  48659. /**
  48660. * Converts a Quaternion to right-handed
  48661. * @param quaternion Source quaternion to convert to right-handed
  48662. */
  48663. private static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  48664. /**
  48665. * Converts a Quaternion to right-handed
  48666. * @param quaternion Source quaternion to convert to right-handed
  48667. */
  48668. private static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  48669. private static _NormalizeTangentFromRef(tangent: Vector4): void;
  48670. }
  48671. }
  48672. declare module BABYLON.GLTF2.Exporter {
  48673. /**
  48674. * Interface for a glTF exporter extension
  48675. * @hidden
  48676. */
  48677. interface IGLTFExporterExtension extends BABYLON.IGLTFExporterExtension, IDisposable {
  48678. /**
  48679. * Define this method to modify the default behavior before exporting a texture
  48680. * @param context The context when loading the asset
  48681. * @param babylonTexture The glTF texture info property
  48682. * @param mimeType The mime-type of the generated image
  48683. * @returns A promise that resolves with the exported glTF texture info when the export is complete, or null if not handled
  48684. */
  48685. preExportTextureAsync?(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<Texture>>;
  48686. /**
  48687. * Define this method to modify the default behavior when exporting texture info
  48688. * @param context The context when loading the asset
  48689. * @param meshPrimitive glTF mesh primitive
  48690. * @param babylonSubMesh Babylon submesh
  48691. * @param binaryWriter glTF serializer binary writer instance
  48692. */
  48693. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Nullable<Promise<IMeshPrimitive>>;
  48694. }
  48695. }
  48696. declare module BABYLON {
  48697. /**
  48698. * Interface for extending the exporter
  48699. * @hidden
  48700. */
  48701. interface IGLTFExporterExtension {
  48702. /**
  48703. * The name of this extension
  48704. */
  48705. readonly name: string;
  48706. /**
  48707. * Defines whether this extension is enabled
  48708. */
  48709. enabled: boolean;
  48710. /**
  48711. * Defines whether this extension is required
  48712. */
  48713. required: boolean;
  48714. }
  48715. }
  48716. /**
  48717. * @hidden
  48718. */
  48719. declare module BABYLON.GLTF2.Exporter.Extensions {
  48720. /**
  48721. * @hidden
  48722. */
  48723. class KHR_texture_transform implements IGLTFExporterExtension {
  48724. /** Name of this extension */
  48725. readonly name: string;
  48726. /** Defines whether this extension is enabled */
  48727. enabled: boolean;
  48728. /** Defines whether this extension is required */
  48729. required: boolean;
  48730. /** Reference to the glTF exporter */
  48731. private _exporter;
  48732. constructor(exporter: _Exporter);
  48733. dispose(): void;
  48734. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<Texture>>;
  48735. /**
  48736. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  48737. * @param babylonTexture
  48738. * @param offset
  48739. * @param rotation
  48740. * @param scale
  48741. * @param scene
  48742. */
  48743. textureTransformTextureAsync(babylonTexture: Texture, offset: Vector2, rotation: number, scale: Vector2, scene: Scene): Promise<BaseTexture>;
  48744. }
  48745. }
  48746. /**
  48747. * @ignoreChildren
  48748. * @ignore
  48749. */
  48750. declare module "babylonjs-gltf2interface" {
  48751. export = BABYLON.GLTF2;
  48752. }
  48753. /**
  48754. * Module for glTF 2.0 Interface
  48755. */
  48756. declare module BABYLON.GLTF2 {
  48757. /**
  48758. * The datatype of the components in the attribute
  48759. */
  48760. const enum AccessorComponentType {
  48761. /**
  48762. * Byte
  48763. */
  48764. BYTE = 5120,
  48765. /**
  48766. * Unsigned Byte
  48767. */
  48768. UNSIGNED_BYTE = 5121,
  48769. /**
  48770. * Short
  48771. */
  48772. SHORT = 5122,
  48773. /**
  48774. * Unsigned Short
  48775. */
  48776. UNSIGNED_SHORT = 5123,
  48777. /**
  48778. * Unsigned Int
  48779. */
  48780. UNSIGNED_INT = 5125,
  48781. /**
  48782. * Float
  48783. */
  48784. FLOAT = 5126,
  48785. }
  48786. /**
  48787. * Specifies if the attirbute is a scalar, vector, or matrix
  48788. */
  48789. const enum AccessorType {
  48790. /**
  48791. * Scalar
  48792. */
  48793. SCALAR = "SCALAR",
  48794. /**
  48795. * Vector2
  48796. */
  48797. VEC2 = "VEC2",
  48798. /**
  48799. * Vector3
  48800. */
  48801. VEC3 = "VEC3",
  48802. /**
  48803. * Vector4
  48804. */
  48805. VEC4 = "VEC4",
  48806. /**
  48807. * Matrix2x2
  48808. */
  48809. MAT2 = "MAT2",
  48810. /**
  48811. * Matrix3x3
  48812. */
  48813. MAT3 = "MAT3",
  48814. /**
  48815. * Matrix4x4
  48816. */
  48817. MAT4 = "MAT4",
  48818. }
  48819. /**
  48820. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  48821. */
  48822. const enum AnimationChannelTargetPath {
  48823. /**
  48824. * Translation
  48825. */
  48826. TRANSLATION = "translation",
  48827. /**
  48828. * Rotation
  48829. */
  48830. ROTATION = "rotation",
  48831. /**
  48832. * Scale
  48833. */
  48834. SCALE = "scale",
  48835. /**
  48836. * Weights
  48837. */
  48838. WEIGHTS = "weights",
  48839. }
  48840. /**
  48841. * Interpolation algorithm
  48842. */
  48843. const enum AnimationSamplerInterpolation {
  48844. /**
  48845. * The animated values are linearly interpolated between keyframes
  48846. */
  48847. LINEAR = "LINEAR",
  48848. /**
  48849. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  48850. */
  48851. STEP = "STEP",
  48852. /**
  48853. * The animation's interpolation is computed using a cubic spline with specified tangents
  48854. */
  48855. CUBICSPLINE = "CUBICSPLINE",
  48856. }
  48857. /**
  48858. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  48859. */
  48860. const enum CameraType {
  48861. /**
  48862. * A perspective camera containing properties to create a perspective projection matrix
  48863. */
  48864. PERSPECTIVE = "perspective",
  48865. /**
  48866. * An orthographic camera containing properties to create an orthographic projection matrix
  48867. */
  48868. ORTHOGRAPHIC = "orthographic",
  48869. }
  48870. /**
  48871. * The mime-type of the image
  48872. */
  48873. const enum ImageMimeType {
  48874. /**
  48875. * JPEG Mime-type
  48876. */
  48877. JPEG = "image/jpeg",
  48878. /**
  48879. * PNG Mime-type
  48880. */
  48881. PNG = "image/png",
  48882. }
  48883. /**
  48884. * The alpha rendering mode of the material
  48885. */
  48886. const enum MaterialAlphaMode {
  48887. /**
  48888. * The alpha value is ignored and the rendered output is fully opaque
  48889. */
  48890. OPAQUE = "OPAQUE",
  48891. /**
  48892. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  48893. */
  48894. MASK = "MASK",
  48895. /**
  48896. * 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)
  48897. */
  48898. BLEND = "BLEND",
  48899. }
  48900. /**
  48901. * The type of the primitives to render
  48902. */
  48903. const enum MeshPrimitiveMode {
  48904. /**
  48905. * Points
  48906. */
  48907. POINTS = 0,
  48908. /**
  48909. * Lines
  48910. */
  48911. LINES = 1,
  48912. /**
  48913. * Line Loop
  48914. */
  48915. LINE_LOOP = 2,
  48916. /**
  48917. * Line Strip
  48918. */
  48919. LINE_STRIP = 3,
  48920. /**
  48921. * Triangles
  48922. */
  48923. TRIANGLES = 4,
  48924. /**
  48925. * Triangle Strip
  48926. */
  48927. TRIANGLE_STRIP = 5,
  48928. /**
  48929. * Triangle Fan
  48930. */
  48931. TRIANGLE_FAN = 6,
  48932. }
  48933. /**
  48934. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  48935. */
  48936. const enum TextureMagFilter {
  48937. /**
  48938. * Nearest
  48939. */
  48940. NEAREST = 9728,
  48941. /**
  48942. * Linear
  48943. */
  48944. LINEAR = 9729,
  48945. }
  48946. /**
  48947. * Minification filter. All valid values correspond to WebGL enums
  48948. */
  48949. const enum TextureMinFilter {
  48950. /**
  48951. * Nearest
  48952. */
  48953. NEAREST = 9728,
  48954. /**
  48955. * Linear
  48956. */
  48957. LINEAR = 9729,
  48958. /**
  48959. * Nearest Mip-Map Nearest
  48960. */
  48961. NEAREST_MIPMAP_NEAREST = 9984,
  48962. /**
  48963. * Linear Mipmap Nearest
  48964. */
  48965. LINEAR_MIPMAP_NEAREST = 9985,
  48966. /**
  48967. * Nearest Mipmap Linear
  48968. */
  48969. NEAREST_MIPMAP_LINEAR = 9986,
  48970. /**
  48971. * Linear Mipmap Linear
  48972. */
  48973. LINEAR_MIPMAP_LINEAR = 9987,
  48974. }
  48975. /**
  48976. * S (U) wrapping mode. All valid values correspond to WebGL enums
  48977. */
  48978. const enum TextureWrapMode {
  48979. /**
  48980. * Clamp to Edge
  48981. */
  48982. CLAMP_TO_EDGE = 33071,
  48983. /**
  48984. * Mirrored Repeat
  48985. */
  48986. MIRRORED_REPEAT = 33648,
  48987. /**
  48988. * Repeat
  48989. */
  48990. REPEAT = 10497,
  48991. }
  48992. /**
  48993. * glTF Property
  48994. */
  48995. interface IProperty {
  48996. /**
  48997. * Dictionary object with extension-specific objects
  48998. */
  48999. extensions?: {
  49000. [key: string]: any;
  49001. };
  49002. /**
  49003. * Application-Specific data
  49004. */
  49005. extras?: any;
  49006. }
  49007. /**
  49008. * glTF Child of Root Property
  49009. */
  49010. interface IChildRootProperty extends IProperty {
  49011. /**
  49012. * The user-defined name of this object
  49013. */
  49014. name?: string;
  49015. }
  49016. /**
  49017. * Indices of those attributes that deviate from their initialization value
  49018. */
  49019. interface IAccessorSparseIndices extends IProperty {
  49020. /**
  49021. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  49022. */
  49023. bufferView: number;
  49024. /**
  49025. * The offset relative to the start of the bufferView in bytes. Must be aligned
  49026. */
  49027. byteOffset?: number;
  49028. /**
  49029. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  49030. */
  49031. componentType: AccessorComponentType;
  49032. }
  49033. /**
  49034. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  49035. */
  49036. interface IAccessorSparseValues extends IProperty {
  49037. /**
  49038. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  49039. */
  49040. bufferView: number;
  49041. /**
  49042. * The offset relative to the start of the bufferView in bytes. Must be aligned
  49043. */
  49044. byteOffset?: number;
  49045. }
  49046. /**
  49047. * Sparse storage of attributes that deviate from their initialization value
  49048. */
  49049. interface IAccessorSparse extends IProperty {
  49050. /**
  49051. * The number of attributes encoded in this sparse accessor
  49052. */
  49053. count: number;
  49054. /**
  49055. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  49056. */
  49057. indices: IAccessorSparseIndices;
  49058. /**
  49059. * 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
  49060. */
  49061. values: IAccessorSparseValues;
  49062. }
  49063. /**
  49064. * 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
  49065. */
  49066. interface IAccessor extends IChildRootProperty {
  49067. /**
  49068. * The index of the bufferview
  49069. */
  49070. bufferView?: number;
  49071. /**
  49072. * The offset relative to the start of the bufferView in bytes
  49073. */
  49074. byteOffset?: number;
  49075. /**
  49076. * The datatype of components in the attribute
  49077. */
  49078. componentType: AccessorComponentType;
  49079. /**
  49080. * Specifies whether integer data values should be normalized
  49081. */
  49082. normalized?: boolean;
  49083. /**
  49084. * The number of attributes referenced by this accessor
  49085. */
  49086. count: number;
  49087. /**
  49088. * Specifies if the attribute is a scalar, vector, or matrix
  49089. */
  49090. type: AccessorType;
  49091. /**
  49092. * Maximum value of each component in this attribute
  49093. */
  49094. max?: number[];
  49095. /**
  49096. * Minimum value of each component in this attribute
  49097. */
  49098. min?: number[];
  49099. /**
  49100. * Sparse storage of attributes that deviate from their initialization value
  49101. */
  49102. sparse?: IAccessorSparse;
  49103. }
  49104. /**
  49105. * Targets an animation's sampler at a node's property
  49106. */
  49107. interface IAnimationChannel extends IProperty {
  49108. /**
  49109. * The index of a sampler in this animation used to compute the value for the target
  49110. */
  49111. sampler: number;
  49112. /**
  49113. * The index of the node and TRS property to target
  49114. */
  49115. target: IAnimationChannelTarget;
  49116. }
  49117. /**
  49118. * The index of the node and TRS property that an animation channel targets
  49119. */
  49120. interface IAnimationChannelTarget extends IProperty {
  49121. /**
  49122. * The index of the node to target
  49123. */
  49124. node: number;
  49125. /**
  49126. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  49127. */
  49128. path: AnimationChannelTargetPath;
  49129. }
  49130. /**
  49131. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  49132. */
  49133. interface IAnimationSampler extends IProperty {
  49134. /**
  49135. * The index of an accessor containing keyframe input values, e.g., time
  49136. */
  49137. input: number;
  49138. /**
  49139. * Interpolation algorithm
  49140. */
  49141. interpolation?: AnimationSamplerInterpolation;
  49142. /**
  49143. * The index of an accessor, containing keyframe output values
  49144. */
  49145. output: number;
  49146. }
  49147. /**
  49148. * A keyframe animation
  49149. */
  49150. interface IAnimation extends IChildRootProperty {
  49151. /**
  49152. * An array of channels, each of which targets an animation's sampler at a node's property
  49153. */
  49154. channels: IAnimationChannel[];
  49155. /**
  49156. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  49157. */
  49158. samplers: IAnimationSampler[];
  49159. }
  49160. /**
  49161. * Metadata about the glTF asset
  49162. */
  49163. interface IAsset extends IChildRootProperty {
  49164. /**
  49165. * A copyright message suitable for display to credit the content creator
  49166. */
  49167. copyright?: string;
  49168. /**
  49169. * Tool that generated this glTF model. Useful for debugging
  49170. */
  49171. generator?: string;
  49172. /**
  49173. * The glTF version that this asset targets
  49174. */
  49175. version: string;
  49176. /**
  49177. * The minimum glTF version that this asset targets
  49178. */
  49179. minVersion?: string;
  49180. }
  49181. /**
  49182. * A buffer points to binary geometry, animation, or skins
  49183. */
  49184. interface IBuffer extends IChildRootProperty {
  49185. /**
  49186. * 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
  49187. */
  49188. uri?: string;
  49189. /**
  49190. * The length of the buffer in bytes
  49191. */
  49192. byteLength: number;
  49193. }
  49194. /**
  49195. * A view into a buffer generally representing a subset of the buffer
  49196. */
  49197. interface IBufferView extends IChildRootProperty {
  49198. /**
  49199. * The index of the buffer
  49200. */
  49201. buffer: number;
  49202. /**
  49203. * The offset into the buffer in bytes
  49204. */
  49205. byteOffset?: number;
  49206. /**
  49207. * The lenth of the bufferView in bytes
  49208. */
  49209. byteLength: number;
  49210. /**
  49211. * The stride, in bytes
  49212. */
  49213. byteStride?: number;
  49214. }
  49215. /**
  49216. * An orthographic camera containing properties to create an orthographic projection matrix
  49217. */
  49218. interface ICameraOrthographic extends IProperty {
  49219. /**
  49220. * The floating-point horizontal magnification of the view. Must not be zero
  49221. */
  49222. xmag: number;
  49223. /**
  49224. * The floating-point vertical magnification of the view. Must not be zero
  49225. */
  49226. ymag: number;
  49227. /**
  49228. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  49229. */
  49230. zfar: number;
  49231. /**
  49232. * The floating-point distance to the near clipping plane
  49233. */
  49234. znear: number;
  49235. }
  49236. /**
  49237. * A perspective camera containing properties to create a perspective projection matrix
  49238. */
  49239. interface ICameraPerspective extends IProperty {
  49240. /**
  49241. * The floating-point aspect ratio of the field of view
  49242. */
  49243. aspectRatio?: number;
  49244. /**
  49245. * The floating-point vertical field of view in radians
  49246. */
  49247. yfov: number;
  49248. /**
  49249. * The floating-point distance to the far clipping plane
  49250. */
  49251. zfar?: number;
  49252. /**
  49253. * The floating-point distance to the near clipping plane
  49254. */
  49255. znear: number;
  49256. }
  49257. /**
  49258. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  49259. */
  49260. interface ICamera extends IChildRootProperty {
  49261. /**
  49262. * An orthographic camera containing properties to create an orthographic projection matrix
  49263. */
  49264. orthographic?: ICameraOrthographic;
  49265. /**
  49266. * A perspective camera containing properties to create a perspective projection matrix
  49267. */
  49268. perspective?: ICameraPerspective;
  49269. /**
  49270. * Specifies if the camera uses a perspective or orthographic projection
  49271. */
  49272. type: CameraType;
  49273. }
  49274. /**
  49275. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  49276. */
  49277. interface IImage extends IChildRootProperty {
  49278. /**
  49279. * 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
  49280. */
  49281. uri?: string;
  49282. /**
  49283. * The image's MIME type
  49284. */
  49285. mimeType?: ImageMimeType;
  49286. /**
  49287. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  49288. */
  49289. bufferView?: number;
  49290. }
  49291. /**
  49292. * Material Normal Texture Info
  49293. */
  49294. interface IMaterialNormalTextureInfo extends ITextureInfo {
  49295. /**
  49296. * The scalar multiplier applied to each normal vector of the normal texture
  49297. */
  49298. scale?: number;
  49299. }
  49300. /**
  49301. * Material Occlusion Texture Info
  49302. */
  49303. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  49304. /**
  49305. * A scalar multiplier controlling the amount of occlusion applied
  49306. */
  49307. strength?: number;
  49308. }
  49309. /**
  49310. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  49311. */
  49312. interface IMaterialPbrMetallicRoughness {
  49313. /**
  49314. * The material's base color factor
  49315. */
  49316. baseColorFactor?: number[];
  49317. /**
  49318. * The base color texture
  49319. */
  49320. baseColorTexture?: ITextureInfo;
  49321. /**
  49322. * The metalness of the material
  49323. */
  49324. metallicFactor?: number;
  49325. /**
  49326. * The roughness of the material
  49327. */
  49328. roughnessFactor?: number;
  49329. /**
  49330. * The metallic-roughness texture
  49331. */
  49332. metallicRoughnessTexture?: ITextureInfo;
  49333. }
  49334. /**
  49335. * The material appearance of a primitive
  49336. */
  49337. interface IMaterial extends IChildRootProperty {
  49338. /**
  49339. * 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
  49340. */
  49341. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  49342. /**
  49343. * The normal map texture
  49344. */
  49345. normalTexture?: IMaterialNormalTextureInfo;
  49346. /**
  49347. * The occlusion map texture
  49348. */
  49349. occlusionTexture?: IMaterialOcclusionTextureInfo;
  49350. /**
  49351. * The emissive map texture
  49352. */
  49353. emissiveTexture?: ITextureInfo;
  49354. /**
  49355. * 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
  49356. */
  49357. emissiveFactor?: number[];
  49358. /**
  49359. * The alpha rendering mode of the material
  49360. */
  49361. alphaMode?: MaterialAlphaMode;
  49362. /**
  49363. * The alpha cutoff value of the material
  49364. */
  49365. alphaCutoff?: number;
  49366. /**
  49367. * Specifies whether the material is double sided
  49368. */
  49369. doubleSided?: boolean;
  49370. }
  49371. /**
  49372. * Geometry to be rendered with the given material
  49373. */
  49374. interface IMeshPrimitive extends IProperty {
  49375. /**
  49376. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  49377. */
  49378. attributes: {
  49379. [name: string]: number;
  49380. };
  49381. /**
  49382. * The index of the accessor that contains the indices
  49383. */
  49384. indices?: number;
  49385. /**
  49386. * The index of the material to apply to this primitive when rendering
  49387. */
  49388. material?: number;
  49389. /**
  49390. * The type of primitives to render. All valid values correspond to WebGL enums
  49391. */
  49392. mode?: MeshPrimitiveMode;
  49393. /**
  49394. * 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
  49395. */
  49396. targets?: {
  49397. [name: string]: number;
  49398. }[];
  49399. }
  49400. /**
  49401. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  49402. */
  49403. interface IMesh extends IChildRootProperty {
  49404. /**
  49405. * An array of primitives, each defining geometry to be rendered with a material
  49406. */
  49407. primitives: IMeshPrimitive[];
  49408. /**
  49409. * Array of weights to be applied to the Morph Targets
  49410. */
  49411. weights?: number[];
  49412. }
  49413. /**
  49414. * A node in the node hierarchy
  49415. */
  49416. interface INode extends IChildRootProperty {
  49417. /**
  49418. * The index of the camera referenced by this node
  49419. */
  49420. camera?: number;
  49421. /**
  49422. * The indices of this node's children
  49423. */
  49424. children?: number[];
  49425. /**
  49426. * The index of the skin referenced by this node
  49427. */
  49428. skin?: number;
  49429. /**
  49430. * A floating-point 4x4 transformation matrix stored in column-major order
  49431. */
  49432. matrix?: number[];
  49433. /**
  49434. * The index of the mesh in this node
  49435. */
  49436. mesh?: number;
  49437. /**
  49438. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  49439. */
  49440. rotation?: number[];
  49441. /**
  49442. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  49443. */
  49444. scale?: number[];
  49445. /**
  49446. * The node's translation along the x, y, and z axes
  49447. */
  49448. translation?: number[];
  49449. /**
  49450. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  49451. */
  49452. weights?: number[];
  49453. }
  49454. /**
  49455. * Texture sampler properties for filtering and wrapping modes
  49456. */
  49457. interface ISampler extends IChildRootProperty {
  49458. /**
  49459. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  49460. */
  49461. magFilter?: TextureMagFilter;
  49462. /**
  49463. * Minification filter. All valid values correspond to WebGL enums
  49464. */
  49465. minFilter?: TextureMinFilter;
  49466. /**
  49467. * S (U) wrapping mode. All valid values correspond to WebGL enums
  49468. */
  49469. wrapS?: TextureWrapMode;
  49470. /**
  49471. * T (V) wrapping mode. All valid values correspond to WebGL enums
  49472. */
  49473. wrapT?: TextureWrapMode;
  49474. }
  49475. /**
  49476. * The root nodes of a scene
  49477. */
  49478. interface IScene extends IChildRootProperty {
  49479. /**
  49480. * The indices of each root node
  49481. */
  49482. nodes: number[];
  49483. }
  49484. /**
  49485. * Joints and matrices defining a skin
  49486. */
  49487. interface ISkin extends IChildRootProperty {
  49488. /**
  49489. * 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
  49490. */
  49491. inverseBindMatrices?: number;
  49492. /**
  49493. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  49494. */
  49495. skeleton?: number;
  49496. /**
  49497. * 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)
  49498. */
  49499. joints: number[];
  49500. }
  49501. /**
  49502. * A texture and its sampler
  49503. */
  49504. interface ITexture extends IChildRootProperty {
  49505. /**
  49506. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  49507. */
  49508. sampler?: number;
  49509. /**
  49510. * The index of the image used by this texture
  49511. */
  49512. source: number;
  49513. }
  49514. /**
  49515. * Reference to a texture
  49516. */
  49517. interface ITextureInfo extends IProperty {
  49518. /**
  49519. * The index of the texture
  49520. */
  49521. index: number;
  49522. /**
  49523. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  49524. */
  49525. texCoord?: number;
  49526. }
  49527. /**
  49528. * The root object for a glTF asset
  49529. */
  49530. interface IGLTF extends IProperty {
  49531. /**
  49532. * An array of accessors. An accessor is a typed view into a bufferView
  49533. */
  49534. accessors?: IAccessor[];
  49535. /**
  49536. * An array of keyframe animations
  49537. */
  49538. animations?: IAnimation[];
  49539. /**
  49540. * Metadata about the glTF asset
  49541. */
  49542. asset: IAsset;
  49543. /**
  49544. * An array of buffers. A buffer points to binary geometry, animation, or skins
  49545. */
  49546. buffers?: IBuffer[];
  49547. /**
  49548. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  49549. */
  49550. bufferViews?: IBufferView[];
  49551. /**
  49552. * An array of cameras
  49553. */
  49554. cameras?: ICamera[];
  49555. /**
  49556. * Names of glTF extensions used somewhere in this asset
  49557. */
  49558. extensionsUsed?: string[];
  49559. /**
  49560. * Names of glTF extensions required to properly load this asset
  49561. */
  49562. extensionsRequired?: string[];
  49563. /**
  49564. * An array of images. An image defines data used to create a texture
  49565. */
  49566. images?: IImage[];
  49567. /**
  49568. * An array of materials. A material defines the appearance of a primitive
  49569. */
  49570. materials?: IMaterial[];
  49571. /**
  49572. * An array of meshes. A mesh is a set of primitives to be rendered
  49573. */
  49574. meshes?: IMesh[];
  49575. /**
  49576. * An array of nodes
  49577. */
  49578. nodes?: INode[];
  49579. /**
  49580. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  49581. */
  49582. samplers?: ISampler[];
  49583. /**
  49584. * The index of the default scene
  49585. */
  49586. scene?: number;
  49587. /**
  49588. * An array of scenes
  49589. */
  49590. scenes?: IScene[];
  49591. /**
  49592. * An array of skins. A skin is defined by joints and matrices
  49593. */
  49594. skins?: ISkin[];
  49595. /**
  49596. * An array of textures
  49597. */
  49598. textures?: ITexture[];
  49599. }
  49600. }
  49601. /**
  49602. * Interface for glTF validation results
  49603. */
  49604. interface IGLTFValidationResults {
  49605. info: {
  49606. generator: string;
  49607. hasAnimations: boolean;
  49608. hasDefaultScene: boolean;
  49609. hasMaterials: boolean;
  49610. hasMorphTargets: boolean;
  49611. hasSkins: boolean;
  49612. hasTextures: boolean;
  49613. maxAttributesUsed: number;
  49614. primitivesCount: number
  49615. };
  49616. issues: {
  49617. messages: Array<string>;
  49618. numErrors: number;
  49619. numHints: number;
  49620. numInfos: number;
  49621. numWarnings: number;
  49622. truncated: boolean
  49623. };
  49624. mimeType: string;
  49625. uri: string;
  49626. validatedAt: string;
  49627. validatorVersion: string;
  49628. }
  49629. /**
  49630. * Interface for glTF validation options
  49631. */
  49632. interface IGLTFValidationOptions {
  49633. uri?: string;
  49634. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  49635. validateAccessorData?: boolean;
  49636. maxIssues?: number;
  49637. ignoredIssues?: Array<string>;
  49638. severityOverrides?: Object;
  49639. }
  49640. /**
  49641. * glTF validator object
  49642. */
  49643. declare var GLTFValidator: {
  49644. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  49645. };