babylon.d.txt 2.2 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968419694197041971419724197341974419754197641977419784197941980419814198241983419844198541986419874198841989419904199141992419934199441995419964199741998419994200042001420024200342004420054200642007420084200942010420114201242013420144201542016420174201842019420204202142022420234202442025420264202742028420294203042031420324203342034420354203642037420384203942040420414204242043420444204542046420474204842049420504205142052420534205442055420564205742058420594206042061420624206342064420654206642067420684206942070420714207242073420744207542076420774207842079420804208142082420834208442085420864208742088420894209042091420924209342094420954209642097420984209942100421014210242103421044210542106421074210842109421104211142112421134211442115421164211742118421194212042121421224212342124421254212642127421284212942130421314213242133421344213542136421374213842139421404214142142421434214442145421464214742148421494215042151421524215342154421554215642157421584215942160421614216242163421644216542166421674216842169421704217142172421734217442175421764217742178421794218042181421824218342184421854218642187421884218942190421914219242193421944219542196421974219842199422004220142202422034220442205422064220742208422094221042211422124221342214422154221642217422184221942220422214222242223422244222542226422274222842229422304223142232422334223442235422364223742238422394224042241422424224342244422454224642247422484224942250422514225242253422544225542256422574225842259422604226142262422634226442265422664226742268422694227042271422724227342274422754227642277422784227942280422814228242283422844228542286422874228842289422904229142292422934229442295422964229742298422994230042301423024230342304423054230642307423084230942310423114231242313423144231542316423174231842319423204232142322423234232442325423264232742328423294233042331423324233342334423354233642337423384233942340423414234242343423444234542346423474234842349423504235142352423534235442355423564235742358423594236042361423624236342364423654236642367423684236942370423714237242373423744237542376423774237842379423804238142382423834238442385423864238742388423894239042391423924239342394423954239642397423984239942400424014240242403424044240542406424074240842409424104241142412424134241442415424164241742418424194242042421424224242342424424254242642427424284242942430424314243242433424344243542436424374243842439424404244142442424434244442445424464244742448424494245042451424524245342454424554245642457424584245942460424614246242463424644246542466424674246842469424704247142472424734247442475424764247742478424794248042481424824248342484424854248642487424884248942490424914249242493424944249542496424974249842499425004250142502425034250442505425064250742508425094251042511425124251342514425154251642517425184251942520425214252242523425244252542526425274252842529425304253142532425334253442535425364253742538425394254042541425424254342544425454254642547425484254942550425514255242553425544255542556425574255842559425604256142562425634256442565425664256742568425694257042571425724257342574425754257642577425784257942580425814258242583425844258542586425874258842589425904259142592425934259442595425964259742598425994260042601426024260342604426054260642607426084260942610426114261242613426144261542616426174261842619426204262142622426234262442625426264262742628426294263042631426324263342634426354263642637426384263942640426414264242643426444264542646426474264842649426504265142652426534265442655426564265742658426594266042661426624266342664426654266642667426684266942670426714267242673426744267542676426774267842679426804268142682426834268442685426864268742688426894269042691426924269342694426954269642697426984269942700427014270242703427044270542706427074270842709427104271142712427134271442715427164271742718427194272042721427224272342724427254272642727427284272942730427314273242733427344273542736427374273842739427404274142742427434274442745427464274742748427494275042751427524275342754427554275642757427584275942760427614276242763427644276542766427674276842769427704277142772427734277442775427764277742778427794278042781427824278342784427854278642787427884278942790427914279242793427944279542796427974279842799428004280142802428034280442805428064280742808428094281042811428124281342814428154281642817428184281942820428214282242823428244282542826428274282842829428304283142832428334283442835428364283742838428394284042841428424284342844428454284642847428484284942850428514285242853428544285542856428574285842859428604286142862428634286442865428664286742868428694287042871428724287342874428754287642877428784287942880428814288242883428844288542886428874288842889428904289142892428934289442895428964289742898428994290042901429024290342904429054290642907429084290942910429114291242913429144291542916429174291842919429204292142922429234292442925429264292742928429294293042931429324293342934429354293642937429384293942940429414294242943429444294542946429474294842949429504295142952429534295442955429564295742958429594296042961429624296342964429654296642967429684296942970429714297242973429744297542976429774297842979429804298142982429834298442985429864298742988429894299042991429924299342994429954299642997429984299943000430014300243003430044300543006430074300843009430104301143012430134301443015430164301743018430194302043021430224302343024430254302643027430284302943030430314303243033430344303543036430374303843039430404304143042430434304443045430464304743048430494305043051430524305343054430554305643057430584305943060430614306243063430644306543066430674306843069430704307143072430734307443075430764307743078430794308043081430824308343084430854308643087430884308943090430914309243093430944309543096430974309843099431004310143102431034310443105431064310743108431094311043111431124311343114431154311643117431184311943120431214312243123431244312543126431274312843129431304313143132431334313443135431364313743138431394314043141431424314343144431454314643147431484314943150431514315243153431544315543156431574315843159431604316143162431634316443165431664316743168431694317043171431724317343174431754317643177431784317943180431814318243183431844318543186431874318843189431904319143192431934319443195431964319743198431994320043201432024320343204432054320643207432084320943210432114321243213432144321543216432174321843219432204322143222432234322443225432264322743228432294323043231432324323343234432354323643237432384323943240432414324243243432444324543246432474324843249432504325143252432534325443255432564325743258432594326043261432624326343264432654326643267432684326943270432714327243273432744327543276432774327843279432804328143282432834328443285432864328743288432894329043291432924329343294432954329643297432984329943300433014330243303433044330543306433074330843309433104331143312433134331443315433164331743318433194332043321433224332343324433254332643327433284332943330433314333243333433344333543336433374333843339433404334143342433434334443345433464334743348433494335043351433524335343354433554335643357433584335943360433614336243363433644336543366433674336843369433704337143372433734337443375433764337743378433794338043381433824338343384433854338643387433884338943390433914339243393433944339543396433974339843399434004340143402434034340443405434064340743408434094341043411434124341343414434154341643417434184341943420434214342243423434244342543426434274342843429434304343143432434334343443435434364343743438434394344043441434424344343444434454344643447434484344943450434514345243453434544345543456434574345843459434604346143462434634346443465434664346743468434694347043471434724347343474434754347643477434784347943480434814348243483434844348543486434874348843489434904349143492434934349443495434964349743498434994350043501435024350343504435054350643507435084350943510435114351243513435144351543516435174351843519435204352143522435234352443525435264352743528435294353043531435324353343534435354353643537435384353943540435414354243543435444354543546435474354843549435504355143552435534355443555435564355743558435594356043561435624356343564435654356643567435684356943570435714357243573435744357543576435774357843579435804358143582435834358443585435864358743588435894359043591435924359343594435954359643597435984359943600436014360243603436044360543606436074360843609436104361143612436134361443615436164361743618436194362043621436224362343624436254362643627436284362943630436314363243633436344363543636436374363843639436404364143642436434364443645436464364743648436494365043651436524365343654436554365643657436584365943660436614366243663436644366543666436674366843669436704367143672436734367443675436764367743678436794368043681436824368343684436854368643687436884368943690436914369243693436944369543696436974369843699437004370143702437034370443705437064370743708437094371043711437124371343714437154371643717437184371943720437214372243723437244372543726437274372843729437304373143732437334373443735437364373743738437394374043741437424374343744437454374643747437484374943750437514375243753437544375543756437574375843759437604376143762437634376443765437664376743768437694377043771437724377343774437754377643777437784377943780437814378243783437844378543786437874378843789437904379143792437934379443795437964379743798437994380043801438024380343804438054380643807438084380943810438114381243813438144381543816438174381843819438204382143822438234382443825438264382743828438294383043831438324383343834438354383643837438384383943840438414384243843438444384543846438474384843849438504385143852438534385443855438564385743858438594386043861438624386343864438654386643867438684386943870438714387243873438744387543876438774387843879438804388143882438834388443885438864388743888438894389043891438924389343894438954389643897438984389943900439014390243903439044390543906439074390843909439104391143912439134391443915439164391743918439194392043921439224392343924439254392643927439284392943930439314393243933439344393543936439374393843939439404394143942439434394443945439464394743948439494395043951439524395343954439554395643957439584395943960439614396243963439644396543966439674396843969439704397143972439734397443975439764397743978439794398043981439824398343984439854398643987439884398943990439914399243993439944399543996439974399843999440004400144002440034400444005440064400744008440094401044011440124401344014440154401644017440184401944020440214402244023440244402544026440274402844029440304403144032440334403444035440364403744038440394404044041440424404344044440454404644047440484404944050440514405244053440544405544056440574405844059440604406144062440634406444065440664406744068440694407044071440724407344074440754407644077440784407944080440814408244083440844408544086440874408844089440904409144092440934409444095440964409744098440994410044101441024410344104441054410644107441084410944110441114411244113441144411544116441174411844119441204412144122441234412444125441264412744128441294413044131441324413344134441354413644137441384413944140441414414244143441444414544146441474414844149441504415144152441534415444155441564415744158441594416044161441624416344164441654416644167441684416944170441714417244173441744417544176441774417844179441804418144182441834418444185441864418744188441894419044191441924419344194441954419644197441984419944200442014420244203442044420544206442074420844209442104421144212442134421444215442164421744218442194422044221442224422344224442254422644227442284422944230442314423244233442344423544236442374423844239442404424144242442434424444245442464424744248442494425044251442524425344254442554425644257442584425944260442614426244263442644426544266442674426844269442704427144272442734427444275442764427744278442794428044281442824428344284442854428644287442884428944290442914429244293442944429544296442974429844299443004430144302443034430444305443064430744308443094431044311443124431344314443154431644317443184431944320443214432244323443244432544326443274432844329443304433144332443334433444335443364433744338443394434044341443424434344344443454434644347443484434944350443514435244353443544435544356443574435844359443604436144362443634436444365443664436744368443694437044371443724437344374443754437644377443784437944380443814438244383443844438544386443874438844389443904439144392443934439444395443964439744398443994440044401444024440344404444054440644407444084440944410444114441244413444144441544416444174441844419444204442144422444234442444425444264442744428444294443044431444324443344434444354443644437444384443944440444414444244443444444444544446444474444844449444504445144452444534445444455444564445744458444594446044461444624446344464444654446644467444684446944470444714447244473444744447544476444774447844479444804448144482444834448444485444864448744488444894449044491444924449344494444954449644497444984449944500445014450244503445044450544506445074450844509445104451144512445134451444515445164451744518445194452044521445224452344524445254452644527445284452944530445314453244533445344453544536445374453844539445404454144542445434454444545445464454744548445494455044551445524455344554445554455644557445584455944560445614456244563445644456544566445674456844569445704457144572445734457444575445764457744578445794458044581445824458344584445854458644587445884458944590445914459244593445944459544596445974459844599446004460144602446034460444605446064460744608446094461044611446124461344614446154461644617446184461944620446214462244623446244462544626446274462844629446304463144632446334463444635446364463744638446394464044641446424464344644446454464644647446484464944650446514465244653446544465544656446574465844659446604466144662446634466444665446664466744668446694467044671446724467344674446754467644677446784467944680446814468244683446844468544686446874468844689446904469144692446934469444695446964469744698446994470044701447024470344704447054470644707447084470944710447114471244713447144471544716447174471844719447204472144722447234472444725447264472744728447294473044731447324473344734447354473644737447384473944740447414474244743447444474544746447474474844749447504475144752447534475444755447564475744758447594476044761447624476344764447654476644767447684476944770447714477244773447744477544776447774477844779447804478144782447834478444785447864478744788447894479044791447924479344794447954479644797447984479944800448014480244803448044480544806448074480844809448104481144812448134481444815448164481744818448194482044821448224482344824448254482644827448284482944830448314483244833448344483544836448374483844839448404484144842448434484444845448464484744848448494485044851448524485344854448554485644857448584485944860448614486244863448644486544866448674486844869448704487144872448734487444875448764487744878448794488044881448824488344884448854488644887448884488944890448914489244893448944489544896448974489844899449004490144902449034490444905449064490744908449094491044911449124491344914449154491644917449184491944920449214492244923449244492544926449274492844929449304493144932449334493444935449364493744938449394494044941449424494344944449454494644947449484494944950449514495244953449544495544956449574495844959449604496144962449634496444965449664496744968449694497044971449724497344974449754497644977449784497944980449814498244983449844498544986449874498844989449904499144992449934499444995449964499744998449994500045001450024500345004450054500645007450084500945010450114501245013450144501545016450174501845019450204502145022450234502445025450264502745028450294503045031450324503345034450354503645037450384503945040450414504245043450444504545046450474504845049450504505145052450534505445055450564505745058450594506045061450624506345064450654506645067450684506945070450714507245073450744507545076450774507845079450804508145082450834508445085450864508745088450894509045091450924509345094450954509645097450984509945100451014510245103451044510545106451074510845109451104511145112451134511445115451164511745118451194512045121451224512345124451254512645127451284512945130451314513245133451344513545136451374513845139451404514145142451434514445145451464514745148451494515045151451524515345154451554515645157451584515945160451614516245163451644516545166451674516845169451704517145172451734517445175451764517745178451794518045181451824518345184451854518645187451884518945190451914519245193451944519545196451974519845199452004520145202452034520445205452064520745208452094521045211452124521345214452154521645217452184521945220452214522245223452244522545226452274522845229452304523145232452334523445235452364523745238452394524045241452424524345244452454524645247452484524945250452514525245253452544525545256452574525845259452604526145262452634526445265452664526745268452694527045271452724527345274452754527645277452784527945280452814528245283452844528545286452874528845289452904529145292452934529445295452964529745298452994530045301453024530345304453054530645307453084530945310453114531245313453144531545316453174531845319453204532145322453234532445325453264532745328453294533045331453324533345334453354533645337453384533945340453414534245343453444534545346453474534845349453504535145352453534535445355453564535745358453594536045361453624536345364453654536645367453684536945370453714537245373453744537545376453774537845379453804538145382453834538445385453864538745388453894539045391453924539345394453954539645397453984539945400454014540245403454044540545406454074540845409454104541145412454134541445415454164541745418454194542045421454224542345424454254542645427454284542945430454314543245433454344543545436454374543845439454404544145442454434544445445454464544745448454494545045451454524545345454454554545645457454584545945460454614546245463454644546545466454674546845469454704547145472454734547445475454764547745478454794548045481454824548345484454854548645487454884548945490454914549245493454944549545496454974549845499455004550145502455034550445505455064550745508455094551045511455124551345514455154551645517455184551945520455214552245523455244552545526455274552845529455304553145532455334553445535455364553745538455394554045541455424554345544455454554645547455484554945550455514555245553455544555545556455574555845559455604556145562455634556445565455664556745568455694557045571455724557345574455754557645577455784557945580455814558245583455844558545586455874558845589455904559145592455934559445595455964559745598455994560045601456024560345604456054560645607456084560945610456114561245613456144561545616456174561845619456204562145622456234562445625456264562745628456294563045631456324563345634456354563645637456384563945640456414564245643456444564545646456474564845649456504565145652456534565445655456564565745658456594566045661456624566345664456654566645667456684566945670456714567245673456744567545676456774567845679456804568145682456834568445685456864568745688456894569045691456924569345694456954569645697456984569945700457014570245703457044570545706457074570845709457104571145712457134571445715457164571745718457194572045721457224572345724457254572645727457284572945730457314573245733457344573545736457374573845739457404574145742457434574445745457464574745748457494575045751457524575345754457554575645757457584575945760457614576245763457644576545766457674576845769457704577145772457734577445775457764577745778457794578045781457824578345784457854578645787457884578945790457914579245793457944579545796457974579845799458004580145802458034580445805458064580745808458094581045811458124581345814458154581645817458184581945820458214582245823458244582545826458274582845829458304583145832458334583445835458364583745838458394584045841458424584345844458454584645847458484584945850458514585245853458544585545856458574585845859458604586145862458634586445865458664586745868458694587045871458724587345874458754587645877458784587945880458814588245883458844588545886458874588845889458904589145892458934589445895458964589745898458994590045901459024590345904459054590645907459084590945910459114591245913459144591545916459174591845919459204592145922459234592445925459264592745928459294593045931459324593345934459354593645937459384593945940459414594245943459444594545946459474594845949459504595145952459534595445955459564595745958459594596045961459624596345964459654596645967459684596945970459714597245973459744597545976459774597845979459804598145982459834598445985459864598745988459894599045991459924599345994459954599645997459984599946000460014600246003460044600546006460074600846009460104601146012460134601446015460164601746018460194602046021460224602346024460254602646027460284602946030460314603246033460344603546036460374603846039460404604146042460434604446045460464604746048460494605046051460524605346054460554605646057460584605946060460614606246063460644606546066460674606846069460704607146072460734607446075460764607746078460794608046081460824608346084460854608646087460884608946090460914609246093460944609546096460974609846099461004610146102461034610446105461064610746108461094611046111461124611346114461154611646117461184611946120461214612246123461244612546126461274612846129461304613146132461334613446135461364613746138461394614046141461424614346144461454614646147461484614946150461514615246153461544615546156461574615846159461604616146162461634616446165461664616746168461694617046171461724617346174461754617646177461784617946180461814618246183461844618546186461874618846189461904619146192461934619446195461964619746198461994620046201462024620346204462054620646207462084620946210462114621246213462144621546216462174621846219462204622146222462234622446225462264622746228462294623046231462324623346234462354623646237462384623946240462414624246243462444624546246462474624846249462504625146252462534625446255462564625746258462594626046261462624626346264462654626646267462684626946270462714627246273462744627546276462774627846279462804628146282462834628446285462864628746288462894629046291462924629346294462954629646297462984629946300463014630246303463044630546306463074630846309463104631146312463134631446315463164631746318463194632046321463224632346324463254632646327463284632946330463314633246333463344633546336463374633846339463404634146342463434634446345463464634746348463494635046351463524635346354463554635646357463584635946360463614636246363463644636546366463674636846369463704637146372463734637446375463764637746378463794638046381463824638346384463854638646387463884638946390463914639246393463944639546396463974639846399464004640146402464034640446405464064640746408464094641046411464124641346414464154641646417464184641946420464214642246423464244642546426464274642846429464304643146432464334643446435464364643746438464394644046441464424644346444464454644646447464484644946450464514645246453464544645546456464574645846459464604646146462464634646446465464664646746468464694647046471464724647346474464754647646477464784647946480464814648246483464844648546486464874648846489464904649146492464934649446495464964649746498464994650046501465024650346504465054650646507465084650946510465114651246513465144651546516465174651846519465204652146522465234652446525465264652746528465294653046531465324653346534465354653646537465384653946540465414654246543465444654546546465474654846549465504655146552465534655446555465564655746558465594656046561465624656346564465654656646567465684656946570465714657246573465744657546576465774657846579465804658146582465834658446585465864658746588465894659046591465924659346594465954659646597465984659946600466014660246603466044660546606466074660846609466104661146612466134661446615466164661746618466194662046621466224662346624466254662646627466284662946630466314663246633466344663546636466374663846639466404664146642466434664446645466464664746648466494665046651466524665346654466554665646657466584665946660466614666246663466644666546666466674666846669466704667146672466734667446675466764667746678466794668046681466824668346684466854668646687466884668946690466914669246693466944669546696466974669846699467004670146702467034670446705467064670746708467094671046711467124671346714467154671646717467184671946720467214672246723467244672546726467274672846729467304673146732467334673446735467364673746738467394674046741467424674346744467454674646747467484674946750467514675246753467544675546756467574675846759467604676146762467634676446765467664676746768467694677046771467724677346774467754677646777467784677946780467814678246783467844678546786467874678846789467904679146792467934679446795467964679746798467994680046801468024680346804468054680646807468084680946810468114681246813468144681546816468174681846819468204682146822468234682446825468264682746828468294683046831468324683346834468354683646837468384683946840468414684246843468444684546846468474684846849468504685146852468534685446855468564685746858468594686046861468624686346864468654686646867468684686946870468714687246873468744687546876468774687846879468804688146882468834688446885468864688746888468894689046891468924689346894468954689646897468984689946900469014690246903469044690546906469074690846909469104691146912469134691446915469164691746918469194692046921469224692346924469254692646927469284692946930469314693246933469344693546936469374693846939469404694146942469434694446945469464694746948469494695046951469524695346954469554695646957469584695946960469614696246963469644696546966469674696846969469704697146972469734697446975469764697746978469794698046981469824698346984469854698646987469884698946990469914699246993469944699546996469974699846999470004700147002470034700447005470064700747008470094701047011470124701347014470154701647017470184701947020470214702247023470244702547026470274702847029470304703147032470334703447035470364703747038470394704047041470424704347044470454704647047470484704947050470514705247053470544705547056470574705847059470604706147062470634706447065470664706747068470694707047071470724707347074470754707647077470784707947080470814708247083470844708547086470874708847089470904709147092470934709447095470964709747098470994710047101471024710347104471054710647107471084710947110471114711247113471144711547116471174711847119471204712147122471234712447125471264712747128471294713047131471324713347134471354713647137471384713947140471414714247143471444714547146471474714847149471504715147152471534715447155471564715747158471594716047161471624716347164471654716647167471684716947170471714717247173471744717547176471774717847179471804718147182471834718447185471864718747188471894719047191471924719347194471954719647197471984719947200472014720247203472044720547206472074720847209472104721147212472134721447215472164721747218472194722047221472224722347224472254722647227472284722947230472314723247233472344723547236472374723847239472404724147242472434724447245472464724747248472494725047251472524725347254472554725647257472584725947260472614726247263472644726547266472674726847269472704727147272472734727447275472764727747278472794728047281472824728347284472854728647287472884728947290472914729247293472944729547296472974729847299473004730147302473034730447305473064730747308473094731047311473124731347314473154731647317473184731947320473214732247323473244732547326473274732847329473304733147332473334733447335473364733747338473394734047341473424734347344473454734647347473484734947350473514735247353473544735547356473574735847359473604736147362473634736447365473664736747368473694737047371473724737347374473754737647377473784737947380473814738247383473844738547386473874738847389473904739147392473934739447395473964739747398473994740047401474024740347404474054740647407474084740947410474114741247413474144741547416474174741847419474204742147422474234742447425474264742747428474294743047431474324743347434474354743647437474384743947440474414744247443474444744547446474474744847449474504745147452474534745447455474564745747458474594746047461474624746347464474654746647467474684746947470474714747247473474744747547476474774747847479474804748147482474834748447485474864748747488474894749047491474924749347494474954749647497474984749947500475014750247503475044750547506475074750847509475104751147512475134751447515475164751747518475194752047521475224752347524475254752647527475284752947530475314753247533475344753547536475374753847539475404754147542475434754447545475464754747548475494755047551475524755347554475554755647557475584755947560475614756247563475644756547566475674756847569475704757147572475734757447575475764757747578475794758047581475824758347584475854758647587475884758947590475914759247593475944759547596475974759847599476004760147602476034760447605476064760747608476094761047611476124761347614476154761647617476184761947620476214762247623476244762547626476274762847629476304763147632476334763447635476364763747638476394764047641476424764347644476454764647647476484764947650476514765247653476544765547656476574765847659476604766147662476634766447665476664766747668476694767047671476724767347674476754767647677476784767947680476814768247683476844768547686476874768847689476904769147692476934769447695476964769747698476994770047701477024770347704477054770647707477084770947710477114771247713477144771547716477174771847719477204772147722477234772447725477264772747728477294773047731477324773347734477354773647737477384773947740477414774247743477444774547746477474774847749477504775147752477534775447755477564775747758477594776047761477624776347764477654776647767477684776947770477714777247773477744777547776477774777847779477804778147782477834778447785477864778747788477894779047791477924779347794477954779647797477984779947800478014780247803478044780547806478074780847809478104781147812478134781447815478164781747818478194782047821478224782347824478254782647827478284782947830478314783247833478344783547836478374783847839478404784147842478434784447845478464784747848478494785047851478524785347854478554785647857478584785947860478614786247863478644786547866478674786847869478704787147872478734787447875478764787747878478794788047881478824788347884478854788647887478884788947890478914789247893478944789547896478974789847899479004790147902479034790447905479064790747908479094791047911479124791347914479154791647917479184791947920479214792247923479244792547926479274792847929479304793147932479334793447935479364793747938479394794047941479424794347944479454794647947479484794947950479514795247953479544795547956479574795847959479604796147962479634796447965479664796747968479694797047971479724797347974479754797647977479784797947980479814798247983479844798547986479874798847989479904799147992479934799447995479964799747998479994800048001480024800348004480054800648007480084800948010480114801248013480144801548016480174801848019480204802148022480234802448025480264802748028480294803048031480324803348034480354803648037480384803948040480414804248043480444804548046480474804848049480504805148052480534805448055480564805748058480594806048061480624806348064480654806648067480684806948070480714807248073480744807548076480774807848079480804808148082480834808448085480864808748088480894809048091480924809348094480954809648097480984809948100481014810248103481044810548106481074810848109481104811148112481134811448115481164811748118481194812048121481224812348124481254812648127481284812948130481314813248133481344813548136481374813848139481404814148142481434814448145481464814748148481494815048151481524815348154481554815648157481584815948160481614816248163481644816548166481674816848169481704817148172481734817448175481764817748178481794818048181481824818348184481854818648187481884818948190481914819248193481944819548196481974819848199482004820148202482034820448205482064820748208482094821048211482124821348214482154821648217482184821948220482214822248223482244822548226482274822848229482304823148232482334823448235482364823748238482394824048241482424824348244482454824648247482484824948250482514825248253482544825548256482574825848259482604826148262482634826448265482664826748268482694827048271482724827348274482754827648277482784827948280482814828248283482844828548286482874828848289482904829148292482934829448295482964829748298482994830048301483024830348304483054830648307483084830948310483114831248313483144831548316483174831848319483204832148322483234832448325483264832748328483294833048331483324833348334483354833648337483384833948340483414834248343483444834548346483474834848349483504835148352483534835448355483564835748358483594836048361483624836348364483654836648367483684836948370483714837248373483744837548376483774837848379483804838148382483834838448385483864838748388483894839048391483924839348394483954839648397483984839948400484014840248403484044840548406484074840848409484104841148412484134841448415484164841748418484194842048421484224842348424484254842648427484284842948430484314843248433484344843548436484374843848439484404844148442484434844448445484464844748448484494845048451484524845348454484554845648457484584845948460484614846248463484644846548466484674846848469484704847148472484734847448475484764847748478484794848048481484824848348484484854848648487484884848948490484914849248493484944849548496484974849848499485004850148502485034850448505485064850748508485094851048511485124851348514485154851648517485184851948520485214852248523485244852548526485274852848529485304853148532485334853448535485364853748538485394854048541485424854348544485454854648547485484854948550485514855248553485544855548556485574855848559485604856148562485634856448565485664856748568485694857048571485724857348574485754857648577485784857948580485814858248583485844858548586485874858848589485904859148592485934859448595485964859748598485994860048601486024860348604486054860648607486084860948610486114861248613486144861548616486174861848619486204862148622486234862448625486264862748628486294863048631486324863348634486354863648637486384863948640486414864248643486444864548646486474864848649486504865148652486534865448655486564865748658486594866048661486624866348664486654866648667486684866948670486714867248673486744867548676486774867848679486804868148682486834868448685486864868748688486894869048691486924869348694486954869648697486984869948700487014870248703487044870548706487074870848709487104871148712487134871448715487164871748718487194872048721487224872348724487254872648727487284872948730487314873248733487344873548736487374873848739487404874148742487434874448745487464874748748487494875048751487524875348754487554875648757487584875948760487614876248763487644876548766487674876848769487704877148772487734877448775487764877748778487794878048781487824878348784487854878648787487884878948790487914879248793487944879548796487974879848799488004880148802488034880448805488064880748808488094881048811488124881348814488154881648817488184881948820488214882248823488244882548826488274882848829488304883148832488334883448835488364883748838488394884048841488424884348844488454884648847488484884948850488514885248853488544885548856488574885848859488604886148862488634886448865488664886748868488694887048871488724887348874488754887648877488784887948880488814888248883488844888548886488874888848889488904889148892488934889448895488964889748898488994890048901489024890348904489054890648907489084890948910489114891248913489144891548916489174891848919489204892148922489234892448925489264892748928489294893048931489324893348934489354893648937489384893948940489414894248943489444894548946489474894848949489504895148952489534895448955489564895748958489594896048961489624896348964489654896648967489684896948970489714897248973489744897548976489774897848979489804898148982489834898448985489864898748988489894899048991489924899348994489954899648997489984899949000490014900249003490044900549006490074900849009490104901149012490134901449015490164901749018490194902049021490224902349024490254902649027490284902949030490314903249033490344903549036490374903849039490404904149042490434904449045490464904749048490494905049051490524905349054490554905649057490584905949060490614906249063490644906549066490674906849069490704907149072490734907449075490764907749078490794908049081490824908349084490854908649087490884908949090490914909249093490944909549096490974909849099491004910149102491034910449105491064910749108491094911049111491124911349114491154911649117491184911949120491214912249123491244912549126491274912849129491304913149132491334913449135491364913749138491394914049141491424914349144491454914649147491484914949150491514915249153491544915549156491574915849159491604916149162491634916449165491664916749168491694917049171491724917349174491754917649177491784917949180491814918249183491844918549186491874918849189491904919149192491934919449195491964919749198491994920049201492024920349204492054920649207492084920949210492114921249213492144921549216492174921849219492204922149222492234922449225492264922749228492294923049231492324923349234492354923649237492384923949240492414924249243492444924549246492474924849249492504925149252492534925449255492564925749258492594926049261492624926349264492654926649267492684926949270492714927249273492744927549276492774927849279492804928149282492834928449285492864928749288492894929049291492924929349294492954929649297492984929949300493014930249303493044930549306493074930849309493104931149312493134931449315493164931749318493194932049321493224932349324493254932649327493284932949330493314933249333493344933549336493374933849339493404934149342493434934449345493464934749348493494935049351493524935349354493554935649357493584935949360493614936249363493644936549366493674936849369493704937149372493734937449375493764937749378493794938049381493824938349384493854938649387493884938949390493914939249393493944939549396493974939849399494004940149402494034940449405494064940749408494094941049411494124941349414494154941649417494184941949420494214942249423494244942549426494274942849429494304943149432494334943449435494364943749438494394944049441494424944349444494454944649447494484944949450494514945249453494544945549456494574945849459494604946149462494634946449465494664946749468494694947049471494724947349474494754947649477494784947949480494814948249483494844948549486494874948849489494904949149492494934949449495494964949749498494994950049501495024950349504495054950649507495084950949510495114951249513495144951549516495174951849519495204952149522495234952449525495264952749528495294953049531495324953349534495354953649537495384953949540495414954249543495444954549546495474954849549495504955149552495534955449555495564955749558495594956049561495624956349564495654956649567495684956949570495714957249573495744957549576495774957849579495804958149582495834958449585495864958749588495894959049591495924959349594495954959649597495984959949600496014960249603496044960549606496074960849609496104961149612496134961449615496164961749618496194962049621496224962349624496254962649627496284962949630496314963249633496344963549636496374963849639496404964149642496434964449645496464964749648496494965049651496524965349654496554965649657496584965949660496614966249663496644966549666496674966849669496704967149672496734967449675496764967749678496794968049681496824968349684496854968649687496884968949690496914969249693496944969549696496974969849699497004970149702497034970449705497064970749708497094971049711497124971349714497154971649717497184971949720497214972249723497244972549726497274972849729497304973149732497334973449735497364973749738497394974049741497424974349744497454974649747497484974949750497514975249753497544975549756497574975849759497604976149762497634976449765497664976749768497694977049771497724977349774497754977649777497784977949780497814978249783497844978549786497874978849789497904979149792497934979449795497964979749798497994980049801498024980349804498054980649807498084980949810498114981249813498144981549816498174981849819498204982149822498234982449825498264982749828498294983049831498324983349834498354983649837498384983949840498414984249843498444984549846498474984849849498504985149852498534985449855498564985749858498594986049861498624986349864498654986649867498684986949870498714987249873498744987549876498774987849879498804988149882498834988449885498864988749888498894989049891498924989349894498954989649897498984989949900499014990249903499044990549906499074990849909499104991149912499134991449915499164991749918499194992049921499224992349924499254992649927499284992949930499314993249933499344993549936499374993849939499404994149942499434994449945499464994749948499494995049951499524995349954499554995649957499584995949960499614996249963499644996549966499674996849969499704997149972499734997449975499764997749978499794998049981499824998349984499854998649987499884998949990499914999249993499944999549996499974999849999500005000150002500035000450005500065000750008500095001050011500125001350014500155001650017500185001950020500215002250023500245002550026500275002850029500305003150032500335003450035500365003750038500395004050041500425004350044500455004650047500485004950050500515005250053500545005550056500575005850059500605006150062500635006450065500665006750068500695007050071500725007350074500755007650077500785007950080500815008250083500845008550086500875008850089500905009150092500935009450095500965009750098500995010050101501025010350104501055010650107501085010950110501115011250113501145011550116501175011850119501205012150122501235012450125501265012750128501295013050131501325013350134501355013650137501385013950140501415014250143501445014550146501475014850149501505015150152501535015450155501565015750158501595016050161501625016350164501655016650167501685016950170501715017250173501745017550176501775017850179501805018150182501835018450185501865018750188501895019050191501925019350194501955019650197501985019950200502015020250203502045020550206502075020850209502105021150212502135021450215502165021750218502195022050221502225022350224502255022650227502285022950230502315023250233502345023550236502375023850239502405024150242502435024450245502465024750248502495025050251502525025350254502555025650257502585025950260502615026250263502645026550266502675026850269502705027150272502735027450275502765027750278502795028050281502825028350284502855028650287502885028950290502915029250293502945029550296502975029850299503005030150302503035030450305503065030750308503095031050311503125031350314503155031650317503185031950320503215032250323503245032550326503275032850329503305033150332503335033450335503365033750338503395034050341503425034350344503455034650347503485034950350503515035250353503545035550356503575035850359503605036150362503635036450365503665036750368503695037050371503725037350374503755037650377503785037950380503815038250383503845038550386503875038850389503905039150392503935039450395503965039750398503995040050401504025040350404504055040650407504085040950410504115041250413504145041550416504175041850419504205042150422504235042450425504265042750428504295043050431504325043350434504355043650437504385043950440504415044250443504445044550446504475044850449504505045150452504535045450455504565045750458504595046050461504625046350464504655046650467504685046950470504715047250473504745047550476504775047850479504805048150482504835048450485504865048750488504895049050491504925049350494504955049650497504985049950500505015050250503505045050550506505075050850509505105051150512505135051450515505165051750518505195052050521505225052350524505255052650527505285052950530505315053250533505345053550536505375053850539505405054150542505435054450545505465054750548505495055050551505525055350554505555055650557505585055950560505615056250563505645056550566505675056850569505705057150572505735057450575505765057750578505795058050581505825058350584505855058650587505885058950590505915059250593505945059550596505975059850599506005060150602506035060450605506065060750608506095061050611506125061350614506155061650617506185061950620506215062250623506245062550626506275062850629506305063150632506335063450635506365063750638506395064050641506425064350644506455064650647506485064950650506515065250653506545065550656506575065850659506605066150662506635066450665506665066750668506695067050671506725067350674506755067650677506785067950680506815068250683506845068550686506875068850689506905069150692506935069450695506965069750698506995070050701507025070350704507055070650707507085070950710507115071250713507145071550716507175071850719507205072150722507235072450725507265072750728507295073050731507325073350734507355073650737507385073950740507415074250743507445074550746507475074850749507505075150752507535075450755507565075750758507595076050761507625076350764507655076650767507685076950770507715077250773507745077550776507775077850779507805078150782507835078450785507865078750788507895079050791507925079350794507955079650797507985079950800508015080250803508045080550806508075080850809508105081150812508135081450815508165081750818508195082050821508225082350824508255082650827508285082950830508315083250833508345083550836508375083850839508405084150842508435084450845508465084750848508495085050851508525085350854508555085650857508585085950860508615086250863508645086550866508675086850869508705087150872508735087450875508765087750878508795088050881508825088350884508855088650887508885088950890508915089250893508945089550896508975089850899509005090150902509035090450905509065090750908509095091050911509125091350914509155091650917509185091950920509215092250923509245092550926509275092850929509305093150932509335093450935509365093750938509395094050941509425094350944509455094650947509485094950950509515095250953509545095550956509575095850959509605096150962509635096450965509665096750968509695097050971509725097350974509755097650977509785097950980509815098250983509845098550986509875098850989509905099150992509935099450995509965099750998509995100051001510025100351004510055100651007510085100951010510115101251013510145101551016510175101851019510205102151022510235102451025510265102751028510295103051031510325103351034510355103651037510385103951040510415104251043510445104551046510475104851049510505105151052510535105451055510565105751058510595106051061510625106351064510655106651067510685106951070510715107251073510745107551076510775107851079510805108151082510835108451085510865108751088510895109051091510925109351094510955109651097510985109951100511015110251103511045110551106511075110851109511105111151112511135111451115511165111751118511195112051121511225112351124511255112651127511285112951130511315113251133511345113551136511375113851139511405114151142511435114451145511465114751148511495115051151511525115351154511555115651157511585115951160511615116251163511645116551166511675116851169511705117151172511735117451175511765117751178511795118051181511825118351184511855118651187511885118951190511915119251193511945119551196511975119851199512005120151202512035120451205512065120751208512095121051211512125121351214512155121651217512185121951220512215122251223512245122551226512275122851229512305123151232512335123451235512365123751238512395124051241512425124351244512455124651247512485124951250512515125251253512545125551256512575125851259512605126151262512635126451265512665126751268512695127051271512725127351274512755127651277512785127951280512815128251283512845128551286512875128851289512905129151292512935129451295512965129751298512995130051301513025130351304513055130651307513085130951310513115131251313513145131551316513175131851319513205132151322513235132451325513265132751328513295133051331513325133351334513355133651337513385133951340513415134251343513445134551346513475134851349513505135151352513535135451355513565135751358513595136051361513625136351364513655136651367513685136951370513715137251373513745137551376513775137851379513805138151382513835138451385513865138751388513895139051391513925139351394513955139651397513985139951400514015140251403514045140551406514075140851409514105141151412514135141451415514165141751418514195142051421514225142351424514255142651427514285142951430514315143251433514345143551436514375143851439514405144151442514435144451445514465144751448514495145051451514525145351454514555145651457514585145951460514615146251463514645146551466514675146851469514705147151472514735147451475514765147751478514795148051481514825148351484514855148651487514885148951490514915149251493514945149551496514975149851499515005150151502515035150451505515065150751508515095151051511515125151351514515155151651517515185151951520515215152251523515245152551526515275152851529515305153151532515335153451535515365153751538515395154051541515425154351544515455154651547515485154951550515515155251553515545155551556515575155851559515605156151562515635156451565515665156751568515695157051571515725157351574515755157651577515785157951580515815158251583515845158551586515875158851589515905159151592515935159451595515965159751598515995160051601516025160351604516055160651607516085160951610516115161251613516145161551616516175161851619516205162151622516235162451625516265162751628516295163051631516325163351634516355163651637516385163951640516415164251643516445164551646516475164851649516505165151652516535165451655516565165751658516595166051661516625166351664516655166651667516685166951670516715167251673516745167551676516775167851679516805168151682516835168451685516865168751688516895169051691516925169351694516955169651697516985169951700517015170251703517045170551706517075170851709517105171151712517135171451715517165171751718517195172051721517225172351724517255172651727517285172951730517315173251733517345173551736517375173851739517405174151742517435174451745517465174751748517495175051751517525175351754517555175651757517585175951760517615176251763517645176551766517675176851769517705177151772517735177451775517765177751778517795178051781517825178351784517855178651787517885178951790517915179251793517945179551796517975179851799518005180151802518035180451805518065180751808518095181051811518125181351814518155181651817518185181951820518215182251823518245182551826518275182851829518305183151832518335183451835518365183751838518395184051841518425184351844518455184651847518485184951850518515185251853518545185551856518575185851859518605186151862518635186451865518665186751868518695187051871518725187351874518755187651877518785187951880518815188251883518845188551886518875188851889518905189151892518935189451895518965189751898518995190051901519025190351904519055190651907519085190951910519115191251913519145191551916519175191851919519205192151922519235192451925519265192751928519295193051931519325193351934519355193651937519385193951940519415194251943519445194551946519475194851949519505195151952519535195451955519565195751958519595196051961519625196351964519655196651967519685196951970519715197251973519745197551976519775197851979519805198151982519835198451985519865198751988519895199051991519925199351994519955199651997519985199952000520015200252003520045200552006520075200852009520105201152012520135201452015520165201752018520195202052021520225202352024520255202652027520285202952030520315203252033520345203552036520375203852039520405204152042520435204452045520465204752048520495205052051520525205352054520555205652057520585205952060520615206252063520645206552066520675206852069520705207152072520735207452075520765207752078520795208052081520825208352084520855208652087520885208952090520915209252093520945209552096520975209852099521005210152102521035210452105521065210752108521095211052111521125211352114521155211652117521185211952120521215212252123521245212552126521275212852129521305213152132521335213452135521365213752138521395214052141521425214352144521455214652147521485214952150521515215252153521545215552156521575215852159521605216152162521635216452165521665216752168521695217052171521725217352174521755217652177521785217952180521815218252183521845218552186521875218852189521905219152192521935219452195521965219752198521995220052201522025220352204522055220652207522085220952210522115221252213522145221552216522175221852219522205222152222522235222452225522265222752228522295223052231522325223352234522355223652237522385223952240522415224252243522445224552246522475224852249522505225152252522535225452255522565225752258522595226052261522625226352264522655226652267522685226952270522715227252273522745227552276522775227852279522805228152282522835228452285522865228752288522895229052291522925229352294522955229652297522985229952300523015230252303523045230552306523075230852309523105231152312523135231452315523165231752318523195232052321523225232352324523255232652327523285232952330523315233252333523345233552336523375233852339523405234152342523435234452345523465234752348523495235052351523525235352354523555235652357523585235952360523615236252363523645236552366523675236852369523705237152372523735237452375523765237752378523795238052381523825238352384523855238652387523885238952390523915239252393523945239552396523975239852399524005240152402524035240452405524065240752408524095241052411524125241352414524155241652417524185241952420524215242252423524245242552426524275242852429524305243152432524335243452435524365243752438524395244052441524425244352444524455244652447524485244952450524515245252453524545245552456524575245852459524605246152462524635246452465524665246752468524695247052471524725247352474524755247652477524785247952480524815248252483524845248552486524875248852489524905249152492524935249452495524965249752498524995250052501525025250352504525055250652507525085250952510525115251252513525145251552516525175251852519525205252152522525235252452525525265252752528525295253052531525325253352534525355253652537525385253952540525415254252543525445254552546525475254852549525505255152552525535255452555525565255752558525595256052561525625256352564525655256652567525685256952570525715257252573525745257552576525775257852579525805258152582525835258452585525865258752588525895259052591525925259352594525955259652597525985259952600526015260252603526045260552606526075260852609526105261152612526135261452615526165261752618526195262052621526225262352624526255262652627526285262952630526315263252633526345263552636526375263852639526405264152642526435264452645526465264752648526495265052651526525265352654526555265652657526585265952660526615266252663526645266552666526675266852669526705267152672526735267452675526765267752678526795268052681526825268352684526855268652687526885268952690526915269252693526945269552696526975269852699527005270152702527035270452705527065270752708527095271052711527125271352714527155271652717527185271952720527215272252723527245272552726527275272852729527305273152732527335273452735527365273752738527395274052741527425274352744527455274652747527485274952750527515275252753527545275552756527575275852759527605276152762527635276452765527665276752768527695277052771527725277352774527755277652777527785277952780527815278252783527845278552786527875278852789527905279152792527935279452795527965279752798527995280052801528025280352804528055280652807528085280952810528115281252813528145281552816528175281852819528205282152822528235282452825528265282752828528295283052831528325283352834528355283652837528385283952840528415284252843528445284552846528475284852849528505285152852528535285452855528565285752858528595286052861528625286352864528655286652867528685286952870528715287252873528745287552876528775287852879528805288152882528835288452885528865288752888528895289052891528925289352894528955289652897528985289952900529015290252903529045290552906529075290852909529105291152912529135291452915529165291752918529195292052921529225292352924529255292652927529285292952930529315293252933529345293552936529375293852939529405294152942529435294452945529465294752948529495295052951529525295352954529555295652957529585295952960529615296252963529645296552966529675296852969529705297152972529735297452975529765297752978529795298052981529825298352984529855298652987529885298952990529915299252993529945299552996529975299852999530005300153002530035300453005530065300753008530095301053011530125301353014530155301653017530185301953020530215302253023530245302553026530275302853029530305303153032530335303453035530365303753038530395304053041530425304353044530455304653047530485304953050530515305253053530545305553056530575305853059530605306153062530635306453065530665306753068530695307053071530725307353074530755307653077530785307953080530815308253083530845308553086530875308853089530905309153092530935309453095530965309753098530995310053101531025310353104531055310653107531085310953110531115311253113531145311553116531175311853119531205312153122531235312453125531265312753128531295313053131531325313353134531355313653137531385313953140531415314253143531445314553146531475314853149531505315153152531535315453155531565315753158531595316053161531625316353164531655316653167531685316953170531715317253173531745317553176531775317853179531805318153182531835318453185531865318753188531895319053191531925319353194531955319653197531985319953200532015320253203532045320553206532075320853209532105321153212532135321453215532165321753218532195322053221532225322353224532255322653227532285322953230532315323253233532345323553236532375323853239532405324153242532435324453245532465324753248532495325053251532525325353254532555325653257532585325953260532615326253263532645326553266532675326853269532705327153272532735327453275532765327753278532795328053281532825328353284532855328653287532885328953290532915329253293532945329553296532975329853299533005330153302533035330453305533065330753308533095331053311533125331353314533155331653317533185331953320533215332253323533245332553326533275332853329533305333153332533335333453335533365333753338533395334053341533425334353344533455334653347533485334953350533515335253353533545335553356533575335853359533605336153362533635336453365533665336753368533695337053371533725337353374533755337653377533785337953380533815338253383533845338553386533875338853389533905339153392533935339453395533965339753398533995340053401534025340353404534055340653407534085340953410534115341253413534145341553416534175341853419534205342153422534235342453425534265342753428534295343053431534325343353434534355343653437534385343953440534415344253443534445344553446534475344853449534505345153452534535345453455534565345753458534595346053461534625346353464534655346653467534685346953470534715347253473534745347553476534775347853479534805348153482534835348453485534865348753488534895349053491534925349353494534955349653497534985349953500535015350253503535045350553506535075350853509535105351153512535135351453515535165351753518535195352053521535225352353524535255352653527535285352953530535315353253533535345353553536535375353853539535405354153542535435354453545535465354753548535495355053551535525355353554535555355653557535585355953560535615356253563535645356553566535675356853569535705357153572535735357453575535765357753578535795358053581535825358353584535855358653587535885358953590535915359253593535945359553596535975359853599536005360153602536035360453605536065360753608536095361053611536125361353614536155361653617536185361953620536215362253623536245362553626536275362853629536305363153632536335363453635536365363753638536395364053641536425364353644536455364653647536485364953650536515365253653536545365553656536575365853659536605366153662536635366453665536665366753668536695367053671536725367353674536755367653677536785367953680536815368253683536845368553686536875368853689536905369153692536935369453695536965369753698536995370053701537025370353704537055370653707537085370953710537115371253713537145371553716537175371853719537205372153722537235372453725537265372753728537295373053731537325373353734537355373653737537385373953740537415374253743537445374553746537475374853749537505375153752537535375453755537565375753758537595376053761537625376353764537655376653767537685376953770537715377253773537745377553776537775377853779537805378153782537835378453785537865378753788537895379053791537925379353794537955379653797537985379953800538015380253803538045380553806538075380853809538105381153812538135381453815538165381753818538195382053821538225382353824538255382653827538285382953830538315383253833538345383553836538375383853839538405384153842538435384453845538465384753848538495385053851538525385353854538555385653857538585385953860538615386253863538645386553866538675386853869538705387153872538735387453875538765387753878538795388053881538825388353884538855388653887538885388953890538915389253893538945389553896538975389853899539005390153902539035390453905539065390753908539095391053911539125391353914539155391653917539185391953920539215392253923539245392553926539275392853929539305393153932539335393453935539365393753938539395394053941539425394353944539455394653947539485394953950539515395253953539545395553956539575395853959539605396153962539635396453965539665396753968539695397053971539725397353974539755397653977539785397953980539815398253983539845398553986539875398853989539905399153992539935399453995539965399753998539995400054001540025400354004540055400654007540085400954010540115401254013540145401554016540175401854019540205402154022540235402454025540265402754028540295403054031540325403354034540355403654037540385403954040540415404254043540445404554046540475404854049540505405154052540535405454055540565405754058540595406054061540625406354064540655406654067540685406954070540715407254073540745407554076540775407854079540805408154082540835408454085540865408754088540895409054091540925409354094540955409654097540985409954100541015410254103541045410554106541075410854109541105411154112541135411454115541165411754118541195412054121541225412354124541255412654127541285412954130541315413254133541345413554136541375413854139541405414154142541435414454145541465414754148541495415054151541525415354154541555415654157541585415954160541615416254163541645416554166541675416854169541705417154172541735417454175541765417754178541795418054181541825418354184541855418654187541885418954190541915419254193541945419554196541975419854199542005420154202542035420454205542065420754208542095421054211542125421354214542155421654217542185421954220542215422254223542245422554226542275422854229542305423154232542335423454235542365423754238542395424054241542425424354244542455424654247542485424954250542515425254253542545425554256542575425854259542605426154262542635426454265542665426754268542695427054271542725427354274542755427654277542785427954280542815428254283542845428554286542875428854289542905429154292542935429454295542965429754298542995430054301543025430354304543055430654307543085430954310543115431254313543145431554316543175431854319543205432154322543235432454325543265432754328543295433054331543325433354334543355433654337543385433954340543415434254343543445434554346543475434854349543505435154352543535435454355543565435754358543595436054361543625436354364543655436654367543685436954370543715437254373543745437554376543775437854379543805438154382543835438454385543865438754388543895439054391543925439354394543955439654397543985439954400544015440254403544045440554406544075440854409544105441154412544135441454415544165441754418544195442054421544225442354424544255442654427544285442954430544315443254433544345443554436544375443854439544405444154442544435444454445544465444754448544495445054451544525445354454544555445654457544585445954460544615446254463544645446554466544675446854469544705447154472544735447454475544765447754478544795448054481544825448354484544855448654487544885448954490544915449254493544945449554496544975449854499545005450154502545035450454505545065450754508545095451054511545125451354514545155451654517545185451954520545215452254523545245452554526545275452854529545305453154532545335453454535545365453754538545395454054541545425454354544545455454654547545485454954550545515455254553545545455554556545575455854559545605456154562545635456454565545665456754568545695457054571545725457354574545755457654577545785457954580545815458254583545845458554586545875458854589545905459154592545935459454595545965459754598545995460054601546025460354604546055460654607546085460954610546115461254613546145461554616546175461854619546205462154622546235462454625546265462754628546295463054631546325463354634546355463654637546385463954640546415464254643546445464554646546475464854649546505465154652546535465454655546565465754658546595466054661546625466354664546655466654667546685466954670546715467254673546745467554676546775467854679546805468154682546835468454685546865468754688546895469054691546925469354694546955469654697546985469954700547015470254703547045470554706547075470854709547105471154712547135471454715547165471754718547195472054721547225472354724547255472654727547285472954730547315473254733547345473554736547375473854739547405474154742547435474454745547465474754748547495475054751547525475354754547555475654757547585475954760547615476254763547645476554766547675476854769547705477154772547735477454775547765477754778547795478054781547825478354784547855478654787547885478954790547915479254793547945479554796547975479854799548005480154802548035480454805548065480754808548095481054811548125481354814548155481654817548185481954820548215482254823548245482554826548275482854829548305483154832548335483454835548365483754838548395484054841548425484354844548455484654847548485484954850548515485254853548545485554856548575485854859548605486154862548635486454865548665486754868548695487054871548725487354874548755487654877548785487954880548815488254883548845488554886548875488854889548905489154892548935489454895548965489754898548995490054901549025490354904549055490654907549085490954910549115491254913549145491554916549175491854919549205492154922549235492454925549265492754928549295493054931549325493354934549355493654937549385493954940549415494254943549445494554946549475494854949549505495154952549535495454955549565495754958549595496054961549625496354964549655496654967549685496954970549715497254973549745497554976549775497854979549805498154982549835498454985549865498754988549895499054991549925499354994549955499654997549985499955000550015500255003550045500555006550075500855009550105501155012550135501455015550165501755018550195502055021550225502355024550255502655027550285502955030550315503255033550345503555036550375503855039550405504155042550435504455045550465504755048550495505055051550525505355054550555505655057550585505955060550615506255063550645506555066550675506855069550705507155072550735507455075550765507755078550795508055081550825508355084550855508655087550885508955090550915509255093550945509555096550975509855099551005510155102551035510455105551065510755108551095511055111551125511355114551155511655117551185511955120551215512255123551245512555126551275512855129551305513155132551335513455135551365513755138551395514055141551425514355144551455514655147551485514955150551515515255153551545515555156551575515855159551605516155162551635516455165551665516755168551695517055171551725517355174551755517655177551785517955180551815518255183551845518555186551875518855189551905519155192551935519455195551965519755198551995520055201552025520355204552055520655207552085520955210552115521255213552145521555216552175521855219552205522155222552235522455225552265522755228552295523055231552325523355234552355523655237552385523955240552415524255243552445524555246552475524855249552505525155252552535525455255552565525755258552595526055261552625526355264552655526655267552685526955270
  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. setImmediate(handler: (...args: any[]) => void): number;
  192. }
  193. interface WebGLProgram {
  194. context?: WebGLRenderingContext;
  195. vertexShader?: WebGLShader;
  196. fragmentShader?: WebGLShader;
  197. isParallelCompiled: boolean;
  198. onCompiled?: () => void;
  199. }
  200. interface WebGLRenderingContext {
  201. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  202. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  203. vertexAttribDivisor(index: number, divisor: number): void;
  204. createVertexArray(): any;
  205. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  206. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  207. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  208. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  209. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  210. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  211. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  212. createQuery(): WebGLQuery;
  213. deleteQuery(query: WebGLQuery): void;
  214. beginQuery(target: number, query: WebGLQuery): void;
  215. endQuery(target: number): void;
  216. getQueryParameter(query: WebGLQuery, pname: number): any;
  217. getQuery(target: number, pname: number): any;
  218. MAX_SAMPLES: number;
  219. RGBA8: number;
  220. READ_FRAMEBUFFER: number;
  221. DRAW_FRAMEBUFFER: number;
  222. UNIFORM_BUFFER: number;
  223. HALF_FLOAT_OES: number;
  224. RGBA16F: number;
  225. RGBA32F: number;
  226. R32F: number;
  227. RG32F: number;
  228. RGB32F: number;
  229. R16F: number;
  230. RG16F: number;
  231. RGB16F: number;
  232. RED: number;
  233. RG: number;
  234. R8: number;
  235. RG8: number;
  236. UNSIGNED_INT_24_8: number;
  237. DEPTH24_STENCIL8: number;
  238. drawBuffers(buffers: number[]): void;
  239. readBuffer(src: number): void;
  240. readonly COLOR_ATTACHMENT0: number;
  241. readonly COLOR_ATTACHMENT1: number;
  242. readonly COLOR_ATTACHMENT2: number;
  243. readonly COLOR_ATTACHMENT3: number;
  244. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  245. ANY_SAMPLES_PASSED: number;
  246. QUERY_RESULT_AVAILABLE: number;
  247. QUERY_RESULT: number;
  248. }
  249. interface Document {
  250. mozCancelFullScreen(): void;
  251. msCancelFullScreen(): void;
  252. webkitCancelFullScreen(): void;
  253. requestPointerLock(): void;
  254. exitPointerLock(): void;
  255. fullscreen: boolean;
  256. mozFullScreen: boolean;
  257. msIsFullScreen: boolean;
  258. readonly webkitIsFullScreen: boolean;
  259. readonly pointerLockElement: Element;
  260. mozPointerLockElement: HTMLElement;
  261. msPointerLockElement: HTMLElement;
  262. webkitPointerLockElement: HTMLElement;
  263. }
  264. interface HTMLCanvasElement {
  265. requestPointerLock(): void;
  266. msRequestPointerLock?(): void;
  267. mozRequestPointerLock?(): void;
  268. webkitRequestPointerLock?(): void;
  269. }
  270. interface CanvasRenderingContext2D {
  271. msImageSmoothingEnabled: boolean;
  272. }
  273. interface WebGLBuffer {
  274. references: number;
  275. capacity: number;
  276. is32Bits: boolean;
  277. }
  278. interface WebGLProgram {
  279. transformFeedback?: WebGLTransformFeedback | null;
  280. }
  281. interface MouseEvent {
  282. mozMovementX: number;
  283. mozMovementY: number;
  284. webkitMovementX: number;
  285. webkitMovementY: number;
  286. msMovementX: number;
  287. msMovementY: number;
  288. }
  289. interface Navigator {
  290. mozGetVRDevices: (any: any) => any;
  291. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  292. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  293. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  294. webkitGetGamepads(): Gamepad[];
  295. msGetGamepads(): Gamepad[];
  296. webkitGamepads(): Gamepad[];
  297. }
  298. interface HTMLVideoElement {
  299. mozSrcObject: any;
  300. }
  301. interface Element {
  302. webkitRequestFullScreen: () => void;
  303. }
  304. interface Screen {
  305. readonly orientation: string;
  306. readonly mozOrientation: string;
  307. }
  308. interface Math {
  309. fround(x: number): number;
  310. imul(a: number, b: number): number;
  311. }
  312. interface EXT_disjoint_timer_query {
  313. QUERY_COUNTER_BITS_EXT: number;
  314. TIME_ELAPSED_EXT: number;
  315. TIMESTAMP_EXT: number;
  316. GPU_DISJOINT_EXT: number;
  317. QUERY_RESULT_EXT: number;
  318. QUERY_RESULT_AVAILABLE_EXT: number;
  319. queryCounterEXT(query: WebGLQuery, target: number): void;
  320. createQueryEXT(): WebGLQuery;
  321. beginQueryEXT(target: number, query: WebGLQuery): void;
  322. endQueryEXT(target: number): void;
  323. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  324. deleteQueryEXT(query: WebGLQuery): void;
  325. }
  326. interface WebGLUniformLocation {
  327. }
  328. declare module BABYLON {
  329. /**
  330. * Defines how a node can be built from a string name.
  331. */
  332. type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  333. /**
  334. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  335. */
  336. class Node implements IBehaviorAware<Node> {
  337. private static _NodeConstructors;
  338. /**
  339. * Add a new node constructor
  340. * @param type defines the type name of the node to construct
  341. * @param constructorFunc defines the constructor function
  342. */
  343. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  344. /**
  345. * Returns a node constructor based on type name
  346. * @param type defines the type name
  347. * @param name defines the new node name
  348. * @param scene defines the hosting scene
  349. * @param options defines optional options to transmit to constructors
  350. * @returns the new constructor or null
  351. */
  352. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  353. /**
  354. * Gets or sets the name of the node
  355. */
  356. name: string;
  357. /**
  358. * Gets or sets the id of the node
  359. */
  360. id: string;
  361. /**
  362. * Gets or sets the unique id of the node
  363. */
  364. uniqueId: number;
  365. /**
  366. * Gets or sets a string used to store user defined state for the node
  367. */
  368. state: string;
  369. /**
  370. * Gets or sets an object used to store user defined information for the node
  371. */
  372. metadata: any;
  373. /**
  374. * Gets or sets a boolean used to define if the node must be serialized
  375. */
  376. doNotSerialize: boolean;
  377. /** @hidden */
  378. /**
  379. * Gets a list of Animations associated with the node
  380. */
  381. animations: Animation[];
  382. protected _ranges: {
  383. [name: string]: Nullable<AnimationRange>;
  384. };
  385. /**
  386. * Callback raised when the node is ready to be used
  387. */
  388. onReady: (node: Node) => void;
  389. private _isEnabled;
  390. private _isParentEnabled;
  391. private _isReady;
  392. /** @hidden */
  393. private _parentRenderId;
  394. protected _childRenderId: number;
  395. /** @hidden */
  396. /** @hidden */
  397. /** @hidden */
  398. private _parentNode;
  399. private _children;
  400. /** @hidden */
  401. /** @hidden */
  402. /** @hidden */
  403. private _sceneRootNodesIndex;
  404. /**
  405. * Gets a boolean indicating if the node has been disposed
  406. * @returns true if the node was disposed
  407. */
  408. isDisposed(): boolean;
  409. /**
  410. * Gets or sets the parent of the node
  411. */
  412. parent: Nullable<Node>;
  413. private addToSceneRootNodes;
  414. private removeFromSceneRootNodes;
  415. private _animationPropertiesOverride;
  416. /**
  417. * Gets or sets the animation properties override
  418. */
  419. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  420. /**
  421. * Gets a string idenfifying the name of the class
  422. * @returns "Node" string
  423. */
  424. getClassName(): string;
  425. /**
  426. * An event triggered when the mesh is disposed
  427. */
  428. onDisposeObservable: Observable<Node>;
  429. private _onDisposeObserver;
  430. /**
  431. * Sets a callback that will be raised when the node will be disposed
  432. */
  433. onDispose: () => void;
  434. /**
  435. * Creates a new Node
  436. * @param name the name and id to be given to this node
  437. * @param scene the scene this node will be added to
  438. */
  439. constructor(name: string, scene?: Nullable<Scene>);
  440. /**
  441. * Gets the scene of the node
  442. * @returns a scene
  443. */
  444. getScene(): Scene;
  445. /**
  446. * Gets the engine of the node
  447. * @returns a Engine
  448. */
  449. getEngine(): Engine;
  450. private _behaviors;
  451. /**
  452. * Attach a behavior to the node
  453. * @see http://doc.babylonjs.com/features/behaviour
  454. * @param behavior defines the behavior to attach
  455. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  456. * @returns the current Node
  457. */
  458. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  459. /**
  460. * Remove an attached behavior
  461. * @see http://doc.babylonjs.com/features/behaviour
  462. * @param behavior defines the behavior to attach
  463. * @returns the current Node
  464. */
  465. removeBehavior(behavior: Behavior<Node>): Node;
  466. /**
  467. * Gets the list of attached behaviors
  468. * @see http://doc.babylonjs.com/features/behaviour
  469. */
  470. readonly behaviors: Behavior<Node>[];
  471. /**
  472. * Gets an attached behavior by name
  473. * @param name defines the name of the behavior to look for
  474. * @see http://doc.babylonjs.com/features/behaviour
  475. * @returns null if behavior was not found else the requested behavior
  476. */
  477. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  478. /**
  479. * Returns the latest update of the World matrix
  480. * @returns a Matrix
  481. */
  482. getWorldMatrix(): Matrix;
  483. /** @hidden */
  484. /**
  485. * Returns directly the latest state of the mesh World matrix.
  486. * A Matrix is returned.
  487. */
  488. readonly worldMatrixFromCache: Matrix;
  489. /** @hidden */
  490. /** @hidden */
  491. updateCache(force?: boolean): void;
  492. /** @hidden */
  493. /** @hidden */
  494. /** @hidden */
  495. /** @hidden */
  496. isSynchronizedWithParent(): boolean;
  497. /** @hidden */
  498. isSynchronized(): boolean;
  499. /**
  500. * Is this node ready to be used/rendered
  501. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  502. * @return true if the node is ready
  503. */
  504. isReady(completeCheck?: boolean): boolean;
  505. /**
  506. * Is this node enabled?
  507. * 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
  508. * @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
  509. * @return whether this node (and its parent) is enabled
  510. */
  511. isEnabled(checkAncestors?: boolean): boolean;
  512. /** @hidden */
  513. protected _syncParentEnabledState(): void;
  514. /**
  515. * Set the enabled state of this node
  516. * @param value defines the new enabled state
  517. */
  518. setEnabled(value: boolean): void;
  519. /**
  520. * Is this node a descendant of the given node?
  521. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  522. * @param ancestor defines the parent node to inspect
  523. * @returns a boolean indicating if this node is a descendant of the given node
  524. */
  525. isDescendantOf(ancestor: Node): boolean;
  526. /** @hidden */
  527. /**
  528. * Will return all nodes that have this node as ascendant
  529. * @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
  530. * @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
  531. * @return all children nodes of all types
  532. */
  533. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  534. /**
  535. * Get all child-meshes of this node
  536. * @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
  537. * @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
  538. * @returns an array of AbstractMesh
  539. */
  540. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  541. /**
  542. * Get all child-transformNodes of this node
  543. * @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
  544. * @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
  545. * @returns an array of TransformNode
  546. */
  547. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  548. /**
  549. * Get all direct children of this node
  550. * @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
  551. * @returns an array of Node
  552. */
  553. getChildren(predicate?: (node: Node) => boolean): Node[];
  554. /** @hidden */
  555. /**
  556. * Get an animation by name
  557. * @param name defines the name of the animation to look for
  558. * @returns null if not found else the requested animation
  559. */
  560. getAnimationByName(name: string): Nullable<Animation>;
  561. /**
  562. * Creates an animation range for this node
  563. * @param name defines the name of the range
  564. * @param from defines the starting key
  565. * @param to defines the end key
  566. */
  567. createAnimationRange(name: string, from: number, to: number): void;
  568. /**
  569. * Delete a specific animation range
  570. * @param name defines the name of the range to delete
  571. * @param deleteFrames defines if animation frames from the range must be deleted as well
  572. */
  573. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  574. /**
  575. * Get an animation range by name
  576. * @param name defines the name of the animation range to look for
  577. * @returns null if not found else the requested animation range
  578. */
  579. getAnimationRange(name: string): Nullable<AnimationRange>;
  580. /**
  581. * Will start the animation sequence
  582. * @param name defines the range frames for animation sequence
  583. * @param loop defines if the animation should loop (false by default)
  584. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  585. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  586. * @returns the object created for this animation. If range does not exist, it will return null
  587. */
  588. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  589. /**
  590. * Serialize animation ranges into a JSON compatible object
  591. * @returns serialization object
  592. */
  593. serializeAnimationRanges(): any;
  594. /**
  595. * Computes the world matrix of the node
  596. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  597. * @returns the world matrix
  598. */
  599. computeWorldMatrix(force?: boolean): Matrix;
  600. /**
  601. * Releases resources associated with this node.
  602. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  603. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  604. */
  605. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  606. /**
  607. * Parse animation range data from a serialization object and store them into a given node
  608. * @param node defines where to store the animation ranges
  609. * @param parsedNode defines the serialization object to read data from
  610. * @param scene defines the hosting scene
  611. */
  612. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  613. }
  614. }
  615. declare module BABYLON {
  616. /**
  617. * Define an interface for all classes that will hold resources
  618. */
  619. interface IDisposable {
  620. /**
  621. * Releases all held resources
  622. */
  623. dispose(): void;
  624. }
  625. /**
  626. * This class is used by the onRenderingGroupObservable
  627. */
  628. class RenderingGroupInfo {
  629. /**
  630. * The Scene that being rendered
  631. */
  632. scene: Scene;
  633. /**
  634. * The camera currently used for the rendering pass
  635. */
  636. camera: Nullable<Camera>;
  637. /**
  638. * The ID of the renderingGroup being processed
  639. */
  640. renderingGroupId: number;
  641. }
  642. /** Interface defining initialization parameters for Scene class */
  643. interface SceneOptions {
  644. /**
  645. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by Id
  646. * It will improve performance when the number of geometries becomes important.
  647. */
  648. useGeometryIdsMap?: boolean;
  649. }
  650. /**
  651. * Represents a scene to be rendered by the engine.
  652. * @see http://doc.babylonjs.com/features/scene
  653. */
  654. class Scene extends AbstractScene implements IAnimatable {
  655. private static _uniqueIdCounter;
  656. /** The fog is deactivated */
  657. static readonly FOGMODE_NONE: number;
  658. /** The fog density is following an exponential function */
  659. static readonly FOGMODE_EXP: number;
  660. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  661. static readonly FOGMODE_EXP2: number;
  662. /** The fog density is following a linear function. */
  663. static readonly FOGMODE_LINEAR: number;
  664. /**
  665. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  666. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  667. */
  668. static MinDeltaTime: number;
  669. /**
  670. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  671. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  672. */
  673. static MaxDeltaTime: number;
  674. /**
  675. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  676. */
  677. autoClear: boolean;
  678. /**
  679. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  680. */
  681. autoClearDepthAndStencil: boolean;
  682. /**
  683. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  684. */
  685. clearColor: Color4;
  686. /**
  687. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  688. */
  689. ambientColor: Color3;
  690. /** @hidden */
  691. /** @hidden */
  692. protected _environmentTexture: BaseTexture;
  693. /**
  694. * Texture used in all pbr material as the reflection texture.
  695. * As in the majority of the scene they are the same (exception for multi room and so on),
  696. * this is easier to reference from here than from all the materials.
  697. */
  698. /**
  699. * Texture used in all pbr material as the reflection texture.
  700. * As in the majority of the scene they are the same (exception for multi room and so on),
  701. * this is easier to set here than in all the materials.
  702. */
  703. environmentTexture: BaseTexture;
  704. /** @hidden */
  705. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  706. /**
  707. * Default image processing configuration used either in the rendering
  708. * Forward main pass or through the imageProcessingPostProcess if present.
  709. * As in the majority of the scene they are the same (exception for multi camera),
  710. * this is easier to reference from here than from all the materials and post process.
  711. *
  712. * No setter as we it is a shared configuration, you can set the values instead.
  713. */
  714. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  715. private _forceWireframe;
  716. /**
  717. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  718. */
  719. forceWireframe: boolean;
  720. private _forcePointsCloud;
  721. /**
  722. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  723. */
  724. forcePointsCloud: boolean;
  725. /**
  726. * Gets or sets the active clipplane 1
  727. */
  728. clipPlane: Nullable<Plane>;
  729. /**
  730. * Gets or sets the active clipplane 2
  731. */
  732. clipPlane2: Nullable<Plane>;
  733. /**
  734. * Gets or sets the active clipplane 3
  735. */
  736. clipPlane3: Nullable<Plane>;
  737. /**
  738. * Gets or sets the active clipplane 4
  739. */
  740. clipPlane4: Nullable<Plane>;
  741. /**
  742. * Gets or sets a boolean indicating if animations are enabled
  743. */
  744. animationsEnabled: boolean;
  745. private _animationPropertiesOverride;
  746. /**
  747. * Gets or sets the animation properties override
  748. */
  749. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  750. /**
  751. * Gets or sets a boolean indicating if a constant deltatime has to be used
  752. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  753. */
  754. useConstantAnimationDeltaTime: boolean;
  755. /**
  756. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  757. * Please note that it requires to run a ray cast through the scene on every frame
  758. */
  759. constantlyUpdateMeshUnderPointer: boolean;
  760. /**
  761. * Defines the HTML cursor to use when hovering over interactive elements
  762. */
  763. hoverCursor: string;
  764. /**
  765. * Defines the HTML default cursor to use (empty by default)
  766. */
  767. defaultCursor: string;
  768. /**
  769. * This is used to call preventDefault() on pointer down
  770. * in order to block unwanted artifacts like system double clicks
  771. */
  772. preventDefaultOnPointerDown: boolean;
  773. /**
  774. * Gets or sets user defined metadata
  775. */
  776. metadata: any;
  777. /**
  778. * Gets the name of the plugin used to load this scene (null by default)
  779. */
  780. loadingPluginName: string;
  781. /**
  782. * Use this array to add regular expressions used to disable offline support for specific urls
  783. */
  784. disableOfflineSupportExceptionRules: RegExp[];
  785. /**
  786. * An event triggered when the scene is disposed.
  787. */
  788. onDisposeObservable: Observable<Scene>;
  789. private _onDisposeObserver;
  790. /** Sets a function to be executed when this scene is disposed. */
  791. onDispose: () => void;
  792. /**
  793. * An event triggered before rendering the scene (right after animations and physics)
  794. */
  795. onBeforeRenderObservable: Observable<Scene>;
  796. private _onBeforeRenderObserver;
  797. /** Sets a function to be executed before rendering this scene */
  798. beforeRender: Nullable<() => void>;
  799. /**
  800. * An event triggered after rendering the scene
  801. */
  802. onAfterRenderObservable: Observable<Scene>;
  803. private _onAfterRenderObserver;
  804. /** Sets a function to be executed after rendering this scene */
  805. afterRender: Nullable<() => void>;
  806. /**
  807. * An event triggered before animating the scene
  808. */
  809. onBeforeAnimationsObservable: Observable<Scene>;
  810. /**
  811. * An event triggered after animations processing
  812. */
  813. onAfterAnimationsObservable: Observable<Scene>;
  814. /**
  815. * An event triggered before draw calls are ready to be sent
  816. */
  817. onBeforeDrawPhaseObservable: Observable<Scene>;
  818. /**
  819. * An event triggered after draw calls have been sent
  820. */
  821. onAfterDrawPhaseObservable: Observable<Scene>;
  822. /**
  823. * An event triggered when the scene is ready
  824. */
  825. onReadyObservable: Observable<Scene>;
  826. /**
  827. * An event triggered before rendering a camera
  828. */
  829. onBeforeCameraRenderObservable: Observable<Camera>;
  830. private _onBeforeCameraRenderObserver;
  831. /** Sets a function to be executed before rendering a camera*/
  832. beforeCameraRender: () => void;
  833. /**
  834. * An event triggered after rendering a camera
  835. */
  836. onAfterCameraRenderObservable: Observable<Camera>;
  837. private _onAfterCameraRenderObserver;
  838. /** Sets a function to be executed after rendering a camera*/
  839. afterCameraRender: () => void;
  840. /**
  841. * An event triggered when active meshes evaluation is about to start
  842. */
  843. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  844. /**
  845. * An event triggered when active meshes evaluation is done
  846. */
  847. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  848. /**
  849. * An event triggered when particles rendering is about to start
  850. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  851. */
  852. onBeforeParticlesRenderingObservable: Observable<Scene>;
  853. /**
  854. * An event triggered when particles rendering is done
  855. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  856. */
  857. onAfterParticlesRenderingObservable: Observable<Scene>;
  858. /**
  859. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  860. */
  861. onDataLoadedObservable: Observable<Scene>;
  862. /**
  863. * An event triggered when a camera is created
  864. */
  865. onNewCameraAddedObservable: Observable<Camera>;
  866. /**
  867. * An event triggered when a camera is removed
  868. */
  869. onCameraRemovedObservable: Observable<Camera>;
  870. /**
  871. * An event triggered when a light is created
  872. */
  873. onNewLightAddedObservable: Observable<Light>;
  874. /**
  875. * An event triggered when a light is removed
  876. */
  877. onLightRemovedObservable: Observable<Light>;
  878. /**
  879. * An event triggered when a geometry is created
  880. */
  881. onNewGeometryAddedObservable: Observable<Geometry>;
  882. /**
  883. * An event triggered when a geometry is removed
  884. */
  885. onGeometryRemovedObservable: Observable<Geometry>;
  886. /**
  887. * An event triggered when a transform node is created
  888. */
  889. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  890. /**
  891. * An event triggered when a transform node is removed
  892. */
  893. onTransformNodeRemovedObservable: Observable<TransformNode>;
  894. /**
  895. * An event triggered when a mesh is created
  896. */
  897. onNewMeshAddedObservable: Observable<AbstractMesh>;
  898. /**
  899. * An event triggered when a mesh is removed
  900. */
  901. onMeshRemovedObservable: Observable<AbstractMesh>;
  902. /**
  903. * An event triggered when a material is created
  904. */
  905. onNewMaterialAddedObservable: Observable<Material>;
  906. /**
  907. * An event triggered when a material is removed
  908. */
  909. onMaterialRemovedObservable: Observable<Material>;
  910. /**
  911. * An event triggered when a texture is created
  912. */
  913. onNewTextureAddedObservable: Observable<BaseTexture>;
  914. /**
  915. * An event triggered when a texture is removed
  916. */
  917. onTextureRemovedObservable: Observable<BaseTexture>;
  918. /**
  919. * An event triggered when render targets are about to be rendered
  920. * Can happen multiple times per frame.
  921. */
  922. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  923. /**
  924. * An event triggered when render targets were rendered.
  925. * Can happen multiple times per frame.
  926. */
  927. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  928. /**
  929. * An event triggered before calculating deterministic simulation step
  930. */
  931. onBeforeStepObservable: Observable<Scene>;
  932. /**
  933. * An event triggered after calculating deterministic simulation step
  934. */
  935. onAfterStepObservable: Observable<Scene>;
  936. /**
  937. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  938. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  939. * 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)
  940. */
  941. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  942. /**
  943. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  944. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  945. * 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)
  946. */
  947. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  948. /**
  949. * This Observable will when a mesh has been imported into the scene.
  950. */
  951. onMeshImportedObservable: Observable<AbstractMesh>;
  952. private _registeredForLateAnimationBindings;
  953. /**
  954. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  955. */
  956. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  957. /**
  958. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  959. */
  960. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  961. /**
  962. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  963. */
  964. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  965. private _onPointerMove;
  966. private _onPointerDown;
  967. private _onPointerUp;
  968. /** Deprecated. Use onPointerObservable instead */
  969. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  970. /** Deprecated. Use onPointerObservable instead */
  971. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  972. /** Deprecated. Use onPointerObservable instead */
  973. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  974. /** Deprecated. Use onPointerObservable instead */
  975. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  976. /**
  977. * 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).
  978. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  979. */
  980. onPrePointerObservable: Observable<PointerInfoPre>;
  981. /**
  982. * Observable event triggered each time an input event is received from the rendering canvas
  983. */
  984. onPointerObservable: Observable<PointerInfo>;
  985. /**
  986. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  987. */
  988. readonly unTranslatedPointer: Vector2;
  989. /** The distance in pixel that you have to move to prevent some events */
  990. static DragMovementThreshold: number;
  991. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  992. static LongPressDelay: number;
  993. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  994. static DoubleClickDelay: number;
  995. /** If you need to check double click without raising a single click at first click, enable this flag */
  996. static ExclusiveDoubleClickMode: boolean;
  997. private _initClickEvent;
  998. private _initActionManager;
  999. private _delayedSimpleClick;
  1000. private _delayedSimpleClickTimeout;
  1001. private _previousDelayedSimpleClickTimeout;
  1002. private _meshPickProceed;
  1003. private _previousButtonPressed;
  1004. private _currentPickResult;
  1005. private _previousPickResult;
  1006. private _totalPointersPressed;
  1007. private _doubleClickOccured;
  1008. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  1009. cameraToUseForPointers: Nullable<Camera>;
  1010. private _pointerX;
  1011. private _pointerY;
  1012. private _unTranslatedPointerX;
  1013. private _unTranslatedPointerY;
  1014. private _startingPointerPosition;
  1015. private _previousStartingPointerPosition;
  1016. private _startingPointerTime;
  1017. private _previousStartingPointerTime;
  1018. private _pointerCaptures;
  1019. private _timeAccumulator;
  1020. private _currentStepId;
  1021. private _currentInternalStep;
  1022. /** @hidden */
  1023. /**
  1024. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  1025. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  1026. */
  1027. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  1028. /**
  1029. * Observable event triggered each time an keyboard event is received from the hosting window
  1030. */
  1031. onKeyboardObservable: Observable<KeyboardInfo>;
  1032. private _onKeyDown;
  1033. private _onKeyUp;
  1034. private _onCanvasFocusObserver;
  1035. private _onCanvasBlurObserver;
  1036. private _useRightHandedSystem;
  1037. /**
  1038. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  1039. */
  1040. useRightHandedSystem: boolean;
  1041. /**
  1042. * Sets the step Id used by deterministic lock step
  1043. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  1044. * @param newStepId defines the step Id
  1045. */
  1046. setStepId(newStepId: number): void;
  1047. /**
  1048. * Gets the step Id used by deterministic lock step
  1049. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  1050. * @returns the step Id
  1051. */
  1052. getStepId(): number;
  1053. /**
  1054. * Gets the internal step used by deterministic lock step
  1055. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  1056. * @returns the internal step
  1057. */
  1058. getInternalStep(): number;
  1059. private _fogEnabled;
  1060. /**
  1061. * Gets or sets a boolean indicating if fog is enabled on this scene
  1062. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1063. * (Default is true)
  1064. */
  1065. fogEnabled: boolean;
  1066. private _fogMode;
  1067. /**
  1068. * Gets or sets the fog mode to use
  1069. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1070. * | mode | value |
  1071. * | --- | --- |
  1072. * | FOGMODE_NONE | 0 |
  1073. * | FOGMODE_EXP | 1 |
  1074. * | FOGMODE_EXP2 | 2 |
  1075. * | FOGMODE_LINEAR | 3 |
  1076. */
  1077. fogMode: number;
  1078. /**
  1079. * Gets or sets the fog color to use
  1080. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1081. * (Default is Color3(0.2, 0.2, 0.3))
  1082. */
  1083. fogColor: Color3;
  1084. /**
  1085. * Gets or sets the fog density to use
  1086. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1087. * (Default is 0.1)
  1088. */
  1089. fogDensity: number;
  1090. /**
  1091. * Gets or sets the fog start distance to use
  1092. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1093. * (Default is 0)
  1094. */
  1095. fogStart: number;
  1096. /**
  1097. * Gets or sets the fog end distance to use
  1098. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1099. * (Default is 1000)
  1100. */
  1101. fogEnd: number;
  1102. private _shadowsEnabled;
  1103. /**
  1104. * Gets or sets a boolean indicating if shadows are enabled on this scene
  1105. */
  1106. shadowsEnabled: boolean;
  1107. private _lightsEnabled;
  1108. /**
  1109. * Gets or sets a boolean indicating if lights are enabled on this scene
  1110. */
  1111. lightsEnabled: boolean;
  1112. /** All of the active cameras added to this scene. */
  1113. activeCameras: Camera[];
  1114. /** The current active camera */
  1115. activeCamera: Nullable<Camera>;
  1116. private _defaultMaterial;
  1117. /** The default material used on meshes when no material is affected */
  1118. /** The default material used on meshes when no material is affected */
  1119. defaultMaterial: Material;
  1120. private _texturesEnabled;
  1121. /**
  1122. * Gets or sets a boolean indicating if textures are enabled on this scene
  1123. */
  1124. texturesEnabled: boolean;
  1125. /**
  1126. * Gets or sets a boolean indicating if particles are enabled on this scene
  1127. */
  1128. particlesEnabled: boolean;
  1129. /**
  1130. * Gets or sets a boolean indicating if sprites are enabled on this scene
  1131. */
  1132. spritesEnabled: boolean;
  1133. private _skeletonsEnabled;
  1134. /**
  1135. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  1136. */
  1137. skeletonsEnabled: boolean;
  1138. /**
  1139. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  1140. */
  1141. lensFlaresEnabled: boolean;
  1142. /**
  1143. * Gets or sets a boolean indicating if collisions are enabled on this scene
  1144. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  1145. */
  1146. collisionsEnabled: boolean;
  1147. private _workerCollisions;
  1148. /** @hidden */
  1149. collisionCoordinator: ICollisionCoordinator;
  1150. /**
  1151. * Defines the gravity applied to this scene (used only for collisions)
  1152. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  1153. */
  1154. gravity: Vector3;
  1155. /**
  1156. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  1157. */
  1158. postProcessesEnabled: boolean;
  1159. /**
  1160. * The list of postprocesses added to the scene
  1161. */
  1162. postProcesses: PostProcess[];
  1163. /**
  1164. * Gets the current postprocess manager
  1165. */
  1166. postProcessManager: PostProcessManager;
  1167. /**
  1168. * Gets or sets a boolean indicating if render targets are enabled on this scene
  1169. */
  1170. renderTargetsEnabled: boolean;
  1171. /**
  1172. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  1173. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  1174. */
  1175. dumpNextRenderTargets: boolean;
  1176. /**
  1177. * The list of user defined render targets added to the scene
  1178. */
  1179. customRenderTargets: RenderTargetTexture[];
  1180. /**
  1181. * Defines if texture loading must be delayed
  1182. * If true, textures will only be loaded when they need to be rendered
  1183. */
  1184. useDelayedTextureLoading: boolean;
  1185. /**
  1186. * Gets the list of meshes imported to the scene through SceneLoader
  1187. */
  1188. importedMeshesFiles: String[];
  1189. /**
  1190. * Gets or sets a boolean indicating if probes are enabled on this scene
  1191. */
  1192. probesEnabled: boolean;
  1193. /**
  1194. * @hidden
  1195. */
  1196. database: Database;
  1197. /**
  1198. * Gets or sets the action manager associated with the scene
  1199. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1200. */
  1201. actionManager: ActionManager;
  1202. private _meshesForIntersections;
  1203. /**
  1204. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  1205. */
  1206. proceduralTexturesEnabled: boolean;
  1207. private _engine;
  1208. private _totalVertices;
  1209. /** @hidden */
  1210. /** @hidden */
  1211. /** @hidden */
  1212. private _animationRatio;
  1213. private _animationTimeLast;
  1214. private _animationTime;
  1215. /**
  1216. * Gets or sets a general scale for animation speed
  1217. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  1218. */
  1219. animationTimeScale: number;
  1220. /** @hidden */
  1221. /** @hidden */
  1222. /** @hidden */
  1223. private _renderId;
  1224. private _frameId;
  1225. private _executeWhenReadyTimeoutId;
  1226. private _intermediateRendering;
  1227. private _viewUpdateFlag;
  1228. private _projectionUpdateFlag;
  1229. private _alternateViewUpdateFlag;
  1230. private _alternateProjectionUpdateFlag;
  1231. /** @hidden */
  1232. private _activeRequests;
  1233. private _pendingData;
  1234. private _isDisposed;
  1235. /**
  1236. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  1237. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  1238. */
  1239. dispatchAllSubMeshesOfActiveMeshes: boolean;
  1240. private _activeMeshes;
  1241. private _processedMaterials;
  1242. private _renderTargets;
  1243. /** @hidden */
  1244. private _activeSkeletons;
  1245. private _softwareSkinnedMeshes;
  1246. private _renderingManager;
  1247. /** @hidden */
  1248. private _transformMatrix;
  1249. private _sceneUbo;
  1250. private _alternateSceneUbo;
  1251. private _pickWithRayInverseMatrix;
  1252. private _viewMatrix;
  1253. private _projectionMatrix;
  1254. private _alternateViewMatrix;
  1255. private _alternateProjectionMatrix;
  1256. private _alternateTransformMatrix;
  1257. private _useAlternateCameraConfiguration;
  1258. private _alternateRendering;
  1259. /** @hidden */
  1260. /** @hidden */
  1261. protected readonly _isAlternateRenderingEnabled: boolean;
  1262. private _frustumPlanes;
  1263. /**
  1264. * Gets the list of frustum planes (built from the active camera)
  1265. */
  1266. readonly frustumPlanes: Plane[];
  1267. /**
  1268. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  1269. * This is useful if there are more lights that the maximum simulteanous authorized
  1270. */
  1271. requireLightSorting: boolean;
  1272. private _pointerOverMesh;
  1273. private _pickedDownMesh;
  1274. private _pickedUpMesh;
  1275. private _externalData;
  1276. private _uid;
  1277. /**
  1278. * @hidden
  1279. * Backing store of defined scene components.
  1280. */
  1281. /**
  1282. * @hidden
  1283. * Backing store of defined scene components.
  1284. */
  1285. /**
  1286. * List of components to register on the next registration step.
  1287. */
  1288. private _transientComponents;
  1289. /**
  1290. * Registers the transient components if needed.
  1291. */
  1292. private _registerTransientComponents;
  1293. /**
  1294. * @hidden
  1295. * Add a component to the scene.
  1296. * Note that the ccomponent could be registered on th next frame if this is called after
  1297. * the register component stage.
  1298. * @param component Defines the component to add to the scene
  1299. */
  1300. /**
  1301. * @hidden
  1302. * Gets a component from the scene.
  1303. * @param name defines the name of the component to retrieve
  1304. * @returns the component or null if not present
  1305. */
  1306. /**
  1307. * @hidden
  1308. * Defines the actions happening before camera updates.
  1309. */
  1310. /**
  1311. * @hidden
  1312. * Defines the actions happening before clear the canvas.
  1313. */
  1314. /**
  1315. * @hidden
  1316. * Defines the actions when collecting render targets for the frame.
  1317. */
  1318. /**
  1319. * @hidden
  1320. * Defines the actions happening for one camera in the frame.
  1321. */
  1322. /**
  1323. * @hidden
  1324. * Defines the actions happening during the per mesh ready checks.
  1325. */
  1326. /**
  1327. * @hidden
  1328. * Defines the actions happening before evaluate active mesh checks.
  1329. */
  1330. /**
  1331. * @hidden
  1332. * Defines the actions happening during the evaluate sub mesh checks.
  1333. */
  1334. /**
  1335. * @hidden
  1336. * Defines the actions happening during the active mesh stage.
  1337. */
  1338. /**
  1339. * @hidden
  1340. * Defines the actions happening during the per camera render target step.
  1341. */
  1342. /**
  1343. * @hidden
  1344. * Defines the actions happening just before the active camera is drawing.
  1345. */
  1346. /**
  1347. * @hidden
  1348. * Defines the actions happening just before a rendering group is drawing.
  1349. */
  1350. /**
  1351. * @hidden
  1352. * Defines the actions happening just before a mesh is drawing.
  1353. */
  1354. /**
  1355. * @hidden
  1356. * Defines the actions happening just after a mesh has been drawn.
  1357. */
  1358. /**
  1359. * @hidden
  1360. * Defines the actions happening just after a rendering group has been drawn.
  1361. */
  1362. /**
  1363. * @hidden
  1364. * Defines the actions happening just after the active camera has been drawn.
  1365. */
  1366. /**
  1367. * @hidden
  1368. * Defines the actions happening just after rendering all cameras and computing intersections.
  1369. */
  1370. /**
  1371. * @hidden
  1372. * Defines the actions happening when a pointer move event happens.
  1373. */
  1374. /**
  1375. * @hidden
  1376. * Defines the actions happening when a pointer down event happens.
  1377. */
  1378. /**
  1379. * @hidden
  1380. * Defines the actions happening when a pointer up event happens.
  1381. */
  1382. /**
  1383. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  1384. */
  1385. private geometriesById;
  1386. /**
  1387. * Creates a new Scene
  1388. * @param engine defines the engine to use to render this scene
  1389. */
  1390. constructor(engine: Engine, options?: SceneOptions);
  1391. private _defaultMeshCandidates;
  1392. /**
  1393. * @hidden
  1394. */
  1395. private _defaultSubMeshCandidates;
  1396. /**
  1397. * @hidden
  1398. */
  1399. /**
  1400. * Sets the default candidate providers for the scene.
  1401. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  1402. * and getCollidingSubMeshCandidates to their default function
  1403. */
  1404. setDefaultCandidateProviders(): void;
  1405. /**
  1406. * Gets a boolean indicating if collisions are processed on a web worker
  1407. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#web-worker-based-collision-system-since-21
  1408. */
  1409. workerCollisions: boolean;
  1410. /**
  1411. * Gets the mesh that is currently under the pointer
  1412. */
  1413. readonly meshUnderPointer: Nullable<AbstractMesh>;
  1414. /**
  1415. * Gets the current on-screen X position of the pointer
  1416. */
  1417. readonly pointerX: number;
  1418. /**
  1419. * Gets the current on-screen Y position of the pointer
  1420. */
  1421. readonly pointerY: number;
  1422. /**
  1423. * Gets the cached material (ie. the latest rendered one)
  1424. * @returns the cached material
  1425. */
  1426. getCachedMaterial(): Nullable<Material>;
  1427. /**
  1428. * Gets the cached effect (ie. the latest rendered one)
  1429. * @returns the cached effect
  1430. */
  1431. getCachedEffect(): Nullable<Effect>;
  1432. /**
  1433. * Gets the cached visibility state (ie. the latest rendered one)
  1434. * @returns the cached visibility state
  1435. */
  1436. getCachedVisibility(): Nullable<number>;
  1437. /**
  1438. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  1439. * @param material defines the current material
  1440. * @param effect defines the current effect
  1441. * @param visibility defines the current visibility state
  1442. * @returns true if one parameter is not cached
  1443. */
  1444. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  1445. /**
  1446. * Gets the engine associated with the scene
  1447. * @returns an Engine
  1448. */
  1449. getEngine(): Engine;
  1450. /**
  1451. * Gets the total number of vertices rendered per frame
  1452. * @returns the total number of vertices rendered per frame
  1453. */
  1454. getTotalVertices(): number;
  1455. /**
  1456. * Gets the performance counter for total vertices
  1457. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1458. */
  1459. readonly totalVerticesPerfCounter: PerfCounter;
  1460. /**
  1461. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  1462. * @returns the total number of active indices rendered per frame
  1463. */
  1464. getActiveIndices(): number;
  1465. /**
  1466. * Gets the performance counter for active indices
  1467. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1468. */
  1469. readonly totalActiveIndicesPerfCounter: PerfCounter;
  1470. /**
  1471. * Gets the total number of active particles rendered per frame
  1472. * @returns the total number of active particles rendered per frame
  1473. */
  1474. getActiveParticles(): number;
  1475. /**
  1476. * Gets the performance counter for active particles
  1477. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1478. */
  1479. readonly activeParticlesPerfCounter: PerfCounter;
  1480. /**
  1481. * Gets the total number of active bones rendered per frame
  1482. * @returns the total number of active bones rendered per frame
  1483. */
  1484. getActiveBones(): number;
  1485. /**
  1486. * Gets the performance counter for active bones
  1487. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1488. */
  1489. readonly activeBonesPerfCounter: PerfCounter;
  1490. /** @hidden */
  1491. getInterFramePerfCounter(): number;
  1492. /** @hidden */
  1493. readonly interFramePerfCounter: Nullable<PerfCounter>;
  1494. /** @hidden */
  1495. getLastFrameDuration(): number;
  1496. /** @hidden */
  1497. readonly lastFramePerfCounter: Nullable<PerfCounter>;
  1498. /** @hidden */
  1499. getEvaluateActiveMeshesDuration(): number;
  1500. /** @hidden */
  1501. readonly evaluateActiveMeshesDurationPerfCounter: Nullable<PerfCounter>;
  1502. /**
  1503. * Gets the array of active meshes
  1504. * @returns an array of AbstractMesh
  1505. */
  1506. getActiveMeshes(): SmartArray<AbstractMesh>;
  1507. /** @hidden */
  1508. getRenderTargetsDuration(): number;
  1509. /** @hidden */
  1510. getRenderDuration(): number;
  1511. /** @hidden */
  1512. readonly renderDurationPerfCounter: Nullable<PerfCounter>;
  1513. /** @hidden */
  1514. getParticlesDuration(): number;
  1515. /** @hidden */
  1516. readonly particlesDurationPerfCounter: Nullable<PerfCounter>;
  1517. /** @hidden */
  1518. getSpritesDuration(): number;
  1519. /** @hidden */
  1520. readonly spriteDuractionPerfCounter: Nullable<PerfCounter>;
  1521. /**
  1522. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  1523. * @returns a number
  1524. */
  1525. getAnimationRatio(): number;
  1526. /**
  1527. * Gets an unique Id for the current render phase
  1528. * @returns a number
  1529. */
  1530. getRenderId(): number;
  1531. /**
  1532. * Gets an unique Id for the current frame
  1533. * @returns a number
  1534. */
  1535. getFrameId(): number;
  1536. /** Call this function if you want to manually increment the render Id*/
  1537. incrementRenderId(): void;
  1538. private _updatePointerPosition;
  1539. private _createUbo;
  1540. private _createAlternateUbo;
  1541. private _setRayOnPointerInfo;
  1542. /**
  1543. * Use this method to simulate a pointer move on a mesh
  1544. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1545. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  1546. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  1547. * @returns the current scene
  1548. */
  1549. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  1550. private _processPointerMove;
  1551. private _checkPrePointerObservable;
  1552. /**
  1553. * Use this method to simulate a pointer down on a mesh
  1554. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1555. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  1556. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  1557. * @returns the current scene
  1558. */
  1559. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  1560. private _processPointerDown;
  1561. /**
  1562. * Use this method to simulate a pointer up on a mesh
  1563. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1564. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  1565. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  1566. * @returns the current scene
  1567. */
  1568. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  1569. private _processPointerUp;
  1570. /**
  1571. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  1572. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  1573. * @returns true if the pointer was captured
  1574. */
  1575. isPointerCaptured(pointerId?: number): boolean;
  1576. /** @hidden */
  1577. /**
  1578. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  1579. * @param attachUp defines if you want to attach events to pointerup
  1580. * @param attachDown defines if you want to attach events to pointerdown
  1581. * @param attachMove defines if you want to attach events to pointermove
  1582. */
  1583. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  1584. /** Detaches all event handlers*/
  1585. detachControl(): void;
  1586. /**
  1587. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  1588. * Delay loaded resources are not taking in account
  1589. * @return true if all required resources are ready
  1590. */
  1591. isReady(): boolean;
  1592. /** Resets all cached information relative to material (including effect and visibility) */
  1593. resetCachedMaterial(): void;
  1594. /**
  1595. * Registers a function to be called before every frame render
  1596. * @param func defines the function to register
  1597. */
  1598. registerBeforeRender(func: () => void): void;
  1599. /**
  1600. * Unregisters a function called before every frame render
  1601. * @param func defines the function to unregister
  1602. */
  1603. unregisterBeforeRender(func: () => void): void;
  1604. /**
  1605. * Registers a function to be called after every frame render
  1606. * @param func defines the function to register
  1607. */
  1608. registerAfterRender(func: () => void): void;
  1609. /**
  1610. * Unregisters a function called after every frame render
  1611. * @param func defines the function to unregister
  1612. */
  1613. unregisterAfterRender(func: () => void): void;
  1614. private _executeOnceBeforeRender;
  1615. /**
  1616. * The provided function will run before render once and will be disposed afterwards.
  1617. * A timeout delay can be provided so that the function will be executed in N ms.
  1618. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  1619. * @param func The function to be executed.
  1620. * @param timeout optional delay in ms
  1621. */
  1622. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  1623. /** @hidden */
  1624. /** @hidden */
  1625. /**
  1626. * Returns the number of items waiting to be loaded
  1627. * @returns the number of items waiting to be loaded
  1628. */
  1629. getWaitingItemsCount(): number;
  1630. /**
  1631. * Returns a boolean indicating if the scene is still loading data
  1632. */
  1633. readonly isLoading: boolean;
  1634. /**
  1635. * Registers a function to be executed when the scene is ready
  1636. * @param {Function} func - the function to be executed
  1637. */
  1638. executeWhenReady(func: () => void): void;
  1639. /**
  1640. * Returns a promise that resolves when the scene is ready
  1641. * @returns A promise that resolves when the scene is ready
  1642. */
  1643. whenReadyAsync(): Promise<void>;
  1644. /** @hidden */
  1645. /**
  1646. * Will start the animation sequence of a given target
  1647. * @param target defines the target
  1648. * @param from defines from which frame should animation start
  1649. * @param to defines until which frame should animation run.
  1650. * @param weight defines the weight to apply to the animation (1.0 by default)
  1651. * @param loop defines if the animation loops
  1652. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  1653. * @param onAnimationEnd defines the function to be executed when the animation ends
  1654. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  1655. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  1656. * @returns the animatable object created for this animation
  1657. */
  1658. beginWeightedAnimation(target: any, from: number, to: number, weight?: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean): Animatable;
  1659. /**
  1660. * Will start the animation sequence of a given target
  1661. * @param target defines the target
  1662. * @param from defines from which frame should animation start
  1663. * @param to defines until which frame should animation run.
  1664. * @param loop defines if the animation loops
  1665. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  1666. * @param onAnimationEnd defines the function to be executed when the animation ends
  1667. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  1668. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  1669. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  1670. * @returns the animatable object created for this animation
  1671. */
  1672. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean): Animatable;
  1673. /**
  1674. * Begin a new animation on a given node
  1675. * @param target defines the target where the animation will take place
  1676. * @param animations defines the list of animations to start
  1677. * @param from defines the initial value
  1678. * @param to defines the final value
  1679. * @param loop defines if you want animation to loop (off by default)
  1680. * @param speedRatio defines the speed ratio to apply to all animations
  1681. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  1682. * @returns the list of created animatables
  1683. */
  1684. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Animatable;
  1685. /**
  1686. * Begin a new animation on a given node and its hierarchy
  1687. * @param target defines the root node where the animation will take place
  1688. * @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.
  1689. * @param animations defines the list of animations to start
  1690. * @param from defines the initial value
  1691. * @param to defines the final value
  1692. * @param loop defines if you want animation to loop (off by default)
  1693. * @param speedRatio defines the speed ratio to apply to all animations
  1694. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  1695. * @returns the list of animatables created for all nodes
  1696. */
  1697. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Animatable[];
  1698. /**
  1699. * Gets the animatable associated with a specific target
  1700. * @param target defines the target of the animatable
  1701. * @returns the required animatable if found
  1702. */
  1703. getAnimatableByTarget(target: any): Nullable<Animatable>;
  1704. /**
  1705. * Gets all animatables associated with a given target
  1706. * @param target defines the target to look animatables for
  1707. * @returns an array of Animatables
  1708. */
  1709. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  1710. /**
  1711. * Gets all animatable attached to the scene
  1712. */
  1713. readonly animatables: Animatable[];
  1714. /**
  1715. * Will stop the animation of the given target
  1716. * @param target - the target
  1717. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  1718. * @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)
  1719. */
  1720. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  1721. /**
  1722. * Stops and removes all animations that have been applied to the scene
  1723. */
  1724. stopAllAnimations(): void;
  1725. private _animate;
  1726. /** @hidden */
  1727. private _processLateAnimationBindingsForMatrices;
  1728. private _processLateAnimationBindingsForQuaternions;
  1729. private _processLateAnimationBindings;
  1730. /** @hidden */
  1731. /**
  1732. * Gets the current view matrix
  1733. * @returns a Matrix
  1734. */
  1735. getViewMatrix(): Matrix;
  1736. /**
  1737. * Gets the current projection matrix
  1738. * @returns a Matrix
  1739. */
  1740. getProjectionMatrix(): Matrix;
  1741. /**
  1742. * Gets the current transform matrix
  1743. * @returns a Matrix made of View * Projection
  1744. */
  1745. getTransformMatrix(): Matrix;
  1746. /**
  1747. * Sets the current transform matrix
  1748. * @param view defines the View matrix to use
  1749. * @param projection defines the Projection matrix to use
  1750. */
  1751. setTransformMatrix(view: Matrix, projection: Matrix): void;
  1752. /** @hidden */
  1753. /**
  1754. * Gets the uniform buffer used to store scene data
  1755. * @returns a UniformBuffer
  1756. */
  1757. getSceneUniformBuffer(): UniformBuffer;
  1758. /**
  1759. * Gets an unique (relatively to the current scene) Id
  1760. * @returns an unique number for the scene
  1761. */
  1762. getUniqueId(): number;
  1763. /**
  1764. * Add a mesh to the list of scene's meshes
  1765. * @param newMesh defines the mesh to add
  1766. * @param recursive if all child meshes should also be added to the scene
  1767. */
  1768. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  1769. /**
  1770. * Remove a mesh for the list of scene's meshes
  1771. * @param toRemove defines the mesh to remove
  1772. * @param recursive if all child meshes should also be removed from the scene
  1773. * @returns the index where the mesh was in the mesh list
  1774. */
  1775. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  1776. /**
  1777. * Add a transform node to the list of scene's transform nodes
  1778. * @param newTransformNode defines the transform node to add
  1779. */
  1780. addTransformNode(newTransformNode: TransformNode): void;
  1781. /**
  1782. * Remove a transform node for the list of scene's transform nodes
  1783. * @param toRemove defines the transform node to remove
  1784. * @returns the index where the transform node was in the transform node list
  1785. */
  1786. removeTransformNode(toRemove: TransformNode): number;
  1787. /**
  1788. * Remove a skeleton for the list of scene's skeletons
  1789. * @param toRemove defines the skeleton to remove
  1790. * @returns the index where the skeleton was in the skeleton list
  1791. */
  1792. removeSkeleton(toRemove: Skeleton): number;
  1793. /**
  1794. * Remove a morph target for the list of scene's morph targets
  1795. * @param toRemove defines the morph target to remove
  1796. * @returns the index where the morph target was in the morph target list
  1797. */
  1798. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  1799. /**
  1800. * Remove a light for the list of scene's lights
  1801. * @param toRemove defines the light to remove
  1802. * @returns the index where the light was in the light list
  1803. */
  1804. removeLight(toRemove: Light): number;
  1805. /**
  1806. * Remove a camera for the list of scene's cameras
  1807. * @param toRemove defines the camera to remove
  1808. * @returns the index where the camera was in the camera list
  1809. */
  1810. removeCamera(toRemove: Camera): number;
  1811. /**
  1812. * Remove a particle system for the list of scene's particle systems
  1813. * @param toRemove defines the particle system to remove
  1814. * @returns the index where the particle system was in the particle system list
  1815. */
  1816. removeParticleSystem(toRemove: IParticleSystem): number;
  1817. /**
  1818. * Remove a animation for the list of scene's animations
  1819. * @param toRemove defines the animation to remove
  1820. * @returns the index where the animation was in the animation list
  1821. */
  1822. removeAnimation(toRemove: Animation): number;
  1823. /**
  1824. * Removes the given animation group from this scene.
  1825. * @param toRemove The animation group to remove
  1826. * @returns The index of the removed animation group
  1827. */
  1828. removeAnimationGroup(toRemove: AnimationGroup): number;
  1829. /**
  1830. * Removes the given multi-material from this scene.
  1831. * @param toRemove The multi-material to remove
  1832. * @returns The index of the removed multi-material
  1833. */
  1834. removeMultiMaterial(toRemove: MultiMaterial): number;
  1835. /**
  1836. * Removes the given material from this scene.
  1837. * @param toRemove The material to remove
  1838. * @returns The index of the removed material
  1839. */
  1840. removeMaterial(toRemove: Material): number;
  1841. /**
  1842. * Removes the given action manager from this scene.
  1843. * @param toRemove The action manager to remove
  1844. * @returns The index of the removed action manager
  1845. */
  1846. removeActionManager(toRemove: ActionManager): number;
  1847. /**
  1848. * Removes the given texture from this scene.
  1849. * @param toRemove The texture to remove
  1850. * @returns The index of the removed texture
  1851. */
  1852. removeTexture(toRemove: BaseTexture): number;
  1853. /**
  1854. * Adds the given light to this scene
  1855. * @param newLight The light to add
  1856. */
  1857. addLight(newLight: Light): void;
  1858. /**
  1859. * Sorts the list list based on light priorities
  1860. */
  1861. sortLightsByPriority(): void;
  1862. /**
  1863. * Adds the given camera to this scene
  1864. * @param newCamera The camera to add
  1865. */
  1866. addCamera(newCamera: Camera): void;
  1867. /**
  1868. * Adds the given skeleton to this scene
  1869. * @param newSkeleton The skeleton to add
  1870. */
  1871. addSkeleton(newSkeleton: Skeleton): void;
  1872. /**
  1873. * Adds the given particle system to this scene
  1874. * @param newParticleSystem The particle system to add
  1875. */
  1876. addParticleSystem(newParticleSystem: IParticleSystem): void;
  1877. /**
  1878. * Adds the given animation to this scene
  1879. * @param newAnimation The animation to add
  1880. */
  1881. addAnimation(newAnimation: Animation): void;
  1882. /**
  1883. * Adds the given animation group to this scene.
  1884. * @param newAnimationGroup The animation group to add
  1885. */
  1886. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  1887. /**
  1888. * Adds the given multi-material to this scene
  1889. * @param newMultiMaterial The multi-material to add
  1890. */
  1891. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  1892. /**
  1893. * Adds the given material to this scene
  1894. * @param newMaterial The material to add
  1895. */
  1896. addMaterial(newMaterial: Material): void;
  1897. /**
  1898. * Adds the given morph target to this scene
  1899. * @param newMorphTargetManager The morph target to add
  1900. */
  1901. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  1902. /**
  1903. * Adds the given geometry to this scene
  1904. * @param newGeometry The geometry to add
  1905. */
  1906. addGeometry(newGeometry: Geometry): void;
  1907. /**
  1908. * Adds the given action manager to this scene
  1909. * @param newActionManager The action manager to add
  1910. */
  1911. addActionManager(newActionManager: ActionManager): void;
  1912. /**
  1913. * Adds the given texture to this scene.
  1914. * @param newTexture The texture to add
  1915. */
  1916. addTexture(newTexture: BaseTexture): void;
  1917. /**
  1918. * Switch active camera
  1919. * @param newCamera defines the new active camera
  1920. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  1921. */
  1922. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  1923. /**
  1924. * sets the active camera of the scene using its ID
  1925. * @param id defines the camera's ID
  1926. * @return the new active camera or null if none found.
  1927. */
  1928. setActiveCameraByID(id: string): Nullable<Camera>;
  1929. /**
  1930. * sets the active camera of the scene using its name
  1931. * @param name defines the camera's name
  1932. * @returns the new active camera or null if none found.
  1933. */
  1934. setActiveCameraByName(name: string): Nullable<Camera>;
  1935. /**
  1936. * get an animation group using its name
  1937. * @param name defines the material's name
  1938. * @return the animation group or null if none found.
  1939. */
  1940. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  1941. /**
  1942. * get a material using its id
  1943. * @param id defines the material's ID
  1944. * @return the material or null if none found.
  1945. */
  1946. getMaterialByID(id: string): Nullable<Material>;
  1947. /**
  1948. * Gets a material using its name
  1949. * @param name defines the material's name
  1950. * @return the material or null if none found.
  1951. */
  1952. getMaterialByName(name: string): Nullable<Material>;
  1953. /**
  1954. * Gets a camera using its id
  1955. * @param id defines the id to look for
  1956. * @returns the camera or null if not found
  1957. */
  1958. getCameraByID(id: string): Nullable<Camera>;
  1959. /**
  1960. * Gets a camera using its unique id
  1961. * @param uniqueId defines the unique id to look for
  1962. * @returns the camera or null if not found
  1963. */
  1964. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  1965. /**
  1966. * Gets a camera using its name
  1967. * @param name defines the camera's name
  1968. * @return the camera or null if none found.
  1969. */
  1970. getCameraByName(name: string): Nullable<Camera>;
  1971. /**
  1972. * Gets a bone using its id
  1973. * @param id defines the bone's id
  1974. * @return the bone or null if not found
  1975. */
  1976. getBoneByID(id: string): Nullable<Bone>;
  1977. /**
  1978. * Gets a bone using its id
  1979. * @param name defines the bone's name
  1980. * @return the bone or null if not found
  1981. */
  1982. getBoneByName(name: string): Nullable<Bone>;
  1983. /**
  1984. * Gets a light node using its name
  1985. * @param name defines the the light's name
  1986. * @return the light or null if none found.
  1987. */
  1988. getLightByName(name: string): Nullable<Light>;
  1989. /**
  1990. * Gets a light node using its id
  1991. * @param id defines the light's id
  1992. * @return the light or null if none found.
  1993. */
  1994. getLightByID(id: string): Nullable<Light>;
  1995. /**
  1996. * Gets a light node using its scene-generated unique ID
  1997. * @param uniqueId defines the light's unique id
  1998. * @return the light or null if none found.
  1999. */
  2000. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  2001. /**
  2002. * Gets a particle system by id
  2003. * @param id defines the particle system id
  2004. * @return the corresponding system or null if none found
  2005. */
  2006. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  2007. /**
  2008. * Gets a geometry using its ID
  2009. * @param id defines the geometry's id
  2010. * @return the geometry or null if none found.
  2011. */
  2012. getGeometryByID(id: string): Nullable<Geometry>;
  2013. /**
  2014. * Add a new geometry to this scene
  2015. * @param geometry defines the geometry to be added to the scene.
  2016. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  2017. * @return a boolean defining if the geometry was added or not
  2018. */
  2019. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  2020. /**
  2021. * Removes an existing geometry
  2022. * @param geometry defines the geometry to be removed from the scene
  2023. * @return a boolean defining if the geometry was removed or not
  2024. */
  2025. removeGeometry(geometry: Geometry): boolean;
  2026. /**
  2027. * Gets the list of geometries attached to the scene
  2028. * @returns an array of Geometry
  2029. */
  2030. getGeometries(): Geometry[];
  2031. /**
  2032. * Gets the first added mesh found of a given ID
  2033. * @param id defines the id to search for
  2034. * @return the mesh found or null if not found at all
  2035. */
  2036. getMeshByID(id: string): Nullable<AbstractMesh>;
  2037. /**
  2038. * Gets a list of meshes using their id
  2039. * @param id defines the id to search for
  2040. * @returns a list of meshes
  2041. */
  2042. getMeshesByID(id: string): Array<AbstractMesh>;
  2043. /**
  2044. * Gets the first added transform node found of a given ID
  2045. * @param id defines the id to search for
  2046. * @return the found transform node or null if not found at all.
  2047. */
  2048. getTransformNodeByID(id: string): Nullable<TransformNode>;
  2049. /**
  2050. * Gets a list of transform nodes using their id
  2051. * @param id defines the id to search for
  2052. * @returns a list of transform nodes
  2053. */
  2054. getTransformNodesByID(id: string): Array<TransformNode>;
  2055. /**
  2056. * Gets a mesh with its auto-generated unique id
  2057. * @param uniqueId defines the unique id to search for
  2058. * @return the found mesh or null if not found at all.
  2059. */
  2060. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  2061. /**
  2062. * Gets a the last added mesh using a given id
  2063. * @param id defines the id to search for
  2064. * @return the found mesh or null if not found at all.
  2065. */
  2066. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  2067. /**
  2068. * Gets a the last added node (Mesh, Camera, Light) using a given id
  2069. * @param id defines the id to search for
  2070. * @return the found node or null if not found at all
  2071. */
  2072. getLastEntryByID(id: string): Nullable<Node>;
  2073. /**
  2074. * Gets a node (Mesh, Camera, Light) using a given id
  2075. * @param id defines the id to search for
  2076. * @return the found node or null if not found at all
  2077. */
  2078. getNodeByID(id: string): Nullable<Node>;
  2079. /**
  2080. * Gets a node (Mesh, Camera, Light) using a given name
  2081. * @param name defines the name to search for
  2082. * @return the found node or null if not found at all.
  2083. */
  2084. getNodeByName(name: string): Nullable<Node>;
  2085. /**
  2086. * Gets a mesh using a given name
  2087. * @param name defines the name to search for
  2088. * @return the found mesh or null if not found at all.
  2089. */
  2090. getMeshByName(name: string): Nullable<AbstractMesh>;
  2091. /**
  2092. * Gets a transform node using a given name
  2093. * @param name defines the name to search for
  2094. * @return the found transform node or null if not found at all.
  2095. */
  2096. getTransformNodeByName(name: string): Nullable<TransformNode>;
  2097. /**
  2098. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  2099. * @param id defines the id to search for
  2100. * @return the found skeleton or null if not found at all.
  2101. */
  2102. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  2103. /**
  2104. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  2105. * @param id defines the id to search for
  2106. * @return the found skeleton or null if not found at all.
  2107. */
  2108. getSkeletonById(id: string): Nullable<Skeleton>;
  2109. /**
  2110. * Gets a skeleton using a given name
  2111. * @param name defines the name to search for
  2112. * @return the found skeleton or null if not found at all.
  2113. */
  2114. getSkeletonByName(name: string): Nullable<Skeleton>;
  2115. /**
  2116. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  2117. * @param id defines the id to search for
  2118. * @return the found morph target manager or null if not found at all.
  2119. */
  2120. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  2121. /**
  2122. * Gets a boolean indicating if the given mesh is active
  2123. * @param mesh defines the mesh to look for
  2124. * @returns true if the mesh is in the active list
  2125. */
  2126. isActiveMesh(mesh: AbstractMesh): boolean;
  2127. /**
  2128. * Return a unique id as a string which can serve as an identifier for the scene
  2129. */
  2130. readonly uid: string;
  2131. /**
  2132. * Add an externaly attached data from its key.
  2133. * This method call will fail and return false, if such key already exists.
  2134. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  2135. * @param key the unique key that identifies the data
  2136. * @param data the data object to associate to the key for this Engine instance
  2137. * @return true if no such key were already present and the data was added successfully, false otherwise
  2138. */
  2139. addExternalData<T>(key: string, data: T): boolean;
  2140. /**
  2141. * Get an externaly attached data from its key
  2142. * @param key the unique key that identifies the data
  2143. * @return the associated data, if present (can be null), or undefined if not present
  2144. */
  2145. getExternalData<T>(key: string): Nullable<T>;
  2146. /**
  2147. * Get an externaly attached data from its key, create it using a factory if it's not already present
  2148. * @param key the unique key that identifies the data
  2149. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  2150. * @return the associated data, can be null if the factory returned null.
  2151. */
  2152. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  2153. /**
  2154. * Remove an externaly attached data from the Engine instance
  2155. * @param key the unique key that identifies the data
  2156. * @return true if the data was successfully removed, false if it doesn't exist
  2157. */
  2158. removeExternalData(key: string): boolean;
  2159. private _evaluateSubMesh;
  2160. /**
  2161. * Clear the processed materials smart array preventing retention point in material dispose.
  2162. */
  2163. freeProcessedMaterials(): void;
  2164. /**
  2165. * Clear the active meshes smart array preventing retention point in mesh dispose.
  2166. */
  2167. freeActiveMeshes(): void;
  2168. /**
  2169. * Clear the info related to rendering groups preventing retention points during dispose.
  2170. */
  2171. freeRenderingGroups(): void;
  2172. /** @hidden */
  2173. /**
  2174. * Lambda returning the list of potentially active meshes.
  2175. */
  2176. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  2177. /**
  2178. * Lambda returning the list of potentially active sub meshes.
  2179. */
  2180. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  2181. /**
  2182. * Lambda returning the list of potentially intersecting sub meshes.
  2183. */
  2184. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  2185. /**
  2186. * Lambda returning the list of potentially colliding sub meshes.
  2187. */
  2188. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  2189. private _activeMeshesFrozen;
  2190. /**
  2191. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  2192. * @returns the current scene
  2193. */
  2194. freezeActiveMeshes(): Scene;
  2195. /**
  2196. * Use this function to restart evaluating active meshes on every frame
  2197. * @returns the current scene
  2198. */
  2199. unfreezeActiveMeshes(): Scene;
  2200. private _evaluateActiveMeshes;
  2201. private _activeMesh;
  2202. /**
  2203. * Update the transform matrix to update from the current active camera
  2204. * @param force defines a boolean used to force the update even if cache is up to date
  2205. */
  2206. updateTransformMatrix(force?: boolean): void;
  2207. /**
  2208. * 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)
  2209. * @param alternateCamera defines the camera to use
  2210. */
  2211. updateAlternateTransformMatrix(alternateCamera: Camera): void;
  2212. /** @hidden */
  2213. private _renderForCamera;
  2214. private _processSubCameras;
  2215. private _checkIntersections;
  2216. /** @hidden */
  2217. /**
  2218. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  2219. */
  2220. getDeterministicFrameTime: () => number;
  2221. /**
  2222. * Render the scene
  2223. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  2224. */
  2225. render(updateCameras?: boolean): void;
  2226. /**
  2227. * Freeze all materials
  2228. * A frozen material will not be updatable but should be faster to render
  2229. */
  2230. freezeMaterials(): void;
  2231. /**
  2232. * Unfreeze all materials
  2233. * A frozen material will not be updatable but should be faster to render
  2234. */
  2235. unfreezeMaterials(): void;
  2236. /**
  2237. * Releases all held ressources
  2238. */
  2239. dispose(): void;
  2240. /**
  2241. * Gets if the scene is already disposed
  2242. */
  2243. readonly isDisposed: boolean;
  2244. /**
  2245. * Call this function to reduce memory footprint of the scene.
  2246. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  2247. */
  2248. clearCachedVertexData(): void;
  2249. /**
  2250. * This function will remove the local cached buffer data from texture.
  2251. * It will save memory but will prevent the texture from being rebuilt
  2252. */
  2253. cleanCachedTextureBuffer(): void;
  2254. /**
  2255. * Get the world extend vectors with an optional filter
  2256. *
  2257. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  2258. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  2259. */
  2260. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  2261. min: Vector3;
  2262. max: Vector3;
  2263. };
  2264. /**
  2265. * Creates a ray that can be used to pick in the scene
  2266. * @param x defines the x coordinate of the origin (on-screen)
  2267. * @param y defines the y coordinate of the origin (on-screen)
  2268. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  2269. * @param camera defines the camera to use for the picking
  2270. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  2271. * @returns a Ray
  2272. */
  2273. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  2274. /**
  2275. * Creates a ray that can be used to pick in the scene
  2276. * @param x defines the x coordinate of the origin (on-screen)
  2277. * @param y defines the y coordinate of the origin (on-screen)
  2278. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  2279. * @param result defines the ray where to store the picking ray
  2280. * @param camera defines the camera to use for the picking
  2281. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  2282. * @returns the current scene
  2283. */
  2284. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  2285. /**
  2286. * Creates a ray that can be used to pick in the scene
  2287. * @param x defines the x coordinate of the origin (on-screen)
  2288. * @param y defines the y coordinate of the origin (on-screen)
  2289. * @param camera defines the camera to use for the picking
  2290. * @returns a Ray
  2291. */
  2292. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  2293. /**
  2294. * Creates a ray that can be used to pick in the scene
  2295. * @param x defines the x coordinate of the origin (on-screen)
  2296. * @param y defines the y coordinate of the origin (on-screen)
  2297. * @param result defines the ray where to store the picking ray
  2298. * @param camera defines the camera to use for the picking
  2299. * @returns the current scene
  2300. */
  2301. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  2302. private _internalPick;
  2303. private _internalMultiPick;
  2304. private _tempPickingRay;
  2305. /** Launch a ray to try to pick a mesh in the scene
  2306. * @param x position on screen
  2307. * @param y position on screen
  2308. * @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
  2309. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  2310. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  2311. * @returns a PickingInfo
  2312. */
  2313. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  2314. private _cachedRayForTransform;
  2315. /** Use the given ray to pick a mesh in the scene
  2316. * @param ray The ray to use to pick meshes
  2317. * @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
  2318. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  2319. * @returns a PickingInfo
  2320. */
  2321. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  2322. /**
  2323. * Launch a ray to try to pick a mesh in the scene
  2324. * @param x X position on screen
  2325. * @param y Y position on screen
  2326. * @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
  2327. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  2328. * @returns an array of PickingInfo
  2329. */
  2330. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  2331. /**
  2332. * Launch a ray to try to pick a mesh in the scene
  2333. * @param ray Ray to use
  2334. * @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
  2335. * @returns an array of PickingInfo
  2336. */
  2337. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean): Nullable<PickingInfo[]>;
  2338. /**
  2339. * Force the value of meshUnderPointer
  2340. * @param mesh defines the mesh to use
  2341. */
  2342. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  2343. /**
  2344. * Gets the mesh under the pointer
  2345. * @returns a Mesh or null if no mesh is under the pointer
  2346. */
  2347. getPointerOverMesh(): Nullable<AbstractMesh>;
  2348. /** @hidden */
  2349. /** @hidden */
  2350. private _getByTags;
  2351. /**
  2352. * Get a list of meshes by tags
  2353. * @param tagsQuery defines the tags query to use
  2354. * @param forEach defines a predicate used to filter results
  2355. * @returns an array of Mesh
  2356. */
  2357. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  2358. /**
  2359. * Get a list of cameras by tags
  2360. * @param tagsQuery defines the tags query to use
  2361. * @param forEach defines a predicate used to filter results
  2362. * @returns an array of Camera
  2363. */
  2364. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  2365. /**
  2366. * Get a list of lights by tags
  2367. * @param tagsQuery defines the tags query to use
  2368. * @param forEach defines a predicate used to filter results
  2369. * @returns an array of Light
  2370. */
  2371. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  2372. /**
  2373. * Get a list of materials by tags
  2374. * @param tagsQuery defines the tags query to use
  2375. * @param forEach defines a predicate used to filter results
  2376. * @returns an array of Material
  2377. */
  2378. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  2379. /**
  2380. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  2381. * This allowed control for front to back rendering or reversly depending of the special needs.
  2382. *
  2383. * @param renderingGroupId The rendering group id corresponding to its index
  2384. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  2385. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  2386. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  2387. */
  2388. 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;
  2389. /**
  2390. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  2391. *
  2392. * @param renderingGroupId The rendering group id corresponding to its index
  2393. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  2394. * @param depth Automatically clears depth between groups if true and autoClear is true.
  2395. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  2396. */
  2397. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  2398. /**
  2399. * Gets the current auto clear configuration for one rendering group of the rendering
  2400. * manager.
  2401. * @param index the rendering group index to get the information for
  2402. * @returns The auto clear setup for the requested rendering group
  2403. */
  2404. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  2405. private _blockMaterialDirtyMechanism;
  2406. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  2407. blockMaterialDirtyMechanism: boolean;
  2408. /**
  2409. * Will flag all materials as dirty to trigger new shader compilation
  2410. * @param flag defines the flag used to specify which material part must be marked as dirty
  2411. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  2412. */
  2413. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  2414. /** @hidden */
  2415. /** @hidden */
  2416. }
  2417. }
  2418. declare module BABYLON {
  2419. /**
  2420. * Groups all the scene component constants in one place to ease maintenance.
  2421. * @hidden
  2422. */
  2423. class SceneComponentConstants {
  2424. static readonly NAME_EFFECTLAYER: string;
  2425. static readonly NAME_LAYER: string;
  2426. static readonly NAME_LENSFLARESYSTEM: string;
  2427. static readonly NAME_BOUNDINGBOXRENDERER: string;
  2428. static readonly NAME_PARTICLESYSTEM: string;
  2429. static readonly NAME_GAMEPAD: string;
  2430. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  2431. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  2432. static readonly NAME_DEPTHRENDERER: string;
  2433. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  2434. static readonly NAME_SPRITE: string;
  2435. static readonly NAME_OUTLINERENDERER: string;
  2436. static readonly NAME_PROCEDURALTEXTURE: string;
  2437. static readonly NAME_SHADOWGENERATOR: string;
  2438. static readonly NAME_OCTREE: string;
  2439. static readonly NAME_PHYSICSENGINE: string;
  2440. static readonly NAME_AUDIO: string;
  2441. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  2442. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  2443. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  2444. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  2445. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  2446. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  2447. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  2448. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  2449. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  2450. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  2451. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  2452. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  2453. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  2454. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  2455. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  2456. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  2457. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  2458. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  2459. static readonly STEP_AFTERRENDER_AUDIO: number;
  2460. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  2461. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  2462. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  2463. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  2464. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  2465. static readonly STEP_POINTERMOVE_SPRITE: number;
  2466. static readonly STEP_POINTERDOWN_SPRITE: number;
  2467. static readonly STEP_POINTERUP_SPRITE: number;
  2468. }
  2469. /**
  2470. * This represents a scene component.
  2471. *
  2472. * This is used to decouple the dependency the scene is having on the different workloads like
  2473. * layers, post processes...
  2474. */
  2475. interface ISceneComponent {
  2476. /**
  2477. * The name of the component. Each component must have a unique name.
  2478. */
  2479. name: string;
  2480. /**
  2481. * The scene the component belongs to.
  2482. */
  2483. scene: Scene;
  2484. /**
  2485. * Register the component to one instance of a scene.
  2486. */
  2487. register(): void;
  2488. /**
  2489. * Rebuilds the elements related to this component in case of
  2490. * context lost for instance.
  2491. */
  2492. rebuild(): void;
  2493. /**
  2494. * Disposes the component and the associated ressources.
  2495. */
  2496. dispose(): void;
  2497. }
  2498. /**
  2499. * This represents a SERIALIZABLE scene component.
  2500. *
  2501. * This extends Scene Component to add Serialization methods on top.
  2502. */
  2503. interface ISceneSerializableComponent extends ISceneComponent {
  2504. /**
  2505. * Adds all the element from the container to the scene
  2506. * @param container the container holding the elements
  2507. */
  2508. addFromContainer(container: AbstractScene): void;
  2509. /**
  2510. * Removes all the elements in the container from the scene
  2511. * @param container contains the elements to remove
  2512. */
  2513. removeFromContainer(container: AbstractScene): void;
  2514. /**
  2515. * Serializes the component data to the specified json object
  2516. * @param serializationObject The object to serialize to
  2517. */
  2518. serialize(serializationObject: any): void;
  2519. }
  2520. /**
  2521. * Strong typing of a Mesh related stage step action
  2522. */
  2523. type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  2524. /**
  2525. * Strong typing of a Evaluate Sub Mesh related stage step action
  2526. */
  2527. type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  2528. /**
  2529. * Strong typing of a Active Mesh related stage step action
  2530. */
  2531. type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  2532. /**
  2533. * Strong typing of a Camera related stage step action
  2534. */
  2535. type CameraStageAction = (camera: Camera) => void;
  2536. /**
  2537. * Strong typing of a RenderingGroup related stage step action
  2538. */
  2539. type RenderingGroupStageAction = (renderingGroupId: number) => void;
  2540. /**
  2541. * Strong typing of a Mesh Render related stage step action
  2542. */
  2543. type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  2544. /**
  2545. * Strong typing of a simple stage step action
  2546. */
  2547. type SimpleStageAction = () => void;
  2548. /**
  2549. * Strong typing of a render target action.
  2550. */
  2551. type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  2552. /**
  2553. * Strong typing of a pointer move action.
  2554. */
  2555. type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  2556. /**
  2557. * Strong typing of a pointer up/down action.
  2558. */
  2559. type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  2560. /**
  2561. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  2562. * @hidden
  2563. */
  2564. class Stage<T extends Function> extends Array<{
  2565. index: number;
  2566. component: ISceneComponent;
  2567. action: T;
  2568. }> {
  2569. /**
  2570. * Hide ctor from the rest of the world.
  2571. * @param items The items to add.
  2572. */
  2573. private constructor();
  2574. /**
  2575. * Creates a new Stage.
  2576. * @returns A new instance of a Stage
  2577. */
  2578. static Create<T extends Function>(): Stage<T>;
  2579. /**
  2580. * Registers a step in an ordered way in the targeted stage.
  2581. * @param index Defines the position to register the step in
  2582. * @param component Defines the component attached to the step
  2583. * @param action Defines the action to launch during the step
  2584. */
  2585. registerStep(index: number, component: ISceneComponent, action: T): void;
  2586. /**
  2587. * Clears all the steps from the stage.
  2588. */
  2589. clear(): void;
  2590. }
  2591. }
  2592. declare module BABYLON {
  2593. /** Alias type for value that can be null */
  2594. type Nullable<T> = T | null;
  2595. /**
  2596. * Alias type for number that are floats
  2597. * @ignorenaming
  2598. */
  2599. type float = number;
  2600. /**
  2601. * Alias type for number that are doubles.
  2602. * @ignorenaming
  2603. */
  2604. type double = number;
  2605. /**
  2606. * Alias type for number that are integer
  2607. * @ignorenaming
  2608. */
  2609. type int = number;
  2610. /** Alias type for number array or Float32Array */
  2611. type FloatArray = number[] | Float32Array;
  2612. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  2613. type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  2614. /**
  2615. * Alias for types that can be used by a Buffer or VertexBuffer.
  2616. */
  2617. type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  2618. }
  2619. declare module BABYLON {
  2620. /**
  2621. * The action to be carried out following a trigger
  2622. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  2623. */
  2624. class Action {
  2625. /** the trigger, with or without parameters, for the action */
  2626. triggerOptions: any;
  2627. /**
  2628. * Trigger for the action
  2629. */
  2630. trigger: number;
  2631. /**
  2632. * Internal only - manager for action
  2633. * @hidden
  2634. */
  2635. private _nextActiveAction;
  2636. private _child;
  2637. private _condition?;
  2638. private _triggerParameter;
  2639. /**
  2640. * An event triggered prior to action being executed.
  2641. */
  2642. onBeforeExecuteObservable: Observable<Action>;
  2643. /**
  2644. * Creates a new Action
  2645. * @param triggerOptions the trigger, with or without parameters, for the action
  2646. * @param condition an optional determinant of action
  2647. */
  2648. constructor(
  2649. /** the trigger, with or without parameters, for the action */
  2650. triggerOptions: any, condition?: Condition);
  2651. /**
  2652. * Internal only
  2653. * @hidden
  2654. */
  2655. /**
  2656. * Gets the trigger parameters
  2657. * @returns the trigger parameters
  2658. */
  2659. getTriggerParameter(): any;
  2660. /**
  2661. * Internal only - executes current action event
  2662. * @hidden
  2663. */
  2664. /**
  2665. * Execute placeholder for child classes
  2666. * @param evt optional action event
  2667. */
  2668. execute(evt?: ActionEvent): void;
  2669. /**
  2670. * Skips to next active action
  2671. */
  2672. skipToNextActiveAction(): void;
  2673. /**
  2674. * Adds action to chain of actions, may be a DoNothingAction
  2675. * @param action defines the next action to execute
  2676. * @returns The action passed in
  2677. * @see https://www.babylonjs-playground.com/#1T30HR#0
  2678. */
  2679. then(action: Action): Action;
  2680. /**
  2681. * Internal only
  2682. * @hidden
  2683. */
  2684. /**
  2685. * Internal only
  2686. * @hidden
  2687. */
  2688. /**
  2689. * Serialize placeholder for child classes
  2690. * @param parent of child
  2691. * @returns the serialized object
  2692. */
  2693. serialize(parent: any): any;
  2694. /**
  2695. * Internal only called by serialize
  2696. * @hidden
  2697. */
  2698. protected _serialize(serializedAction: any, parent?: any): any;
  2699. /**
  2700. * Internal only
  2701. * @hidden
  2702. */
  2703. private static _SerializeValueAsString: (value: any) => string;
  2704. /**
  2705. * Internal only
  2706. * @hidden
  2707. */
  2708. private static _GetTargetProperty: (target: Scene | Node) => {
  2709. name: string;
  2710. targetType: string;
  2711. value: string;
  2712. };
  2713. }
  2714. }
  2715. declare module BABYLON {
  2716. /**
  2717. * ActionEvent is the event being sent when an action is triggered.
  2718. */
  2719. class ActionEvent {
  2720. /** The mesh or sprite that triggered the action */
  2721. source: any;
  2722. /** The X mouse cursor position at the time of the event */
  2723. pointerX: number;
  2724. /** The Y mouse cursor position at the time of the event */
  2725. pointerY: number;
  2726. /** The mesh that is currently pointed at (can be null) */
  2727. meshUnderPointer: Nullable<AbstractMesh>;
  2728. /** the original (browser) event that triggered the ActionEvent */
  2729. sourceEvent?: any;
  2730. /** additional data for the event */
  2731. additionalData?: any;
  2732. /**
  2733. * Creates a new ActionEvent
  2734. * @param source The mesh or sprite that triggered the action
  2735. * @param pointerX The X mouse cursor position at the time of the event
  2736. * @param pointerY The Y mouse cursor position at the time of the event
  2737. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  2738. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  2739. * @param additionalData additional data for the event
  2740. */
  2741. constructor(
  2742. /** The mesh or sprite that triggered the action */
  2743. source: any,
  2744. /** The X mouse cursor position at the time of the event */
  2745. pointerX: number,
  2746. /** The Y mouse cursor position at the time of the event */
  2747. pointerY: number,
  2748. /** The mesh that is currently pointed at (can be null) */
  2749. meshUnderPointer: Nullable<AbstractMesh>,
  2750. /** the original (browser) event that triggered the ActionEvent */
  2751. sourceEvent?: any,
  2752. /** additional data for the event */
  2753. additionalData?: any);
  2754. /**
  2755. * Helper function to auto-create an ActionEvent from a source mesh.
  2756. * @param source The source mesh that triggered the event
  2757. * @param evt The original (browser) event
  2758. * @param additionalData additional data for the event
  2759. * @returns the new ActionEvent
  2760. */
  2761. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  2762. /**
  2763. * Helper function to auto-create an ActionEvent from a source sprite
  2764. * @param source The source sprite that triggered the event
  2765. * @param scene Scene associated with the sprite
  2766. * @param evt The original (browser) event
  2767. * @param additionalData additional data for the event
  2768. * @returns the new ActionEvent
  2769. */
  2770. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  2771. /**
  2772. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  2773. * @param scene the scene where the event occurred
  2774. * @param evt The original (browser) event
  2775. * @returns the new ActionEvent
  2776. */
  2777. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  2778. /**
  2779. * Helper function to auto-create an ActionEvent from a primitive
  2780. * @param prim defines the target primitive
  2781. * @param pointerPos defines the pointer position
  2782. * @param evt The original (browser) event
  2783. * @param additionalData additional data for the event
  2784. * @returns the new ActionEvent
  2785. */
  2786. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  2787. }
  2788. /**
  2789. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  2790. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  2791. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  2792. */
  2793. class ActionManager {
  2794. /**
  2795. * Nothing
  2796. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2797. */
  2798. static readonly NothingTrigger: number;
  2799. /**
  2800. * On pick
  2801. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2802. */
  2803. static readonly OnPickTrigger: number;
  2804. /**
  2805. * On left pick
  2806. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2807. */
  2808. static readonly OnLeftPickTrigger: number;
  2809. /**
  2810. * On right pick
  2811. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2812. */
  2813. static readonly OnRightPickTrigger: number;
  2814. /**
  2815. * On center pick
  2816. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2817. */
  2818. static readonly OnCenterPickTrigger: number;
  2819. /**
  2820. * On pick down
  2821. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2822. */
  2823. static readonly OnPickDownTrigger: number;
  2824. /**
  2825. * On double pick
  2826. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2827. */
  2828. static readonly OnDoublePickTrigger: number;
  2829. /**
  2830. * On pick up
  2831. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2832. */
  2833. static readonly OnPickUpTrigger: number;
  2834. /**
  2835. * On pick out.
  2836. * This trigger will only be raised if you also declared a OnPickDown
  2837. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2838. */
  2839. static readonly OnPickOutTrigger: number;
  2840. /**
  2841. * On long press
  2842. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2843. */
  2844. static readonly OnLongPressTrigger: number;
  2845. /**
  2846. * On pointer over
  2847. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2848. */
  2849. static readonly OnPointerOverTrigger: number;
  2850. /**
  2851. * On pointer out
  2852. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2853. */
  2854. static readonly OnPointerOutTrigger: number;
  2855. /**
  2856. * On every frame
  2857. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2858. */
  2859. static readonly OnEveryFrameTrigger: number;
  2860. /**
  2861. * On intersection enter
  2862. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2863. */
  2864. static readonly OnIntersectionEnterTrigger: number;
  2865. /**
  2866. * On intersection exit
  2867. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2868. */
  2869. static readonly OnIntersectionExitTrigger: number;
  2870. /**
  2871. * On key down
  2872. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2873. */
  2874. static readonly OnKeyDownTrigger: number;
  2875. /**
  2876. * On key up
  2877. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2878. */
  2879. static readonly OnKeyUpTrigger: number;
  2880. /** Gets the list of active triggers */
  2881. static Triggers: {
  2882. [key: string]: number;
  2883. };
  2884. /** Gets the list of actions */
  2885. actions: Action[];
  2886. /** Gets the cursor to use when hovering items */
  2887. hoverCursor: string;
  2888. private _scene;
  2889. /**
  2890. * Creates a new action manager
  2891. * @param scene defines the hosting scene
  2892. */
  2893. constructor(scene: Scene);
  2894. /**
  2895. * Releases all associated resources
  2896. */
  2897. dispose(): void;
  2898. /**
  2899. * Gets hosting scene
  2900. * @returns the hosting scene
  2901. */
  2902. getScene(): Scene;
  2903. /**
  2904. * Does this action manager handles actions of any of the given triggers
  2905. * @param triggers defines the triggers to be tested
  2906. * @return a boolean indicating whether one (or more) of the triggers is handled
  2907. */
  2908. hasSpecificTriggers(triggers: number[]): boolean;
  2909. /**
  2910. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  2911. * speed.
  2912. * @param triggerA defines the trigger to be tested
  2913. * @param triggerB defines the trigger to be tested
  2914. * @return a boolean indicating whether one (or more) of the triggers is handled
  2915. */
  2916. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  2917. /**
  2918. * Does this action manager handles actions of a given trigger
  2919. * @param trigger defines the trigger to be tested
  2920. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  2921. * @return whether the trigger is handled
  2922. */
  2923. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  2924. /**
  2925. * Does this action manager has pointer triggers
  2926. */
  2927. readonly hasPointerTriggers: boolean;
  2928. /**
  2929. * Does this action manager has pick triggers
  2930. */
  2931. readonly hasPickTriggers: boolean;
  2932. /**
  2933. * Does exist one action manager with at least one trigger
  2934. **/
  2935. static readonly HasTriggers: boolean;
  2936. /**
  2937. * Does exist one action manager with at least one pick trigger
  2938. **/
  2939. static readonly HasPickTriggers: boolean;
  2940. /**
  2941. * Does exist one action manager that handles actions of a given trigger
  2942. * @param trigger defines the trigger to be tested
  2943. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  2944. **/
  2945. static HasSpecificTrigger(trigger: number): boolean;
  2946. /**
  2947. * Registers an action to this action manager
  2948. * @param action defines the action to be registered
  2949. * @return the action amended (prepared) after registration
  2950. */
  2951. registerAction(action: Action): Nullable<Action>;
  2952. /**
  2953. * Unregisters an action to this action manager
  2954. * @param action defines the action to be unregistered
  2955. * @return a boolean indicating whether the action has been unregistered
  2956. */
  2957. unregisterAction(action: Action): Boolean;
  2958. /**
  2959. * Process a specific trigger
  2960. * @param trigger defines the trigger to process
  2961. * @param evt defines the event details to be processed
  2962. */
  2963. processTrigger(trigger: number, evt?: ActionEvent): void;
  2964. /** @hidden */
  2965. /** @hidden */
  2966. /**
  2967. * Serialize this manager to a JSON object
  2968. * @param name defines the property name to store this manager
  2969. * @returns a JSON representation of this manager
  2970. */
  2971. serialize(name: string): any;
  2972. /**
  2973. * Creates a new ActionManager from a JSON data
  2974. * @param parsedActions defines the JSON data to read from
  2975. * @param object defines the hosting mesh
  2976. * @param scene defines the hosting scene
  2977. */
  2978. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  2979. /**
  2980. * Get a trigger name by index
  2981. * @param trigger defines the trigger index
  2982. * @returns a trigger name
  2983. */
  2984. static GetTriggerName(trigger: number): string;
  2985. }
  2986. }
  2987. declare module BABYLON {
  2988. /**
  2989. * A Condition applied to an Action
  2990. */
  2991. class Condition {
  2992. /**
  2993. * Internal only - manager for action
  2994. * @hidden
  2995. */
  2996. /**
  2997. * Internal only
  2998. * @hidden
  2999. */
  3000. /**
  3001. * Internal only
  3002. * @hidden
  3003. */
  3004. /**
  3005. * Creates a new Condition
  3006. * @param actionManager the manager of the action the condition is applied to
  3007. */
  3008. constructor(actionManager: ActionManager);
  3009. /**
  3010. * Check if the current condition is valid
  3011. * @returns a boolean
  3012. */
  3013. isValid(): boolean;
  3014. /**
  3015. * Internal only
  3016. * @hidden
  3017. */
  3018. /**
  3019. * Internal only
  3020. * @hidden
  3021. */
  3022. /**
  3023. * Serialize placeholder for child classes
  3024. * @returns the serialized object
  3025. */
  3026. serialize(): any;
  3027. /**
  3028. * Internal only
  3029. * @hidden
  3030. */
  3031. protected _serialize(serializedCondition: any): any;
  3032. }
  3033. /**
  3034. * Defines specific conditional operators as extensions of Condition
  3035. */
  3036. class ValueCondition extends Condition {
  3037. /** path to specify the property of the target the conditional operator uses */
  3038. propertyPath: string;
  3039. /** the value compared by the conditional operator against the current value of the property */
  3040. value: any;
  3041. /** the conditional operator, default ValueCondition.IsEqual */
  3042. operator: number;
  3043. /**
  3044. * Internal only
  3045. * @hidden
  3046. */
  3047. private static _IsEqual;
  3048. /**
  3049. * Internal only
  3050. * @hidden
  3051. */
  3052. private static _IsDifferent;
  3053. /**
  3054. * Internal only
  3055. * @hidden
  3056. */
  3057. private static _IsGreater;
  3058. /**
  3059. * Internal only
  3060. * @hidden
  3061. */
  3062. private static _IsLesser;
  3063. /**
  3064. * returns the number for IsEqual
  3065. */
  3066. static readonly IsEqual: number;
  3067. /**
  3068. * Returns the number for IsDifferent
  3069. */
  3070. static readonly IsDifferent: number;
  3071. /**
  3072. * Returns the number for IsGreater
  3073. */
  3074. static readonly IsGreater: number;
  3075. /**
  3076. * Returns the number for IsLesser
  3077. */
  3078. static readonly IsLesser: number;
  3079. /**
  3080. * Internal only The action manager for the condition
  3081. * @hidden
  3082. */
  3083. /**
  3084. * Internal only
  3085. * @hidden
  3086. */
  3087. private _target;
  3088. /**
  3089. * Internal only
  3090. * @hidden
  3091. */
  3092. private _effectiveTarget;
  3093. /**
  3094. * Internal only
  3095. * @hidden
  3096. */
  3097. private _property;
  3098. /**
  3099. * Creates a new ValueCondition
  3100. * @param actionManager manager for the action the condition applies to
  3101. * @param target for the action
  3102. * @param propertyPath path to specify the property of the target the conditional operator uses
  3103. * @param value the value compared by the conditional operator against the current value of the property
  3104. * @param operator the conditional operator, default ValueCondition.IsEqual
  3105. */
  3106. constructor(actionManager: ActionManager, target: any,
  3107. /** path to specify the property of the target the conditional operator uses */
  3108. propertyPath: string,
  3109. /** the value compared by the conditional operator against the current value of the property */
  3110. value: any,
  3111. /** the conditional operator, default ValueCondition.IsEqual */
  3112. operator?: number);
  3113. /**
  3114. * Compares the given value with the property value for the specified conditional operator
  3115. * @returns the result of the comparison
  3116. */
  3117. isValid(): boolean;
  3118. /**
  3119. * Serialize the ValueCondition into a JSON compatible object
  3120. * @returns serialization object
  3121. */
  3122. serialize(): any;
  3123. /**
  3124. * Gets the name of the conditional operator for the ValueCondition
  3125. * @param operator the conditional operator
  3126. * @returns the name
  3127. */
  3128. static GetOperatorName(operator: number): string;
  3129. }
  3130. /**
  3131. * Defines a predicate condition as an extension of Condition
  3132. */
  3133. class PredicateCondition extends Condition {
  3134. /** defines the predicate function used to validate the condition */
  3135. predicate: () => boolean;
  3136. /**
  3137. * Internal only - manager for action
  3138. * @hidden
  3139. */
  3140. /**
  3141. * Creates a new PredicateCondition
  3142. * @param actionManager manager for the action the condition applies to
  3143. * @param predicate defines the predicate function used to validate the condition
  3144. */
  3145. constructor(actionManager: ActionManager,
  3146. /** defines the predicate function used to validate the condition */
  3147. predicate: () => boolean);
  3148. /**
  3149. * @returns the validity of the predicate condition
  3150. */
  3151. isValid(): boolean;
  3152. }
  3153. /**
  3154. * Defines a state condition as an extension of Condition
  3155. */
  3156. class StateCondition extends Condition {
  3157. /** Value to compare with target state */
  3158. value: string;
  3159. /**
  3160. * Internal only - manager for action
  3161. * @hidden
  3162. */
  3163. /**
  3164. * Internal only
  3165. * @hidden
  3166. */
  3167. private _target;
  3168. /**
  3169. * Creates a new StateCondition
  3170. * @param actionManager manager for the action the condition applies to
  3171. * @param target of the condition
  3172. * @param value to compare with target state
  3173. */
  3174. constructor(actionManager: ActionManager, target: any,
  3175. /** Value to compare with target state */
  3176. value: string);
  3177. /**
  3178. * Gets a boolean indicating if the current condition is met
  3179. * @returns the validity of the state
  3180. */
  3181. isValid(): boolean;
  3182. /**
  3183. * Serialize the StateCondition into a JSON compatible object
  3184. * @returns serialization object
  3185. */
  3186. serialize(): any;
  3187. }
  3188. }
  3189. declare module BABYLON {
  3190. /**
  3191. * This defines an action responsible to toggle a boolean once triggered.
  3192. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3193. */
  3194. class SwitchBooleanAction extends Action {
  3195. /**
  3196. * The path to the boolean property in the target object
  3197. */
  3198. propertyPath: string;
  3199. private _target;
  3200. private _effectiveTarget;
  3201. private _property;
  3202. /**
  3203. * Instantiate the action
  3204. * @param triggerOptions defines the trigger options
  3205. * @param target defines the object containing the boolean
  3206. * @param propertyPath defines the path to the boolean property in the target object
  3207. * @param condition defines the trigger related conditions
  3208. */
  3209. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  3210. /** @hidden */
  3211. /**
  3212. * Execute the action toggle the boolean value.
  3213. */
  3214. execute(): void;
  3215. /**
  3216. * Serializes the actions and its related information.
  3217. * @param parent defines the object to serialize in
  3218. * @returns the serialized object
  3219. */
  3220. serialize(parent: any): any;
  3221. }
  3222. /**
  3223. * This defines an action responsible to set a the state field of the target
  3224. * to a desired value once triggered.
  3225. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3226. */
  3227. class SetStateAction extends Action {
  3228. /**
  3229. * The value to store in the state field.
  3230. */
  3231. value: string;
  3232. private _target;
  3233. /**
  3234. * Instantiate the action
  3235. * @param triggerOptions defines the trigger options
  3236. * @param target defines the object containing the state property
  3237. * @param value defines the value to store in the state field
  3238. * @param condition defines the trigger related conditions
  3239. */
  3240. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  3241. /**
  3242. * Execute the action and store the value on the target state property.
  3243. */
  3244. execute(): void;
  3245. /**
  3246. * Serializes the actions and its related information.
  3247. * @param parent defines the object to serialize in
  3248. * @returns the serialized object
  3249. */
  3250. serialize(parent: any): any;
  3251. }
  3252. /**
  3253. * This defines an action responsible to set a property of the target
  3254. * to a desired value once triggered.
  3255. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3256. */
  3257. class SetValueAction extends Action {
  3258. /**
  3259. * The path of the property to set in the target.
  3260. */
  3261. propertyPath: string;
  3262. /**
  3263. * The value to set in the property
  3264. */
  3265. value: any;
  3266. private _target;
  3267. private _effectiveTarget;
  3268. private _property;
  3269. /**
  3270. * Instantiate the action
  3271. * @param triggerOptions defines the trigger options
  3272. * @param target defines the object containing the property
  3273. * @param propertyPath defines the path of the property to set in the target
  3274. * @param value defines the value to set in the property
  3275. * @param condition defines the trigger related conditions
  3276. */
  3277. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  3278. /** @hidden */
  3279. /**
  3280. * Execute the action and set the targetted property to the desired value.
  3281. */
  3282. execute(): void;
  3283. /**
  3284. * Serializes the actions and its related information.
  3285. * @param parent defines the object to serialize in
  3286. * @returns the serialized object
  3287. */
  3288. serialize(parent: any): any;
  3289. }
  3290. /**
  3291. * This defines an action responsible to increment the target value
  3292. * to a desired value once triggered.
  3293. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3294. */
  3295. class IncrementValueAction extends Action {
  3296. /**
  3297. * The path of the property to increment in the target.
  3298. */
  3299. propertyPath: string;
  3300. /**
  3301. * The value we should increment the property by.
  3302. */
  3303. value: any;
  3304. private _target;
  3305. private _effectiveTarget;
  3306. private _property;
  3307. /**
  3308. * Instantiate the action
  3309. * @param triggerOptions defines the trigger options
  3310. * @param target defines the object containing the property
  3311. * @param propertyPath defines the path of the property to increment in the target
  3312. * @param value defines the value value we should increment the property by
  3313. * @param condition defines the trigger related conditions
  3314. */
  3315. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  3316. /** @hidden */
  3317. /**
  3318. * Execute the action and increment the target of the value amount.
  3319. */
  3320. execute(): void;
  3321. /**
  3322. * Serializes the actions and its related information.
  3323. * @param parent defines the object to serialize in
  3324. * @returns the serialized object
  3325. */
  3326. serialize(parent: any): any;
  3327. }
  3328. /**
  3329. * This defines an action responsible to start an animation once triggered.
  3330. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3331. */
  3332. class PlayAnimationAction extends Action {
  3333. /**
  3334. * Where the animation should start (animation frame)
  3335. */
  3336. from: number;
  3337. /**
  3338. * Where the animation should stop (animation frame)
  3339. */
  3340. to: number;
  3341. /**
  3342. * Define if the animation should loop or stop after the first play.
  3343. */
  3344. loop?: boolean;
  3345. private _target;
  3346. /**
  3347. * Instantiate the action
  3348. * @param triggerOptions defines the trigger options
  3349. * @param target defines the target animation or animation name
  3350. * @param from defines from where the animation should start (animation frame)
  3351. * @param end defines where the animation should stop (animation frame)
  3352. * @param loop defines if the animation should loop or stop after the first play
  3353. * @param condition defines the trigger related conditions
  3354. */
  3355. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  3356. /** @hidden */
  3357. /**
  3358. * Execute the action and play the animation.
  3359. */
  3360. execute(): void;
  3361. /**
  3362. * Serializes the actions and its related information.
  3363. * @param parent defines the object to serialize in
  3364. * @returns the serialized object
  3365. */
  3366. serialize(parent: any): any;
  3367. }
  3368. /**
  3369. * This defines an action responsible to stop an animation once triggered.
  3370. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3371. */
  3372. class StopAnimationAction extends Action {
  3373. private _target;
  3374. /**
  3375. * Instantiate the action
  3376. * @param triggerOptions defines the trigger options
  3377. * @param target defines the target animation or animation name
  3378. * @param condition defines the trigger related conditions
  3379. */
  3380. constructor(triggerOptions: any, target: any, condition?: Condition);
  3381. /** @hidden */
  3382. /**
  3383. * Execute the action and stop the animation.
  3384. */
  3385. execute(): void;
  3386. /**
  3387. * Serializes the actions and its related information.
  3388. * @param parent defines the object to serialize in
  3389. * @returns the serialized object
  3390. */
  3391. serialize(parent: any): any;
  3392. }
  3393. /**
  3394. * This defines an action responsible that does nothing once triggered.
  3395. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3396. */
  3397. class DoNothingAction extends Action {
  3398. /**
  3399. * Instantiate the action
  3400. * @param triggerOptions defines the trigger options
  3401. * @param condition defines the trigger related conditions
  3402. */
  3403. constructor(triggerOptions?: any, condition?: Condition);
  3404. /**
  3405. * Execute the action and do nothing.
  3406. */
  3407. execute(): void;
  3408. /**
  3409. * Serializes the actions and its related information.
  3410. * @param parent defines the object to serialize in
  3411. * @returns the serialized object
  3412. */
  3413. serialize(parent: any): any;
  3414. }
  3415. /**
  3416. * This defines an action responsible to trigger several actions once triggered.
  3417. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3418. */
  3419. class CombineAction extends Action {
  3420. /**
  3421. * The list of aggregated animations to run.
  3422. */
  3423. children: Action[];
  3424. /**
  3425. * Instantiate the action
  3426. * @param triggerOptions defines the trigger options
  3427. * @param children defines the list of aggregated animations to run
  3428. * @param condition defines the trigger related conditions
  3429. */
  3430. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  3431. /** @hidden */
  3432. /**
  3433. * Execute the action and executes all the aggregated actions.
  3434. */
  3435. execute(evt: ActionEvent): 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. * This defines an action responsible to run code (external event) once triggered.
  3445. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3446. */
  3447. class ExecuteCodeAction extends Action {
  3448. /**
  3449. * The callback function to run.
  3450. */
  3451. func: (evt: ActionEvent) => void;
  3452. /**
  3453. * Instantiate the action
  3454. * @param triggerOptions defines the trigger options
  3455. * @param func defines the callback function to run
  3456. * @param condition defines the trigger related conditions
  3457. */
  3458. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  3459. /**
  3460. * Execute the action and run the attached code.
  3461. */
  3462. execute(evt: ActionEvent): void;
  3463. }
  3464. /**
  3465. * This defines an action responsible to set the parent property of the target once triggered.
  3466. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3467. */
  3468. class SetParentAction extends Action {
  3469. private _parent;
  3470. private _target;
  3471. /**
  3472. * Instantiate the action
  3473. * @param triggerOptions defines the trigger options
  3474. * @param target defines the target containing the parent property
  3475. * @param parent defines from where the animation should start (animation frame)
  3476. * @param condition defines the trigger related conditions
  3477. */
  3478. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  3479. /** @hidden */
  3480. /**
  3481. * Execute the action and set the parent property.
  3482. */
  3483. execute(): void;
  3484. /**
  3485. * Serializes the actions and its related information.
  3486. * @param parent defines the object to serialize in
  3487. * @returns the serialized object
  3488. */
  3489. serialize(parent: any): any;
  3490. }
  3491. }
  3492. declare module BABYLON {
  3493. /**
  3494. * This defines an action helpful to play a defined sound on a triggered action.
  3495. */
  3496. class PlaySoundAction extends Action {
  3497. private _sound;
  3498. /**
  3499. * Instantiate the action
  3500. * @param triggerOptions defines the trigger options
  3501. * @param sound defines the sound to play
  3502. * @param condition defines the trigger related conditions
  3503. */
  3504. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  3505. /** @hidden */
  3506. /**
  3507. * Execute the action and play the sound.
  3508. */
  3509. execute(): void;
  3510. /**
  3511. * Serializes the actions and its related information.
  3512. * @param parent defines the object to serialize in
  3513. * @returns the serialized object
  3514. */
  3515. serialize(parent: any): any;
  3516. }
  3517. /**
  3518. * This defines an action helpful to stop a defined sound on a triggered action.
  3519. */
  3520. class StopSoundAction extends Action {
  3521. private _sound;
  3522. /**
  3523. * Instantiate the action
  3524. * @param triggerOptions defines the trigger options
  3525. * @param sound defines the sound to stop
  3526. * @param condition defines the trigger related conditions
  3527. */
  3528. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  3529. /** @hidden */
  3530. /**
  3531. * Execute the action and stop the sound.
  3532. */
  3533. execute(): void;
  3534. /**
  3535. * Serializes the actions and its related information.
  3536. * @param parent defines the object to serialize in
  3537. * @returns the serialized object
  3538. */
  3539. serialize(parent: any): any;
  3540. }
  3541. }
  3542. declare module BABYLON {
  3543. /**
  3544. * This defines an action responsible to change the value of a property
  3545. * by interpolating between its current value and the newly set one once triggered.
  3546. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3547. */
  3548. class InterpolateValueAction extends Action {
  3549. /**
  3550. * Defines the path of the property where the value should be interpolated
  3551. */
  3552. propertyPath: string;
  3553. /**
  3554. * Defines the target value at the end of the interpolation.
  3555. */
  3556. value: any;
  3557. /**
  3558. * Defines the time it will take for the property to interpolate to the value.
  3559. */
  3560. duration: number;
  3561. /**
  3562. * Defines if the other scene animations should be stopped when the action has been triggered
  3563. */
  3564. stopOtherAnimations?: boolean;
  3565. /**
  3566. * Defines a callback raised once the interpolation animation has been done.
  3567. */
  3568. onInterpolationDone?: () => void;
  3569. /**
  3570. * Observable triggered once the interpolation animation has been done.
  3571. */
  3572. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  3573. private _target;
  3574. private _effectiveTarget;
  3575. private _property;
  3576. /**
  3577. * Instantiate the action
  3578. * @param triggerOptions defines the trigger options
  3579. * @param target defines the object containing the value to interpolate
  3580. * @param propertyPath defines the path to the property in the target object
  3581. * @param value defines the target value at the end of the interpolation
  3582. * @param duration deines the time it will take for the property to interpolate to the value.
  3583. * @param condition defines the trigger related conditions
  3584. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  3585. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  3586. */
  3587. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  3588. /** @hidden */
  3589. /**
  3590. * Execute the action starts the value interpolation.
  3591. */
  3592. execute(): void;
  3593. /**
  3594. * Serializes the actions and its related information.
  3595. * @param parent defines the object to serialize in
  3596. * @returns the serialized object
  3597. */
  3598. serialize(parent: any): any;
  3599. }
  3600. }
  3601. declare module BABYLON {
  3602. /**
  3603. * Class used to work with sound analyzer using fast fourier transform (FFT)
  3604. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  3605. */
  3606. class Analyser {
  3607. /**
  3608. * Gets or sets the smoothing
  3609. * @ignorenaming
  3610. */
  3611. SMOOTHING: number;
  3612. /**
  3613. * Gets or sets the FFT table size
  3614. * @ignorenaming
  3615. */
  3616. FFT_SIZE: number;
  3617. /**
  3618. * Gets or sets the bar graph amplitude
  3619. * @ignorenaming
  3620. */
  3621. BARGRAPHAMPLITUDE: number;
  3622. /**
  3623. * Gets or sets the position of the debug canvas
  3624. * @ignorenaming
  3625. */
  3626. DEBUGCANVASPOS: {
  3627. x: number;
  3628. y: number;
  3629. };
  3630. /**
  3631. * Gets or sets the debug canvas size
  3632. * @ignorenaming
  3633. */
  3634. DEBUGCANVASSIZE: {
  3635. width: number;
  3636. height: number;
  3637. };
  3638. private _byteFreqs;
  3639. private _byteTime;
  3640. private _floatFreqs;
  3641. private _webAudioAnalyser;
  3642. private _debugCanvas;
  3643. private _debugCanvasContext;
  3644. private _scene;
  3645. private _registerFunc;
  3646. private _audioEngine;
  3647. /**
  3648. * Creates a new analyser
  3649. * @param scene defines hosting scene
  3650. */
  3651. constructor(scene: Scene);
  3652. /**
  3653. * Get the number of data values you will have to play with for the visualization
  3654. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  3655. * @returns a number
  3656. */
  3657. getFrequencyBinCount(): number;
  3658. /**
  3659. * Gets the current frequency data as a byte array
  3660. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  3661. * @returns a Uint8Array
  3662. */
  3663. getByteFrequencyData(): Uint8Array;
  3664. /**
  3665. * Gets the current waveform as a byte array
  3666. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  3667. * @returns a Uint8Array
  3668. */
  3669. getByteTimeDomainData(): Uint8Array;
  3670. /**
  3671. * Gets the current frequency data as a float array
  3672. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  3673. * @returns a Float32Array
  3674. */
  3675. getFloatFrequencyData(): Float32Array;
  3676. /**
  3677. * Renders the debug canvas
  3678. */
  3679. drawDebugCanvas(): void;
  3680. /**
  3681. * Stops rendering the debug canvas and removes it
  3682. */
  3683. stopDebugCanvas(): void;
  3684. /**
  3685. * Connects two audio nodes
  3686. * @param inputAudioNode defines first node to connect
  3687. * @param outputAudioNode defines second node to connect
  3688. */
  3689. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  3690. /**
  3691. * Releases all associated resources
  3692. */
  3693. dispose(): void;
  3694. }
  3695. }
  3696. declare module BABYLON {
  3697. /**
  3698. * This represents an audio engine and it is responsible
  3699. * to play, synchronize and analyse sounds throughout the application.
  3700. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  3701. */
  3702. interface IAudioEngine extends IDisposable {
  3703. /**
  3704. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  3705. */
  3706. readonly canUseWebAudio: boolean;
  3707. /**
  3708. * Gets the current AudioContext if available.
  3709. */
  3710. readonly audioContext: Nullable<AudioContext>;
  3711. /**
  3712. * The master gain node defines the global audio volume of your audio engine.
  3713. */
  3714. readonly masterGain: GainNode;
  3715. /**
  3716. * Gets whether or not mp3 are supported by your browser.
  3717. */
  3718. readonly isMP3supported: boolean;
  3719. /**
  3720. * Gets whether or not ogg are supported by your browser.
  3721. */
  3722. readonly isOGGsupported: boolean;
  3723. /**
  3724. * Defines if Babylon should emit a warning if WebAudio is not supported.
  3725. * @ignoreNaming
  3726. */
  3727. WarnedWebAudioUnsupported: boolean;
  3728. /**
  3729. * Defines if the audio engine relies on a custom unlocked button.
  3730. * In this case, the embedded button will not be displayed.
  3731. */
  3732. useCustomUnlockedButton: boolean;
  3733. /**
  3734. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  3735. */
  3736. readonly unlocked: boolean;
  3737. /**
  3738. * Event raised when audio has been unlocked on the browser.
  3739. */
  3740. onAudioUnlockedObservable: Observable<AudioEngine>;
  3741. /**
  3742. * Event raised when audio has been locked on the browser.
  3743. */
  3744. onAudioLockedObservable: Observable<AudioEngine>;
  3745. /**
  3746. * Flags the audio engine in Locked state.
  3747. * This happens due to new browser policies preventing audio to autoplay.
  3748. */
  3749. lock(): void;
  3750. /**
  3751. * Unlocks the audio engine once a user action has been done on the dom.
  3752. * This is helpful to resume play once browser policies have been satisfied.
  3753. */
  3754. unlock(): void;
  3755. }
  3756. /**
  3757. * This represents the default audio engine used in babylon.
  3758. * It is responsible to play, synchronize and analyse sounds throughout the application.
  3759. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  3760. */
  3761. class AudioEngine implements IAudioEngine {
  3762. private _audioContext;
  3763. private _audioContextInitialized;
  3764. private _muteButton;
  3765. private _hostElement;
  3766. /**
  3767. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  3768. */
  3769. canUseWebAudio: boolean;
  3770. /**
  3771. * The master gain node defines the global audio volume of your audio engine.
  3772. */
  3773. masterGain: GainNode;
  3774. /**
  3775. * Defines if Babylon should emit a warning if WebAudio is not supported.
  3776. * @ignoreNaming
  3777. */
  3778. WarnedWebAudioUnsupported: boolean;
  3779. /**
  3780. * Gets whether or not mp3 are supported by your browser.
  3781. */
  3782. isMP3supported: boolean;
  3783. /**
  3784. * Gets whether or not ogg are supported by your browser.
  3785. */
  3786. isOGGsupported: boolean;
  3787. /**
  3788. * Gets whether audio has been unlocked on the device.
  3789. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  3790. * a user interaction has happened.
  3791. */
  3792. unlocked: boolean;
  3793. /**
  3794. * Defines if the audio engine relies on a custom unlocked button.
  3795. * In this case, the embedded button will not be displayed.
  3796. */
  3797. useCustomUnlockedButton: boolean;
  3798. /**
  3799. * Event raised when audio has been unlocked on the browser.
  3800. */
  3801. onAudioUnlockedObservable: Observable<AudioEngine>;
  3802. /**
  3803. * Event raised when audio has been locked on the browser.
  3804. */
  3805. onAudioLockedObservable: Observable<AudioEngine>;
  3806. /**
  3807. * Gets the current AudioContext if available.
  3808. */
  3809. readonly audioContext: Nullable<AudioContext>;
  3810. private _connectedAnalyser;
  3811. /**
  3812. * Instantiates a new audio engine.
  3813. *
  3814. * There should be only one per page as some browsers restrict the number
  3815. * of audio contexts you can create.
  3816. * @param hostElement defines the host element where to display the mute icon if necessary
  3817. */
  3818. constructor(hostElement?: Nullable<HTMLElement>);
  3819. /**
  3820. * Flags the audio engine in Locked state.
  3821. * This happens due to new browser policies preventing audio to autoplay.
  3822. */
  3823. lock(): void;
  3824. /**
  3825. * Unlocks the audio engine once a user action has been done on the dom.
  3826. * This is helpful to resume play once browser policies have been satisfied.
  3827. */
  3828. unlock(): void;
  3829. private _resumeAudioContext;
  3830. private _initializeAudioContext;
  3831. private _tryToRun;
  3832. private _triggerRunningState;
  3833. private _triggerSuspendedState;
  3834. private _displayMuteButton;
  3835. private _moveButtonToTopLeft;
  3836. private _onResize;
  3837. private _hideMuteButton;
  3838. /**
  3839. * Destroy and release the resources associated with the audio ccontext.
  3840. */
  3841. dispose(): void;
  3842. /**
  3843. * Gets the global volume sets on the master gain.
  3844. * @returns the global volume if set or -1 otherwise
  3845. */
  3846. getGlobalVolume(): number;
  3847. /**
  3848. * Sets the global volume of your experience (sets on the master gain).
  3849. * @param newVolume Defines the new global volume of the application
  3850. */
  3851. setGlobalVolume(newVolume: number): void;
  3852. /**
  3853. * Connect the audio engine to an audio analyser allowing some amazing
  3854. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  3855. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  3856. * @param analyser The analyser to connect to the engine
  3857. */
  3858. connectToAnalyser(analyser: Analyser): void;
  3859. }
  3860. }
  3861. declare module BABYLON {
  3862. interface AbstractScene {
  3863. /**
  3864. * The list of sounds used in the scene.
  3865. */
  3866. sounds: Nullable<Array<Sound>>;
  3867. }
  3868. interface Scene {
  3869. /**
  3870. * @hidden
  3871. * Backing field
  3872. */
  3873. /**
  3874. * The main sound track played by the scene.
  3875. * It cotains your primary collection of sounds.
  3876. */
  3877. mainSoundTrack: SoundTrack;
  3878. /**
  3879. * The list of sound tracks added to the scene
  3880. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  3881. */
  3882. soundTracks: Nullable<Array<SoundTrack>>;
  3883. /**
  3884. * Gets a sound using a given name
  3885. * @param name defines the name to search for
  3886. * @return the found sound or null if not found at all.
  3887. */
  3888. getSoundByName(name: string): Nullable<Sound>;
  3889. /**
  3890. * Gets or sets if audio support is enabled
  3891. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  3892. */
  3893. audioEnabled: boolean;
  3894. /**
  3895. * Gets or sets if audio will be output to headphones
  3896. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  3897. */
  3898. headphone: boolean;
  3899. }
  3900. /**
  3901. * Defines the sound scene component responsible to manage any sounds
  3902. * in a given scene.
  3903. */
  3904. class AudioSceneComponent implements ISceneSerializableComponent {
  3905. /**
  3906. * The component name helpfull to identify the component in the list of scene components.
  3907. */
  3908. readonly name: string;
  3909. /**
  3910. * The scene the component belongs to.
  3911. */
  3912. scene: Scene;
  3913. private _audioEnabled;
  3914. /**
  3915. * Gets whether audio is enabled or not.
  3916. * Please use related enable/disable method to switch state.
  3917. */
  3918. readonly audioEnabled: boolean;
  3919. private _headphone;
  3920. /**
  3921. * Gets whether audio is outputing to headphone or not.
  3922. * Please use the according Switch methods to change output.
  3923. */
  3924. readonly headphone: boolean;
  3925. /**
  3926. * Creates a new instance of the component for the given scene
  3927. * @param scene Defines the scene to register the component in
  3928. */
  3929. constructor(scene: Scene);
  3930. /**
  3931. * Registers the component in a given scene
  3932. */
  3933. register(): void;
  3934. /**
  3935. * Rebuilds the elements related to this component in case of
  3936. * context lost for instance.
  3937. */
  3938. rebuild(): void;
  3939. /**
  3940. * Serializes the component data to the specified json object
  3941. * @param serializationObject The object to serialize to
  3942. */
  3943. serialize(serializationObject: any): void;
  3944. /**
  3945. * Adds all the element from the container to the scene
  3946. * @param container the container holding the elements
  3947. */
  3948. addFromContainer(container: AbstractScene): void;
  3949. /**
  3950. * Removes all the elements in the container from the scene
  3951. * @param container contains the elements to remove
  3952. */
  3953. removeFromContainer(container: AbstractScene): void;
  3954. /**
  3955. * Disposes the component and the associated ressources.
  3956. */
  3957. dispose(): void;
  3958. /**
  3959. * Disables audio in the associated scene.
  3960. */
  3961. disableAudio(): void;
  3962. /**
  3963. * Enables audio in the associated scene.
  3964. */
  3965. enableAudio(): void;
  3966. /**
  3967. * Switch audio to headphone output.
  3968. */
  3969. switchAudioModeForHeadphones(): void;
  3970. /**
  3971. * Switch audio to normal speakers.
  3972. */
  3973. switchAudioModeForNormalSpeakers(): void;
  3974. private _afterRender;
  3975. }
  3976. }
  3977. declare module BABYLON {
  3978. /**
  3979. * Defines a sound that can be played in the application.
  3980. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  3981. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  3982. */
  3983. class Sound {
  3984. /**
  3985. * The name of the sound in the scene.
  3986. */
  3987. name: string;
  3988. /**
  3989. * Does the sound autoplay once loaded.
  3990. */
  3991. autoplay: boolean;
  3992. /**
  3993. * Does the sound loop after it finishes playing once.
  3994. */
  3995. loop: boolean;
  3996. /**
  3997. * Does the sound use a custom attenuation curve to simulate the falloff
  3998. * happening when the source gets further away from the camera.
  3999. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  4000. */
  4001. useCustomAttenuation: boolean;
  4002. /**
  4003. * The sound track id this sound belongs to.
  4004. */
  4005. soundTrackId: number;
  4006. /**
  4007. * Is this sound currently played.
  4008. */
  4009. isPlaying: boolean;
  4010. /**
  4011. * Is this sound currently paused.
  4012. */
  4013. isPaused: boolean;
  4014. /**
  4015. * Does this sound enables spatial sound.
  4016. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  4017. */
  4018. spatialSound: boolean;
  4019. /**
  4020. * Define the reference distance the sound should be heard perfectly.
  4021. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  4022. */
  4023. refDistance: number;
  4024. /**
  4025. * Define the roll off factor of spatial sounds.
  4026. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  4027. */
  4028. rolloffFactor: number;
  4029. /**
  4030. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  4031. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  4032. */
  4033. maxDistance: number;
  4034. /**
  4035. * Define the distance attenuation model the sound will follow.
  4036. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  4037. */
  4038. distanceModel: string;
  4039. /**
  4040. * @hidden
  4041. * Back Compat
  4042. **/
  4043. onended: () => any;
  4044. /**
  4045. * Observable event when the current playing sound finishes.
  4046. */
  4047. onEndedObservable: Observable<Sound>;
  4048. private _panningModel;
  4049. private _playbackRate;
  4050. private _streaming;
  4051. private _startTime;
  4052. private _startOffset;
  4053. private _position;
  4054. /** @hidden */
  4055. private _localDirection;
  4056. private _volume;
  4057. private _isReadyToPlay;
  4058. private _isDirectional;
  4059. private _readyToPlayCallback;
  4060. private _audioBuffer;
  4061. private _soundSource;
  4062. private _streamingSource;
  4063. private _soundPanner;
  4064. private _soundGain;
  4065. private _inputAudioNode;
  4066. private _outputAudioNode;
  4067. private _coneInnerAngle;
  4068. private _coneOuterAngle;
  4069. private _coneOuterGain;
  4070. private _scene;
  4071. private _connectedMesh;
  4072. private _customAttenuationFunction;
  4073. private _registerFunc;
  4074. private _isOutputConnected;
  4075. private _htmlAudioElement;
  4076. private _urlType;
  4077. /**
  4078. * Create a sound and attach it to a scene
  4079. * @param name Name of your sound
  4080. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  4081. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  4082. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  4083. */
  4084. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  4085. /**
  4086. * Release the sound and its associated resources
  4087. */
  4088. dispose(): void;
  4089. /**
  4090. * Gets if the sounds is ready to be played or not.
  4091. * @returns true if ready, otherwise false
  4092. */
  4093. isReady(): boolean;
  4094. private _soundLoaded;
  4095. /**
  4096. * Sets the data of the sound from an audiobuffer
  4097. * @param audioBuffer The audioBuffer containing the data
  4098. */
  4099. setAudioBuffer(audioBuffer: AudioBuffer): void;
  4100. /**
  4101. * Updates the current sounds options such as maxdistance, loop...
  4102. * @param options A JSON object containing values named as the object properties
  4103. */
  4104. updateOptions(options: any): void;
  4105. private _createSpatialParameters;
  4106. private _updateSpatialParameters;
  4107. /**
  4108. * Switch the panning model to HRTF:
  4109. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  4110. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  4111. */
  4112. switchPanningModelToHRTF(): void;
  4113. /**
  4114. * Switch the panning model to Equal Power:
  4115. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  4116. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  4117. */
  4118. switchPanningModelToEqualPower(): void;
  4119. private _switchPanningModel;
  4120. /**
  4121. * Connect this sound to a sound track audio node like gain...
  4122. * @param soundTrackAudioNode the sound track audio node to connect to
  4123. */
  4124. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  4125. /**
  4126. * Transform this sound into a directional source
  4127. * @param coneInnerAngle Size of the inner cone in degree
  4128. * @param coneOuterAngle Size of the outer cone in degree
  4129. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  4130. */
  4131. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  4132. /**
  4133. * Gets or sets the inner angle for the directional cone.
  4134. */
  4135. /**
  4136. * Gets or sets the inner angle for the directional cone.
  4137. */
  4138. directionalConeInnerAngle: number;
  4139. /**
  4140. * Gets or sets the outer angle for the directional cone.
  4141. */
  4142. /**
  4143. * Gets or sets the outer angle for the directional cone.
  4144. */
  4145. directionalConeOuterAngle: number;
  4146. /**
  4147. * Sets the position of the emitter if spatial sound is enabled
  4148. * @param newPosition Defines the new posisiton
  4149. */
  4150. setPosition(newPosition: Vector3): void;
  4151. /**
  4152. * Sets the local direction of the emitter if spatial sound is enabled
  4153. * @param newLocalDirection Defines the new local direction
  4154. */
  4155. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  4156. private _updateDirection;
  4157. /** @hidden */
  4158. updateDistanceFromListener(): void;
  4159. /**
  4160. * Sets a new custom attenuation function for the sound.
  4161. * @param callback Defines the function used for the attenuation
  4162. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  4163. */
  4164. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  4165. /**
  4166. * Play the sound
  4167. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  4168. * @param offset (optional) Start the sound setting it at a specific time
  4169. */
  4170. play(time?: number, offset?: number): void;
  4171. private _onended;
  4172. /**
  4173. * Stop the sound
  4174. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  4175. */
  4176. stop(time?: number): void;
  4177. /**
  4178. * Put the sound in pause
  4179. */
  4180. pause(): void;
  4181. /**
  4182. * Sets a dedicated volume for this sounds
  4183. * @param newVolume Define the new volume of the sound
  4184. * @param time Define in how long the sound should be at this value
  4185. */
  4186. setVolume(newVolume: number, time?: number): void;
  4187. /**
  4188. * Set the sound play back rate
  4189. * @param newPlaybackRate Define the playback rate the sound should be played at
  4190. */
  4191. setPlaybackRate(newPlaybackRate: number): void;
  4192. /**
  4193. * Gets the volume of the sound.
  4194. * @returns the volume of the sound
  4195. */
  4196. getVolume(): number;
  4197. /**
  4198. * Attach the sound to a dedicated mesh
  4199. * @param meshToConnectTo The mesh to connect the sound with
  4200. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  4201. */
  4202. attachToMesh(meshToConnectTo: AbstractMesh): void;
  4203. /**
  4204. * Detach the sound from the previously attached mesh
  4205. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  4206. */
  4207. detachFromMesh(): void;
  4208. private _onRegisterAfterWorldMatrixUpdate;
  4209. /**
  4210. * Clone the current sound in the scene.
  4211. * @returns the new sound clone
  4212. */
  4213. clone(): Nullable<Sound>;
  4214. /**
  4215. * Gets the current underlying audio buffer containing the data
  4216. * @returns the audio buffer
  4217. */
  4218. getAudioBuffer(): Nullable<AudioBuffer>;
  4219. /**
  4220. * Serializes the Sound in a JSON representation
  4221. * @returns the JSON representation of the sound
  4222. */
  4223. serialize(): any;
  4224. /**
  4225. * Parse a JSON representation of a sound to innstantiate in a given scene
  4226. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  4227. * @param scene Define the scene the new parsed sound should be created in
  4228. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  4229. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  4230. * @returns the newly parsed sound
  4231. */
  4232. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  4233. }
  4234. }
  4235. declare module BABYLON {
  4236. /**
  4237. * Options allowed during the creation of a sound track.
  4238. */
  4239. interface ISoundTrackOptions {
  4240. /**
  4241. * The volume the sound track should take during creation
  4242. */
  4243. volume?: number;
  4244. /**
  4245. * Define if the sound track is the main sound track of the scene
  4246. */
  4247. mainTrack?: boolean;
  4248. }
  4249. /**
  4250. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  4251. * It will be also used in a future release to apply effects on a specific track.
  4252. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  4253. */
  4254. class SoundTrack {
  4255. /**
  4256. * The unique identifier of the sound track in the scene.
  4257. */
  4258. id: number;
  4259. /**
  4260. * The list of sounds included in the sound track.
  4261. */
  4262. soundCollection: Array<Sound>;
  4263. private _outputAudioNode;
  4264. private _scene;
  4265. private _isMainTrack;
  4266. private _connectedAnalyser;
  4267. private _options;
  4268. private _isInitialized;
  4269. /**
  4270. * Creates a new sound track.
  4271. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  4272. * @param scene Define the scene the sound track belongs to
  4273. * @param options
  4274. */
  4275. constructor(scene: Scene, options?: ISoundTrackOptions);
  4276. private _initializeSoundTrackAudioGraph;
  4277. /**
  4278. * Release the sound track and its associated resources
  4279. */
  4280. dispose(): void;
  4281. /**
  4282. * Adds a sound to this sound track
  4283. * @param sound define the cound to add
  4284. * @ignoreNaming
  4285. */
  4286. AddSound(sound: Sound): void;
  4287. /**
  4288. * Removes a sound to this sound track
  4289. * @param sound define the cound to remove
  4290. * @ignoreNaming
  4291. */
  4292. RemoveSound(sound: Sound): void;
  4293. /**
  4294. * Set a global volume for the full sound track.
  4295. * @param newVolume Define the new volume of the sound track
  4296. */
  4297. setVolume(newVolume: number): void;
  4298. /**
  4299. * Switch the panning model to HRTF:
  4300. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  4301. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  4302. */
  4303. switchPanningModelToHRTF(): void;
  4304. /**
  4305. * Switch the panning model to Equal Power:
  4306. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  4307. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  4308. */
  4309. switchPanningModelToEqualPower(): void;
  4310. /**
  4311. * Connect the sound track to an audio analyser allowing some amazing
  4312. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  4313. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  4314. * @param analyser The analyser to connect to the engine
  4315. */
  4316. connectToAnalyser(analyser: Analyser): void;
  4317. }
  4318. }
  4319. declare module BABYLON {
  4320. /**
  4321. * Wraps one or more Sound objects and selects one with random weight for playback.
  4322. */
  4323. class WeightedSound {
  4324. /** When true a Sound will be selected and played when the current playing Sound completes. */
  4325. loop: boolean;
  4326. private _coneInnerAngle;
  4327. private _coneOuterAngle;
  4328. private _volume;
  4329. /** A Sound is currently playing. */
  4330. isPlaying: boolean;
  4331. /** A Sound is currently paused. */
  4332. isPaused: boolean;
  4333. private _sounds;
  4334. private _weights;
  4335. private _currentIndex?;
  4336. /**
  4337. * Creates a new WeightedSound from the list of sounds given.
  4338. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  4339. * @param sounds Array of Sounds that will be selected from.
  4340. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  4341. */
  4342. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  4343. /**
  4344. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  4345. */
  4346. /**
  4347. * The size of cone in degress for a directional sound in which there will be no attenuation.
  4348. */
  4349. directionalConeInnerAngle: number;
  4350. /**
  4351. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  4352. * Listener angles between innerAngle and outerAngle will falloff linearly.
  4353. */
  4354. /**
  4355. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  4356. * Listener angles between innerAngle and outerAngle will falloff linearly.
  4357. */
  4358. directionalConeOuterAngle: number;
  4359. /**
  4360. * Playback volume.
  4361. */
  4362. /**
  4363. * Playback volume.
  4364. */
  4365. volume: number;
  4366. private _onended;
  4367. /**
  4368. * Suspend playback
  4369. */
  4370. pause(): void;
  4371. /**
  4372. * Stop playback
  4373. */
  4374. stop(): void;
  4375. /**
  4376. * Start playback.
  4377. * @param startOffset Position the clip head at a specific time in seconds.
  4378. */
  4379. play(startOffset?: number): void;
  4380. }
  4381. }
  4382. declare module BABYLON {
  4383. /**
  4384. * Class used to store an actual running animation
  4385. */
  4386. class Animatable {
  4387. /** defines the target object */
  4388. target: any;
  4389. /** defines the starting frame number (default is 0) */
  4390. fromFrame: number;
  4391. /** defines the ending frame number (default is 100) */
  4392. toFrame: number;
  4393. /** defines if the animation must loop (default is false) */
  4394. loopAnimation: boolean;
  4395. /** defines a callback to call when animation ends if it is not looping */
  4396. onAnimationEnd?: (() => void) | null | undefined;
  4397. private _localDelayOffset;
  4398. private _pausedDelay;
  4399. private _runtimeAnimations;
  4400. private _paused;
  4401. private _scene;
  4402. private _speedRatio;
  4403. private _weight;
  4404. private _syncRoot;
  4405. /**
  4406. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  4407. * This will only apply for non looping animation (default is true)
  4408. */
  4409. disposeOnEnd: boolean;
  4410. /**
  4411. * Gets a boolean indicating if the animation has started
  4412. */
  4413. animationStarted: boolean;
  4414. /**
  4415. * Observer raised when the animation ends
  4416. */
  4417. onAnimationEndObservable: Observable<Animatable>;
  4418. /**
  4419. * Gets the root Animatable used to synchronize and normalize animations
  4420. */
  4421. readonly syncRoot: Animatable;
  4422. /**
  4423. * Gets the current frame of the first RuntimeAnimation
  4424. * Used to synchronize Animatables
  4425. */
  4426. readonly masterFrame: number;
  4427. /**
  4428. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  4429. */
  4430. weight: number;
  4431. /**
  4432. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  4433. */
  4434. speedRatio: number;
  4435. /**
  4436. * Creates a new Animatable
  4437. * @param scene defines the hosting scene
  4438. * @param target defines the target object
  4439. * @param fromFrame defines the starting frame number (default is 0)
  4440. * @param toFrame defines the ending frame number (default is 100)
  4441. * @param loopAnimation defines if the animation must loop (default is false)
  4442. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  4443. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  4444. * @param animations defines a group of animation to add to the new Animatable
  4445. */
  4446. constructor(scene: Scene,
  4447. /** defines the target object */
  4448. target: any,
  4449. /** defines the starting frame number (default is 0) */
  4450. fromFrame?: number,
  4451. /** defines the ending frame number (default is 100) */
  4452. toFrame?: number,
  4453. /** defines if the animation must loop (default is false) */
  4454. loopAnimation?: boolean, speedRatio?: number,
  4455. /** defines a callback to call when animation ends if it is not looping */
  4456. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[]);
  4457. /**
  4458. * Synchronize and normalize current Animatable with a source Animatable
  4459. * This is useful when using animation weights and when animations are not of the same length
  4460. * @param root defines the root Animatable to synchronize with
  4461. * @returns the current Animatable
  4462. */
  4463. syncWith(root: Animatable): Animatable;
  4464. /**
  4465. * Gets the list of runtime animations
  4466. * @returns an array of RuntimeAnimation
  4467. */
  4468. getAnimations(): RuntimeAnimation[];
  4469. /**
  4470. * Adds more animations to the current animatable
  4471. * @param target defines the target of the animations
  4472. * @param animations defines the new animations to add
  4473. */
  4474. appendAnimations(target: any, animations: Animation[]): void;
  4475. /**
  4476. * Gets the source animation for a specific property
  4477. * @param property defines the propertyu to look for
  4478. * @returns null or the source animation for the given property
  4479. */
  4480. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  4481. /**
  4482. * Gets the runtime animation for a specific property
  4483. * @param property defines the propertyu to look for
  4484. * @returns null or the runtime animation for the given property
  4485. */
  4486. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  4487. /**
  4488. * Resets the animatable to its original state
  4489. */
  4490. reset(): void;
  4491. /**
  4492. * Allows the animatable to blend with current running animations
  4493. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  4494. * @param blendingSpeed defines the blending speed to use
  4495. */
  4496. enableBlending(blendingSpeed: number): void;
  4497. /**
  4498. * Disable animation blending
  4499. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  4500. */
  4501. disableBlending(): void;
  4502. /**
  4503. * Jump directly to a given frame
  4504. * @param frame defines the frame to jump to
  4505. */
  4506. goToFrame(frame: number): void;
  4507. /**
  4508. * Pause the animation
  4509. */
  4510. pause(): void;
  4511. /**
  4512. * Restart the animation
  4513. */
  4514. restart(): void;
  4515. private _raiseOnAnimationEnd;
  4516. /**
  4517. * Stop and delete the current animation
  4518. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  4519. * @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)
  4520. */
  4521. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  4522. /**
  4523. * Wait asynchronously for the animation to end
  4524. * @returns a promise which will be fullfilled when the animation ends
  4525. */
  4526. waitAsync(): Promise<Animatable>;
  4527. /** @hidden */
  4528. }
  4529. }
  4530. declare module BABYLON {
  4531. /**
  4532. * Represents the range of an animation
  4533. */
  4534. class AnimationRange {
  4535. /**The name of the animation range**/
  4536. name: string;
  4537. /**The starting frame of the animation */
  4538. from: number;
  4539. /**The ending frame of the animation*/
  4540. to: number;
  4541. /**
  4542. * Initializes the range of an animation
  4543. * @param name The name of the animation range
  4544. * @param from The starting frame of the animation
  4545. * @param to The ending frame of the animation
  4546. */
  4547. constructor(
  4548. /**The name of the animation range**/
  4549. name: string,
  4550. /**The starting frame of the animation */
  4551. from: number,
  4552. /**The ending frame of the animation*/
  4553. to: number);
  4554. /**
  4555. * Makes a copy of the animation range
  4556. * @returns A copy of the animation range
  4557. */
  4558. clone(): AnimationRange;
  4559. }
  4560. /**
  4561. * Composed of a frame, and an action function
  4562. */
  4563. class AnimationEvent {
  4564. /** The frame for which the event is triggered **/
  4565. frame: number;
  4566. /** The event to perform when triggered **/
  4567. action: (currentFrame: number) => void;
  4568. /** Specifies if the event should be triggered only once**/
  4569. onlyOnce?: boolean | undefined;
  4570. /**
  4571. * Specifies if the animation event is done
  4572. */
  4573. isDone: boolean;
  4574. /**
  4575. * Initializes the animation event
  4576. * @param frame The frame for which the event is triggered
  4577. * @param action The event to perform when triggered
  4578. * @param onlyOnce Specifies if the event should be triggered only once
  4579. */
  4580. constructor(
  4581. /** The frame for which the event is triggered **/
  4582. frame: number,
  4583. /** The event to perform when triggered **/
  4584. action: (currentFrame: number) => void,
  4585. /** Specifies if the event should be triggered only once**/
  4586. onlyOnce?: boolean | undefined);
  4587. /** @hidden */
  4588. }
  4589. /**
  4590. * A cursor which tracks a point on a path
  4591. */
  4592. class PathCursor {
  4593. private path;
  4594. /**
  4595. * Stores path cursor callbacks for when an onchange event is triggered
  4596. */
  4597. private _onchange;
  4598. /**
  4599. * The value of the path cursor
  4600. */
  4601. value: number;
  4602. /**
  4603. * The animation array of the path cursor
  4604. */
  4605. animations: Animation[];
  4606. /**
  4607. * Initializes the path cursor
  4608. * @param path The path to track
  4609. */
  4610. constructor(path: Path2);
  4611. /**
  4612. * Gets the cursor point on the path
  4613. * @returns A point on the path cursor at the cursor location
  4614. */
  4615. getPoint(): Vector3;
  4616. /**
  4617. * Moves the cursor ahead by the step amount
  4618. * @param step The amount to move the cursor forward
  4619. * @returns This path cursor
  4620. */
  4621. moveAhead(step?: number): PathCursor;
  4622. /**
  4623. * Moves the cursor behind by the step amount
  4624. * @param step The amount to move the cursor back
  4625. * @returns This path cursor
  4626. */
  4627. moveBack(step?: number): PathCursor;
  4628. /**
  4629. * Moves the cursor by the step amount
  4630. * If the step amount is greater than one, an exception is thrown
  4631. * @param step The amount to move the cursor
  4632. * @returns This path cursor
  4633. */
  4634. move(step: number): PathCursor;
  4635. /**
  4636. * Ensures that the value is limited between zero and one
  4637. * @returns This path cursor
  4638. */
  4639. private ensureLimits;
  4640. /**
  4641. * Runs onchange callbacks on change (used by the animation engine)
  4642. * @returns This path cursor
  4643. */
  4644. private raiseOnChange;
  4645. /**
  4646. * Executes a function on change
  4647. * @param f A path cursor onchange callback
  4648. * @returns This path cursor
  4649. */
  4650. onchange(f: (cursor: PathCursor) => void): PathCursor;
  4651. }
  4652. /**
  4653. * Defines an interface which represents an animation key frame
  4654. */
  4655. interface IAnimationKey {
  4656. /**
  4657. * Frame of the key frame
  4658. */
  4659. frame: number;
  4660. /**
  4661. * Value at the specifies key frame
  4662. */
  4663. value: any;
  4664. /**
  4665. * The input tangent for the cubic hermite spline
  4666. */
  4667. inTangent?: any;
  4668. /**
  4669. * The output tangent for the cubic hermite spline
  4670. */
  4671. outTangent?: any;
  4672. /**
  4673. * The animation interpolation type
  4674. */
  4675. interpolation?: AnimationKeyInterpolation;
  4676. }
  4677. /**
  4678. * Enum for the animation key frame interpolation type
  4679. */
  4680. enum AnimationKeyInterpolation {
  4681. /**
  4682. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  4683. */
  4684. STEP = 1
  4685. }
  4686. /**
  4687. * Class used to store any kind of animation
  4688. */
  4689. class Animation {
  4690. /**Name of the animation */
  4691. name: string;
  4692. /**Property to animate */
  4693. targetProperty: string;
  4694. /**The frames per second of the animation */
  4695. framePerSecond: number;
  4696. /**The data type of the animation */
  4697. dataType: number;
  4698. /**The loop mode of the animation */
  4699. loopMode?: number | undefined;
  4700. /**Specifies if blending should be enabled */
  4701. enableBlending?: boolean | undefined;
  4702. /**
  4703. * Use matrix interpolation instead of using direct key value when animating matrices
  4704. */
  4705. static AllowMatricesInterpolation: boolean;
  4706. /**
  4707. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  4708. */
  4709. static AllowMatrixDecomposeForInterpolation: boolean;
  4710. /**
  4711. * Stores the key frames of the animation
  4712. */
  4713. private _keys;
  4714. /**
  4715. * Stores the easing function of the animation
  4716. */
  4717. private _easingFunction;
  4718. /**
  4719. * @hidden Internal use only
  4720. */
  4721. /**
  4722. * The set of event that will be linked to this animation
  4723. */
  4724. private _events;
  4725. /**
  4726. * Stores an array of target property paths
  4727. */
  4728. targetPropertyPath: string[];
  4729. /**
  4730. * Stores the blending speed of the animation
  4731. */
  4732. blendingSpeed: number;
  4733. /**
  4734. * Stores the animation ranges for the animation
  4735. */
  4736. private _ranges;
  4737. /**
  4738. * @hidden Internal use
  4739. */
  4740. private static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  4741. /**
  4742. * Sets up an animation
  4743. * @param property The property to animate
  4744. * @param animationType The animation type to apply
  4745. * @param framePerSecond The frames per second of the animation
  4746. * @param easingFunction The easing function used in the animation
  4747. * @returns The created animation
  4748. */
  4749. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  4750. /**
  4751. * Create and start an animation on a node
  4752. * @param name defines the name of the global animation that will be run on all nodes
  4753. * @param node defines the root node where the animation will take place
  4754. * @param targetProperty defines property to animate
  4755. * @param framePerSecond defines the number of frame per second yo use
  4756. * @param totalFrame defines the number of frames in total
  4757. * @param from defines the initial value
  4758. * @param to defines the final value
  4759. * @param loopMode defines which loop mode you want to use (off by default)
  4760. * @param easingFunction defines the easing function to use (linear by default)
  4761. * @param onAnimationEnd defines the callback to call when animation end
  4762. * @returns the animatable created for this animation
  4763. */
  4764. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  4765. /**
  4766. * Create and start an animation on a node and its descendants
  4767. * @param name defines the name of the global animation that will be run on all nodes
  4768. * @param node defines the root node where the animation will take place
  4769. * @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
  4770. * @param targetProperty defines property to animate
  4771. * @param framePerSecond defines the number of frame per second to use
  4772. * @param totalFrame defines the number of frames in total
  4773. * @param from defines the initial value
  4774. * @param to defines the final value
  4775. * @param loopMode defines which loop mode you want to use (off by default)
  4776. * @param easingFunction defines the easing function to use (linear by default)
  4777. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  4778. * @returns the list of animatables created for all nodes
  4779. * @example https://www.babylonjs-playground.com/#MH0VLI
  4780. */
  4781. 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[]>;
  4782. /**
  4783. * Creates a new animation, merges it with the existing animations and starts it
  4784. * @param name Name of the animation
  4785. * @param node Node which contains the scene that begins the animations
  4786. * @param targetProperty Specifies which property to animate
  4787. * @param framePerSecond The frames per second of the animation
  4788. * @param totalFrame The total number of frames
  4789. * @param from The frame at the beginning of the animation
  4790. * @param to The frame at the end of the animation
  4791. * @param loopMode Specifies the loop mode of the animation
  4792. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  4793. * @param onAnimationEnd Callback to run once the animation is complete
  4794. * @returns Nullable animation
  4795. */
  4796. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  4797. /**
  4798. * Transition property of an host to the target Value
  4799. * @param property The property to transition
  4800. * @param targetValue The target Value of the property
  4801. * @param host The object where the property to animate belongs
  4802. * @param scene Scene used to run the animation
  4803. * @param frameRate Framerate (in frame/s) to use
  4804. * @param transition The transition type we want to use
  4805. * @param duration The duration of the animation, in milliseconds
  4806. * @param onAnimationEnd Callback trigger at the end of the animation
  4807. * @returns Nullable animation
  4808. */
  4809. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  4810. /**
  4811. * Return the array of runtime animations currently using this animation
  4812. */
  4813. readonly runtimeAnimations: RuntimeAnimation[];
  4814. /**
  4815. * Specifies if any of the runtime animations are currently running
  4816. */
  4817. readonly hasRunningRuntimeAnimations: boolean;
  4818. /**
  4819. * Initializes the animation
  4820. * @param name Name of the animation
  4821. * @param targetProperty Property to animate
  4822. * @param framePerSecond The frames per second of the animation
  4823. * @param dataType The data type of the animation
  4824. * @param loopMode The loop mode of the animation
  4825. * @param enableBlendings Specifies if blending should be enabled
  4826. */
  4827. constructor(
  4828. /**Name of the animation */
  4829. name: string,
  4830. /**Property to animate */
  4831. targetProperty: string,
  4832. /**The frames per second of the animation */
  4833. framePerSecond: number,
  4834. /**The data type of the animation */
  4835. dataType: number,
  4836. /**The loop mode of the animation */
  4837. loopMode?: number | undefined,
  4838. /**Specifies if blending should be enabled */
  4839. enableBlending?: boolean | undefined);
  4840. /**
  4841. * Converts the animation to a string
  4842. * @param fullDetails support for multiple levels of logging within scene loading
  4843. * @returns String form of the animation
  4844. */
  4845. toString(fullDetails?: boolean): string;
  4846. /**
  4847. * Add an event to this animation
  4848. * @param event Event to add
  4849. */
  4850. addEvent(event: AnimationEvent): void;
  4851. /**
  4852. * Remove all events found at the given frame
  4853. * @param frame The frame to remove events from
  4854. */
  4855. removeEvents(frame: number): void;
  4856. /**
  4857. * Retrieves all the events from the animation
  4858. * @returns Events from the animation
  4859. */
  4860. getEvents(): AnimationEvent[];
  4861. /**
  4862. * Creates an animation range
  4863. * @param name Name of the animation range
  4864. * @param from Starting frame of the animation range
  4865. * @param to Ending frame of the animation
  4866. */
  4867. createRange(name: string, from: number, to: number): void;
  4868. /**
  4869. * Deletes an animation range by name
  4870. * @param name Name of the animation range to delete
  4871. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  4872. */
  4873. deleteRange(name: string, deleteFrames?: boolean): void;
  4874. /**
  4875. * Gets the animation range by name, or null if not defined
  4876. * @param name Name of the animation range
  4877. * @returns Nullable animation range
  4878. */
  4879. getRange(name: string): Nullable<AnimationRange>;
  4880. /**
  4881. * Gets the key frames from the animation
  4882. * @returns The key frames of the animation
  4883. */
  4884. getKeys(): Array<IAnimationKey>;
  4885. /**
  4886. * Gets the highest frame rate of the animation
  4887. * @returns Highest frame rate of the animation
  4888. */
  4889. getHighestFrame(): number;
  4890. /**
  4891. * Gets the easing function of the animation
  4892. * @returns Easing function of the animation
  4893. */
  4894. getEasingFunction(): IEasingFunction;
  4895. /**
  4896. * Sets the easing function of the animation
  4897. * @param easingFunction A custom mathematical formula for animation
  4898. */
  4899. setEasingFunction(easingFunction: EasingFunction): void;
  4900. /**
  4901. * Interpolates a scalar linearly
  4902. * @param startValue Start value of the animation curve
  4903. * @param endValue End value of the animation curve
  4904. * @param gradient Scalar amount to interpolate
  4905. * @returns Interpolated scalar value
  4906. */
  4907. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  4908. /**
  4909. * Interpolates a scalar cubically
  4910. * @param startValue Start value of the animation curve
  4911. * @param outTangent End tangent of the animation
  4912. * @param endValue End value of the animation curve
  4913. * @param inTangent Start tangent of the animation curve
  4914. * @param gradient Scalar amount to interpolate
  4915. * @returns Interpolated scalar value
  4916. */
  4917. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  4918. /**
  4919. * Interpolates a quaternion using a spherical linear interpolation
  4920. * @param startValue Start value of the animation curve
  4921. * @param endValue End value of the animation curve
  4922. * @param gradient Scalar amount to interpolate
  4923. * @returns Interpolated quaternion value
  4924. */
  4925. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  4926. /**
  4927. * Interpolates a quaternion cubically
  4928. * @param startValue Start value of the animation curve
  4929. * @param outTangent End tangent of the animation curve
  4930. * @param endValue End value of the animation curve
  4931. * @param inTangent Start tangent of the animation curve
  4932. * @param gradient Scalar amount to interpolate
  4933. * @returns Interpolated quaternion value
  4934. */
  4935. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  4936. /**
  4937. * Interpolates a Vector3 linearl
  4938. * @param startValue Start value of the animation curve
  4939. * @param endValue End value of the animation curve
  4940. * @param gradient Scalar amount to interpolate
  4941. * @returns Interpolated scalar value
  4942. */
  4943. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  4944. /**
  4945. * Interpolates a Vector3 cubically
  4946. * @param startValue Start value of the animation curve
  4947. * @param outTangent End tangent of the animation
  4948. * @param endValue End value of the animation curve
  4949. * @param inTangent Start tangent of the animation curve
  4950. * @param gradient Scalar amount to interpolate
  4951. * @returns InterpolatedVector3 value
  4952. */
  4953. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  4954. /**
  4955. * Interpolates a Vector2 linearly
  4956. * @param startValue Start value of the animation curve
  4957. * @param endValue End value of the animation curve
  4958. * @param gradient Scalar amount to interpolate
  4959. * @returns Interpolated Vector2 value
  4960. */
  4961. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  4962. /**
  4963. * Interpolates a Vector2 cubically
  4964. * @param startValue Start value of the animation curve
  4965. * @param outTangent End tangent of the animation
  4966. * @param endValue End value of the animation curve
  4967. * @param inTangent Start tangent of the animation curve
  4968. * @param gradient Scalar amount to interpolate
  4969. * @returns Interpolated Vector2 value
  4970. */
  4971. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  4972. /**
  4973. * Interpolates a size linearly
  4974. * @param startValue Start value of the animation curve
  4975. * @param endValue End value of the animation curve
  4976. * @param gradient Scalar amount to interpolate
  4977. * @returns Interpolated Size value
  4978. */
  4979. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  4980. /**
  4981. * Interpolates a Color3 linearly
  4982. * @param startValue Start value of the animation curve
  4983. * @param endValue End value of the animation curve
  4984. * @param gradient Scalar amount to interpolate
  4985. * @returns Interpolated Color3 value
  4986. */
  4987. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  4988. /**
  4989. * @hidden Internal use only
  4990. */
  4991. /**
  4992. * @hidden Internal use only
  4993. */
  4994. /**
  4995. * Defines the function to use to interpolate matrices
  4996. * @param startValue defines the start matrix
  4997. * @param endValue defines the end matrix
  4998. * @param gradient defines the gradient between both matrices
  4999. * @param result defines an optional target matrix where to store the interpolation
  5000. * @returns the interpolated matrix
  5001. */
  5002. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  5003. /**
  5004. * Makes a copy of the animation
  5005. * @returns Cloned animation
  5006. */
  5007. clone(): Animation;
  5008. /**
  5009. * Sets the key frames of the animation
  5010. * @param values The animation key frames to set
  5011. */
  5012. setKeys(values: Array<IAnimationKey>): void;
  5013. /**
  5014. * Serializes the animation to an object
  5015. * @returns Serialized object
  5016. */
  5017. serialize(): any;
  5018. /**
  5019. * Float animation type
  5020. */
  5021. private static _ANIMATIONTYPE_FLOAT;
  5022. /**
  5023. * Vector3 animation type
  5024. */
  5025. private static _ANIMATIONTYPE_VECTOR3;
  5026. /**
  5027. * Quaternion animation type
  5028. */
  5029. private static _ANIMATIONTYPE_QUATERNION;
  5030. /**
  5031. * Matrix animation type
  5032. */
  5033. private static _ANIMATIONTYPE_MATRIX;
  5034. /**
  5035. * Color3 animation type
  5036. */
  5037. private static _ANIMATIONTYPE_COLOR3;
  5038. /**
  5039. * Vector2 animation type
  5040. */
  5041. private static _ANIMATIONTYPE_VECTOR2;
  5042. /**
  5043. * Size animation type
  5044. */
  5045. private static _ANIMATIONTYPE_SIZE;
  5046. /**
  5047. * Relative Loop Mode
  5048. */
  5049. private static _ANIMATIONLOOPMODE_RELATIVE;
  5050. /**
  5051. * Cycle Loop Mode
  5052. */
  5053. private static _ANIMATIONLOOPMODE_CYCLE;
  5054. /**
  5055. * Constant Loop Mode
  5056. */
  5057. private static _ANIMATIONLOOPMODE_CONSTANT;
  5058. /**
  5059. * Get the float animation type
  5060. */
  5061. static readonly ANIMATIONTYPE_FLOAT: number;
  5062. /**
  5063. * Get the Vector3 animation type
  5064. */
  5065. static readonly ANIMATIONTYPE_VECTOR3: number;
  5066. /**
  5067. * Get the Vector2 animation type
  5068. */
  5069. static readonly ANIMATIONTYPE_VECTOR2: number;
  5070. /**
  5071. * Get the Size animation type
  5072. */
  5073. static readonly ANIMATIONTYPE_SIZE: number;
  5074. /**
  5075. * Get the Quaternion animation type
  5076. */
  5077. static readonly ANIMATIONTYPE_QUATERNION: number;
  5078. /**
  5079. * Get the Matrix animation type
  5080. */
  5081. static readonly ANIMATIONTYPE_MATRIX: number;
  5082. /**
  5083. * Get the Color3 animation type
  5084. */
  5085. static readonly ANIMATIONTYPE_COLOR3: number;
  5086. /**
  5087. * Get the Relative Loop Mode
  5088. */
  5089. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  5090. /**
  5091. * Get the Cycle Loop Mode
  5092. */
  5093. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  5094. /**
  5095. * Get the Constant Loop Mode
  5096. */
  5097. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  5098. /** @hidden */
  5099. private static _UniversalLerp(left: any, right: any, amount: number): any;
  5100. /**
  5101. * Parses an animation object and creates an animation
  5102. * @param parsedAnimation Parsed animation object
  5103. * @returns Animation object
  5104. */
  5105. static Parse(parsedAnimation: any): Animation;
  5106. /**
  5107. * Appends the serialized animations from the source animations
  5108. * @param source Source containing the animations
  5109. * @param destination Target to store the animations
  5110. */
  5111. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  5112. }
  5113. }
  5114. declare module BABYLON {
  5115. /**
  5116. * This class defines the direct association between an animation and a target
  5117. */
  5118. class TargetedAnimation {
  5119. /**
  5120. * Animation to perform
  5121. */
  5122. animation: Animation;
  5123. /**
  5124. * Target to animate
  5125. */
  5126. target: any;
  5127. }
  5128. /**
  5129. * Use this class to create coordinated animations on multiple targets
  5130. */
  5131. class AnimationGroup implements IDisposable {
  5132. /** The name of the animation group */
  5133. name: string;
  5134. private _scene;
  5135. private _targetedAnimations;
  5136. private _animatables;
  5137. private _from;
  5138. private _to;
  5139. private _isStarted;
  5140. private _speedRatio;
  5141. /**
  5142. * This observable will notify when one animation have ended.
  5143. */
  5144. onAnimationEndObservable: Observable<TargetedAnimation>;
  5145. /**
  5146. * This observable will notify when all animations have ended.
  5147. */
  5148. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  5149. /**
  5150. * This observable will notify when all animations have paused.
  5151. */
  5152. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  5153. /**
  5154. * Gets the first frame
  5155. */
  5156. readonly from: number;
  5157. /**
  5158. * Gets the last frame
  5159. */
  5160. readonly to: number;
  5161. /**
  5162. * Define if the animations are started
  5163. */
  5164. readonly isStarted: boolean;
  5165. /**
  5166. * Gets or sets the speed ratio to use for all animations
  5167. */
  5168. /**
  5169. * Gets or sets the speed ratio to use for all animations
  5170. */
  5171. speedRatio: number;
  5172. /**
  5173. * Gets the targeted animations for this animation group
  5174. */
  5175. readonly targetedAnimations: Array<TargetedAnimation>;
  5176. /**
  5177. * returning the list of animatables controlled by this animation group.
  5178. */
  5179. readonly animatables: Array<Animatable>;
  5180. /**
  5181. * Instantiates a new Animation Group.
  5182. * This helps managing several animations at once.
  5183. * @see http://doc.babylonjs.com/how_to/group
  5184. * @param name Defines the name of the group
  5185. * @param scene Defines the scene the group belongs to
  5186. */
  5187. constructor(
  5188. /** The name of the animation group */
  5189. name: string, scene?: Nullable<Scene>);
  5190. /**
  5191. * Add an animation (with its target) in the group
  5192. * @param animation defines the animation we want to add
  5193. * @param target defines the target of the animation
  5194. * @returns the TargetedAnimation object
  5195. */
  5196. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  5197. /**
  5198. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  5199. * It can add constant keys at begin or end
  5200. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  5201. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  5202. * @returns the animation group
  5203. */
  5204. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  5205. /**
  5206. * Start all animations on given targets
  5207. * @param loop defines if animations must loop
  5208. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  5209. * @param from defines the from key (optional)
  5210. * @param to defines the to key (optional)
  5211. * @returns the current animation group
  5212. */
  5213. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  5214. /**
  5215. * Pause all animations
  5216. * @returns the animation group
  5217. */
  5218. pause(): AnimationGroup;
  5219. /**
  5220. * Play all animations to initial state
  5221. * This function will start() the animations if they were not started or will restart() them if they were paused
  5222. * @param loop defines if animations must loop
  5223. * @returns the animation group
  5224. */
  5225. play(loop?: boolean): AnimationGroup;
  5226. /**
  5227. * Reset all animations to initial state
  5228. * @returns the animation group
  5229. */
  5230. reset(): AnimationGroup;
  5231. /**
  5232. * Restart animations from key 0
  5233. * @returns the animation group
  5234. */
  5235. restart(): AnimationGroup;
  5236. /**
  5237. * Stop all animations
  5238. * @returns the animation group
  5239. */
  5240. stop(): AnimationGroup;
  5241. /**
  5242. * Set animation weight for all animatables
  5243. * @param weight defines the weight to use
  5244. * @return the animationGroup
  5245. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  5246. */
  5247. setWeightForAllAnimatables(weight: number): AnimationGroup;
  5248. /**
  5249. * Synchronize and normalize all animatables with a source animatable
  5250. * @param root defines the root animatable to synchronize with
  5251. * @return the animationGroup
  5252. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  5253. */
  5254. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  5255. /**
  5256. * Goes to a specific frame in this animation group
  5257. * @param frame the frame number to go to
  5258. * @return the animationGroup
  5259. */
  5260. goToFrame(frame: number): AnimationGroup;
  5261. /**
  5262. * Dispose all associated resources
  5263. */
  5264. dispose(): void;
  5265. private _checkAnimationGroupEnded;
  5266. /**
  5267. * Returns a new AnimationGroup object parsed from the source provided.
  5268. * @param parsedAnimationGroup defines the source
  5269. * @param scene defines the scene that will receive the animationGroup
  5270. * @returns a new AnimationGroup
  5271. */
  5272. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  5273. /**
  5274. * Returns the string "AnimationGroup"
  5275. * @returns "AnimationGroup"
  5276. */
  5277. getClassName(): string;
  5278. /**
  5279. * Creates a detailled string about the object
  5280. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  5281. * @returns a string representing the object
  5282. */
  5283. toString(fullDetails?: boolean): string;
  5284. }
  5285. }
  5286. declare module BABYLON {
  5287. /**
  5288. * Class used to override all child animations of a given target
  5289. */
  5290. class AnimationPropertiesOverride {
  5291. /**
  5292. * Gets or sets a value indicating if animation blending must be used
  5293. */
  5294. enableBlending: boolean;
  5295. /**
  5296. * Gets or sets the blending speed to use when enableBlending is true
  5297. */
  5298. blendingSpeed: number;
  5299. /**
  5300. * Gets or sets the default loop mode to use
  5301. */
  5302. loopMode: number;
  5303. }
  5304. }
  5305. declare module BABYLON {
  5306. /**
  5307. * This represents the main contract an easing function should follow.
  5308. * Easing functions are used throughout the animation system.
  5309. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5310. */
  5311. interface IEasingFunction {
  5312. /**
  5313. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5314. * of the easing function.
  5315. * The link below provides some of the most common examples of easing functions.
  5316. * @see https://easings.net/
  5317. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5318. * @returns the corresponding value on the curve defined by the easing function
  5319. */
  5320. ease(gradient: number): number;
  5321. }
  5322. /**
  5323. * Base class used for every default easing function.
  5324. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5325. */
  5326. class EasingFunction implements IEasingFunction {
  5327. /**
  5328. * Interpolation follows the mathematical formula associated with the easing function.
  5329. */
  5330. static readonly EASINGMODE_EASEIN: number;
  5331. /**
  5332. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5333. */
  5334. static readonly EASINGMODE_EASEOUT: number;
  5335. /**
  5336. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5337. */
  5338. static readonly EASINGMODE_EASEINOUT: number;
  5339. private _easingMode;
  5340. /**
  5341. * Sets the easing mode of the current function.
  5342. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5343. */
  5344. setEasingMode(easingMode: number): void;
  5345. /**
  5346. * Gets the current easing mode.
  5347. * @returns the easing mode
  5348. */
  5349. getEasingMode(): number;
  5350. /**
  5351. * @hidden
  5352. */
  5353. easeInCore(gradient: number): number;
  5354. /**
  5355. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5356. * of the easing function.
  5357. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5358. * @returns the corresponding value on the curve defined by the easing function
  5359. */
  5360. ease(gradient: number): number;
  5361. }
  5362. /**
  5363. * Easing function with a circle shape (see link below).
  5364. * @see https://easings.net/#easeInCirc
  5365. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5366. */
  5367. class CircleEase extends EasingFunction implements IEasingFunction {
  5368. /** @hidden */
  5369. easeInCore(gradient: number): number;
  5370. }
  5371. /**
  5372. * Easing function with a ease back shape (see link below).
  5373. * @see https://easings.net/#easeInBack
  5374. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5375. */
  5376. class BackEase extends EasingFunction implements IEasingFunction {
  5377. /** Defines the amplitude of the function */
  5378. amplitude: number;
  5379. /**
  5380. * Instantiates a back ease easing
  5381. * @see https://easings.net/#easeInBack
  5382. * @param amplitude Defines the amplitude of the function
  5383. */
  5384. constructor(
  5385. /** Defines the amplitude of the function */
  5386. amplitude?: number);
  5387. /** @hidden */
  5388. easeInCore(gradient: number): number;
  5389. }
  5390. /**
  5391. * Easing function with a bouncing shape (see link below).
  5392. * @see https://easings.net/#easeInBounce
  5393. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5394. */
  5395. class BounceEase extends EasingFunction implements IEasingFunction {
  5396. /** Defines the number of bounces */
  5397. bounces: number;
  5398. /** Defines the amplitude of the bounce */
  5399. bounciness: number;
  5400. /**
  5401. * Instantiates a bounce easing
  5402. * @see https://easings.net/#easeInBounce
  5403. * @param bounces Defines the number of bounces
  5404. * @param bounciness Defines the amplitude of the bounce
  5405. */
  5406. constructor(
  5407. /** Defines the number of bounces */
  5408. bounces?: number,
  5409. /** Defines the amplitude of the bounce */
  5410. bounciness?: number);
  5411. /** @hidden */
  5412. easeInCore(gradient: number): number;
  5413. }
  5414. /**
  5415. * Easing function with a power of 3 shape (see link below).
  5416. * @see https://easings.net/#easeInCubic
  5417. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5418. */
  5419. class CubicEase extends EasingFunction implements IEasingFunction {
  5420. /** @hidden */
  5421. easeInCore(gradient: number): number;
  5422. }
  5423. /**
  5424. * Easing function with an elastic shape (see link below).
  5425. * @see https://easings.net/#easeInElastic
  5426. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5427. */
  5428. class ElasticEase extends EasingFunction implements IEasingFunction {
  5429. /** Defines the number of oscillations*/
  5430. oscillations: number;
  5431. /** Defines the amplitude of the oscillations*/
  5432. springiness: number;
  5433. /**
  5434. * Instantiates an elastic easing function
  5435. * @see https://easings.net/#easeInElastic
  5436. * @param oscillations Defines the number of oscillations
  5437. * @param springiness Defines the amplitude of the oscillations
  5438. */
  5439. constructor(
  5440. /** Defines the number of oscillations*/
  5441. oscillations?: number,
  5442. /** Defines the amplitude of the oscillations*/
  5443. springiness?: number);
  5444. /** @hidden */
  5445. easeInCore(gradient: number): number;
  5446. }
  5447. /**
  5448. * Easing function with an exponential shape (see link below).
  5449. * @see https://easings.net/#easeInExpo
  5450. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5451. */
  5452. class ExponentialEase extends EasingFunction implements IEasingFunction {
  5453. /** Defines the exponent of the function */
  5454. exponent: number;
  5455. /**
  5456. * Instantiates an exponential easing function
  5457. * @see https://easings.net/#easeInExpo
  5458. * @param exponent Defines the exponent of the function
  5459. */
  5460. constructor(
  5461. /** Defines the exponent of the function */
  5462. exponent?: number);
  5463. /** @hidden */
  5464. easeInCore(gradient: number): number;
  5465. }
  5466. /**
  5467. * Easing function with a power shape (see link below).
  5468. * @see https://easings.net/#easeInQuad
  5469. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5470. */
  5471. class PowerEase extends EasingFunction implements IEasingFunction {
  5472. /** Defines the power of the function */
  5473. power: number;
  5474. /**
  5475. * Instantiates an power base easing function
  5476. * @see https://easings.net/#easeInQuad
  5477. * @param power Defines the power of the function
  5478. */
  5479. constructor(
  5480. /** Defines the power of the function */
  5481. power?: number);
  5482. /** @hidden */
  5483. easeInCore(gradient: number): number;
  5484. }
  5485. /**
  5486. * Easing function with a power of 2 shape (see link below).
  5487. * @see https://easings.net/#easeInQuad
  5488. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5489. */
  5490. class QuadraticEase extends EasingFunction implements IEasingFunction {
  5491. /** @hidden */
  5492. easeInCore(gradient: number): number;
  5493. }
  5494. /**
  5495. * Easing function with a power of 4 shape (see link below).
  5496. * @see https://easings.net/#easeInQuart
  5497. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5498. */
  5499. class QuarticEase extends EasingFunction implements IEasingFunction {
  5500. /** @hidden */
  5501. easeInCore(gradient: number): number;
  5502. }
  5503. /**
  5504. * Easing function with a power of 5 shape (see link below).
  5505. * @see https://easings.net/#easeInQuint
  5506. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5507. */
  5508. class QuinticEase extends EasingFunction implements IEasingFunction {
  5509. /** @hidden */
  5510. easeInCore(gradient: number): number;
  5511. }
  5512. /**
  5513. * Easing function with a sin shape (see link below).
  5514. * @see https://easings.net/#easeInSine
  5515. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5516. */
  5517. class SineEase extends EasingFunction implements IEasingFunction {
  5518. /** @hidden */
  5519. easeInCore(gradient: number): number;
  5520. }
  5521. /**
  5522. * Easing function with a bezier shape (see link below).
  5523. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5524. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5525. */
  5526. class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5527. /** Defines the x component of the start tangent in the bezier curve */
  5528. x1: number;
  5529. /** Defines the y component of the start tangent in the bezier curve */
  5530. y1: number;
  5531. /** Defines the x component of the end tangent in the bezier curve */
  5532. x2: number;
  5533. /** Defines the y component of the end tangent in the bezier curve */
  5534. y2: number;
  5535. /**
  5536. * Instantiates a bezier function
  5537. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5538. * @param x1 Defines the x component of the start tangent in the bezier curve
  5539. * @param y1 Defines the y component of the start tangent in the bezier curve
  5540. * @param x2 Defines the x component of the end tangent in the bezier curve
  5541. * @param y2 Defines the y component of the end tangent in the bezier curve
  5542. */
  5543. constructor(
  5544. /** Defines the x component of the start tangent in the bezier curve */
  5545. x1?: number,
  5546. /** Defines the y component of the start tangent in the bezier curve */
  5547. y1?: number,
  5548. /** Defines the x component of the end tangent in the bezier curve */
  5549. x2?: number,
  5550. /** Defines the y component of the end tangent in the bezier curve */
  5551. y2?: number);
  5552. /** @hidden */
  5553. easeInCore(gradient: number): number;
  5554. }
  5555. }
  5556. declare module BABYLON {
  5557. /**
  5558. * Defines a runtime animation
  5559. */
  5560. class RuntimeAnimation {
  5561. private _events;
  5562. /**
  5563. * The current frame of the runtime animation
  5564. */
  5565. private _currentFrame;
  5566. /**
  5567. * The animation used by the runtime animation
  5568. */
  5569. private _animation;
  5570. /**
  5571. * The target of the runtime animation
  5572. */
  5573. private _target;
  5574. /**
  5575. * The initiating animatable
  5576. */
  5577. private _host;
  5578. /**
  5579. * The original value of the runtime animation
  5580. */
  5581. private _originalValue;
  5582. /**
  5583. * The original blend value of the runtime animation
  5584. */
  5585. private _originalBlendValue;
  5586. /**
  5587. * The offsets cache of the runtime animation
  5588. */
  5589. private _offsetsCache;
  5590. /**
  5591. * The high limits cache of the runtime animation
  5592. */
  5593. private _highLimitsCache;
  5594. /**
  5595. * Specifies if the runtime animation has been stopped
  5596. */
  5597. private _stopped;
  5598. /**
  5599. * The blending factor of the runtime animation
  5600. */
  5601. private _blendingFactor;
  5602. /**
  5603. * The BabylonJS scene
  5604. */
  5605. private _scene;
  5606. /**
  5607. * The current value of the runtime animation
  5608. */
  5609. private _currentValue;
  5610. /** @hidden */
  5611. /**
  5612. * The active target of the runtime animation
  5613. */
  5614. private _activeTarget;
  5615. /**
  5616. * The target path of the runtime animation
  5617. */
  5618. private _targetPath;
  5619. /**
  5620. * The weight of the runtime animation
  5621. */
  5622. private _weight;
  5623. /**
  5624. * The ratio offset of the runtime animation
  5625. */
  5626. private _ratioOffset;
  5627. /**
  5628. * The previous delay of the runtime animation
  5629. */
  5630. private _previousDelay;
  5631. /**
  5632. * The previous ratio of the runtime animation
  5633. */
  5634. private _previousRatio;
  5635. /**
  5636. * Gets the current frame of the runtime animation
  5637. */
  5638. readonly currentFrame: number;
  5639. /**
  5640. * Gets the weight of the runtime animation
  5641. */
  5642. readonly weight: number;
  5643. /**
  5644. * Gets the current value of the runtime animation
  5645. */
  5646. readonly currentValue: any;
  5647. /**
  5648. * Gets the target path of the runtime animation
  5649. */
  5650. readonly targetPath: string;
  5651. /**
  5652. * Gets the actual target of the runtime animation
  5653. */
  5654. readonly target: any;
  5655. /**
  5656. * Create a new RuntimeAnimation object
  5657. * @param target defines the target of the animation
  5658. * @param animation defines the source animation object
  5659. * @param scene defines the hosting scene
  5660. * @param host defines the initiating Animatable
  5661. */
  5662. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  5663. /**
  5664. * Gets the animation from the runtime animation
  5665. */
  5666. readonly animation: Animation;
  5667. /**
  5668. * Resets the runtime animation to the beginning
  5669. * @param restoreOriginal defines whether to restore the target property to the original value
  5670. */
  5671. reset(restoreOriginal?: boolean): void;
  5672. /**
  5673. * Specifies if the runtime animation is stopped
  5674. * @returns Boolean specifying if the runtime animation is stopped
  5675. */
  5676. isStopped(): boolean;
  5677. /**
  5678. * Disposes of the runtime animation
  5679. */
  5680. dispose(): void;
  5681. /**
  5682. * Interpolates the animation from the current frame
  5683. * @param currentFrame The frame to interpolate the animation to
  5684. * @param repeatCount The number of times that the animation should loop
  5685. * @param loopMode The type of looping mode to use
  5686. * @param offsetValue Animation offset value
  5687. * @param highLimitValue The high limit value
  5688. * @returns The interpolated value
  5689. */
  5690. private _interpolate;
  5691. /**
  5692. * Apply the interpolated value to the target
  5693. * @param currentValue defines the value computed by the animation
  5694. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  5695. */
  5696. setValue(currentValue: any, weight?: number): void;
  5697. private _setValue;
  5698. /**
  5699. * Gets the loop pmode of the runtime animation
  5700. * @returns Loop Mode
  5701. */
  5702. private _getCorrectLoopMode;
  5703. /**
  5704. * Move the current animation to a given frame
  5705. * @param frame defines the frame to move to
  5706. */
  5707. goToFrame(frame: number): void;
  5708. /**
  5709. * @hidden Internal use only
  5710. */
  5711. /**
  5712. * Execute the current animation
  5713. * @param delay defines the delay to add to the current frame
  5714. * @param from defines the lower bound of the animation range
  5715. * @param to defines the upper bound of the animation range
  5716. * @param loop defines if the current animation must loop
  5717. * @param speedRatio defines the current speed ratio
  5718. * @param weight defines the weight of the animation (default is -1 so no weight)
  5719. * @returns a boolean indicating if the animation is running
  5720. */
  5721. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  5722. }
  5723. }
  5724. declare module BABYLON {
  5725. /**
  5726. * Interface used to define a behavior
  5727. */
  5728. interface Behavior<T> {
  5729. /** gets or sets behavior's name */
  5730. name: string;
  5731. /**
  5732. * Function called when the behavior needs to be initialized (after attaching it to a target)
  5733. */
  5734. init(): void;
  5735. /**
  5736. * Called when the behavior is attached to a target
  5737. * @param target defines the target where the behavior is attached to
  5738. */
  5739. attach(target: T): void;
  5740. /**
  5741. * Called when the behavior is detached from its target
  5742. */
  5743. detach(): void;
  5744. }
  5745. /**
  5746. * Interface implemented by classes supporting behaviors
  5747. */
  5748. interface IBehaviorAware<T> {
  5749. /**
  5750. * Attach a behavior
  5751. * @param behavior defines the behavior to attach
  5752. * @returns the current host
  5753. */
  5754. addBehavior(behavior: Behavior<T>): T;
  5755. /**
  5756. * Remove a behavior from the current object
  5757. * @param behavior defines the behavior to detach
  5758. * @returns the current host
  5759. */
  5760. removeBehavior(behavior: Behavior<T>): T;
  5761. /**
  5762. * Gets a behavior using its name to search
  5763. * @param name defines the name to search
  5764. * @returns the behavior or null if not found
  5765. */
  5766. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  5767. }
  5768. }
  5769. declare module BABYLON {
  5770. /**
  5771. * Class used to store bone information
  5772. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  5773. */
  5774. class Bone extends Node {
  5775. /**
  5776. * defines the bone name
  5777. */
  5778. name: string;
  5779. private static _tmpVecs;
  5780. private static _tmpQuat;
  5781. private static _tmpMats;
  5782. /**
  5783. * Gets the list of child bones
  5784. */
  5785. children: Bone[];
  5786. /** Gets the animations associated with this bone */
  5787. animations: Animation[];
  5788. /**
  5789. * Gets or sets bone length
  5790. */
  5791. length: number;
  5792. /**
  5793. * @hidden Internal only
  5794. * Set this value to map this bone to a different index in the transform matrices
  5795. * Set this value to -1 to exclude the bone from the transform matrices
  5796. */
  5797. private _skeleton;
  5798. private _localMatrix;
  5799. private _restPose;
  5800. private _baseMatrix;
  5801. private _absoluteTransform;
  5802. private _invertedAbsoluteTransform;
  5803. private _parent;
  5804. private _scalingDeterminant;
  5805. private _worldTransform;
  5806. private _localScaling;
  5807. private _localRotation;
  5808. private _localPosition;
  5809. private _needToDecompose;
  5810. private _needToCompose;
  5811. /** @hidden */
  5812. /** @hidden */
  5813. /**
  5814. * Create a new bone
  5815. * @param name defines the bone name
  5816. * @param skeleton defines the parent skeleton
  5817. * @param parentBone defines the parent (can be null if the bone is the root)
  5818. * @param localMatrix defines the local matrix
  5819. * @param restPose defines the rest pose matrix
  5820. * @param baseMatrix defines the base matrix
  5821. * @param index defines index of the bone in the hiearchy
  5822. */
  5823. constructor(
  5824. /**
  5825. * defines the bone name
  5826. */
  5827. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  5828. /**
  5829. * Gets the parent skeleton
  5830. * @returns a skeleton
  5831. */
  5832. getSkeleton(): Skeleton;
  5833. /**
  5834. * Gets parent bone
  5835. * @returns a bone or null if the bone is the root of the bone hierarchy
  5836. */
  5837. getParent(): Nullable<Bone>;
  5838. /**
  5839. * Sets the parent bone
  5840. * @param parent defines the parent (can be null if the bone is the root)
  5841. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  5842. */
  5843. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  5844. /**
  5845. * Gets the local matrix
  5846. * @returns a matrix
  5847. */
  5848. getLocalMatrix(): Matrix;
  5849. /**
  5850. * Gets the base matrix (initial matrix which remains unchanged)
  5851. * @returns a matrix
  5852. */
  5853. getBaseMatrix(): Matrix;
  5854. /**
  5855. * Gets the rest pose matrix
  5856. * @returns a matrix
  5857. */
  5858. getRestPose(): Matrix;
  5859. /**
  5860. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  5861. */
  5862. getWorldMatrix(): Matrix;
  5863. /**
  5864. * Sets the local matrix to rest pose matrix
  5865. */
  5866. returnToRest(): void;
  5867. /**
  5868. * Gets the inverse of the absolute transform matrix.
  5869. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  5870. * @returns a matrix
  5871. */
  5872. getInvertedAbsoluteTransform(): Matrix;
  5873. /**
  5874. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  5875. * @returns a matrix
  5876. */
  5877. getAbsoluteTransform(): Matrix;
  5878. /** Gets or sets current position (in local space) */
  5879. position: Vector3;
  5880. /** Gets or sets current rotation (in local space) */
  5881. rotation: Vector3;
  5882. /** Gets or sets current rotation quaternion (in local space) */
  5883. rotationQuaternion: Quaternion;
  5884. /** Gets or sets current scaling (in local space) */
  5885. scaling: Vector3;
  5886. /**
  5887. * Gets the animation properties override
  5888. */
  5889. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  5890. private _decompose;
  5891. private _compose;
  5892. /**
  5893. * Update the base and local matrices
  5894. * @param matrix defines the new base or local matrix
  5895. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  5896. * @param updateLocalMatrix defines if the local matrix should be updated
  5897. */
  5898. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  5899. /** @hidden */
  5900. /**
  5901. * Flag the bone as dirty (Forcing it to update everything)
  5902. */
  5903. markAsDirty(): void;
  5904. private _markAsDirtyAndCompose;
  5905. private _markAsDirtyAndDecompose;
  5906. /**
  5907. * Copy an animation range from another bone
  5908. * @param source defines the source bone
  5909. * @param rangeName defines the range name to copy
  5910. * @param frameOffset defines the frame offset
  5911. * @param rescaleAsRequired defines if rescaling must be applied if required
  5912. * @param skelDimensionsRatio defines the scaling ratio
  5913. * @returns true if operation was successful
  5914. */
  5915. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired?: boolean, skelDimensionsRatio?: Nullable<Vector3>): boolean;
  5916. /**
  5917. * Translate the bone in local or world space
  5918. * @param vec The amount to translate the bone
  5919. * @param space The space that the translation is in
  5920. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5921. */
  5922. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  5923. /**
  5924. * Set the postion of the bone in local or world space
  5925. * @param position The position to set the bone
  5926. * @param space The space that the position is in
  5927. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5928. */
  5929. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  5930. /**
  5931. * Set the absolute position of the bone (world space)
  5932. * @param position The position to set the bone
  5933. * @param mesh The mesh that this bone is attached to
  5934. */
  5935. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  5936. /**
  5937. * Scale the bone on the x, y and z axes (in local space)
  5938. * @param x The amount to scale the bone on the x axis
  5939. * @param y The amount to scale the bone on the y axis
  5940. * @param z The amount to scale the bone on the z axis
  5941. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  5942. */
  5943. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  5944. /**
  5945. * Set the bone scaling in local space
  5946. * @param scale defines the scaling vector
  5947. */
  5948. setScale(scale: Vector3): void;
  5949. /**
  5950. * Gets the current scaling in local space
  5951. * @returns the current scaling vector
  5952. */
  5953. getScale(): Vector3;
  5954. /**
  5955. * Gets the current scaling in local space and stores it in a target vector
  5956. * @param result defines the target vector
  5957. */
  5958. getScaleToRef(result: Vector3): void;
  5959. /**
  5960. * Set the yaw, pitch, and roll of the bone in local or world space
  5961. * @param yaw The rotation of the bone on the y axis
  5962. * @param pitch The rotation of the bone on the x axis
  5963. * @param roll The rotation of the bone on the z axis
  5964. * @param space The space that the axes of rotation are in
  5965. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5966. */
  5967. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  5968. /**
  5969. * Add a rotation to the bone on an axis in local or world space
  5970. * @param axis The axis to rotate the bone on
  5971. * @param amount The amount to rotate the bone
  5972. * @param space The space that the axis is in
  5973. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5974. */
  5975. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  5976. /**
  5977. * Set the rotation of the bone to a particular axis angle in local or world space
  5978. * @param axis The axis to rotate the bone on
  5979. * @param angle The angle that the bone should be rotated to
  5980. * @param space The space that the axis is in
  5981. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5982. */
  5983. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  5984. /**
  5985. * Set the euler rotation of the bone in local of world space
  5986. * @param rotation The euler rotation that the bone should be set to
  5987. * @param space The space that the rotation is in
  5988. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5989. */
  5990. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  5991. /**
  5992. * Set the quaternion rotation of the bone in local of world space
  5993. * @param quat The quaternion rotation that the bone should be set to
  5994. * @param space The space that the rotation is in
  5995. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5996. */
  5997. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  5998. /**
  5999. * Set the rotation matrix of the bone in local of world space
  6000. * @param rotMat The rotation matrix that the bone should be set to
  6001. * @param space The space that the rotation is in
  6002. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6003. */
  6004. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  6005. private _rotateWithMatrix;
  6006. private _getNegativeRotationToRef;
  6007. /**
  6008. * Get the position of the bone in local or world space
  6009. * @param space The space that the returned position is in
  6010. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6011. * @returns The position of the bone
  6012. */
  6013. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  6014. /**
  6015. * Copy the position of the bone to a vector3 in local or world space
  6016. * @param space The space that the returned position is in
  6017. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6018. * @param result The vector3 to copy the position to
  6019. */
  6020. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  6021. /**
  6022. * Get the absolute position of the bone (world space)
  6023. * @param mesh The mesh that this bone is attached to
  6024. * @returns The absolute position of the bone
  6025. */
  6026. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  6027. /**
  6028. * Copy the absolute position of the bone (world space) to the result param
  6029. * @param mesh The mesh that this bone is attached to
  6030. * @param result The vector3 to copy the absolute position to
  6031. */
  6032. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  6033. /**
  6034. * Compute the absolute transforms of this bone and its children
  6035. */
  6036. computeAbsoluteTransforms(): void;
  6037. /**
  6038. * Get the world direction from an axis that is in the local space of the bone
  6039. * @param localAxis The local direction that is used to compute the world direction
  6040. * @param mesh The mesh that this bone is attached to
  6041. * @returns The world direction
  6042. */
  6043. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  6044. /**
  6045. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  6046. * @param localAxis The local direction that is used to compute the world direction
  6047. * @param mesh The mesh that this bone is attached to
  6048. * @param result The vector3 that the world direction will be copied to
  6049. */
  6050. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  6051. /**
  6052. * Get the euler rotation of the bone in local or world space
  6053. * @param space The space that the rotation should be in
  6054. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6055. * @returns The euler rotation
  6056. */
  6057. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  6058. /**
  6059. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  6060. * @param space The space that the rotation should be in
  6061. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6062. * @param result The vector3 that the rotation should be copied to
  6063. */
  6064. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  6065. /**
  6066. * Get the quaternion rotation of the bone in either local or world space
  6067. * @param space The space that the rotation should be in
  6068. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6069. * @returns The quaternion rotation
  6070. */
  6071. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  6072. /**
  6073. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  6074. * @param space The space that the rotation should be in
  6075. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6076. * @param result The quaternion that the rotation should be copied to
  6077. */
  6078. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  6079. /**
  6080. * Get the rotation matrix of the bone in local or world space
  6081. * @param space The space that the rotation should be in
  6082. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6083. * @returns The rotation matrix
  6084. */
  6085. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  6086. /**
  6087. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  6088. * @param space The space that the rotation should be in
  6089. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6090. * @param result The quaternion that the rotation should be copied to
  6091. */
  6092. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  6093. /**
  6094. * Get the world position of a point that is in the local space of the bone
  6095. * @param position The local position
  6096. * @param mesh The mesh that this bone is attached to
  6097. * @returns The world position
  6098. */
  6099. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  6100. /**
  6101. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  6102. * @param position The local position
  6103. * @param mesh The mesh that this bone is attached to
  6104. * @param result The vector3 that the world position should be copied to
  6105. */
  6106. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  6107. /**
  6108. * Get the local position of a point that is in world space
  6109. * @param position The world position
  6110. * @param mesh The mesh that this bone is attached to
  6111. * @returns The local position
  6112. */
  6113. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  6114. /**
  6115. * Get the local position of a point that is in world space and copy it to the result param
  6116. * @param position The world position
  6117. * @param mesh The mesh that this bone is attached to
  6118. * @param result The vector3 that the local position should be copied to
  6119. */
  6120. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  6121. }
  6122. }
  6123. declare module BABYLON {
  6124. /**
  6125. * Class used to apply inverse kinematics to bones
  6126. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  6127. */
  6128. class BoneIKController {
  6129. private static _tmpVecs;
  6130. private static _tmpQuat;
  6131. private static _tmpMats;
  6132. /**
  6133. * Gets or sets the target mesh
  6134. */
  6135. targetMesh: AbstractMesh;
  6136. /** Gets or sets the mesh used as pole */
  6137. poleTargetMesh: AbstractMesh;
  6138. /**
  6139. * Gets or sets the bone used as pole
  6140. */
  6141. poleTargetBone: Nullable<Bone>;
  6142. /**
  6143. * Gets or sets the target position
  6144. */
  6145. targetPosition: Vector3;
  6146. /**
  6147. * Gets or sets the pole target position
  6148. */
  6149. poleTargetPosition: Vector3;
  6150. /**
  6151. * Gets or sets the pole target local offset
  6152. */
  6153. poleTargetLocalOffset: Vector3;
  6154. /**
  6155. * Gets or sets the pole angle
  6156. */
  6157. poleAngle: number;
  6158. /**
  6159. * Gets or sets the mesh associated with the controller
  6160. */
  6161. mesh: AbstractMesh;
  6162. /**
  6163. * 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)
  6164. */
  6165. slerpAmount: number;
  6166. private _bone1Quat;
  6167. private _bone1Mat;
  6168. private _bone2Ang;
  6169. private _bone1;
  6170. private _bone2;
  6171. private _bone1Length;
  6172. private _bone2Length;
  6173. private _maxAngle;
  6174. private _maxReach;
  6175. private _rightHandedSystem;
  6176. private _bendAxis;
  6177. private _slerping;
  6178. private _adjustRoll;
  6179. /**
  6180. * Gets or sets maximum allowed angle
  6181. */
  6182. maxAngle: number;
  6183. /**
  6184. * Creates a new BoneIKController
  6185. * @param mesh defines the mesh to control
  6186. * @param bone defines the bone to control
  6187. * @param options defines options to set up the controller
  6188. */
  6189. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  6190. targetMesh?: AbstractMesh;
  6191. poleTargetMesh?: AbstractMesh;
  6192. poleTargetBone?: Bone;
  6193. poleTargetLocalOffset?: Vector3;
  6194. poleAngle?: number;
  6195. bendAxis?: Vector3;
  6196. maxAngle?: number;
  6197. slerpAmount?: number;
  6198. });
  6199. private _setMaxAngle;
  6200. /**
  6201. * Force the controller to update the bones
  6202. */
  6203. update(): void;
  6204. }
  6205. }
  6206. declare module BABYLON {
  6207. /**
  6208. * Class used to make a bone look toward a point in space
  6209. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  6210. */
  6211. class BoneLookController {
  6212. private static _tmpVecs;
  6213. private static _tmpQuat;
  6214. private static _tmpMats;
  6215. /**
  6216. * The target Vector3 that the bone will look at
  6217. */
  6218. target: Vector3;
  6219. /**
  6220. * The mesh that the bone is attached to
  6221. */
  6222. mesh: AbstractMesh;
  6223. /**
  6224. * The bone that will be looking to the target
  6225. */
  6226. bone: Bone;
  6227. /**
  6228. * The up axis of the coordinate system that is used when the bone is rotated
  6229. */
  6230. upAxis: Vector3;
  6231. /**
  6232. * The space that the up axis is in - BABYLON.Space.BONE, BABYLON.Space.LOCAL (default), or BABYLON.Space.WORLD
  6233. */
  6234. upAxisSpace: Space;
  6235. /**
  6236. * Used to make an adjustment to the yaw of the bone
  6237. */
  6238. adjustYaw: number;
  6239. /**
  6240. * Used to make an adjustment to the pitch of the bone
  6241. */
  6242. adjustPitch: number;
  6243. /**
  6244. * Used to make an adjustment to the roll of the bone
  6245. */
  6246. adjustRoll: number;
  6247. /**
  6248. * 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)
  6249. */
  6250. slerpAmount: number;
  6251. private _minYaw;
  6252. private _maxYaw;
  6253. private _minPitch;
  6254. private _maxPitch;
  6255. private _minYawSin;
  6256. private _minYawCos;
  6257. private _maxYawSin;
  6258. private _maxYawCos;
  6259. private _midYawConstraint;
  6260. private _minPitchTan;
  6261. private _maxPitchTan;
  6262. private _boneQuat;
  6263. private _slerping;
  6264. private _transformYawPitch;
  6265. private _transformYawPitchInv;
  6266. private _firstFrameSkipped;
  6267. private _yawRange;
  6268. private _fowardAxis;
  6269. /**
  6270. * Gets or sets the minimum yaw angle that the bone can look to
  6271. */
  6272. minYaw: number;
  6273. /**
  6274. * Gets or sets the maximum yaw angle that the bone can look to
  6275. */
  6276. maxYaw: number;
  6277. /**
  6278. * Gets or sets the minimum pitch angle that the bone can look to
  6279. */
  6280. minPitch: number;
  6281. /**
  6282. * Gets or sets the maximum pitch angle that the bone can look to
  6283. */
  6284. maxPitch: number;
  6285. /**
  6286. * Create a BoneLookController
  6287. * @param mesh the mesh that the bone belongs to
  6288. * @param bone the bone that will be looking to the target
  6289. * @param target the target Vector3 to look at
  6290. * @param settings optional settings:
  6291. * * maxYaw: the maximum angle the bone will yaw to
  6292. * * minYaw: the minimum angle the bone will yaw to
  6293. * * maxPitch: the maximum angle the bone will pitch to
  6294. * * minPitch: the minimum angle the bone will yaw to
  6295. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  6296. * * upAxis: the up axis of the coordinate system
  6297. * * upAxisSpace: the space that the up axis is in - BABYLON.Space.BONE, BABYLON.Space.LOCAL (default), or BABYLON.Space.WORLD.
  6298. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  6299. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  6300. * * adjustYaw: used to make an adjustment to the yaw of the bone
  6301. * * adjustPitch: used to make an adjustment to the pitch of the bone
  6302. * * adjustRoll: used to make an adjustment to the roll of the bone
  6303. **/
  6304. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  6305. maxYaw?: number;
  6306. minYaw?: number;
  6307. maxPitch?: number;
  6308. minPitch?: number;
  6309. slerpAmount?: number;
  6310. upAxis?: Vector3;
  6311. upAxisSpace?: Space;
  6312. yawAxis?: Vector3;
  6313. pitchAxis?: Vector3;
  6314. adjustYaw?: number;
  6315. adjustPitch?: number;
  6316. adjustRoll?: number;
  6317. });
  6318. /**
  6319. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  6320. */
  6321. update(): void;
  6322. private _getAngleDiff;
  6323. private _getAngleBetween;
  6324. private _isAngleBetween;
  6325. }
  6326. }
  6327. declare module BABYLON {
  6328. /**
  6329. * Class used to handle skinning animations
  6330. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  6331. */
  6332. class Skeleton implements IAnimatable {
  6333. /** defines the skeleton name */
  6334. name: string;
  6335. /** defines the skeleton Id */
  6336. id: string;
  6337. /**
  6338. * Gets the list of child bones
  6339. */
  6340. bones: Bone[];
  6341. /**
  6342. * Gets an estimate of the dimension of the skeleton at rest
  6343. */
  6344. dimensionsAtRest: Vector3;
  6345. /**
  6346. * Gets a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  6347. */
  6348. needInitialSkinMatrix: boolean;
  6349. /**
  6350. * Gets the list of animations attached to this skeleton
  6351. */
  6352. animations: Array<Animation>;
  6353. private _scene;
  6354. private _isDirty;
  6355. private _transformMatrices;
  6356. private _meshesWithPoseMatrix;
  6357. private _animatables;
  6358. private _identity;
  6359. private _synchronizedWithMesh;
  6360. private _ranges;
  6361. private _lastAbsoluteTransformsUpdateId;
  6362. /**
  6363. * Specifies if the skeleton should be serialized
  6364. */
  6365. doNotSerialize: boolean;
  6366. private _animationPropertiesOverride;
  6367. /**
  6368. * Gets or sets the animation properties override
  6369. */
  6370. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  6371. /**
  6372. * An observable triggered before computing the skeleton's matrices
  6373. */
  6374. onBeforeComputeObservable: Observable<Skeleton>;
  6375. /**
  6376. * Creates a new skeleton
  6377. * @param name defines the skeleton name
  6378. * @param id defines the skeleton Id
  6379. * @param scene defines the hosting scene
  6380. */
  6381. constructor(
  6382. /** defines the skeleton name */
  6383. name: string,
  6384. /** defines the skeleton Id */
  6385. id: string, scene: Scene);
  6386. /**
  6387. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  6388. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  6389. * @returns a Float32Array containing matrices data
  6390. */
  6391. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  6392. /**
  6393. * Gets the current hosting scene
  6394. * @returns a scene object
  6395. */
  6396. getScene(): Scene;
  6397. /**
  6398. * Gets a string representing the current skeleton data
  6399. * @param fullDetails defines a boolean indicating if we want a verbose version
  6400. * @returns a string representing the current skeleton data
  6401. */
  6402. toString(fullDetails?: boolean): string;
  6403. /**
  6404. * Get bone's index searching by name
  6405. * @param name defines bone's name to search for
  6406. * @return the indice of the bone. Returns -1 if not found
  6407. */
  6408. getBoneIndexByName(name: string): number;
  6409. /**
  6410. * Creater a new animation range
  6411. * @param name defines the name of the range
  6412. * @param from defines the start key
  6413. * @param to defines the end key
  6414. */
  6415. createAnimationRange(name: string, from: number, to: number): void;
  6416. /**
  6417. * Delete a specific animation range
  6418. * @param name defines the name of the range
  6419. * @param deleteFrames defines if frames must be removed as well
  6420. */
  6421. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  6422. /**
  6423. * Gets a specific animation range
  6424. * @param name defines the name of the range to look for
  6425. * @returns the requested animation range or null if not found
  6426. */
  6427. getAnimationRange(name: string): Nullable<AnimationRange>;
  6428. /**
  6429. * Gets the list of all animation ranges defined on this skeleton
  6430. * @returns an array
  6431. */
  6432. getAnimationRanges(): Nullable<AnimationRange>[];
  6433. /**
  6434. * Copy animation range from a source skeleton.
  6435. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  6436. * @param source defines the source skeleton
  6437. * @param name defines the name of the range to copy
  6438. * @param rescaleAsRequired defines if rescaling must be applied if required
  6439. * @returns true if operation was successful
  6440. */
  6441. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  6442. /**
  6443. * Forces the skeleton to go to rest pose
  6444. */
  6445. returnToRest(): void;
  6446. private _getHighestAnimationFrame;
  6447. /**
  6448. * Begin a specific animation range
  6449. * @param name defines the name of the range to start
  6450. * @param loop defines if looping must be turned on (false by default)
  6451. * @param speedRatio defines the speed ratio to apply (1 by default)
  6452. * @param onAnimationEnd defines a callback which will be called when animation will end
  6453. * @returns a new animatable
  6454. */
  6455. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  6456. /** @hidden */
  6457. /** @hidden */
  6458. /** @hidden */
  6459. /** @hidden */
  6460. /**
  6461. * Build all resources required to render a skeleton
  6462. */
  6463. prepare(): void;
  6464. /**
  6465. * Gets the list of animatables currently running for this skeleton
  6466. * @returns an array of animatables
  6467. */
  6468. getAnimatables(): IAnimatable[];
  6469. /**
  6470. * Clone the current skeleton
  6471. * @param name defines the name of the new skeleton
  6472. * @param id defines the id of the enw skeleton
  6473. * @returns the new skeleton
  6474. */
  6475. clone(name: string, id: string): Skeleton;
  6476. /**
  6477. * Enable animation blending for this skeleton
  6478. * @param blendingSpeed defines the blending speed to apply
  6479. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  6480. */
  6481. enableBlending(blendingSpeed?: number): void;
  6482. /**
  6483. * Releases all resources associated with the current skeleton
  6484. */
  6485. dispose(): void;
  6486. /**
  6487. * Serialize the skeleton in a JSON object
  6488. * @returns a JSON object
  6489. */
  6490. serialize(): any;
  6491. /**
  6492. * Creates a new skeleton from serialized data
  6493. * @param parsedSkeleton defines the serialized data
  6494. * @param scene defines the hosting scene
  6495. * @returns a new skeleton
  6496. */
  6497. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  6498. /**
  6499. * Compute all node absolute transforms
  6500. * @param forceUpdate defines if computation must be done even if cache is up to date
  6501. */
  6502. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  6503. /**
  6504. * Gets the root pose matrix
  6505. * @returns a matrix
  6506. */
  6507. getPoseMatrix(): Nullable<Matrix>;
  6508. /**
  6509. * Sorts bones per internal index
  6510. */
  6511. sortBones(): void;
  6512. private _sortBones;
  6513. }
  6514. }
  6515. declare module BABYLON {
  6516. /**
  6517. * This represents an orbital type of camera.
  6518. *
  6519. * 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.
  6520. * 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.
  6521. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  6522. */
  6523. class ArcRotateCamera extends TargetCamera {
  6524. /**
  6525. * Defines the rotation angle of the camera along the longitudinal axis.
  6526. */
  6527. alpha: number;
  6528. /**
  6529. * Defines the rotation angle of the camera along the latitudinal axis.
  6530. */
  6531. beta: number;
  6532. /**
  6533. * Defines the radius of the camera from it s target point.
  6534. */
  6535. radius: number;
  6536. protected _target: Vector3;
  6537. protected _targetHost: Nullable<AbstractMesh>;
  6538. /**
  6539. * Defines the target point of the camera.
  6540. * The camera looks towards it form the radius distance.
  6541. */
  6542. target: Vector3;
  6543. /**
  6544. * Current inertia value on the longitudinal axis.
  6545. * The bigger this number the longer it will take for the camera to stop.
  6546. */
  6547. inertialAlphaOffset: number;
  6548. /**
  6549. * Current inertia value on the latitudinal axis.
  6550. * The bigger this number the longer it will take for the camera to stop.
  6551. */
  6552. inertialBetaOffset: number;
  6553. /**
  6554. * Current inertia value on the radius axis.
  6555. * The bigger this number the longer it will take for the camera to stop.
  6556. */
  6557. inertialRadiusOffset: number;
  6558. /**
  6559. * Minimum allowed angle on the longitudinal axis.
  6560. * This can help limiting how the Camera is able to move in the scene.
  6561. */
  6562. lowerAlphaLimit: Nullable<number>;
  6563. /**
  6564. * Maximum allowed angle on the longitudinal axis.
  6565. * This can help limiting how the Camera is able to move in the scene.
  6566. */
  6567. upperAlphaLimit: Nullable<number>;
  6568. /**
  6569. * Minimum allowed angle on the latitudinal axis.
  6570. * This can help limiting how the Camera is able to move in the scene.
  6571. */
  6572. lowerBetaLimit: number;
  6573. /**
  6574. * Maximum allowed angle on the latitudinal axis.
  6575. * This can help limiting how the Camera is able to move in the scene.
  6576. */
  6577. upperBetaLimit: number;
  6578. /**
  6579. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  6580. * This can help limiting how the Camera is able to move in the scene.
  6581. */
  6582. lowerRadiusLimit: Nullable<number>;
  6583. /**
  6584. * Maximum allowed distance of the camera to the target (The camera can not get further).
  6585. * This can help limiting how the Camera is able to move in the scene.
  6586. */
  6587. upperRadiusLimit: Nullable<number>;
  6588. /**
  6589. * Defines the current inertia value used during panning of the camera along the X axis.
  6590. */
  6591. inertialPanningX: number;
  6592. /**
  6593. * Defines the current inertia value used during panning of the camera along the Y axis.
  6594. */
  6595. inertialPanningY: number;
  6596. /**
  6597. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  6598. * Basically if your fingers moves away from more than this distance you will be considered
  6599. * in pinch mode.
  6600. */
  6601. pinchToPanMaxDistance: number;
  6602. /**
  6603. * Defines the maximum distance the camera can pan.
  6604. * This could help keeping the cammera always in your scene.
  6605. */
  6606. panningDistanceLimit: Nullable<number>;
  6607. /**
  6608. * Defines the target of the camera before paning.
  6609. */
  6610. panningOriginTarget: Vector3;
  6611. /**
  6612. * Defines the value of the inertia used during panning.
  6613. * 0 would mean stop inertia and one would mean no decelleration at all.
  6614. */
  6615. panningInertia: number;
  6616. /**
  6617. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  6618. */
  6619. angularSensibilityX: number;
  6620. /**
  6621. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  6622. */
  6623. angularSensibilityY: number;
  6624. /**
  6625. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  6626. */
  6627. pinchPrecision: number;
  6628. /**
  6629. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  6630. * It will be used instead of pinchDeltaPrecision if different from 0.
  6631. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  6632. */
  6633. pinchDeltaPercentage: number;
  6634. /**
  6635. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  6636. */
  6637. panningSensibility: number;
  6638. /**
  6639. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  6640. */
  6641. keysUp: number[];
  6642. /**
  6643. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  6644. */
  6645. keysDown: number[];
  6646. /**
  6647. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  6648. */
  6649. keysLeft: number[];
  6650. /**
  6651. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  6652. */
  6653. keysRight: number[];
  6654. /**
  6655. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  6656. */
  6657. wheelPrecision: number;
  6658. /**
  6659. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  6660. * It will be used instead of pinchDeltaPrecision if different from 0.
  6661. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  6662. */
  6663. wheelDeltaPercentage: number;
  6664. /**
  6665. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  6666. */
  6667. zoomOnFactor: number;
  6668. /**
  6669. * Defines a screen offset for the camera position.
  6670. */
  6671. targetScreenOffset: Vector2;
  6672. /**
  6673. * Allows the camera to be completely reversed.
  6674. * If false the camera can not arrive upside down.
  6675. */
  6676. allowUpsideDown: boolean;
  6677. /**
  6678. * Define if double tap/click is used to restore the previously saved state of the camera.
  6679. */
  6680. useInputToRestoreState: boolean;
  6681. /** @hidden */
  6682. /** @hidden */
  6683. /** @hidden */
  6684. /**
  6685. * Defines the inpute associated to the camera.
  6686. */
  6687. inputs: ArcRotateCameraInputsManager;
  6688. /** @hidden */
  6689. /**
  6690. * Defines the allowed panning axis.
  6691. */
  6692. panningAxis: Vector3;
  6693. protected _localDirection: Vector3;
  6694. protected _transformedDirection: Vector3;
  6695. private _bouncingBehavior;
  6696. /**
  6697. * Gets the bouncing behavior of the camera if it has been enabled.
  6698. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  6699. */
  6700. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  6701. /**
  6702. * Defines if the bouncing behavior of the camera is enabled on the camera.
  6703. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  6704. */
  6705. useBouncingBehavior: boolean;
  6706. private _framingBehavior;
  6707. /**
  6708. * Gets the framing behavior of the camera if it has been enabled.
  6709. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  6710. */
  6711. readonly framingBehavior: Nullable<FramingBehavior>;
  6712. /**
  6713. * Defines if the framing behavior of the camera is enabled on the camera.
  6714. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  6715. */
  6716. useFramingBehavior: boolean;
  6717. private _autoRotationBehavior;
  6718. /**
  6719. * Gets the auto rotation behavior of the camera if it has been enabled.
  6720. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  6721. */
  6722. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  6723. /**
  6724. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  6725. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  6726. */
  6727. useAutoRotationBehavior: boolean;
  6728. /**
  6729. * Observable triggered when the mesh target has been changed on the camera.
  6730. */
  6731. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  6732. /**
  6733. * Event raised when the camera is colliding with a mesh.
  6734. */
  6735. onCollide: (collidedMesh: AbstractMesh) => void;
  6736. /**
  6737. * Defines whether the camera should check collision with the objects oh the scene.
  6738. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  6739. */
  6740. checkCollisions: boolean;
  6741. /**
  6742. * Defines the collision radius of the camera.
  6743. * This simulates a sphere around the camera.
  6744. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  6745. */
  6746. collisionRadius: Vector3;
  6747. protected _collider: Collider;
  6748. protected _previousPosition: Vector3;
  6749. protected _collisionVelocity: Vector3;
  6750. protected _newPosition: Vector3;
  6751. protected _previousAlpha: number;
  6752. protected _previousBeta: number;
  6753. protected _previousRadius: number;
  6754. protected _collisionTriggered: boolean;
  6755. protected _targetBoundingCenter: Nullable<Vector3>;
  6756. private _computationVector;
  6757. /**
  6758. * Instantiates a new ArcRotateCamera in a given scene
  6759. * @param name Defines the name of the camera
  6760. * @param alpha Defines the camera rotation along the logitudinal axis
  6761. * @param beta Defines the camera rotation along the latitudinal axis
  6762. * @param radius Defines the camera distance from its target
  6763. * @param target Defines the camera target
  6764. * @param scene Defines the scene the camera belongs to
  6765. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  6766. */
  6767. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  6768. /** @hidden */
  6769. /** @hidden */
  6770. protected _getTargetPosition(): Vector3;
  6771. private _storedAlpha;
  6772. private _storedBeta;
  6773. private _storedRadius;
  6774. private _storedTarget;
  6775. /**
  6776. * Stores the current state of the camera (alpha, beta, radius and target)
  6777. * @returns the camera itself
  6778. */
  6779. storeState(): Camera;
  6780. /**
  6781. * @hidden
  6782. * Restored camera state. You must call storeState() first
  6783. */
  6784. /** @hidden */
  6785. /**
  6786. * Attached controls to the current camera.
  6787. * @param element Defines the element the controls should be listened from
  6788. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6789. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  6790. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  6791. */
  6792. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  6793. /**
  6794. * Detach the current controls from the camera.
  6795. * The camera will stop reacting to inputs.
  6796. * @param element Defines the element to stop listening the inputs from
  6797. */
  6798. detachControl(element: HTMLElement): void;
  6799. /** @hidden */
  6800. protected _checkLimits(): void;
  6801. /**
  6802. * Rebuilds angles (alpha, beta) and radius from the give position and target.
  6803. */
  6804. rebuildAnglesAndRadius(): void;
  6805. /**
  6806. * Use a position to define the current camera related information like aplha, beta and radius
  6807. * @param position Defines the position to set the camera at
  6808. */
  6809. setPosition(position: Vector3): void;
  6810. /**
  6811. * Defines the target the camera should look at.
  6812. * This will automatically adapt alpha beta and radius to fit within the new target.
  6813. * @param target Defines the new target as a Vector or a mesh
  6814. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  6815. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  6816. */
  6817. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  6818. /** @hidden */
  6819. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  6820. /**
  6821. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  6822. * @param meshes Defines the mesh to zoom on
  6823. * @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)
  6824. */
  6825. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  6826. /**
  6827. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  6828. * The target will be changed but the radius
  6829. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  6830. * @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)
  6831. */
  6832. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  6833. min: Vector3;
  6834. max: Vector3;
  6835. distance: number;
  6836. }, doNotUpdateMaxZ?: boolean): void;
  6837. /**
  6838. * @override
  6839. * Override Camera.createRigCamera
  6840. */
  6841. createRigCamera(name: string, cameraIndex: number): Camera;
  6842. /**
  6843. * @hidden
  6844. * @override
  6845. * Override Camera._updateRigCameras
  6846. */
  6847. /**
  6848. * Destroy the camera and release the current resources hold by it.
  6849. */
  6850. dispose(): void;
  6851. /**
  6852. * Gets the current object class name.
  6853. * @return the class name
  6854. */
  6855. getClassName(): string;
  6856. }
  6857. }
  6858. declare module BABYLON {
  6859. /**
  6860. * Default Inputs manager for the ArcRotateCamera.
  6861. * It groups all the default supported inputs for ease of use.
  6862. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6863. */
  6864. class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  6865. /**
  6866. * Instantiates a new ArcRotateCameraInputsManager.
  6867. * @param camera Defines the camera the inputs belong to
  6868. */
  6869. constructor(camera: ArcRotateCamera);
  6870. /**
  6871. * Add mouse wheel input support to the input manager.
  6872. * @returns the current input manager
  6873. */
  6874. addMouseWheel(): ArcRotateCameraInputsManager;
  6875. /**
  6876. * Add pointers input support to the input manager.
  6877. * @returns the current input manager
  6878. */
  6879. addPointers(): ArcRotateCameraInputsManager;
  6880. /**
  6881. * Add keyboard input support to the input manager.
  6882. * @returns the current input manager
  6883. */
  6884. addKeyboard(): ArcRotateCameraInputsManager;
  6885. /**
  6886. * Add orientation input support to the input manager.
  6887. * @returns the current input manager
  6888. */
  6889. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  6890. }
  6891. }
  6892. declare module BABYLON {
  6893. /**
  6894. * This is the base class of all the camera used in the application.
  6895. * @see http://doc.babylonjs.com/features/cameras
  6896. */
  6897. class Camera extends Node {
  6898. /**
  6899. * This is the default projection mode used by the cameras.
  6900. * It helps recreating a feeling of perspective and better appreciate depth.
  6901. * This is the best way to simulate real life cameras.
  6902. */
  6903. static readonly PERSPECTIVE_CAMERA: number;
  6904. /**
  6905. * This helps creating camera with an orthographic mode.
  6906. * 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.
  6907. */
  6908. static readonly ORTHOGRAPHIC_CAMERA: number;
  6909. /**
  6910. * This is the default FOV mode for perspective cameras.
  6911. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  6912. */
  6913. static readonly FOVMODE_VERTICAL_FIXED: number;
  6914. /**
  6915. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  6916. */
  6917. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  6918. /**
  6919. * This specifies ther is no need for a camera rig.
  6920. * Basically only one eye is rendered corresponding to the camera.
  6921. */
  6922. static readonly RIG_MODE_NONE: number;
  6923. /**
  6924. * Simulates a camera Rig with one blue eye and one red eye.
  6925. * This can be use with 3d blue and red glasses.
  6926. */
  6927. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  6928. /**
  6929. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  6930. */
  6931. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  6932. /**
  6933. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  6934. */
  6935. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  6936. /**
  6937. * Defines that both eyes of the camera will be rendered over under each other.
  6938. */
  6939. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  6940. /**
  6941. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  6942. */
  6943. static readonly RIG_MODE_VR: number;
  6944. /**
  6945. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  6946. */
  6947. static readonly RIG_MODE_WEBVR: number;
  6948. /**
  6949. * Defines if by default attaching controls should prevent the default javascript event to continue.
  6950. */
  6951. static ForceAttachControlToAlwaysPreventDefault: boolean;
  6952. /**
  6953. * @hidden
  6954. * Might be removed once multiview will be a thing
  6955. */
  6956. static UseAlternateWebVRRendering: boolean;
  6957. /**
  6958. * Define the input manager associated with the camera.
  6959. */
  6960. inputs: CameraInputsManager<Camera>;
  6961. /**
  6962. * Define the current local position of the camera in the scene
  6963. */
  6964. position: Vector3;
  6965. /**
  6966. * The vector the camera should consider as up.
  6967. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  6968. */
  6969. upVector: Vector3;
  6970. /**
  6971. * Define the current limit on the left side for an orthographic camera
  6972. * In scene unit
  6973. */
  6974. orthoLeft: Nullable<number>;
  6975. /**
  6976. * Define the current limit on the right side for an orthographic camera
  6977. * In scene unit
  6978. */
  6979. orthoRight: Nullable<number>;
  6980. /**
  6981. * Define the current limit on the bottom side for an orthographic camera
  6982. * In scene unit
  6983. */
  6984. orthoBottom: Nullable<number>;
  6985. /**
  6986. * Define the current limit on the top side for an orthographic camera
  6987. * In scene unit
  6988. */
  6989. orthoTop: Nullable<number>;
  6990. /**
  6991. * Field Of View is set in Radians. (default is 0.8)
  6992. */
  6993. fov: number;
  6994. /**
  6995. * Define the minimum distance the camera can see from.
  6996. * This is important to note that the depth buffer are not infinite and the closer it starts
  6997. * the more your scene might encounter depth fighting issue.
  6998. */
  6999. minZ: number;
  7000. /**
  7001. * Define the maximum distance the camera can see to.
  7002. * This is important to note that the depth buffer are not infinite and the further it end
  7003. * the more your scene might encounter depth fighting issue.
  7004. */
  7005. maxZ: number;
  7006. /**
  7007. * Define the default inertia of the camera.
  7008. * This helps giving a smooth feeling to the camera movement.
  7009. */
  7010. inertia: number;
  7011. /**
  7012. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  7013. */
  7014. mode: number;
  7015. /**
  7016. * Define wether the camera is intermediate.
  7017. * This is usefull to not present the output directly to the screen in case of rig without post process for instance
  7018. */
  7019. isIntermediate: boolean;
  7020. /**
  7021. * Define the viewport of the camera.
  7022. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  7023. */
  7024. viewport: Viewport;
  7025. /**
  7026. * Restricts the camera to viewing objects with the same layerMask.
  7027. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  7028. */
  7029. layerMask: number;
  7030. /**
  7031. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  7032. */
  7033. fovMode: number;
  7034. /**
  7035. * Rig mode of the camera.
  7036. * This is usefull to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  7037. * This is normally controlled byt the camera themselves as internal use.
  7038. */
  7039. cameraRigMode: number;
  7040. /**
  7041. * Defines the distance between both "eyes" in case of a RIG
  7042. */
  7043. interaxialDistance: number;
  7044. /**
  7045. * Defines if stereoscopic rendering is done side by side or over under.
  7046. */
  7047. isStereoscopicSideBySide: boolean;
  7048. /**
  7049. * Defines the list of custom render target the camera should render to.
  7050. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  7051. * else in the scene.
  7052. */
  7053. customRenderTargets: RenderTargetTexture[];
  7054. /**
  7055. * Observable triggered when the camera view matrix has changed.
  7056. */
  7057. onViewMatrixChangedObservable: Observable<Camera>;
  7058. /**
  7059. * Observable triggered when the camera Projection matrix has changed.
  7060. */
  7061. onProjectionMatrixChangedObservable: Observable<Camera>;
  7062. /**
  7063. * Observable triggered when the inputs have been processed.
  7064. */
  7065. onAfterCheckInputsObservable: Observable<Camera>;
  7066. /**
  7067. * Observable triggered when reset has been called and applied to the camera.
  7068. */
  7069. onRestoreStateObservable: Observable<Camera>;
  7070. /** @hidden */
  7071. /** @hidden */
  7072. /** @hidden */
  7073. protected _webvrViewMatrix: Matrix;
  7074. /** @hidden */
  7075. /** @hidden */
  7076. /** @hidden */
  7077. /** @hidden */
  7078. /** @hidden */
  7079. protected _globalPosition: Vector3;
  7080. private _computedViewMatrix;
  7081. private _doNotComputeProjectionMatrix;
  7082. private _transformMatrix;
  7083. private _frustumPlanes;
  7084. private _refreshFrustumPlanes;
  7085. private _storedFov;
  7086. private _stateStored;
  7087. /**
  7088. * Instantiates a new camera object.
  7089. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  7090. * @see http://doc.babylonjs.com/features/cameras
  7091. * @param name Defines the name of the camera in the scene
  7092. * @param position Defines the position of the camera
  7093. * @param scene Defines the scene the camera belongs too
  7094. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  7095. */
  7096. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  7097. /**
  7098. * Store current camera state (fov, position, etc..)
  7099. * @returns the camera
  7100. */
  7101. storeState(): Camera;
  7102. /**
  7103. * Restores the camera state values if it has been stored. You must call storeState() first
  7104. */
  7105. protected _restoreStateValues(): boolean;
  7106. /**
  7107. * Restored camera state. You must call storeState() first.
  7108. * @returns true if restored and false otherwise
  7109. */
  7110. restoreState(): boolean;
  7111. /**
  7112. * Gets the class name of the camera.
  7113. * @returns the class name
  7114. */
  7115. getClassName(): string;
  7116. /**
  7117. * Gets a string representation of the camera usefull for debug purpose.
  7118. * @param fullDetails Defines that a more verboe level of logging is required
  7119. * @returns the string representation
  7120. */
  7121. toString(fullDetails?: boolean): string;
  7122. /**
  7123. * Gets the current world space position of the camera.
  7124. */
  7125. readonly globalPosition: Vector3;
  7126. /**
  7127. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  7128. * @returns the active meshe list
  7129. */
  7130. getActiveMeshes(): SmartArray<AbstractMesh>;
  7131. /**
  7132. * Check wether a mesh is part of the current active mesh list of the camera
  7133. * @param mesh Defines the mesh to check
  7134. * @returns true if active, false otherwise
  7135. */
  7136. isActiveMesh(mesh: Mesh): boolean;
  7137. /**
  7138. * Is this camera ready to be used/rendered
  7139. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  7140. * @return true if the camera is ready
  7141. */
  7142. isReady(completeCheck?: boolean): boolean;
  7143. /** @hidden */
  7144. /** @hidden */
  7145. /** @hidden */
  7146. /** @hidden */
  7147. /** @hidden */
  7148. /**
  7149. * Attach the input controls to a specific dom element to get the input from.
  7150. * @param element Defines the element the controls should be listened from
  7151. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  7152. */
  7153. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  7154. /**
  7155. * Detach the current controls from the specified dom element.
  7156. * @param element Defines the element to stop listening the inputs from
  7157. */
  7158. detachControl(element: HTMLElement): void;
  7159. /**
  7160. * Update the camera state according to the different inputs gathered during the frame.
  7161. */
  7162. update(): void;
  7163. /** @hidden */
  7164. /** @hidden */
  7165. readonly rigCameras: Camera[];
  7166. /**
  7167. * Gets the post process used by the rig cameras
  7168. */
  7169. readonly rigPostProcess: Nullable<PostProcess>;
  7170. /**
  7171. * Internal, gets the first post proces.
  7172. * @returns the first post process to be run on this camera.
  7173. */
  7174. private _cascadePostProcessesToRigCams;
  7175. /**
  7176. * Attach a post process to the camera.
  7177. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  7178. * @param postProcess The post process to attach to the camera
  7179. * @param insertAt The position of the post process in case several of them are in use in the scene
  7180. * @returns the position the post process has been inserted at
  7181. */
  7182. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  7183. /**
  7184. * Detach a post process to the camera.
  7185. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  7186. * @param postProcess The post process to detach from the camera
  7187. */
  7188. detachPostProcess(postProcess: PostProcess): void;
  7189. /**
  7190. * Gets the current world matrix of the camera
  7191. */
  7192. getWorldMatrix(): Matrix;
  7193. /** @hidden */
  7194. protected _getViewMatrix(): Matrix;
  7195. /**
  7196. * Gets the current view matrix of the camera.
  7197. * @param force forces the camera to recompute the matrix without looking at the cached state
  7198. * @returns the view matrix
  7199. */
  7200. getViewMatrix(force?: boolean): Matrix;
  7201. /**
  7202. * Freeze the projection matrix.
  7203. * It will prevent the cache check of the camera projection compute and can speed up perf
  7204. * if no parameter of the camera are meant to change
  7205. * @param projection Defines manually a projection if necessary
  7206. */
  7207. freezeProjectionMatrix(projection?: Matrix): void;
  7208. /**
  7209. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  7210. */
  7211. unfreezeProjectionMatrix(): void;
  7212. /**
  7213. * Gets the current projection matrix of the camera.
  7214. * @param force forces the camera to recompute the matrix without looking at the cached state
  7215. * @returns the projection matrix
  7216. */
  7217. getProjectionMatrix(force?: boolean): Matrix;
  7218. /**
  7219. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  7220. * @returns a Matrix
  7221. */
  7222. getTransformationMatrix(): Matrix;
  7223. private _updateFrustumPlanes;
  7224. /**
  7225. * Checks if a cullable object (mesh...) is in the camera frustum
  7226. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  7227. * @param target The object to check
  7228. * @returns true if the object is in frustum otherwise false
  7229. */
  7230. isInFrustum(target: ICullable): boolean;
  7231. /**
  7232. * Checks if a cullable object (mesh...) is in the camera frustum
  7233. * Unlike isInFrustum this cheks the full bounding box
  7234. * @param target The object to check
  7235. * @returns true if the object is in frustum otherwise false
  7236. */
  7237. isCompletelyInFrustum(target: ICullable): boolean;
  7238. /**
  7239. * Gets a ray in the forward direction from the camera.
  7240. * @param length Defines the length of the ray to create
  7241. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  7242. * @param origin Defines the start point of the ray which defaults to the camera position
  7243. * @returns the forward ray
  7244. */
  7245. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  7246. /**
  7247. * Releases resources associated with this node.
  7248. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  7249. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  7250. */
  7251. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  7252. /**
  7253. * Gets the left camera of a rig setup in case of Rigged Camera
  7254. */
  7255. readonly leftCamera: Nullable<FreeCamera>;
  7256. /**
  7257. * Gets the right camera of a rig setup in case of Rigged Camera
  7258. */
  7259. readonly rightCamera: Nullable<FreeCamera>;
  7260. /**
  7261. * Gets the left camera target of a rig setup in case of Rigged Camera
  7262. * @returns the target position
  7263. */
  7264. getLeftTarget(): Nullable<Vector3>;
  7265. /**
  7266. * Gets the right camera target of a rig setup in case of Rigged Camera
  7267. * @returns the target position
  7268. */
  7269. getRightTarget(): Nullable<Vector3>;
  7270. /**
  7271. * @hidden
  7272. */
  7273. setCameraRigMode(mode: number, rigParams: any): void;
  7274. private _getVRProjectionMatrix;
  7275. protected _updateCameraRotationMatrix(): void;
  7276. protected _updateWebVRCameraRotationMatrix(): void;
  7277. /**
  7278. * This function MUST be overwritten by the different WebVR cameras available.
  7279. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  7280. */
  7281. protected _getWebVRProjectionMatrix(): Matrix;
  7282. /**
  7283. * This function MUST be overwritten by the different WebVR cameras available.
  7284. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  7285. */
  7286. protected _getWebVRViewMatrix(): Matrix;
  7287. /** @hidden */
  7288. setCameraRigParameter(name: string, value: any): void;
  7289. /**
  7290. * needs to be overridden by children so sub has required properties to be copied
  7291. * @hidden
  7292. */
  7293. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  7294. /**
  7295. * May need to be overridden by children
  7296. * @hidden
  7297. */
  7298. /** @hidden */
  7299. /**
  7300. * Serialiaze the camera setup to a json represention
  7301. * @returns the JSON representation
  7302. */
  7303. serialize(): any;
  7304. /**
  7305. * Clones the current camera.
  7306. * @param name The cloned camera name
  7307. * @returns the cloned camera
  7308. */
  7309. clone(name: string): Camera;
  7310. /**
  7311. * Gets the direction of the camera relative to a given local axis.
  7312. * @param localAxis Defines the reference axis to provide a relative direction.
  7313. * @return the direction
  7314. */
  7315. getDirection(localAxis: Vector3): Vector3;
  7316. /**
  7317. * Gets the direction of the camera relative to a given local axis into a passed vector.
  7318. * @param localAxis Defines the reference axis to provide a relative direction.
  7319. * @param result Defines the vector to store the result in
  7320. */
  7321. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  7322. /**
  7323. * Gets a camera constructor for a given camera type
  7324. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  7325. * @param name The name of the camera the result will be able to instantiate
  7326. * @param scene The scene the result will construct the camera in
  7327. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  7328. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  7329. * @returns a factory method to construc the camera
  7330. */
  7331. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  7332. /**
  7333. * Compute the world matrix of the camera.
  7334. * @returns the camera workd matrix
  7335. */
  7336. computeWorldMatrix(): Matrix;
  7337. /**
  7338. * Parse a JSON and creates the camera from the parsed information
  7339. * @param parsedCamera The JSON to parse
  7340. * @param scene The scene to instantiate the camera in
  7341. * @returns the newly constructed camera
  7342. */
  7343. static Parse(parsedCamera: any, scene: Scene): Camera;
  7344. }
  7345. }
  7346. declare module BABYLON {
  7347. /**
  7348. * @ignore
  7349. * This is a list of all the different input types that are available in the application.
  7350. * Fo instance: ArcRotateCameraGamepadInput...
  7351. */
  7352. var CameraInputTypes: {};
  7353. /**
  7354. * This is the contract to implement in order to create a new input class.
  7355. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  7356. */
  7357. interface ICameraInput<TCamera extends Camera> {
  7358. /**
  7359. * Defines the camera the input is attached to.
  7360. */
  7361. camera: Nullable<TCamera>;
  7362. /**
  7363. * Gets the class name of the current intput.
  7364. * @returns the class name
  7365. */
  7366. getClassName(): string;
  7367. /**
  7368. * Get the friendly name associated with the input class.
  7369. * @returns the input friendly name
  7370. */
  7371. getSimpleName(): string;
  7372. /**
  7373. * Attach the input controls to a specific dom element to get the input from.
  7374. * @param element Defines the element the controls should be listened from
  7375. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  7376. */
  7377. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  7378. /**
  7379. * Detach the current controls from the specified dom element.
  7380. * @param element Defines the element to stop listening the inputs from
  7381. */
  7382. detachControl(element: Nullable<HTMLElement>): void;
  7383. /**
  7384. * Update the current camera state depending on the inputs that have been used this frame.
  7385. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  7386. */
  7387. checkInputs?: () => void;
  7388. }
  7389. /**
  7390. * Represents a map of input types to input instance or input index to input instance.
  7391. */
  7392. interface CameraInputsMap<TCamera extends Camera> {
  7393. /**
  7394. * Accessor to the input by input type.
  7395. */
  7396. [name: string]: ICameraInput<TCamera>;
  7397. /**
  7398. * Accessor to the input by input index.
  7399. */
  7400. [idx: number]: ICameraInput<TCamera>;
  7401. }
  7402. /**
  7403. * This represents the input manager used within a camera.
  7404. * It helps dealing with all the different kind of input attached to a camera.
  7405. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  7406. */
  7407. class CameraInputsManager<TCamera extends Camera> {
  7408. /**
  7409. * Defines the list of inputs attahed to the camera.
  7410. */
  7411. attached: CameraInputsMap<TCamera>;
  7412. /**
  7413. * Defines the dom element the camera is collecting inputs from.
  7414. * This is null if the controls have not been attached.
  7415. */
  7416. attachedElement: Nullable<HTMLElement>;
  7417. /**
  7418. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  7419. */
  7420. noPreventDefault: boolean;
  7421. /**
  7422. * Defined the camera the input manager belongs to.
  7423. */
  7424. camera: TCamera;
  7425. /**
  7426. * Update the current camera state depending on the inputs that have been used this frame.
  7427. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  7428. */
  7429. checkInputs: () => void;
  7430. /**
  7431. * Instantiate a new Camera Input Manager.
  7432. * @param camera Defines the camera the input manager blongs to
  7433. */
  7434. constructor(camera: TCamera);
  7435. /**
  7436. * Add an input method to a camera
  7437. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  7438. * @param input camera input method
  7439. */
  7440. add(input: ICameraInput<TCamera>): void;
  7441. /**
  7442. * Remove a specific input method from a camera
  7443. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  7444. * @param inputToRemove camera input method
  7445. */
  7446. remove(inputToRemove: ICameraInput<TCamera>): void;
  7447. /**
  7448. * Remove a specific input type from a camera
  7449. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  7450. * @param inputType the type of the input to remove
  7451. */
  7452. removeByType(inputType: string): void;
  7453. private _addCheckInputs;
  7454. /**
  7455. * Attach the input controls to the currently attached dom element to listen the events from.
  7456. * @param input Defines the input to attach
  7457. */
  7458. attachInput(input: ICameraInput<TCamera>): void;
  7459. /**
  7460. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  7461. * @param element Defines the dom element to collect the events from
  7462. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  7463. */
  7464. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  7465. /**
  7466. * Detach the current manager inputs controls from a specific dom element.
  7467. * @param element Defines the dom element to collect the events from
  7468. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  7469. */
  7470. detachElement(element: HTMLElement, disconnect?: boolean): void;
  7471. /**
  7472. * Rebuild the dynamic inputCheck function from the current list of
  7473. * defined inputs in the manager.
  7474. */
  7475. rebuildInputCheck(): void;
  7476. /**
  7477. * Remove all attached input methods from a camera
  7478. */
  7479. clear(): void;
  7480. /**
  7481. * Serialize the current input manager attached to a camera.
  7482. * This ensures than once parsed,
  7483. * the input associated to the camera will be identical to the current ones
  7484. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  7485. */
  7486. serialize(serializedCamera: any): void;
  7487. /**
  7488. * Parses an input manager serialized JSON to restore the previous list of inputs
  7489. * and states associated to a camera.
  7490. * @param parsedCamera Defines the JSON to parse
  7491. */
  7492. parse(parsedCamera: any): void;
  7493. }
  7494. }
  7495. declare module BABYLON {
  7496. /**
  7497. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  7498. * being tilted forward or back and left or right.
  7499. */
  7500. class DeviceOrientationCamera extends FreeCamera {
  7501. private _initialQuaternion;
  7502. private _quaternionCache;
  7503. /**
  7504. * Creates a new device orientation camera
  7505. * @param name The name of the camera
  7506. * @param position The start position camera
  7507. * @param scene The scene the camera belongs to
  7508. */
  7509. constructor(name: string, position: Vector3, scene: Scene);
  7510. /**
  7511. * Gets the current instance class name ("DeviceOrientationCamera").
  7512. * This helps avoiding instanceof at run time.
  7513. * @returns the class name
  7514. */
  7515. getClassName(): string;
  7516. /**
  7517. * @hidden
  7518. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  7519. */
  7520. /**
  7521. * Reset the camera to its default orientation on the specified axis only.
  7522. * @param axis The axis to reset
  7523. */
  7524. resetToCurrentRotation(axis?: Axis): void;
  7525. }
  7526. }
  7527. declare module BABYLON {
  7528. /**
  7529. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  7530. * an arc rotate version arcFollowCamera are available.
  7531. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  7532. */
  7533. class FollowCamera extends TargetCamera {
  7534. /**
  7535. * Distance the follow camera should follow an object at
  7536. */
  7537. radius: number;
  7538. /**
  7539. * Define a rotation offset between the camera and the object it follows
  7540. */
  7541. rotationOffset: number;
  7542. /**
  7543. * Define a height offset between the camera and the object it follows.
  7544. * It can help following an object from the top (like a car chaing a plane)
  7545. */
  7546. heightOffset: number;
  7547. /**
  7548. * Define how fast the camera can accelerate to follow it s target.
  7549. */
  7550. cameraAcceleration: number;
  7551. /**
  7552. * Define the speed limit of the camera following an object.
  7553. */
  7554. maxCameraSpeed: number;
  7555. /**
  7556. * Define the target of the camera.
  7557. */
  7558. lockedTarget: Nullable<AbstractMesh>;
  7559. /**
  7560. * Instantiates the follow camera.
  7561. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  7562. * @param name Define the name of the camera in the scene
  7563. * @param position Define the position of the camera
  7564. * @param scene Define the scene the camera belong to
  7565. * @param lockedTarget Define the target of the camera
  7566. */
  7567. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  7568. private _follow;
  7569. /** @hidden */
  7570. /**
  7571. * Gets the camera class name.
  7572. * @returns the class name
  7573. */
  7574. getClassName(): string;
  7575. }
  7576. /**
  7577. * Arc Rotate version of the follow camera.
  7578. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  7579. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  7580. */
  7581. class ArcFollowCamera extends TargetCamera {
  7582. /** The longitudinal angle of the camera */
  7583. alpha: number;
  7584. /** The latitudinal angle of the camera */
  7585. beta: number;
  7586. /** The radius of the camera from its target */
  7587. radius: number;
  7588. /** Define the camera target (the messh it should follow) */
  7589. target: Nullable<AbstractMesh>;
  7590. private _cartesianCoordinates;
  7591. /**
  7592. * Instantiates a new ArcFollowCamera
  7593. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  7594. * @param name Define the name of the camera
  7595. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  7596. * @param beta Define the rotation angle of the camera around the elevation axis
  7597. * @param radius Define the radius of the camera from its target point
  7598. * @param target Define the target of the camera
  7599. * @param scene Define the scene the camera belongs to
  7600. */
  7601. constructor(name: string,
  7602. /** The longitudinal angle of the camera */
  7603. alpha: number,
  7604. /** The latitudinal angle of the camera */
  7605. beta: number,
  7606. /** The radius of the camera from its target */
  7607. radius: number,
  7608. /** Define the camera target (the messh it should follow) */
  7609. target: Nullable<AbstractMesh>, scene: Scene);
  7610. private _follow;
  7611. /** @hidden */
  7612. /**
  7613. * Returns the class name of the object.
  7614. * It is mostly used internally for serialization purposes.
  7615. */
  7616. getClassName(): string;
  7617. }
  7618. }
  7619. declare module BABYLON {
  7620. /**
  7621. * This represents a free type of camera. It can be usefull in First Person Shooter game for instance.
  7622. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  7623. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  7624. */
  7625. class FreeCamera extends TargetCamera {
  7626. /**
  7627. * Define the collision ellipsoid of the camera.
  7628. * This is helpful to simulate a camera body like the player body around the camera
  7629. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  7630. */
  7631. ellipsoid: Vector3;
  7632. /**
  7633. * Define an offset for the position of the ellipsoid around the camera.
  7634. * This can be helpful to determine the center of the body near the gravity center of the body
  7635. * instead of its head.
  7636. */
  7637. ellipsoidOffset: Vector3;
  7638. /**
  7639. * Enable or disable collisions of the camera with the rest of the scene objects.
  7640. */
  7641. checkCollisions: boolean;
  7642. /**
  7643. * Enable or disable gravity on the camera.
  7644. */
  7645. applyGravity: boolean;
  7646. /**
  7647. * Define the input manager associated to the camera.
  7648. */
  7649. inputs: FreeCameraInputsManager;
  7650. /**
  7651. * Gets the input sensibility for a mouse input. (default is 2000.0)
  7652. * Higher values reduce sensitivity.
  7653. */
  7654. /**
  7655. * Sets the input sensibility for a mouse input. (default is 2000.0)
  7656. * Higher values reduce sensitivity.
  7657. */
  7658. angularSensibility: number;
  7659. /**
  7660. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  7661. */
  7662. keysUp: number[];
  7663. /**
  7664. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  7665. */
  7666. keysDown: number[];
  7667. /**
  7668. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  7669. */
  7670. keysLeft: number[];
  7671. /**
  7672. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  7673. */
  7674. keysRight: number[];
  7675. /**
  7676. * Event raised when the camera collide with a mesh in the scene.
  7677. */
  7678. onCollide: (collidedMesh: AbstractMesh) => void;
  7679. private _collider;
  7680. private _needMoveForGravity;
  7681. private _oldPosition;
  7682. private _diffPosition;
  7683. private _newPosition;
  7684. /** @hidden */
  7685. /** @hidden */
  7686. /**
  7687. * Instantiates a Free Camera.
  7688. * This represents a free type of camera. It can be usefull in First Person Shooter game for instance.
  7689. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  7690. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  7691. * @param name Define the name of the camera in the scene
  7692. * @param position Define the start position of the camera in the scene
  7693. * @param scene Define the scene the camera belongs to
  7694. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  7695. */
  7696. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  7697. /**
  7698. * Attached controls to the current camera.
  7699. * @param element Defines the element the controls should be listened from
  7700. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  7701. */
  7702. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  7703. /**
  7704. * Detach the current controls from the camera.
  7705. * The camera will stop reacting to inputs.
  7706. * @param element Defines the element to stop listening the inputs from
  7707. */
  7708. detachControl(element: HTMLElement): void;
  7709. private _collisionMask;
  7710. /**
  7711. * Define a collision mask to limit the list of object the camera can collide with
  7712. */
  7713. collisionMask: number;
  7714. /** @hidden */
  7715. private _onCollisionPositionChange;
  7716. /** @hidden */
  7717. /** @hidden */
  7718. /** @hidden */
  7719. /**
  7720. * Destroy the camera and release the current resources hold by it.
  7721. */
  7722. dispose(): void;
  7723. /**
  7724. * Gets the current object class name.
  7725. * @return the class name
  7726. */
  7727. getClassName(): string;
  7728. }
  7729. }
  7730. declare module BABYLON {
  7731. /**
  7732. * Default Inputs manager for the FreeCamera.
  7733. * It groups all the default supported inputs for ease of use.
  7734. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  7735. */
  7736. class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  7737. /**
  7738. * Instantiates a new FreeCameraInputsManager.
  7739. * @param camera Defines the camera the inputs belong to
  7740. */
  7741. constructor(camera: FreeCamera);
  7742. /**
  7743. * Add keyboard input support to the input manager.
  7744. * @returns the current input manager
  7745. */
  7746. addKeyboard(): FreeCameraInputsManager;
  7747. /**
  7748. * Add mouse input support to the input manager.
  7749. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  7750. * @returns the current input manager
  7751. */
  7752. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  7753. /**
  7754. * Add orientation input support to the input manager.
  7755. * @returns the current input manager
  7756. */
  7757. addDeviceOrientation(): FreeCameraInputsManager;
  7758. /**
  7759. * Add touch input support to the input manager.
  7760. * @returns the current input manager
  7761. */
  7762. addTouch(): FreeCameraInputsManager;
  7763. /**
  7764. * Add virtual joystick input support to the input manager.
  7765. * @returns the current input manager
  7766. */
  7767. addVirtualJoystick(): FreeCameraInputsManager;
  7768. }
  7769. }
  7770. declare module BABYLON {
  7771. /**
  7772. * This represents a FPS type of camera. This is only here for back compat purpose.
  7773. * Please use the UniversalCamera instead as both are identical.
  7774. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  7775. */
  7776. class GamepadCamera extends UniversalCamera {
  7777. /**
  7778. * Instantiates a new Gamepad Camera
  7779. * This represents a FPS type of camera. This is only here for back compat purpose.
  7780. * Please use the UniversalCamera instead as both are identical.
  7781. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  7782. * @param name Define the name of the camera in the scene
  7783. * @param position Define the start position of the camera in the scene
  7784. * @param scene Define the scene the camera belongs to
  7785. */
  7786. constructor(name: string, position: Vector3, scene: Scene);
  7787. /**
  7788. * Gets the current object class name.
  7789. * @return the class name
  7790. */
  7791. getClassName(): string;
  7792. }
  7793. }
  7794. declare module BABYLON {
  7795. /**
  7796. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  7797. * This is the base of the follow, arc rotate cameras and Free camera
  7798. * @see http://doc.babylonjs.com/features/cameras
  7799. */
  7800. class TargetCamera extends Camera {
  7801. /**
  7802. * Define the current direction the camera is moving to
  7803. */
  7804. cameraDirection: Vector3;
  7805. /**
  7806. * Define the current rotation the camera is rotating to
  7807. */
  7808. cameraRotation: Vector2;
  7809. /**
  7810. * Define the current rotation of the camera
  7811. */
  7812. rotation: Vector3;
  7813. /**
  7814. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  7815. */
  7816. rotationQuaternion: Quaternion;
  7817. /**
  7818. * Define the current speed of the camera
  7819. */
  7820. speed: number;
  7821. /**
  7822. * Add cconstraint to the camera to prevent it to move freely in all directions and
  7823. * around all axis.
  7824. */
  7825. noRotationConstraint: boolean;
  7826. /**
  7827. * Define the current target of the camera as an object or a position.
  7828. */
  7829. lockedTarget: any;
  7830. /** @hidden */
  7831. /** @hidden */
  7832. /** @hidden */
  7833. /** @hidden */
  7834. /** @hidden */
  7835. private _rigCamTransformMatrix;
  7836. /** @hidden */
  7837. /** @hidden */
  7838. protected _globalCurrentTarget: Vector3;
  7839. protected _globalCurrentUpVector: Vector3;
  7840. /** @hidden */
  7841. private _defaultUp;
  7842. /**
  7843. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  7844. * This is the base of the follow, arc rotate cameras and Free camera
  7845. * @see http://doc.babylonjs.com/features/cameras
  7846. * @param name Defines the name of the camera in the scene
  7847. * @param position Defines the start position of the camera in the scene
  7848. * @param scene Defines the scene the camera belongs to
  7849. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  7850. */
  7851. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  7852. /**
  7853. * Gets the position in front of the camera at a given distance.
  7854. * @param distance The distance from the camera we want the position to be
  7855. * @returns the position
  7856. */
  7857. getFrontPosition(distance: number): Vector3;
  7858. /** @hidden */
  7859. private _storedPosition;
  7860. private _storedRotation;
  7861. private _storedRotationQuaternion;
  7862. /**
  7863. * Store current camera state of the camera (fov, position, rotation, etc..)
  7864. * @returns the camera
  7865. */
  7866. storeState(): Camera;
  7867. /**
  7868. * Restored camera state. You must call storeState() first
  7869. * @returns whether it was successful or not
  7870. * @hidden
  7871. */
  7872. /** @hidden */
  7873. /** @hidden */
  7874. /** @hidden */
  7875. /** @hidden */
  7876. /** @hidden */
  7877. setTarget(target: Vector3): void;
  7878. /**
  7879. * Return the current target position of the camera. This value is expressed in local space.
  7880. * @returns the target position
  7881. */
  7882. getTarget(): Vector3;
  7883. /** @hidden */
  7884. /** @hidden */
  7885. /** @hidden */
  7886. protected _updateCameraRotationMatrix(): void;
  7887. /**
  7888. * 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)
  7889. * @returns the current camera
  7890. */
  7891. private _rotateUpVectorWithCameraRotationMatrix;
  7892. private _cachedRotationZ;
  7893. private _cachedQuaternionRotationZ;
  7894. /** @hidden */
  7895. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  7896. /**
  7897. * @hidden
  7898. */
  7899. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  7900. /**
  7901. * @hidden
  7902. */
  7903. private _getRigCamPosition;
  7904. /**
  7905. * Gets the current object class name.
  7906. * @return the class name
  7907. */
  7908. getClassName(): string;
  7909. }
  7910. }
  7911. declare module BABYLON {
  7912. /**
  7913. * This represents a FPS type of camera controlled by touch.
  7914. * This is like a universal camera minus the Gamepad controls.
  7915. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  7916. */
  7917. class TouchCamera extends FreeCamera {
  7918. /**
  7919. * Defines the touch sensibility for rotation.
  7920. * The higher the faster.
  7921. */
  7922. touchAngularSensibility: number;
  7923. /**
  7924. * Defines the touch sensibility for move.
  7925. * The higher the faster.
  7926. */
  7927. touchMoveSensibility: number;
  7928. /**
  7929. * Instantiates a new touch camera.
  7930. * This represents a FPS type of camera controlled by touch.
  7931. * This is like a universal camera minus the Gamepad controls.
  7932. * @see http://doc.babylonjs.com/features/cameras#universal-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. /** @hidden */
  7944. }
  7945. }
  7946. declare module BABYLON {
  7947. /**
  7948. * 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,
  7949. * which still works and will still be found in many Playgrounds.
  7950. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  7951. */
  7952. class UniversalCamera extends TouchCamera {
  7953. /**
  7954. * Defines the gamepad rotation sensiblity.
  7955. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  7956. */
  7957. gamepadAngularSensibility: number;
  7958. /**
  7959. * Defines the gamepad move sensiblity.
  7960. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  7961. */
  7962. gamepadMoveSensibility: number;
  7963. /**
  7964. * 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,
  7965. * which still works and will still be found in many Playgrounds.
  7966. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  7967. * @param name Define the name of the camera in the scene
  7968. * @param position Define the start position of the camera in the scene
  7969. * @param scene Define the scene the camera belongs to
  7970. */
  7971. constructor(name: string, position: Vector3, scene: Scene);
  7972. /**
  7973. * Gets the current object class name.
  7974. * @return the class name
  7975. */
  7976. getClassName(): string;
  7977. }
  7978. }
  7979. declare module BABYLON {
  7980. /**
  7981. * This represents a free type of camera. It can be usefull in First Person Shooter game for instance.
  7982. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  7983. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  7984. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  7985. */
  7986. class VirtualJoysticksCamera extends FreeCamera {
  7987. /**
  7988. * Intantiates a VirtualJoysticksCamera. It can be usefull in First Person Shooter game for instance.
  7989. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  7990. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  7991. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  7992. * @param name Define the name of the camera in the scene
  7993. * @param position Define the start position of the camera in the scene
  7994. * @param scene Define the scene the camera belongs to
  7995. */
  7996. constructor(name: string, position: Vector3, scene: Scene);
  7997. /**
  7998. * Gets the current object class name.
  7999. * @return the class name
  8000. */
  8001. getClassName(): string;
  8002. }
  8003. }
  8004. interface VRDisplay extends EventTarget {
  8005. /**
  8006. * Dictionary of capabilities describing the VRDisplay.
  8007. */
  8008. readonly capabilities: VRDisplayCapabilities;
  8009. /**
  8010. * z-depth defining the far plane of the eye view frustum
  8011. * enables mapping of values in the render target depth
  8012. * attachment to scene coordinates. Initially set to 10000.0.
  8013. */
  8014. depthFar: number;
  8015. /**
  8016. * z-depth defining the near plane of the eye view frustum
  8017. * enables mapping of values in the render target depth
  8018. * attachment to scene coordinates. Initially set to 0.01.
  8019. */
  8020. depthNear: number;
  8021. /**
  8022. * An identifier for this distinct VRDisplay. Used as an
  8023. * association point in the Gamepad API.
  8024. */
  8025. readonly displayId: number;
  8026. /**
  8027. * A display name, a user-readable name identifying it.
  8028. */
  8029. readonly displayName: string;
  8030. readonly isConnected: boolean;
  8031. readonly isPresenting: boolean;
  8032. /**
  8033. * If this VRDisplay supports room-scale experiences, the optional
  8034. * stage attribute contains details on the room-scale parameters.
  8035. */
  8036. readonly stageParameters: VRStageParameters | null;
  8037. /**
  8038. * Passing the value returned by `requestAnimationFrame` to
  8039. * `cancelAnimationFrame` will unregister the callback.
  8040. * @param handle Define the hanle of the request to cancel
  8041. */
  8042. cancelAnimationFrame(handle: number): void;
  8043. /**
  8044. * Stops presenting to the VRDisplay.
  8045. * @returns a promise to know when it stopped
  8046. */
  8047. exitPresent(): Promise<void>;
  8048. /**
  8049. * Return the current VREyeParameters for the given eye.
  8050. * @param whichEye Define the eye we want the parameter for
  8051. * @returns the eye parameters
  8052. */
  8053. getEyeParameters(whichEye: string): VREyeParameters;
  8054. /**
  8055. * Populates the passed VRFrameData with the information required to render
  8056. * the current frame.
  8057. * @param frameData Define the data structure to populate
  8058. * @returns true if ok otherwise false
  8059. */
  8060. getFrameData(frameData: VRFrameData): boolean;
  8061. /**
  8062. * Get the layers currently being presented.
  8063. * @returns the list of VR layers
  8064. */
  8065. getLayers(): VRLayer[];
  8066. /**
  8067. * Return a VRPose containing the future predicted pose of the VRDisplay
  8068. * when the current frame will be presented. The value returned will not
  8069. * change until JavaScript has returned control to the browser.
  8070. *
  8071. * The VRPose will contain the position, orientation, velocity,
  8072. * and acceleration of each of these properties.
  8073. * @returns the pose object
  8074. */
  8075. getPose(): VRPose;
  8076. /**
  8077. * Return the current instantaneous pose of the VRDisplay, with no
  8078. * prediction applied.
  8079. * @returns the current instantaneous pose
  8080. */
  8081. getImmediatePose(): VRPose;
  8082. /**
  8083. * The callback passed to `requestAnimationFrame` will be called
  8084. * any time a new frame should be rendered. When the VRDisplay is
  8085. * presenting the callback will be called at the native refresh
  8086. * rate of the HMD. When not presenting this function acts
  8087. * identically to how window.requestAnimationFrame acts. Content should
  8088. * make no assumptions of frame rate or vsync behavior as the HMD runs
  8089. * asynchronously from other displays and at differing refresh rates.
  8090. * @param callback Define the eaction to run next frame
  8091. * @returns the request handle it
  8092. */
  8093. requestAnimationFrame(callback: FrameRequestCallback): number;
  8094. /**
  8095. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  8096. * Repeat calls while already presenting will update the VRLayers being displayed.
  8097. * @param layers Define the list of layer to present
  8098. * @returns a promise to know when the request has been fulfilled
  8099. */
  8100. requestPresent(layers: VRLayer[]): Promise<void>;
  8101. /**
  8102. * Reset the pose for this display, treating its current position and
  8103. * orientation as the "origin/zero" values. VRPose.position,
  8104. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  8105. * updated when calling resetPose(). This should be called in only
  8106. * sitting-space experiences.
  8107. */
  8108. resetPose(): void;
  8109. /**
  8110. * The VRLayer provided to the VRDisplay will be captured and presented
  8111. * in the HMD. Calling this function has the same effect on the source
  8112. * canvas as any other operation that uses its source image, and canvases
  8113. * created without preserveDrawingBuffer set to true will be cleared.
  8114. * @param pose Define the pose to submit
  8115. */
  8116. submitFrame(pose?: VRPose): void;
  8117. }
  8118. declare var VRDisplay: {
  8119. prototype: VRDisplay;
  8120. new (): VRDisplay;
  8121. };
  8122. interface VRLayer {
  8123. leftBounds?: number[] | Float32Array | null;
  8124. rightBounds?: number[] | Float32Array | null;
  8125. source?: HTMLCanvasElement | null;
  8126. }
  8127. interface VRDisplayCapabilities {
  8128. readonly canPresent: boolean;
  8129. readonly hasExternalDisplay: boolean;
  8130. readonly hasOrientation: boolean;
  8131. readonly hasPosition: boolean;
  8132. readonly maxLayers: number;
  8133. }
  8134. interface VREyeParameters {
  8135. /** @deprecated */
  8136. readonly fieldOfView: VRFieldOfView;
  8137. readonly offset: Float32Array;
  8138. readonly renderHeight: number;
  8139. readonly renderWidth: number;
  8140. }
  8141. interface VRFieldOfView {
  8142. readonly downDegrees: number;
  8143. readonly leftDegrees: number;
  8144. readonly rightDegrees: number;
  8145. readonly upDegrees: number;
  8146. }
  8147. interface VRFrameData {
  8148. readonly leftProjectionMatrix: Float32Array;
  8149. readonly leftViewMatrix: Float32Array;
  8150. readonly pose: VRPose;
  8151. readonly rightProjectionMatrix: Float32Array;
  8152. readonly rightViewMatrix: Float32Array;
  8153. readonly timestamp: number;
  8154. }
  8155. interface VRPose {
  8156. readonly angularAcceleration: Float32Array | null;
  8157. readonly angularVelocity: Float32Array | null;
  8158. readonly linearAcceleration: Float32Array | null;
  8159. readonly linearVelocity: Float32Array | null;
  8160. readonly orientation: Float32Array | null;
  8161. readonly position: Float32Array | null;
  8162. readonly timestamp: number;
  8163. }
  8164. interface VRStageParameters {
  8165. sittingToStandingTransform?: Float32Array;
  8166. sizeX?: number;
  8167. sizeY?: number;
  8168. }
  8169. interface Navigator {
  8170. getVRDisplays(): Promise<VRDisplay[]>;
  8171. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  8172. }
  8173. interface Window {
  8174. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  8175. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  8176. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  8177. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  8178. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  8179. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  8180. }
  8181. interface Gamepad {
  8182. readonly displayId: number;
  8183. }
  8184. declare module BABYLON {
  8185. /** @hidden */
  8186. class Collider {
  8187. /** Define if a collision was found */
  8188. collisionFound: boolean;
  8189. /**
  8190. * Define last intersection point in local space
  8191. */
  8192. intersectionPoint: Vector3;
  8193. /**
  8194. * Define last collided mesh
  8195. */
  8196. collidedMesh: Nullable<AbstractMesh>;
  8197. private _collisionPoint;
  8198. private _planeIntersectionPoint;
  8199. private _tempVector;
  8200. private _tempVector2;
  8201. private _tempVector3;
  8202. private _tempVector4;
  8203. private _edge;
  8204. private _baseToVertex;
  8205. private _destinationPoint;
  8206. private _slidePlaneNormal;
  8207. private _displacementVector;
  8208. /** @hidden */
  8209. /** @hidden */
  8210. private _velocity;
  8211. private _basePoint;
  8212. private _epsilon;
  8213. /** @hidden */
  8214. /** @hidden */
  8215. private _velocityWorld;
  8216. private _normalizedVelocity;
  8217. /** @hidden */
  8218. /** @hidden */
  8219. private _nearestDistance;
  8220. private _collisionMask;
  8221. collisionMask: number;
  8222. /**
  8223. * Gets the plane normal used to compute the sliding response (in local space)
  8224. */
  8225. readonly slidePlaneNormal: Vector3;
  8226. /** @hidden */
  8227. /** @hidden */
  8228. /** @hidden */
  8229. /** @hidden */
  8230. /** @hidden */
  8231. /** @hidden */
  8232. }
  8233. }
  8234. declare module BABYLON {
  8235. /** @hidden */
  8236. var CollisionWorker: string;
  8237. /** @hidden */
  8238. interface ICollisionCoordinator {
  8239. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  8240. init(scene: Scene): void;
  8241. destroy(): void;
  8242. onMeshAdded(mesh: AbstractMesh): void;
  8243. onMeshUpdated(mesh: AbstractMesh): void;
  8244. onMeshRemoved(mesh: AbstractMesh): void;
  8245. onGeometryAdded(geometry: Geometry): void;
  8246. onGeometryUpdated(geometry: Geometry): void;
  8247. onGeometryDeleted(geometry: Geometry): void;
  8248. }
  8249. /** @hidden */
  8250. interface SerializedMesh {
  8251. id: string;
  8252. name: string;
  8253. uniqueId: number;
  8254. geometryId: Nullable<string>;
  8255. sphereCenter: Array<number>;
  8256. sphereRadius: number;
  8257. boxMinimum: Array<number>;
  8258. boxMaximum: Array<number>;
  8259. worldMatrixFromCache: any;
  8260. subMeshes: Array<SerializedSubMesh>;
  8261. checkCollisions: boolean;
  8262. }
  8263. /** @hidden */
  8264. interface SerializedSubMesh {
  8265. position: number;
  8266. verticesStart: number;
  8267. verticesCount: number;
  8268. indexStart: number;
  8269. indexCount: number;
  8270. hasMaterial: boolean;
  8271. sphereCenter: Array<number>;
  8272. sphereRadius: number;
  8273. boxMinimum: Array<number>;
  8274. boxMaximum: Array<number>;
  8275. }
  8276. /**
  8277. * Interface describing the value associated with a geometry.
  8278. * @hidden
  8279. */
  8280. interface SerializedGeometry {
  8281. /**
  8282. * Defines the unique ID of the geometry
  8283. */
  8284. id: string;
  8285. /**
  8286. * Defines the array containing the positions
  8287. */
  8288. positions: Float32Array;
  8289. /**
  8290. * Defines the array containing the indices
  8291. */
  8292. indices: Uint32Array;
  8293. /**
  8294. * Defines the array containing the normals
  8295. */
  8296. normals: Float32Array;
  8297. }
  8298. /** @hidden */
  8299. interface BabylonMessage {
  8300. taskType: WorkerTaskType;
  8301. payload: InitPayload | CollidePayload | UpdatePayload;
  8302. }
  8303. /** @hidden */
  8304. interface SerializedColliderToWorker {
  8305. position: Array<number>;
  8306. velocity: Array<number>;
  8307. radius: Array<number>;
  8308. }
  8309. /** Defines supported task for worker process */
  8310. enum WorkerTaskType {
  8311. /** Initialization */
  8312. INIT = 0,
  8313. /** Update of geometry */
  8314. UPDATE = 1,
  8315. /** Evaluate collision */
  8316. COLLIDE = 2
  8317. }
  8318. /** @hidden */
  8319. interface WorkerReply {
  8320. error: WorkerReplyType;
  8321. taskType: WorkerTaskType;
  8322. payload?: any;
  8323. }
  8324. /** @hidden */
  8325. interface CollisionReplyPayload {
  8326. newPosition: Array<number>;
  8327. collisionId: number;
  8328. collidedMeshUniqueId: number;
  8329. }
  8330. /** @hidden */
  8331. interface InitPayload {
  8332. }
  8333. /** @hidden */
  8334. interface CollidePayload {
  8335. collisionId: number;
  8336. collider: SerializedColliderToWorker;
  8337. maximumRetry: number;
  8338. excludedMeshUniqueId: Nullable<number>;
  8339. }
  8340. /** @hidden */
  8341. interface UpdatePayload {
  8342. updatedMeshes: {
  8343. [n: number]: SerializedMesh;
  8344. };
  8345. updatedGeometries: {
  8346. [s: string]: SerializedGeometry;
  8347. };
  8348. removedMeshes: Array<number>;
  8349. removedGeometries: Array<string>;
  8350. }
  8351. /** Defines kind of replies returned by worker */
  8352. enum WorkerReplyType {
  8353. /** Success */
  8354. SUCCESS = 0,
  8355. /** Unkown error */
  8356. UNKNOWN_ERROR = 1
  8357. }
  8358. /** @hidden */
  8359. class CollisionCoordinatorWorker implements ICollisionCoordinator {
  8360. private _scene;
  8361. private _scaledPosition;
  8362. private _scaledVelocity;
  8363. private _collisionsCallbackArray;
  8364. private _init;
  8365. private _runningUpdated;
  8366. private _worker;
  8367. private _addUpdateMeshesList;
  8368. private _addUpdateGeometriesList;
  8369. private _toRemoveMeshesArray;
  8370. private _toRemoveGeometryArray;
  8371. constructor();
  8372. static SerializeMesh: (mesh: AbstractMesh) => SerializedMesh;
  8373. static SerializeGeometry: (geometry: Geometry) => SerializedGeometry;
  8374. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  8375. init(scene: Scene): void;
  8376. destroy(): void;
  8377. onMeshAdded(mesh: AbstractMesh): void;
  8378. onMeshUpdated: (transformNode: TransformNode) => void;
  8379. onMeshRemoved(mesh: AbstractMesh): void;
  8380. onGeometryAdded(geometry: Geometry): void;
  8381. onGeometryUpdated: (geometry: Geometry) => void;
  8382. onGeometryDeleted(geometry: Geometry): void;
  8383. private _afterRender;
  8384. private _onMessageFromWorker;
  8385. }
  8386. /** @hidden */
  8387. class CollisionCoordinatorLegacy implements ICollisionCoordinator {
  8388. private _scene;
  8389. private _scaledPosition;
  8390. private _scaledVelocity;
  8391. private _finalPosition;
  8392. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  8393. init(scene: Scene): void;
  8394. destroy(): void;
  8395. onMeshAdded(mesh: AbstractMesh): void;
  8396. onMeshUpdated(mesh: AbstractMesh): void;
  8397. onMeshRemoved(mesh: AbstractMesh): void;
  8398. onGeometryAdded(geometry: Geometry): void;
  8399. onGeometryUpdated(geometry: Geometry): void;
  8400. onGeometryDeleted(geometry: Geometry): void;
  8401. private _collideWithWorld;
  8402. }
  8403. }
  8404. declare function importScripts(...urls: string[]): void;
  8405. declare const safePostMessage: any;
  8406. declare module BABYLON {
  8407. /** @hidden */
  8408. var WorkerIncluded: boolean;
  8409. /** @hidden */
  8410. class CollisionCache {
  8411. private _meshes;
  8412. private _geometries;
  8413. getMeshes(): {
  8414. [n: number]: SerializedMesh;
  8415. };
  8416. getGeometries(): {
  8417. [s: number]: SerializedGeometry;
  8418. };
  8419. getMesh(id: any): SerializedMesh;
  8420. addMesh(mesh: SerializedMesh): void;
  8421. removeMesh(uniqueId: number): void;
  8422. getGeometry(id: string): SerializedGeometry;
  8423. addGeometry(geometry: SerializedGeometry): void;
  8424. removeGeometry(id: string): void;
  8425. }
  8426. /** @hidden */
  8427. class CollideWorker {
  8428. collider: Collider;
  8429. private _collisionCache;
  8430. private finalPosition;
  8431. private collisionsScalingMatrix;
  8432. private collisionTranformationMatrix;
  8433. constructor(collider: Collider, _collisionCache: CollisionCache, finalPosition: Vector3);
  8434. collideWithWorld(position: Vector3, velocity: Vector3, maximumRetry: number, excludedMeshUniqueId: Nullable<number>): void;
  8435. private checkCollision;
  8436. private processCollisionsForSubMeshes;
  8437. private collideForSubMesh;
  8438. private checkSubmeshCollision;
  8439. }
  8440. /** @hidden */
  8441. interface ICollisionDetector {
  8442. onInit(payload: InitPayload): void;
  8443. onUpdate(payload: UpdatePayload): void;
  8444. onCollision(payload: CollidePayload): void;
  8445. }
  8446. /** @hidden */
  8447. class CollisionDetectorTransferable implements ICollisionDetector {
  8448. private _collisionCache;
  8449. onInit(payload: InitPayload): void;
  8450. onUpdate(payload: UpdatePayload): void;
  8451. onCollision(payload: CollidePayload): void;
  8452. }
  8453. }
  8454. declare module BABYLON {
  8455. /**
  8456. * @hidden
  8457. */
  8458. class IntersectionInfo {
  8459. bu: Nullable<number>;
  8460. bv: Nullable<number>;
  8461. distance: number;
  8462. faceId: number;
  8463. subMeshId: number;
  8464. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  8465. }
  8466. /**
  8467. * Information about the result of picking within a scene
  8468. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  8469. */
  8470. class PickingInfo {
  8471. /**
  8472. * If the pick collided with an object
  8473. */
  8474. hit: boolean;
  8475. /**
  8476. * Distance away where the pick collided
  8477. */
  8478. distance: number;
  8479. /**
  8480. * The location of pick collision
  8481. */
  8482. pickedPoint: Nullable<Vector3>;
  8483. /**
  8484. * The mesh corresponding the the pick collision
  8485. */
  8486. pickedMesh: Nullable<AbstractMesh>;
  8487. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  8488. bu: number;
  8489. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  8490. bv: number;
  8491. /** The id of the face on the mesh that was picked */
  8492. faceId: number;
  8493. /** Id of the the submesh that was picked */
  8494. subMeshId: number;
  8495. /** If a sprite was picked, this will be the sprite the pick collided with */
  8496. pickedSprite: Nullable<Sprite>;
  8497. /**
  8498. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  8499. */
  8500. originMesh: Nullable<AbstractMesh>;
  8501. /**
  8502. * The ray that was used to perform the picking.
  8503. */
  8504. ray: Nullable<Ray>;
  8505. /**
  8506. * Gets the normal correspodning to the face the pick collided with
  8507. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  8508. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  8509. * @returns The normal correspodning to the face the pick collided with
  8510. */
  8511. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  8512. /**
  8513. * Gets the texture coordinates of where the pick occured
  8514. * @returns the vector containing the coordnates of the texture
  8515. */
  8516. getTextureCoordinates(): Nullable<Vector2>;
  8517. }
  8518. }
  8519. declare module BABYLON {
  8520. /**
  8521. * Class used to store bounding box information
  8522. */
  8523. class BoundingBox implements ICullable {
  8524. /**
  8525. * Gets the 8 vectors representing the bounding box in local space
  8526. */
  8527. vectors: Vector3[];
  8528. /**
  8529. * Gets the center of the bounding box in local space
  8530. */
  8531. center: Vector3;
  8532. /**
  8533. * Gets the center of the bounding box in world space
  8534. */
  8535. centerWorld: Vector3;
  8536. /**
  8537. * Gets the extend size in local space
  8538. */
  8539. extendSize: Vector3;
  8540. /**
  8541. * Gets the extend size in world space
  8542. */
  8543. extendSizeWorld: Vector3;
  8544. /**
  8545. * Gets the OBB (object bounding box) directions
  8546. */
  8547. directions: Vector3[];
  8548. /**
  8549. * Gets the 8 vectors representing the bounding box in world space
  8550. */
  8551. vectorsWorld: Vector3[];
  8552. /**
  8553. * Gets the minimum vector in world space
  8554. */
  8555. minimumWorld: Vector3;
  8556. /**
  8557. * Gets the maximum vector in world space
  8558. */
  8559. maximumWorld: Vector3;
  8560. /**
  8561. * Gets the minimum vector in local space
  8562. */
  8563. minimum: Vector3;
  8564. /**
  8565. * Gets the maximum vector in local space
  8566. */
  8567. maximum: Vector3;
  8568. private _worldMatrix;
  8569. /**
  8570. * @hidden
  8571. */
  8572. /**
  8573. * Creates a new bounding box
  8574. * @param min defines the minimum vector (in local space)
  8575. * @param max defines the maximum vector (in local space)
  8576. */
  8577. constructor(min: Vector3, max: Vector3);
  8578. /**
  8579. * Recreates the entire bounding box from scratch
  8580. * @param min defines the new minimum vector (in local space)
  8581. * @param max defines the new maximum vector (in local space)
  8582. */
  8583. reConstruct(min: Vector3, max: Vector3): void;
  8584. /**
  8585. * Scale the current bounding box by applying a scale factor
  8586. * @param factor defines the scale factor to apply
  8587. * @returns the current bounding box
  8588. */
  8589. scale(factor: number): BoundingBox;
  8590. /**
  8591. * Gets the world matrix of the bounding box
  8592. * @returns a matrix
  8593. */
  8594. getWorldMatrix(): Matrix;
  8595. /**
  8596. * Sets the world matrix stored in the bounding box
  8597. * @param matrix defines the matrix to store
  8598. * @returns current bounding box
  8599. */
  8600. setWorldMatrix(matrix: Matrix): BoundingBox;
  8601. /** @hidden */
  8602. /**
  8603. * Tests if the bounding box is intersecting the frustum planes
  8604. * @param frustumPlanes defines the frustum planes to test
  8605. * @returns true if there is an intersection
  8606. */
  8607. isInFrustum(frustumPlanes: Plane[]): boolean;
  8608. /**
  8609. * Tests if the bounding box is entirely inside the frustum planes
  8610. * @param frustumPlanes defines the frustum planes to test
  8611. * @returns true if there is an inclusion
  8612. */
  8613. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  8614. /**
  8615. * Tests if a point is inside the bounding box
  8616. * @param point defines the point to test
  8617. * @returns true if the point is inside the bounding box
  8618. */
  8619. intersectsPoint(point: Vector3): boolean;
  8620. /**
  8621. * Tests if the bounding box intersects with a bounding sphere
  8622. * @param sphere defines the sphere to test
  8623. * @returns true if there is an intersection
  8624. */
  8625. intersectsSphere(sphere: BoundingSphere): boolean;
  8626. /**
  8627. * Tests if the bounding box intersects with a box defined by a min and max vectors
  8628. * @param min defines the min vector to use
  8629. * @param max defines the max vector to use
  8630. * @returns true if there is an intersection
  8631. */
  8632. intersectsMinMax(min: Vector3, max: Vector3): boolean;
  8633. /**
  8634. * Tests if two bounding boxes are intersections
  8635. * @param box0 defines the first box to test
  8636. * @param box1 defines the second box to test
  8637. * @returns true if there is an intersection
  8638. */
  8639. static Intersects(box0: BoundingBox, box1: BoundingBox): boolean;
  8640. /**
  8641. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  8642. * @param minPoint defines the minimum vector of the bounding box
  8643. * @param maxPoint defines the maximum vector of the bounding box
  8644. * @param sphereCenter defines the sphere center
  8645. * @param sphereRadius defines the sphere radius
  8646. * @returns true if there is an intersection
  8647. */
  8648. static IntersectsSphere(minPoint: Vector3, maxPoint: Vector3, sphereCenter: Vector3, sphereRadius: number): boolean;
  8649. /**
  8650. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  8651. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  8652. * @param frustumPlanes defines the frustum planes to test
  8653. * @return true if there is an inclusion
  8654. */
  8655. static IsCompletelyInFrustum(boundingVectors: Vector3[], frustumPlanes: Plane[]): boolean;
  8656. /**
  8657. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  8658. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  8659. * @param frustumPlanes defines the frustum planes to test
  8660. * @return true if there is an intersection
  8661. */
  8662. static IsInFrustum(boundingVectors: Vector3[], frustumPlanes: Plane[]): boolean;
  8663. }
  8664. }
  8665. declare module BABYLON {
  8666. /**
  8667. * Interface for cullable objects
  8668. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  8669. */
  8670. interface ICullable {
  8671. /**
  8672. * Checks if the object or part of the object is in the frustum
  8673. * @param frustumPlanes Camera near/planes
  8674. * @returns true if the object is in frustum otherwise false
  8675. */
  8676. isInFrustum(frustumPlanes: Plane[]): boolean;
  8677. /**
  8678. * Checks if a cullable object (mesh...) is in the camera frustum
  8679. * Unlike isInFrustum this cheks the full bounding box
  8680. * @param frustumPlanes Camera near/planes
  8681. * @returns true if the object is in frustum otherwise false
  8682. */
  8683. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  8684. }
  8685. /**
  8686. * Info for a bounding data of a mesh
  8687. */
  8688. class BoundingInfo implements ICullable {
  8689. /**
  8690. * Bounding box for the mesh
  8691. */
  8692. boundingBox: BoundingBox;
  8693. /**
  8694. * Bounding sphere for the mesh
  8695. */
  8696. boundingSphere: BoundingSphere;
  8697. private _isLocked;
  8698. /**
  8699. * Constructs bounding info
  8700. * @param minimum min vector of the bounding box/sphere
  8701. * @param maximum max vector of the bounding box/sphere
  8702. */
  8703. constructor(minimum: Vector3, maximum: Vector3);
  8704. /**
  8705. * min vector of the bounding box/sphere
  8706. */
  8707. readonly minimum: Vector3;
  8708. /**
  8709. * max vector of the bounding box/sphere
  8710. */
  8711. readonly maximum: Vector3;
  8712. /**
  8713. * If the info is locked and won't be updated to avoid perf overhead
  8714. */
  8715. isLocked: boolean;
  8716. /**
  8717. * Updates the boudning sphere and box
  8718. * @param world world matrix to be used to update
  8719. */
  8720. update(world: Matrix): void;
  8721. /**
  8722. * Recreate the bounding info to be centered around a specific point given a specific extend.
  8723. * @param center New center of the bounding info
  8724. * @param extend New extend of the bounding info
  8725. * @returns the current bounding info
  8726. */
  8727. centerOn(center: Vector3, extend: Vector3): BoundingInfo;
  8728. /**
  8729. * Scale the current bounding info by applying a scale factor
  8730. * @param factor defines the scale factor to apply
  8731. * @returns the current bounding info
  8732. */
  8733. scale(factor: number): BoundingInfo;
  8734. /**
  8735. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  8736. * @param frustumPlanes defines the frustum to test
  8737. * @param strategy defines the strategy to use for the culling (default is BABYLON.Scene.CULLINGSTRATEGY_STANDARD)
  8738. * @returns true if the bounding info is in the frustum planes
  8739. */
  8740. isInFrustum(frustumPlanes: Plane[], strategy?: number): boolean;
  8741. /**
  8742. * Gets the world distance between the min and max points of the bounding box
  8743. */
  8744. readonly diagonalLength: number;
  8745. /**
  8746. * Checks if a cullable object (mesh...) is in the camera frustum
  8747. * Unlike isInFrustum this cheks the full bounding box
  8748. * @param frustumPlanes Camera near/planes
  8749. * @returns true if the object is in frustum otherwise false
  8750. */
  8751. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  8752. /** @hidden */
  8753. /**
  8754. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  8755. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  8756. * @param point the point to check intersection with
  8757. * @returns if the point intersects
  8758. */
  8759. intersectsPoint(point: Vector3): boolean;
  8760. /**
  8761. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  8762. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  8763. * @param boundingInfo the bounding info to check intersection with
  8764. * @param precise if the intersection should be done using OBB
  8765. * @returns if the bounding info intersects
  8766. */
  8767. intersects(boundingInfo: BoundingInfo, precise: boolean): boolean;
  8768. }
  8769. }
  8770. declare module BABYLON {
  8771. /**
  8772. * Class used to store bounding sphere information
  8773. */
  8774. class BoundingSphere {
  8775. /**
  8776. * Gets the center of the bounding sphere in local space
  8777. */
  8778. center: Vector3;
  8779. /**
  8780. * Radius of the bounding sphere in local space
  8781. */
  8782. radius: number;
  8783. /**
  8784. * Gets the center of the bounding sphere in world space
  8785. */
  8786. centerWorld: Vector3;
  8787. /**
  8788. * Radius of the bounding sphere in world space
  8789. */
  8790. radiusWorld: number;
  8791. /**
  8792. * Gets the minimum vector in local space
  8793. */
  8794. minimum: Vector3;
  8795. /**
  8796. * Gets the maximum vector in local space
  8797. */
  8798. maximum: Vector3;
  8799. /**
  8800. * Creates a new bounding sphere
  8801. * @param min defines the minimum vector (in local space)
  8802. * @param max defines the maximum vector (in local space)
  8803. */
  8804. constructor(min: Vector3, max: Vector3);
  8805. /**
  8806. * Recreates the entire bounding sphere from scratch
  8807. * @param min defines the new minimum vector (in local space)
  8808. * @param max defines the new maximum vector (in local space)
  8809. */
  8810. reConstruct(min: Vector3, max: Vector3): void;
  8811. /**
  8812. * Scale the current bounding sphere by applying a scale factor
  8813. * @param factor defines the scale factor to apply
  8814. * @returns the current bounding box
  8815. */
  8816. scale(factor: number): BoundingSphere;
  8817. /** @hidden */
  8818. /**
  8819. * Tests if the bounding sphere is intersecting the frustum planes
  8820. * @param frustumPlanes defines the frustum planes to test
  8821. * @returns true if there is an intersection
  8822. */
  8823. isInFrustum(frustumPlanes: Plane[]): boolean;
  8824. /**
  8825. * Tests if a point is inside the bounding sphere
  8826. * @param point defines the point to test
  8827. * @returns true if the point is inside the bounding sphere
  8828. */
  8829. intersectsPoint(point: Vector3): boolean;
  8830. /**
  8831. * Checks if two sphere intersct
  8832. * @param sphere0 sphere 0
  8833. * @param sphere1 sphere 1
  8834. * @returns true if the speres intersect
  8835. */
  8836. static Intersects(sphere0: BoundingSphere, sphere1: BoundingSphere): boolean;
  8837. }
  8838. }
  8839. declare module BABYLON {
  8840. /**
  8841. * Class representing a ray with position and direction
  8842. */
  8843. class Ray {
  8844. /** origin point */
  8845. origin: Vector3;
  8846. /** direction */
  8847. direction: Vector3;
  8848. /** length of the ray */
  8849. length: number;
  8850. private _edge1;
  8851. private _edge2;
  8852. private _pvec;
  8853. private _tvec;
  8854. private _qvec;
  8855. private _tmpRay;
  8856. /**
  8857. * Creates a new ray
  8858. * @param origin origin point
  8859. * @param direction direction
  8860. * @param length length of the ray
  8861. */
  8862. constructor(
  8863. /** origin point */
  8864. origin: Vector3,
  8865. /** direction */
  8866. direction: Vector3,
  8867. /** length of the ray */
  8868. length?: number);
  8869. /**
  8870. * Checks if the ray intersects a box
  8871. * @param minimum bound of the box
  8872. * @param maximum bound of the box
  8873. * @returns if the box was hit
  8874. */
  8875. intersectsBoxMinMax(minimum: Vector3, maximum: Vector3): boolean;
  8876. /**
  8877. * Checks if the ray intersects a box
  8878. * @param box the bounding box to check
  8879. * @returns if the box was hit
  8880. */
  8881. intersectsBox(box: BoundingBox): boolean;
  8882. /**
  8883. * If the ray hits a sphere
  8884. * @param sphere the bounding sphere to check
  8885. * @returns true if it hits the sphere
  8886. */
  8887. intersectsSphere(sphere: BoundingSphere): boolean;
  8888. /**
  8889. * If the ray hits a triange
  8890. * @param vertex0 triangle vertex
  8891. * @param vertex1 triangle vertex
  8892. * @param vertex2 triangle vertex
  8893. * @returns intersection information if hit
  8894. */
  8895. intersectsTriangle(vertex0: Vector3, vertex1: Vector3, vertex2: Vector3): Nullable<IntersectionInfo>;
  8896. /**
  8897. * Checks if ray intersects a plane
  8898. * @param plane the plane to check
  8899. * @returns the distance away it was hit
  8900. */
  8901. intersectsPlane(plane: Plane): Nullable<number>;
  8902. /**
  8903. * Checks if ray intersects a mesh
  8904. * @param mesh the mesh to check
  8905. * @param fastCheck if only the bounding box should checked
  8906. * @returns picking info of the intersecton
  8907. */
  8908. intersectsMesh(mesh: AbstractMesh, fastCheck?: boolean): PickingInfo;
  8909. /**
  8910. * Checks if ray intersects a mesh
  8911. * @param meshes the meshes to check
  8912. * @param fastCheck if only the bounding box should checked
  8913. * @param results array to store result in
  8914. * @returns Array of picking infos
  8915. */
  8916. intersectsMeshes(meshes: Array<AbstractMesh>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  8917. private _comparePickingInfo;
  8918. private static smallnum;
  8919. private static rayl;
  8920. /**
  8921. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  8922. * @param sega the first point of the segment to test the intersection against
  8923. * @param segb the second point of the segment to test the intersection against
  8924. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  8925. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  8926. */
  8927. intersectionSegment(sega: Vector3, segb: Vector3, threshold: number): number;
  8928. /**
  8929. * Update the ray from viewport position
  8930. * @param x position
  8931. * @param y y position
  8932. * @param viewportWidth viewport width
  8933. * @param viewportHeight viewport height
  8934. * @param world world matrix
  8935. * @param view view matrix
  8936. * @param projection projection matrix
  8937. * @returns this ray updated
  8938. */
  8939. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Ray;
  8940. /**
  8941. * Creates a ray with origin and direction of 0,0,0
  8942. * @returns the new ray
  8943. */
  8944. static Zero(): Ray;
  8945. /**
  8946. * Creates a new ray from screen space and viewport
  8947. * @param x position
  8948. * @param y y position
  8949. * @param viewportWidth viewport width
  8950. * @param viewportHeight viewport height
  8951. * @param world world matrix
  8952. * @param view view matrix
  8953. * @param projection projection matrix
  8954. * @returns new ray
  8955. */
  8956. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Ray;
  8957. /**
  8958. * 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
  8959. * transformed to the given world matrix.
  8960. * @param origin The origin point
  8961. * @param end The end point
  8962. * @param world a matrix to transform the ray to. Default is the identity matrix.
  8963. * @returns the new ray
  8964. */
  8965. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: Matrix): Ray;
  8966. /**
  8967. * Transforms a ray by a matrix
  8968. * @param ray ray to transform
  8969. * @param matrix matrix to apply
  8970. * @returns the resulting new ray
  8971. */
  8972. static Transform(ray: Ray, matrix: Matrix): Ray;
  8973. /**
  8974. * Transforms a ray by a matrix
  8975. * @param ray ray to transform
  8976. * @param matrix matrix to apply
  8977. * @param result ray to store result in
  8978. */
  8979. static TransformToRef(ray: Ray, matrix: Matrix, result: Ray): void;
  8980. }
  8981. }
  8982. /**
  8983. * Module Debug contains the (visual) components to debug a scene correctly
  8984. */
  8985. declare module BABYLON.Debug {
  8986. /**
  8987. * The Axes viewer will show 3 axes in a specific point in space
  8988. */
  8989. class AxesViewer {
  8990. private _xline;
  8991. private _yline;
  8992. private _zline;
  8993. private _xmesh;
  8994. private _ymesh;
  8995. private _zmesh;
  8996. /**
  8997. * Gets the hosting scene
  8998. */
  8999. scene: Nullable<Scene>;
  9000. /**
  9001. * Gets or sets a number used to scale line length
  9002. */
  9003. scaleLines: number;
  9004. /**
  9005. * Creates a new AxesViewer
  9006. * @param scene defines the hosting scene
  9007. * @param scaleLines defines a number used to scale line length (1 by default)
  9008. */
  9009. constructor(scene: Scene, scaleLines?: number);
  9010. /**
  9011. * Force the viewer to update
  9012. * @param position defines the position of the viewer
  9013. * @param xaxis defines the x axis of the viewer
  9014. * @param yaxis defines the y axis of the viewer
  9015. * @param zaxis defines the z axis of the viewer
  9016. */
  9017. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  9018. /** Releases resources */
  9019. dispose(): void;
  9020. }
  9021. }
  9022. declare module BABYLON.Debug {
  9023. /**
  9024. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  9025. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  9026. */
  9027. class BoneAxesViewer extends AxesViewer {
  9028. /**
  9029. * Gets or sets the target mesh where to display the axes viewer
  9030. */
  9031. mesh: Nullable<Mesh>;
  9032. /**
  9033. * Gets or sets the target bone where to display the axes viewer
  9034. */
  9035. bone: Nullable<Bone>;
  9036. /** Gets current position */
  9037. pos: Vector3;
  9038. /** Gets direction of X axis */
  9039. xaxis: Vector3;
  9040. /** Gets direction of Y axis */
  9041. yaxis: Vector3;
  9042. /** Gets direction of Z axis */
  9043. zaxis: Vector3;
  9044. /**
  9045. * Creates a new BoneAxesViewer
  9046. * @param scene defines the hosting scene
  9047. * @param bone defines the target bone
  9048. * @param mesh defines the target mesh
  9049. * @param scaleLines defines a scaling factor for line length (1 by default)
  9050. */
  9051. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  9052. /**
  9053. * Force the viewer to update
  9054. */
  9055. update(): void;
  9056. /** Releases resources */
  9057. dispose(): void;
  9058. }
  9059. }
  9060. declare module BABYLON {
  9061. interface Scene {
  9062. /**
  9063. * @hidden
  9064. * Backing field
  9065. */
  9066. /**
  9067. * Gets the debug layer (aka Inspector) associated with the scene
  9068. * @see http://doc.babylonjs.com/features/playground_debuglayer
  9069. */
  9070. debugLayer: DebugLayer;
  9071. }
  9072. /**
  9073. * The debug layer (aka Inspector) is the go to tool in order to better understand
  9074. * what is happening in your scene
  9075. * @see http://doc.babylonjs.com/features/playground_debuglayer
  9076. */
  9077. class DebugLayer {
  9078. /**
  9079. * Define the url to get the inspector script from.
  9080. * By default it uses the babylonjs CDN.
  9081. * @ignoreNaming
  9082. */
  9083. static InspectorURL: string;
  9084. private _scene;
  9085. private _inspector;
  9086. private BJSINSPECTOR;
  9087. /**
  9088. * Observable triggered when a property is changed through the inspector.
  9089. */
  9090. onPropertyChangedObservable: Observable<{
  9091. object: any;
  9092. property: string;
  9093. value: any;
  9094. initialValue: any;
  9095. }>;
  9096. /**
  9097. * Instantiates a new debug layer.
  9098. * The debug layer (aka Inspector) is the go to tool in order to better understand
  9099. * what is happening in your scene
  9100. * @see http://doc.babylonjs.com/features/playground_debuglayer
  9101. * @param scene Defines the scene to inspect
  9102. */
  9103. constructor(scene: Scene);
  9104. /** Creates the inspector window. */
  9105. private _createInspector;
  9106. /**
  9107. * Get if the inspector is visible or not.
  9108. * @returns true if visible otherwise, false
  9109. */
  9110. isVisible(): boolean;
  9111. /**
  9112. * Hide the inspector and close its window.
  9113. */
  9114. hide(): void;
  9115. /**
  9116. *
  9117. * Launch the debugLayer.
  9118. *
  9119. * initialTab:
  9120. * | Value | Tab Name |
  9121. * | --- | --- |
  9122. * | 0 | Scene |
  9123. * | 1 | Console |
  9124. * | 2 | Stats |
  9125. * | 3 | Textures |
  9126. * | 4 | Mesh |
  9127. * | 5 | Light |
  9128. * | 6 | Material |
  9129. * | 7 | GLTF |
  9130. * | 8 | GUI |
  9131. * | 9 | Physics |
  9132. * | 10 | Camera |
  9133. * | 11 | Audio |
  9134. *
  9135. * @param config Define the configuration of the inspector
  9136. */
  9137. show(config?: {
  9138. popup?: boolean;
  9139. initialTab?: number | string;
  9140. parentElement?: HTMLElement;
  9141. newColors?: {
  9142. backgroundColor?: string;
  9143. backgroundColorLighter?: string;
  9144. backgroundColorLighter2?: string;
  9145. backgroundColorLighter3?: string;
  9146. color?: string;
  9147. colorTop?: string;
  9148. colorBot?: string;
  9149. };
  9150. }): void;
  9151. /**
  9152. * Gets the active tab
  9153. * @return the index of the active tab or -1 if the inspector is hidden
  9154. */
  9155. getActiveTab(): number;
  9156. }
  9157. }
  9158. declare module BABYLON.Debug {
  9159. /**
  9160. * Used to show the physics impostor around the specific mesh
  9161. */
  9162. class PhysicsViewer {
  9163. /** @hidden */
  9164. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  9165. /** @hidden */
  9166. protected _meshes: Array<Nullable<AbstractMesh>>;
  9167. /** @hidden */
  9168. protected _scene: Nullable<Scene>;
  9169. /** @hidden */
  9170. protected _numMeshes: number;
  9171. /** @hidden */
  9172. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  9173. private _renderFunction;
  9174. private _debugBoxMesh;
  9175. private _debugSphereMesh;
  9176. private _debugMaterial;
  9177. /**
  9178. * Creates a new PhysicsViewer
  9179. * @param scene defines the hosting scene
  9180. */
  9181. constructor(scene: Scene);
  9182. /** @hidden */
  9183. protected _updateDebugMeshes(): void;
  9184. /**
  9185. * Renders a specified physic impostor
  9186. * @param impostor defines the impostor to render
  9187. */
  9188. showImpostor(impostor: PhysicsImpostor): void;
  9189. /**
  9190. * Hides a specified physic impostor
  9191. * @param impostor defines the impostor to hide
  9192. */
  9193. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  9194. private _getDebugMaterial;
  9195. private _getDebugBoxMesh;
  9196. private _getDebugSphereMesh;
  9197. private _getDebugMesh;
  9198. /** Releases all resources */
  9199. dispose(): void;
  9200. }
  9201. }
  9202. declare module BABYLON {
  9203. /**
  9204. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  9205. * in order to better appreciate the issue one might have.
  9206. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  9207. */
  9208. class RayHelper {
  9209. /**
  9210. * Defines the ray we are currently tryin to visualize.
  9211. */
  9212. ray: Nullable<Ray>;
  9213. private _renderPoints;
  9214. private _renderLine;
  9215. private _renderFunction;
  9216. private _scene;
  9217. private _updateToMeshFunction;
  9218. private _attachedToMesh;
  9219. private _meshSpaceDirection;
  9220. private _meshSpaceOrigin;
  9221. /**
  9222. * Helper function to create a colored helper in a scene in one line.
  9223. * @param ray Defines the ray we are currently tryin to visualize
  9224. * @param scene Defines the scene the ray is used in
  9225. * @param color Defines the color we want to see the ray in
  9226. * @returns The newly created ray helper.
  9227. */
  9228. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  9229. /**
  9230. * Instantiate a new ray helper.
  9231. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  9232. * in order to better appreciate the issue one might have.
  9233. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  9234. * @param ray Defines the ray we are currently tryin to visualize
  9235. */
  9236. constructor(ray: Ray);
  9237. /**
  9238. * Shows the ray we are willing to debug.
  9239. * @param scene Defines the scene the ray needs to be rendered in
  9240. * @param color Defines the color the ray needs to be rendered in
  9241. */
  9242. show(scene: Scene, color?: Color3): void;
  9243. /**
  9244. * Hides the ray we are debugging.
  9245. */
  9246. hide(): void;
  9247. private _render;
  9248. /**
  9249. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  9250. * @param mesh Defines the mesh we want the helper attached to
  9251. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  9252. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  9253. * @param length Defines the length of the ray
  9254. */
  9255. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  9256. /**
  9257. * Detach the ray helper from the mesh it has previously been attached to.
  9258. */
  9259. detachFromMesh(): void;
  9260. private _updateToMesh;
  9261. /**
  9262. * Dispose the helper and release its associated resources.
  9263. */
  9264. dispose(): void;
  9265. }
  9266. }
  9267. declare module BABYLON.Debug {
  9268. /**
  9269. * Class used to render a debug view of a given skeleton
  9270. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  9271. */
  9272. class SkeletonViewer {
  9273. /** defines the skeleton to render */
  9274. skeleton: Skeleton;
  9275. /** defines the mesh attached to the skeleton */
  9276. mesh: AbstractMesh;
  9277. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  9278. autoUpdateBonesMatrices: boolean;
  9279. /** defines the rendering group id to use with the viewer */
  9280. renderingGroupId: number;
  9281. /** Gets or sets the color used to render the skeleton */
  9282. color: Color3;
  9283. private _scene;
  9284. private _debugLines;
  9285. private _debugMesh;
  9286. private _isEnabled;
  9287. private _renderFunction;
  9288. /**
  9289. * Creates a new SkeletonViewer
  9290. * @param skeleton defines the skeleton to render
  9291. * @param mesh defines the mesh attached to the skeleton
  9292. * @param scene defines the hosting scene
  9293. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  9294. * @param renderingGroupId defines the rendering group id to use with the viewer
  9295. */
  9296. constructor(
  9297. /** defines the skeleton to render */
  9298. skeleton: Skeleton,
  9299. /** defines the mesh attached to the skeleton */
  9300. mesh: AbstractMesh, scene: Scene,
  9301. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  9302. autoUpdateBonesMatrices?: boolean,
  9303. /** defines the rendering group id to use with the viewer */
  9304. renderingGroupId?: number);
  9305. /** Gets or sets a boolean indicating if the viewer is enabled */
  9306. isEnabled: boolean;
  9307. private _getBonePosition;
  9308. private _getLinesForBonesWithLength;
  9309. private _getLinesForBonesNoLength;
  9310. /** Update the viewer to sync with current skeleton state */
  9311. update(): void;
  9312. /** Release associated resources */
  9313. dispose(): void;
  9314. }
  9315. }
  9316. declare module BABYLON {
  9317. /**
  9318. * Interface for attribute information associated with buffer instanciation
  9319. */
  9320. class InstancingAttributeInfo {
  9321. /**
  9322. * Index/offset of the attribute in the vertex shader
  9323. */
  9324. index: number;
  9325. /**
  9326. * size of the attribute, 1, 2, 3 or 4
  9327. */
  9328. attributeSize: number;
  9329. /**
  9330. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  9331. * default is FLOAT
  9332. */
  9333. attribyteType: number;
  9334. /**
  9335. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  9336. */
  9337. normalized: boolean;
  9338. /**
  9339. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  9340. */
  9341. offset: number;
  9342. /**
  9343. * Name of the GLSL attribute, for debugging purpose only
  9344. */
  9345. attributeName: string;
  9346. }
  9347. /**
  9348. * Define options used to create a render target texture
  9349. */
  9350. class RenderTargetCreationOptions {
  9351. /**
  9352. * Specifies is mipmaps must be generated
  9353. */
  9354. generateMipMaps?: boolean;
  9355. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  9356. generateDepthBuffer?: boolean;
  9357. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  9358. generateStencilBuffer?: boolean;
  9359. /** Defines texture type (int by default) */
  9360. type?: number;
  9361. /** Defines sampling mode (trilinear by default) */
  9362. samplingMode?: number;
  9363. /** Defines format (RGBA by default) */
  9364. format?: number;
  9365. }
  9366. /**
  9367. * Define options used to create a depth texture
  9368. */
  9369. class DepthTextureCreationOptions {
  9370. /** Specifies whether or not a stencil should be allocated in the texture */
  9371. generateStencil?: boolean;
  9372. /** Specifies whether or not bilinear filtering is enable on the texture */
  9373. bilinearFiltering?: boolean;
  9374. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  9375. comparisonFunction?: number;
  9376. /** Specifies if the created texture is a cube texture */
  9377. isCube?: boolean;
  9378. }
  9379. /**
  9380. * Class used to describe the capabilities of the engine relatively to the current browser
  9381. */
  9382. class EngineCapabilities {
  9383. /** Maximum textures units per fragment shader */
  9384. maxTexturesImageUnits: number;
  9385. /** Maximum texture units per vertex shader */
  9386. maxVertexTextureImageUnits: number;
  9387. /** Maximum textures units in the entire pipeline */
  9388. maxCombinedTexturesImageUnits: number;
  9389. /** Maximum texture size */
  9390. maxTextureSize: number;
  9391. /** Maximum cube texture size */
  9392. maxCubemapTextureSize: number;
  9393. /** Maximum render texture size */
  9394. maxRenderTextureSize: number;
  9395. /** Maximum number of vertex attributes */
  9396. maxVertexAttribs: number;
  9397. /** Maximum number of varyings */
  9398. maxVaryingVectors: number;
  9399. /** Maximum number of uniforms per vertex shader */
  9400. maxVertexUniformVectors: number;
  9401. /** Maximum number of uniforms per fragment shader */
  9402. maxFragmentUniformVectors: number;
  9403. /** Defines if standard derivates (dx/dy) are supported */
  9404. standardDerivatives: boolean;
  9405. /** Defines if s3tc texture compression is supported */
  9406. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  9407. /** Defines if pvrtc texture compression is supported */
  9408. pvrtc: any;
  9409. /** Defines if etc1 texture compression is supported */
  9410. etc1: any;
  9411. /** Defines if etc2 texture compression is supported */
  9412. etc2: any;
  9413. /** Defines if astc texture compression is supported */
  9414. astc: any;
  9415. /** Defines if float textures are supported */
  9416. textureFloat: boolean;
  9417. /** Defines if vertex array objects are supported */
  9418. vertexArrayObject: boolean;
  9419. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  9420. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  9421. /** Gets the maximum level of anisotropy supported */
  9422. maxAnisotropy: number;
  9423. /** Defines if instancing is supported */
  9424. instancedArrays: boolean;
  9425. /** Defines if 32 bits indices are supported */
  9426. uintIndices: boolean;
  9427. /** Defines if high precision shaders are supported */
  9428. highPrecisionShaderSupported: boolean;
  9429. /** Defines if depth reading in the fragment shader is supported */
  9430. fragmentDepthSupported: boolean;
  9431. /** Defines if float texture linear filtering is supported*/
  9432. textureFloatLinearFiltering: boolean;
  9433. /** Defines if rendering to float textures is supported */
  9434. textureFloatRender: boolean;
  9435. /** Defines if half float textures are supported*/
  9436. textureHalfFloat: boolean;
  9437. /** Defines if half float texture linear filtering is supported*/
  9438. textureHalfFloatLinearFiltering: boolean;
  9439. /** Defines if rendering to half float textures is supported */
  9440. textureHalfFloatRender: boolean;
  9441. /** Defines if textureLOD shader command is supported */
  9442. textureLOD: boolean;
  9443. /** Defines if draw buffers extension is supported */
  9444. drawBuffersExtension: boolean;
  9445. /** Defines if depth textures are supported */
  9446. depthTextureExtension: boolean;
  9447. /** Defines if float color buffer are supported */
  9448. colorBufferFloat: boolean;
  9449. /** Gets disjoint timer query extension (null if not supported) */
  9450. timerQuery: EXT_disjoint_timer_query;
  9451. /** Defines if timestamp can be used with timer query */
  9452. canUseTimestampForTimerQuery: boolean;
  9453. /** Function used to let the system compiles shaders in background */
  9454. parallelShaderCompile: {
  9455. MAX_SHADER_COMPILER_THREADS_KHR: number;
  9456. maxShaderCompilerThreadsKHR: (thread: number) => void;
  9457. COMPLETION_STATUS_KHR: number;
  9458. };
  9459. }
  9460. /** Interface defining initialization parameters for Engine class */
  9461. interface EngineOptions extends WebGLContextAttributes {
  9462. /**
  9463. * Defines if the engine should no exceed a specified device ratio
  9464. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  9465. */
  9466. limitDeviceRatio?: number;
  9467. /**
  9468. * Defines if webvr should be enabled automatically
  9469. * @see http://doc.babylonjs.com/how_to/webvr_camera
  9470. */
  9471. autoEnableWebVR?: boolean;
  9472. /**
  9473. * Defines if webgl2 should be turned off even if supported
  9474. * @see http://doc.babylonjs.com/features/webgl2
  9475. */
  9476. disableWebGL2Support?: boolean;
  9477. /**
  9478. * Defines if webaudio should be initialized as well
  9479. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  9480. */
  9481. audioEngine?: boolean;
  9482. /**
  9483. * Defines if animations should run using a deterministic lock step
  9484. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  9485. */
  9486. deterministicLockstep?: boolean;
  9487. /** Defines the maximum steps to use with deterministic lock step mode */
  9488. lockstepMaxSteps?: number;
  9489. /**
  9490. * Defines that engine should ignore context lost events
  9491. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  9492. */
  9493. doNotHandleContextLost?: boolean;
  9494. }
  9495. /**
  9496. * Defines the interface used by display changed events
  9497. */
  9498. interface IDisplayChangedEventArgs {
  9499. /** Gets the vrDisplay object (if any) */
  9500. vrDisplay: Nullable<any>;
  9501. /** Gets a boolean indicating if webVR is supported */
  9502. vrSupported: boolean;
  9503. }
  9504. /**
  9505. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  9506. */
  9507. class Engine {
  9508. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  9509. static ExceptionList: ({
  9510. key: string;
  9511. capture: string;
  9512. captureConstraint: number;
  9513. targets: string[];
  9514. } | {
  9515. key: string;
  9516. capture: null;
  9517. captureConstraint: null;
  9518. targets: string[];
  9519. })[];
  9520. /** Gets the list of created engines */
  9521. static Instances: Engine[];
  9522. /**
  9523. * Gets the latest created engine
  9524. */
  9525. static readonly LastCreatedEngine: Nullable<Engine>;
  9526. /**
  9527. * Gets the latest created scene
  9528. */
  9529. static readonly LastCreatedScene: Nullable<Scene>;
  9530. /**
  9531. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  9532. * @param flag defines which part of the materials must be marked as dirty
  9533. * @param predicate defines a predicate used to filter which materials should be affected
  9534. */
  9535. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  9536. /**
  9537. * Hidden
  9538. */
  9539. private static _TextureLoaders: IInternalTextureLoader[];
  9540. /** Defines that alpha blending is disabled */
  9541. static readonly ALPHA_DISABLE: number;
  9542. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  9543. static readonly ALPHA_ADD: number;
  9544. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  9545. static readonly ALPHA_COMBINE: number;
  9546. /** Defines that alpha blending to DEST - SRC * DEST */
  9547. static readonly ALPHA_SUBTRACT: number;
  9548. /** Defines that alpha blending to SRC * DEST */
  9549. static readonly ALPHA_MULTIPLY: number;
  9550. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  9551. static readonly ALPHA_MAXIMIZED: number;
  9552. /** Defines that alpha blending to SRC + DEST */
  9553. static readonly ALPHA_ONEONE: number;
  9554. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  9555. static readonly ALPHA_PREMULTIPLIED: number;
  9556. /**
  9557. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  9558. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  9559. */
  9560. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  9561. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  9562. static readonly ALPHA_INTERPOLATE: number;
  9563. /**
  9564. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  9565. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  9566. */
  9567. static readonly ALPHA_SCREENMODE: number;
  9568. /** Defines that the ressource is not delayed*/
  9569. static readonly DELAYLOADSTATE_NONE: number;
  9570. /** Defines that the ressource was successfully delay loaded */
  9571. static readonly DELAYLOADSTATE_LOADED: number;
  9572. /** Defines that the ressource is currently delay loading */
  9573. static readonly DELAYLOADSTATE_LOADING: number;
  9574. /** Defines that the ressource is delayed and has not started loading */
  9575. static readonly DELAYLOADSTATE_NOTLOADED: number;
  9576. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  9577. static readonly NEVER: number;
  9578. /** 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 */
  9579. static readonly ALWAYS: number;
  9580. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  9581. static readonly LESS: number;
  9582. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  9583. static readonly EQUAL: number;
  9584. /** 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 */
  9585. static readonly LEQUAL: number;
  9586. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  9587. static readonly GREATER: number;
  9588. /** 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 */
  9589. static readonly GEQUAL: number;
  9590. /** 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 */
  9591. static readonly NOTEQUAL: number;
  9592. /** Passed to stencilOperation to specify that stencil value must be kept */
  9593. static readonly KEEP: number;
  9594. /** Passed to stencilOperation to specify that stencil value must be replaced */
  9595. static readonly REPLACE: number;
  9596. /** Passed to stencilOperation to specify that stencil value must be incremented */
  9597. static readonly INCR: number;
  9598. /** Passed to stencilOperation to specify that stencil value must be decremented */
  9599. static readonly DECR: number;
  9600. /** Passed to stencilOperation to specify that stencil value must be inverted */
  9601. static readonly INVERT: number;
  9602. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  9603. static readonly INCR_WRAP: number;
  9604. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  9605. static readonly DECR_WRAP: number;
  9606. /** Texture is not repeating outside of 0..1 UVs */
  9607. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  9608. /** Texture is repeating outside of 0..1 UVs */
  9609. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  9610. /** Texture is repeating and mirrored */
  9611. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  9612. /** ALPHA */
  9613. static readonly TEXTUREFORMAT_ALPHA: number;
  9614. /** LUMINANCE */
  9615. static readonly TEXTUREFORMAT_LUMINANCE: number;
  9616. /** LUMINANCE_ALPHA */
  9617. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  9618. /** RGB */
  9619. static readonly TEXTUREFORMAT_RGB: number;
  9620. /** RGBA */
  9621. static readonly TEXTUREFORMAT_RGBA: number;
  9622. /** RED */
  9623. static readonly TEXTUREFORMAT_RED: number;
  9624. /** RED (2nd reference) */
  9625. static readonly TEXTUREFORMAT_R: number;
  9626. /** RG */
  9627. static readonly TEXTUREFORMAT_RG: number;
  9628. /** RED_INTEGER */
  9629. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  9630. /** RED_INTEGER (2nd reference) */
  9631. static readonly TEXTUREFORMAT_R_INTEGER: number;
  9632. /** RG_INTEGER */
  9633. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  9634. /** RGB_INTEGER */
  9635. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  9636. /** RGBA_INTEGER */
  9637. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  9638. /** UNSIGNED_BYTE */
  9639. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  9640. /** UNSIGNED_BYTE (2nd reference) */
  9641. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  9642. /** FLOAT */
  9643. static readonly TEXTURETYPE_FLOAT: number;
  9644. /** HALF_FLOAT */
  9645. static readonly TEXTURETYPE_HALF_FLOAT: number;
  9646. /** BYTE */
  9647. static readonly TEXTURETYPE_BYTE: number;
  9648. /** SHORT */
  9649. static readonly TEXTURETYPE_SHORT: number;
  9650. /** UNSIGNED_SHORT */
  9651. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  9652. /** INT */
  9653. static readonly TEXTURETYPE_INT: number;
  9654. /** UNSIGNED_INT */
  9655. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  9656. /** UNSIGNED_SHORT_4_4_4_4 */
  9657. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  9658. /** UNSIGNED_SHORT_5_5_5_1 */
  9659. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  9660. /** UNSIGNED_SHORT_5_6_5 */
  9661. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  9662. /** UNSIGNED_INT_2_10_10_10_REV */
  9663. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  9664. /** UNSIGNED_INT_24_8 */
  9665. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  9666. /** UNSIGNED_INT_10F_11F_11F_REV */
  9667. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  9668. /** UNSIGNED_INT_5_9_9_9_REV */
  9669. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  9670. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  9671. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  9672. /** nearest is mag = nearest and min = nearest and mip = linear */
  9673. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  9674. /** Bilinear is mag = linear and min = linear and mip = nearest */
  9675. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  9676. /** Trilinear is mag = linear and min = linear and mip = linear */
  9677. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  9678. /** nearest is mag = nearest and min = nearest and mip = linear */
  9679. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  9680. /** Bilinear is mag = linear and min = linear and mip = nearest */
  9681. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  9682. /** Trilinear is mag = linear and min = linear and mip = linear */
  9683. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  9684. /** mag = nearest and min = nearest and mip = nearest */
  9685. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  9686. /** mag = nearest and min = linear and mip = nearest */
  9687. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  9688. /** mag = nearest and min = linear and mip = linear */
  9689. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  9690. /** mag = nearest and min = linear and mip = none */
  9691. static readonly TEXTURE_NEAREST_LINEAR: number;
  9692. /** mag = nearest and min = nearest and mip = none */
  9693. static readonly TEXTURE_NEAREST_NEAREST: number;
  9694. /** mag = linear and min = nearest and mip = nearest */
  9695. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  9696. /** mag = linear and min = nearest and mip = linear */
  9697. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  9698. /** mag = linear and min = linear and mip = none */
  9699. static readonly TEXTURE_LINEAR_LINEAR: number;
  9700. /** mag = linear and min = nearest and mip = none */
  9701. static readonly TEXTURE_LINEAR_NEAREST: number;
  9702. /** Explicit coordinates mode */
  9703. static readonly TEXTURE_EXPLICIT_MODE: number;
  9704. /** Spherical coordinates mode */
  9705. static readonly TEXTURE_SPHERICAL_MODE: number;
  9706. /** Planar coordinates mode */
  9707. static readonly TEXTURE_PLANAR_MODE: number;
  9708. /** Cubic coordinates mode */
  9709. static readonly TEXTURE_CUBIC_MODE: number;
  9710. /** Projection coordinates mode */
  9711. static readonly TEXTURE_PROJECTION_MODE: number;
  9712. /** Skybox coordinates mode */
  9713. static readonly TEXTURE_SKYBOX_MODE: number;
  9714. /** Inverse Cubic coordinates mode */
  9715. static readonly TEXTURE_INVCUBIC_MODE: number;
  9716. /** Equirectangular coordinates mode */
  9717. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  9718. /** Equirectangular Fixed coordinates mode */
  9719. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  9720. /** Equirectangular Fixed Mirrored coordinates mode */
  9721. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  9722. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  9723. static readonly SCALEMODE_FLOOR: number;
  9724. /** Defines that texture rescaling will look for the nearest power of 2 size */
  9725. static readonly SCALEMODE_NEAREST: number;
  9726. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  9727. static readonly SCALEMODE_CEILING: number;
  9728. /**
  9729. * Returns the current version of the framework
  9730. */
  9731. static readonly Version: string;
  9732. /**
  9733. * Gets or sets the epsilon value used by collision engine
  9734. */
  9735. static CollisionsEpsilon: number;
  9736. /**
  9737. * Gets or sets the relative url used to load code if using the engine in non-minified mode
  9738. */
  9739. static CodeRepository: string;
  9740. /**
  9741. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  9742. */
  9743. static ShadersRepository: string;
  9744. /**
  9745. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  9746. */
  9747. forcePOTTextures: boolean;
  9748. /**
  9749. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  9750. */
  9751. isFullscreen: boolean;
  9752. /**
  9753. * Gets a boolean indicating if the pointer is currently locked
  9754. */
  9755. isPointerLock: boolean;
  9756. /**
  9757. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  9758. */
  9759. cullBackFaces: boolean;
  9760. /**
  9761. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  9762. */
  9763. renderEvenInBackground: boolean;
  9764. /**
  9765. * Gets or sets a boolean indicating that cache can be kept between frames
  9766. */
  9767. preventCacheWipeBetweenFrames: boolean;
  9768. /**
  9769. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  9770. **/
  9771. enableOfflineSupport: boolean;
  9772. /**
  9773. * 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)
  9774. **/
  9775. disableManifestCheck: boolean;
  9776. /**
  9777. * Gets the list of created scenes
  9778. */
  9779. scenes: Scene[];
  9780. /**
  9781. * Gets the list of created postprocesses
  9782. */
  9783. postProcesses: PostProcess[];
  9784. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  9785. validateShaderPrograms: boolean;
  9786. /**
  9787. * Observable event triggered each time the rendering canvas is resized
  9788. */
  9789. onResizeObservable: Observable<Engine>;
  9790. /**
  9791. * Observable event triggered each time the canvas loses focus
  9792. */
  9793. onCanvasBlurObservable: Observable<Engine>;
  9794. /**
  9795. * Observable event triggered each time the canvas gains focus
  9796. */
  9797. onCanvasFocusObservable: Observable<Engine>;
  9798. /**
  9799. * Observable event triggered each time the canvas receives pointerout event
  9800. */
  9801. onCanvasPointerOutObservable: Observable<PointerEvent>;
  9802. /**
  9803. * Observable event triggered before each texture is initialized
  9804. */
  9805. onBeforeTextureInitObservable: Observable<Texture>;
  9806. private _vrDisplay;
  9807. private _vrSupported;
  9808. private _oldSize;
  9809. private _oldHardwareScaleFactor;
  9810. private _vrExclusivePointerMode;
  9811. private _webVRInitPromise;
  9812. /**
  9813. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  9814. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  9815. */
  9816. readonly isInVRExclusivePointerMode: boolean;
  9817. /**
  9818. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  9819. */
  9820. disableUniformBuffers: boolean;
  9821. /** @hidden */
  9822. /**
  9823. * Gets a boolean indicating that the engine supports uniform buffers
  9824. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  9825. */
  9826. readonly supportsUniformBuffers: boolean;
  9827. /**
  9828. * Observable raised when the engine begins a new frame
  9829. */
  9830. onBeginFrameObservable: Observable<Engine>;
  9831. /**
  9832. * Observable raised when the engine ends the current frame
  9833. */
  9834. onEndFrameObservable: Observable<Engine>;
  9835. /**
  9836. * Observable raised when the engine is about to compile a shader
  9837. */
  9838. onBeforeShaderCompilationObservable: Observable<Engine>;
  9839. /**
  9840. * Observable raised when the engine has jsut compiled a shader
  9841. */
  9842. onAfterShaderCompilationObservable: Observable<Engine>;
  9843. /** @hidden */
  9844. private _renderingCanvas;
  9845. private _windowIsBackground;
  9846. private _webGLVersion;
  9847. /**
  9848. * Gets a boolean indicating that only power of 2 textures are supported
  9849. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  9850. */
  9851. readonly needPOTTextures: boolean;
  9852. /** @hidden */
  9853. /** @hidden */
  9854. /**
  9855. * Gets or sets a value indicating if we want to disable texture binding optmization.
  9856. * This could be required on some buggy drivers which wants to have textures bound in a progressive order.
  9857. * By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is
  9858. */
  9859. disableTextureBindingOptimization: boolean;
  9860. /**
  9861. * Gets the audio engine
  9862. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  9863. * @ignorenaming
  9864. */
  9865. static audioEngine: IAudioEngine;
  9866. /**
  9867. * Default AudioEngine Factory responsible of creating the Audio Engine.
  9868. * By default, this will create a BabylonJS Audio Engine if the workload
  9869. * has been embedded.
  9870. */
  9871. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  9872. private _onFocus;
  9873. private _onBlur;
  9874. private _onCanvasPointerOut;
  9875. private _onCanvasBlur;
  9876. private _onCanvasFocus;
  9877. private _onFullscreenChange;
  9878. private _onPointerLockChange;
  9879. private _onVRDisplayPointerRestricted;
  9880. private _onVRDisplayPointerUnrestricted;
  9881. private _onVrDisplayConnect;
  9882. private _onVrDisplayDisconnect;
  9883. private _onVrDisplayPresentChange;
  9884. /**
  9885. * Observable signaled when VR display mode changes
  9886. */
  9887. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  9888. /**
  9889. * Observable signaled when VR request present is complete
  9890. */
  9891. onVRRequestPresentComplete: Observable<boolean>;
  9892. /**
  9893. * Observable signaled when VR request present starts
  9894. */
  9895. onVRRequestPresentStart: Observable<Engine>;
  9896. private _hardwareScalingLevel;
  9897. /** @hidden */
  9898. protected _caps: EngineCapabilities;
  9899. private _pointerLockRequested;
  9900. private _isStencilEnable;
  9901. private _colorWrite;
  9902. private _loadingScreen;
  9903. /** @hidden */
  9904. /** @hidden */
  9905. private _glVersion;
  9906. private _glRenderer;
  9907. private _glVendor;
  9908. private _videoTextureSupported;
  9909. private _renderingQueueLaunched;
  9910. private _activeRenderLoops;
  9911. private _deterministicLockstep;
  9912. private _lockstepMaxSteps;
  9913. /**
  9914. * Observable signaled when a context lost event is raised
  9915. */
  9916. onContextLostObservable: Observable<Engine>;
  9917. /**
  9918. * Observable signaled when a context restored event is raised
  9919. */
  9920. onContextRestoredObservable: Observable<Engine>;
  9921. private _onContextLost;
  9922. private _onContextRestored;
  9923. private _contextWasLost;
  9924. private _doNotHandleContextLost;
  9925. /**
  9926. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  9927. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  9928. */
  9929. doNotHandleContextLost: boolean;
  9930. private _performanceMonitor;
  9931. private _fps;
  9932. private _deltaTime;
  9933. /**
  9934. * Turn this value on if you want to pause FPS computation when in background
  9935. */
  9936. disablePerformanceMonitorInBackground: boolean;
  9937. /**
  9938. * Gets the performance monitor attached to this engine
  9939. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  9940. */
  9941. readonly performanceMonitor: PerformanceMonitor;
  9942. /** @hidden */
  9943. protected _depthCullingState: _DepthCullingState;
  9944. /** @hidden */
  9945. protected _stencilState: _StencilState;
  9946. /** @hidden */
  9947. protected _alphaState: _AlphaState;
  9948. /** @hidden */
  9949. protected _alphaMode: number;
  9950. protected _internalTexturesCache: InternalTexture[];
  9951. /** @hidden */
  9952. protected _activeChannel: number;
  9953. private _currentTextureChannel;
  9954. /** @hidden */
  9955. protected _boundTexturesCache: {
  9956. [key: string]: Nullable<InternalTexture>;
  9957. };
  9958. /** @hidden */
  9959. protected _currentEffect: Nullable<Effect>;
  9960. /** @hidden */
  9961. protected _currentProgram: Nullable<WebGLProgram>;
  9962. private _compiledEffects;
  9963. private _vertexAttribArraysEnabled;
  9964. /** @hidden */
  9965. protected _cachedViewport: Nullable<Viewport>;
  9966. private _cachedVertexArrayObject;
  9967. /** @hidden */
  9968. protected _cachedVertexBuffers: any;
  9969. /** @hidden */
  9970. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  9971. /** @hidden */
  9972. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  9973. /** @hidden */
  9974. protected _currentRenderTarget: Nullable<InternalTexture>;
  9975. private _uintIndicesCurrentlySet;
  9976. private _currentBoundBuffer;
  9977. /** @hidden */
  9978. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  9979. private _currentBufferPointers;
  9980. private _currentInstanceLocations;
  9981. private _currentInstanceBuffers;
  9982. private _textureUnits;
  9983. private _firstBoundInternalTextureTracker;
  9984. private _lastBoundInternalTextureTracker;
  9985. private _workingCanvas;
  9986. private _workingContext;
  9987. private _rescalePostProcess;
  9988. private _dummyFramebuffer;
  9989. private _externalData;
  9990. private _bindedRenderFunction;
  9991. private _vaoRecordInProgress;
  9992. private _mustWipeVertexAttributes;
  9993. private _emptyTexture;
  9994. private _emptyCubeTexture;
  9995. private _emptyTexture3D;
  9996. private _frameHandler;
  9997. private _nextFreeTextureSlots;
  9998. private _maxSimultaneousTextures;
  9999. private _activeRequests;
  10000. private _texturesSupported;
  10001. private _textureFormatInUse;
  10002. /**
  10003. * Gets the list of texture formats supported
  10004. */
  10005. readonly texturesSupported: Array<string>;
  10006. /**
  10007. * Gets the list of texture formats in use
  10008. */
  10009. readonly textureFormatInUse: Nullable<string>;
  10010. /**
  10011. * Gets the current viewport
  10012. */
  10013. readonly currentViewport: Nullable<Viewport>;
  10014. /**
  10015. * Gets the default empty texture
  10016. */
  10017. readonly emptyTexture: InternalTexture;
  10018. /**
  10019. * Gets the default empty 3D texture
  10020. */
  10021. readonly emptyTexture3D: InternalTexture;
  10022. /**
  10023. * Gets the default empty cube texture
  10024. */
  10025. readonly emptyCubeTexture: InternalTexture;
  10026. /**
  10027. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  10028. */
  10029. readonly premultipliedAlpha: boolean;
  10030. /**
  10031. * Creates a new engine
  10032. * @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
  10033. * @param antialias defines enable antialiasing (default: false)
  10034. * @param options defines further options to be sent to the getContext() function
  10035. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  10036. */
  10037. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  10038. private _rebuildInternalTextures;
  10039. private _rebuildEffects;
  10040. private _rebuildBuffers;
  10041. private _initGLContext;
  10042. /**
  10043. * Gets version of the current webGL context
  10044. */
  10045. readonly webGLVersion: number;
  10046. /**
  10047. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  10048. */
  10049. readonly isStencilEnable: boolean;
  10050. private _prepareWorkingCanvas;
  10051. /**
  10052. * Reset the texture cache to empty state
  10053. */
  10054. resetTextureCache(): void;
  10055. /**
  10056. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  10057. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  10058. * @returns true if engine is in deterministic lock step mode
  10059. */
  10060. isDeterministicLockStep(): boolean;
  10061. /**
  10062. * Gets the max steps when engine is running in deterministic lock step
  10063. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  10064. * @returns the max steps
  10065. */
  10066. getLockstepMaxSteps(): number;
  10067. /**
  10068. * Gets an object containing information about the current webGL context
  10069. * @returns an object containing the vender, the renderer and the version of the current webGL context
  10070. */
  10071. getGlInfo(): {
  10072. vendor: string;
  10073. renderer: string;
  10074. version: string;
  10075. };
  10076. /**
  10077. * Gets current aspect ratio
  10078. * @param camera defines the camera to use to get the aspect ratio
  10079. * @param useScreen defines if screen size must be used (or the current render target if any)
  10080. * @returns a number defining the aspect ratio
  10081. */
  10082. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  10083. /**
  10084. * Gets current screen aspect ratio
  10085. * @returns a number defining the aspect ratio
  10086. */
  10087. getScreenAspectRatio(): number;
  10088. /**
  10089. * Gets the current render width
  10090. * @param useScreen defines if screen size must be used (or the current render target if any)
  10091. * @returns a number defining the current render width
  10092. */
  10093. getRenderWidth(useScreen?: boolean): number;
  10094. /**
  10095. * Gets the current render height
  10096. * @param useScreen defines if screen size must be used (or the current render target if any)
  10097. * @returns a number defining the current render height
  10098. */
  10099. getRenderHeight(useScreen?: boolean): number;
  10100. /**
  10101. * Gets the HTML canvas attached with the current webGL context
  10102. * @returns a HTML canvas
  10103. */
  10104. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  10105. /**
  10106. * Gets the client rect of the HTML canvas attached with the current webGL context
  10107. * @returns a client rectanglee
  10108. */
  10109. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  10110. /**
  10111. * Defines the hardware scaling level.
  10112. * By default the hardware scaling level is computed from the window device ratio.
  10113. * 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.
  10114. * @param level defines the level to use
  10115. */
  10116. setHardwareScalingLevel(level: number): void;
  10117. /**
  10118. * Gets the current hardware scaling level.
  10119. * By default the hardware scaling level is computed from the window device ratio.
  10120. * 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.
  10121. * @returns a number indicating the current hardware scaling level
  10122. */
  10123. getHardwareScalingLevel(): number;
  10124. /**
  10125. * Gets the list of loaded textures
  10126. * @returns an array containing all loaded textures
  10127. */
  10128. getLoadedTexturesCache(): InternalTexture[];
  10129. /**
  10130. * Gets the object containing all engine capabilities
  10131. * @returns the EngineCapabilities object
  10132. */
  10133. getCaps(): EngineCapabilities;
  10134. /** @hidden */
  10135. readonly drawCalls: number;
  10136. /** @hidden */
  10137. readonly drawCallsPerfCounter: Nullable<PerfCounter>;
  10138. /**
  10139. * Gets the current depth function
  10140. * @returns a number defining the depth function
  10141. */
  10142. getDepthFunction(): Nullable<number>;
  10143. /**
  10144. * Sets the current depth function
  10145. * @param depthFunc defines the function to use
  10146. */
  10147. setDepthFunction(depthFunc: number): void;
  10148. /**
  10149. * Sets the current depth function to GREATER
  10150. */
  10151. setDepthFunctionToGreater(): void;
  10152. /**
  10153. * Sets the current depth function to GEQUAL
  10154. */
  10155. setDepthFunctionToGreaterOrEqual(): void;
  10156. /**
  10157. * Sets the current depth function to LESS
  10158. */
  10159. setDepthFunctionToLess(): void;
  10160. /**
  10161. * Sets the current depth function to LEQUAL
  10162. */
  10163. setDepthFunctionToLessOrEqual(): void;
  10164. /**
  10165. * Gets a boolean indicating if stencil buffer is enabled
  10166. * @returns the current stencil buffer state
  10167. */
  10168. getStencilBuffer(): boolean;
  10169. /**
  10170. * Enable or disable the stencil buffer
  10171. * @param enable defines if the stencil buffer must be enabled or disabled
  10172. */
  10173. setStencilBuffer(enable: boolean): void;
  10174. /**
  10175. * Gets the current stencil mask
  10176. * @returns a number defining the new stencil mask to use
  10177. */
  10178. getStencilMask(): number;
  10179. /**
  10180. * Sets the current stencil mask
  10181. * @param mask defines the new stencil mask to use
  10182. */
  10183. setStencilMask(mask: number): void;
  10184. /**
  10185. * Gets the current stencil function
  10186. * @returns a number defining the stencil function to use
  10187. */
  10188. getStencilFunction(): number;
  10189. /**
  10190. * Gets the current stencil reference value
  10191. * @returns a number defining the stencil reference value to use
  10192. */
  10193. getStencilFunctionReference(): number;
  10194. /**
  10195. * Gets the current stencil mask
  10196. * @returns a number defining the stencil mask to use
  10197. */
  10198. getStencilFunctionMask(): number;
  10199. /**
  10200. * Sets the current stencil function
  10201. * @param stencilFunc defines the new stencil function to use
  10202. */
  10203. setStencilFunction(stencilFunc: number): void;
  10204. /**
  10205. * Sets the current stencil reference
  10206. * @param reference defines the new stencil reference to use
  10207. */
  10208. setStencilFunctionReference(reference: number): void;
  10209. /**
  10210. * Sets the current stencil mask
  10211. * @param mask defines the new stencil mask to use
  10212. */
  10213. setStencilFunctionMask(mask: number): void;
  10214. /**
  10215. * Gets the current stencil operation when stencil fails
  10216. * @returns a number defining stencil operation to use when stencil fails
  10217. */
  10218. getStencilOperationFail(): number;
  10219. /**
  10220. * Gets the current stencil operation when depth fails
  10221. * @returns a number defining stencil operation to use when depth fails
  10222. */
  10223. getStencilOperationDepthFail(): number;
  10224. /**
  10225. * Gets the current stencil operation when stencil passes
  10226. * @returns a number defining stencil operation to use when stencil passes
  10227. */
  10228. getStencilOperationPass(): number;
  10229. /**
  10230. * Sets the stencil operation to use when stencil fails
  10231. * @param operation defines the stencil operation to use when stencil fails
  10232. */
  10233. setStencilOperationFail(operation: number): void;
  10234. /**
  10235. * Sets the stencil operation to use when depth fails
  10236. * @param operation defines the stencil operation to use when depth fails
  10237. */
  10238. setStencilOperationDepthFail(operation: number): void;
  10239. /**
  10240. * Sets the stencil operation to use when stencil passes
  10241. * @param operation defines the stencil operation to use when stencil passes
  10242. */
  10243. setStencilOperationPass(operation: number): void;
  10244. /**
  10245. * Sets a boolean indicating if the dithering state is enabled or disabled
  10246. * @param value defines the dithering state
  10247. */
  10248. setDitheringState(value: boolean): void;
  10249. /**
  10250. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  10251. * @param value defines the rasterizer state
  10252. */
  10253. setRasterizerState(value: boolean): void;
  10254. /**
  10255. * stop executing a render loop function and remove it from the execution array
  10256. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  10257. */
  10258. stopRenderLoop(renderFunction?: () => void): void;
  10259. /** @hidden */
  10260. /**
  10261. * Register and execute a render loop. The engine can have more than one render function
  10262. * @param renderFunction defines the function to continuously execute
  10263. */
  10264. runRenderLoop(renderFunction: () => void): void;
  10265. /**
  10266. * Toggle full screen mode
  10267. * @param requestPointerLock defines if a pointer lock should be requested from the user
  10268. */
  10269. switchFullscreen(requestPointerLock: boolean): void;
  10270. /**
  10271. * Clear the current render buffer or the current render target (if any is set up)
  10272. * @param color defines the color to use
  10273. * @param backBuffer defines if the back buffer must be cleared
  10274. * @param depth defines if the depth buffer must be cleared
  10275. * @param stencil defines if the stencil buffer must be cleared
  10276. */
  10277. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  10278. /**
  10279. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  10280. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  10281. * @param y defines the y-coordinate of the corner of the clear rectangle
  10282. * @param width defines the width of the clear rectangle
  10283. * @param height defines the height of the clear rectangle
  10284. * @param clearColor defines the clear color
  10285. */
  10286. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  10287. private _viewportCached;
  10288. /** @hidden */
  10289. /**
  10290. * Set the WebGL's viewport
  10291. * @param viewport defines the viewport element to be used
  10292. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  10293. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  10294. */
  10295. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  10296. /**
  10297. * Directly set the WebGL Viewport
  10298. * @param x defines the x coordinate of the viewport (in screen space)
  10299. * @param y defines the y coordinate of the viewport (in screen space)
  10300. * @param width defines the width of the viewport (in screen space)
  10301. * @param height defines the height of the viewport (in screen space)
  10302. * @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
  10303. */
  10304. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  10305. /**
  10306. * Begin a new frame
  10307. */
  10308. beginFrame(): void;
  10309. /**
  10310. * Enf the current frame
  10311. */
  10312. endFrame(): void;
  10313. /**
  10314. * Resize the view according to the canvas' size
  10315. */
  10316. resize(): void;
  10317. /**
  10318. * Force a specific size of the canvas
  10319. * @param width defines the new canvas' width
  10320. * @param height defines the new canvas' height
  10321. */
  10322. setSize(width: number, height: number): void;
  10323. /**
  10324. * Gets a boolean indicating if a webVR device was detected
  10325. * @returns true if a webVR device was detected
  10326. */
  10327. isVRDevicePresent(): boolean;
  10328. /**
  10329. * Gets the current webVR device
  10330. * @returns the current webVR device (or null)
  10331. */
  10332. getVRDevice(): any;
  10333. /**
  10334. * Initializes a webVR display and starts listening to display change events
  10335. * The onVRDisplayChangedObservable will be notified upon these changes
  10336. * @returns The onVRDisplayChangedObservable
  10337. */
  10338. initWebVR(): Observable<IDisplayChangedEventArgs>;
  10339. /**
  10340. * Initializes a webVR display and starts listening to display change events
  10341. * The onVRDisplayChangedObservable will be notified upon these changes
  10342. * @returns A promise containing a VRDisplay and if vr is supported
  10343. */
  10344. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  10345. /**
  10346. * Call this function to switch to webVR mode
  10347. * Will do nothing if webVR is not supported or if there is no webVR device
  10348. * @see http://doc.babylonjs.com/how_to/webvr_camera
  10349. */
  10350. enableVR(): void;
  10351. /**
  10352. * Call this function to leave webVR mode
  10353. * Will do nothing if webVR is not supported or if there is no webVR device
  10354. * @see http://doc.babylonjs.com/how_to/webvr_camera
  10355. */
  10356. disableVR(): void;
  10357. private _onVRFullScreenTriggered;
  10358. private _getVRDisplaysAsync;
  10359. /**
  10360. * Binds the frame buffer to the specified texture.
  10361. * @param texture The texture to render to or null for the default canvas
  10362. * @param faceIndex The face of the texture to render to in case of cube texture
  10363. * @param requiredWidth The width of the target to render to
  10364. * @param requiredHeight The height of the target to render to
  10365. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  10366. * @param depthStencilTexture The depth stencil texture to use to render
  10367. * @param lodLevel defines le lod level to bind to the frame buffer
  10368. */
  10369. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  10370. private bindUnboundFramebuffer;
  10371. /**
  10372. * Unbind the current render target texture from the webGL context
  10373. * @param texture defines the render target texture to unbind
  10374. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  10375. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  10376. */
  10377. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  10378. /**
  10379. * Unbind a list of render target textures from the webGL context
  10380. * This is used only when drawBuffer extension or webGL2 are active
  10381. * @param textures defines the render target textures to unbind
  10382. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  10383. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  10384. */
  10385. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  10386. /**
  10387. * Force the mipmap generation for the given render target texture
  10388. * @param texture defines the render target texture to use
  10389. */
  10390. generateMipMapsForCubemap(texture: InternalTexture): void;
  10391. /**
  10392. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  10393. */
  10394. flushFramebuffer(): void;
  10395. /**
  10396. * Unbind the current render target and bind the default framebuffer
  10397. */
  10398. restoreDefaultFramebuffer(): void;
  10399. /**
  10400. * Create an uniform buffer
  10401. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  10402. * @param elements defines the content of the uniform buffer
  10403. * @returns the webGL uniform buffer
  10404. */
  10405. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  10406. /**
  10407. * Create a dynamic uniform buffer
  10408. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  10409. * @param elements defines the content of the uniform buffer
  10410. * @returns the webGL uniform buffer
  10411. */
  10412. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  10413. /**
  10414. * Update an existing uniform buffer
  10415. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  10416. * @param uniformBuffer defines the target uniform buffer
  10417. * @param elements defines the content to update
  10418. * @param offset defines the offset in the uniform buffer where update should start
  10419. * @param count defines the size of the data to update
  10420. */
  10421. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  10422. private _resetVertexBufferBinding;
  10423. /**
  10424. * Creates a vertex buffer
  10425. * @param data the data for the vertex buffer
  10426. * @returns the new WebGL static buffer
  10427. */
  10428. createVertexBuffer(data: DataArray): WebGLBuffer;
  10429. /**
  10430. * Creates a dynamic vertex buffer
  10431. * @param data the data for the dynamic vertex buffer
  10432. * @returns the new WebGL dynamic buffer
  10433. */
  10434. createDynamicVertexBuffer(data: DataArray): WebGLBuffer;
  10435. /**
  10436. * Update a dynamic index buffer
  10437. * @param indexBuffer defines the target index buffer
  10438. * @param indices defines the data to update
  10439. * @param offset defines the offset in the target index buffer where update should start
  10440. */
  10441. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  10442. /**
  10443. * Updates a dynamic vertex buffer.
  10444. * @param vertexBuffer the vertex buffer to update
  10445. * @param data the data used to update the vertex buffer
  10446. * @param byteOffset the byte offset of the data
  10447. * @param byteLength the byte length of the data
  10448. */
  10449. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  10450. private _resetIndexBufferBinding;
  10451. /**
  10452. * Creates a new index buffer
  10453. * @param indices defines the content of the index buffer
  10454. * @param updatable defines if the index buffer must be updatable
  10455. * @returns a new webGL buffer
  10456. */
  10457. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  10458. /**
  10459. * Bind a webGL buffer to the webGL context
  10460. * @param buffer defines the buffer to bind
  10461. */
  10462. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  10463. /**
  10464. * Bind an uniform buffer to the current webGL context
  10465. * @param buffer defines the buffer to bind
  10466. */
  10467. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  10468. /**
  10469. * Bind a buffer to the current webGL context at a given location
  10470. * @param buffer defines the buffer to bind
  10471. * @param location defines the index where to bind the buffer
  10472. */
  10473. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  10474. /**
  10475. * Bind a specific block at a given index in a specific shader program
  10476. * @param shaderProgram defines the shader program
  10477. * @param blockName defines the block name
  10478. * @param index defines the index where to bind the block
  10479. */
  10480. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  10481. private bindIndexBuffer;
  10482. private bindBuffer;
  10483. /**
  10484. * update the bound buffer with the given data
  10485. * @param data defines the data to update
  10486. */
  10487. updateArrayBuffer(data: Float32Array): void;
  10488. private _vertexAttribPointer;
  10489. private _bindIndexBufferWithCache;
  10490. private _bindVertexBuffersAttributes;
  10491. /**
  10492. * Records a vertex array object
  10493. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  10494. * @param vertexBuffers defines the list of vertex buffers to store
  10495. * @param indexBuffer defines the index buffer to store
  10496. * @param effect defines the effect to store
  10497. * @returns the new vertex array object
  10498. */
  10499. recordVertexArrayObject(vertexBuffers: {
  10500. [key: string]: VertexBuffer;
  10501. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  10502. /**
  10503. * Bind a specific vertex array object
  10504. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  10505. * @param vertexArrayObject defines the vertex array object to bind
  10506. * @param indexBuffer defines the index buffer to bind
  10507. */
  10508. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  10509. /**
  10510. * Bind webGl buffers directly to the webGL context
  10511. * @param vertexBuffer defines the vertex buffer to bind
  10512. * @param indexBuffer defines the index buffer to bind
  10513. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  10514. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  10515. * @param effect defines the effect associated with the vertex buffer
  10516. */
  10517. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  10518. private _unbindVertexArrayObject;
  10519. /**
  10520. * Bind a list of vertex buffers to the webGL context
  10521. * @param vertexBuffers defines the list of vertex buffers to bind
  10522. * @param indexBuffer defines the index buffer to bind
  10523. * @param effect defines the effect associated with the vertex buffers
  10524. */
  10525. bindBuffers(vertexBuffers: {
  10526. [key: string]: Nullable<VertexBuffer>;
  10527. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  10528. /**
  10529. * Unbind all instance attributes
  10530. */
  10531. unbindInstanceAttributes(): void;
  10532. /**
  10533. * Release and free the memory of a vertex array object
  10534. * @param vao defines the vertex array object to delete
  10535. */
  10536. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  10537. /** @hidden */
  10538. /**
  10539. * Creates a webGL buffer to use with instanciation
  10540. * @param capacity defines the size of the buffer
  10541. * @returns the webGL buffer
  10542. */
  10543. createInstancesBuffer(capacity: number): WebGLBuffer;
  10544. /**
  10545. * Delete a webGL buffer used with instanciation
  10546. * @param buffer defines the webGL buffer to delete
  10547. */
  10548. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  10549. /**
  10550. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  10551. * @param instancesBuffer defines the webGL buffer to update and bind
  10552. * @param data defines the data to store in the buffer
  10553. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  10554. */
  10555. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  10556. /**
  10557. * Apply all cached states (depth, culling, stencil and alpha)
  10558. */
  10559. applyStates(): void;
  10560. /**
  10561. * Send a draw order
  10562. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  10563. * @param indexStart defines the starting index
  10564. * @param indexCount defines the number of index to draw
  10565. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  10566. */
  10567. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  10568. /**
  10569. * Draw a list of points
  10570. * @param verticesStart defines the index of first vertex to draw
  10571. * @param verticesCount defines the count of vertices to draw
  10572. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  10573. */
  10574. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  10575. /**
  10576. * Draw a list of unindexed primitives
  10577. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  10578. * @param verticesStart defines the index of first vertex to draw
  10579. * @param verticesCount defines the count of vertices to draw
  10580. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  10581. */
  10582. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  10583. /**
  10584. * Draw a list of indexed primitives
  10585. * @param fillMode defines the primitive to use
  10586. * @param indexStart defines the starting index
  10587. * @param indexCount defines the number of index to draw
  10588. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  10589. */
  10590. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  10591. /**
  10592. * Draw a list of unindexed primitives
  10593. * @param fillMode defines the primitive to use
  10594. * @param verticesStart defines the index of first vertex to draw
  10595. * @param verticesCount defines the count of vertices to draw
  10596. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  10597. */
  10598. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  10599. private _drawMode;
  10600. /** @hidden */
  10601. /** @hidden */
  10602. /**
  10603. * Create a new effect (used to store vertex/fragment shaders)
  10604. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  10605. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  10606. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  10607. * @param samplers defines an array of string used to represent textures
  10608. * @param defines defines the string containing the defines to use to compile the shaders
  10609. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  10610. * @param onCompiled defines a function to call when the effect creation is successful
  10611. * @param onError defines a function to call when the effect creation has failed
  10612. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  10613. * @returns the new Effect
  10614. */
  10615. 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;
  10616. private _compileShader;
  10617. private _compileRawShader;
  10618. /**
  10619. * Directly creates a webGL program
  10620. * @param vertexCode defines the vertex shader code to use
  10621. * @param fragmentCode defines the fragment shader code to use
  10622. * @param context defines the webGL context to use (if not set, the current one will be used)
  10623. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  10624. * @returns the new webGL program
  10625. */
  10626. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  10627. /**
  10628. * Creates a webGL program
  10629. * @param vertexCode defines the vertex shader code to use
  10630. * @param fragmentCode defines the fragment shader code to use
  10631. * @param defines defines the string containing the defines to use to compile the shaders
  10632. * @param context defines the webGL context to use (if not set, the current one will be used)
  10633. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  10634. * @returns the new webGL program
  10635. */
  10636. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  10637. private _createShaderProgram;
  10638. private _finalizeProgram;
  10639. /** @hidden */
  10640. /** @hidden */
  10641. /**
  10642. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  10643. * @param shaderProgram defines the webGL program to use
  10644. * @param uniformsNames defines the list of uniform names
  10645. * @returns an array of webGL uniform locations
  10646. */
  10647. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  10648. /**
  10649. * Gets the lsit of active attributes for a given webGL program
  10650. * @param shaderProgram defines the webGL program to use
  10651. * @param attributesNames defines the list of attribute names to get
  10652. * @returns an array of indices indicating the offset of each attribute
  10653. */
  10654. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  10655. /**
  10656. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  10657. * @param effect defines the effect to activate
  10658. */
  10659. enableEffect(effect: Nullable<Effect>): void;
  10660. /**
  10661. * Set the value of an uniform to an array of int32
  10662. * @param uniform defines the webGL uniform location where to store the value
  10663. * @param array defines the array of int32 to store
  10664. */
  10665. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  10666. /**
  10667. * Set the value of an uniform to an array of int32 (stored as vec2)
  10668. * @param uniform defines the webGL uniform location where to store the value
  10669. * @param array defines the array of int32 to store
  10670. */
  10671. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  10672. /**
  10673. * Set the value of an uniform to an array of int32 (stored as vec3)
  10674. * @param uniform defines the webGL uniform location where to store the value
  10675. * @param array defines the array of int32 to store
  10676. */
  10677. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  10678. /**
  10679. * Set the value of an uniform to an array of int32 (stored as vec4)
  10680. * @param uniform defines the webGL uniform location where to store the value
  10681. * @param array defines the array of int32 to store
  10682. */
  10683. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  10684. /**
  10685. * Set the value of an uniform to an array of float32
  10686. * @param uniform defines the webGL uniform location where to store the value
  10687. * @param array defines the array of float32 to store
  10688. */
  10689. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  10690. /**
  10691. * Set the value of an uniform to an array of float32 (stored as vec2)
  10692. * @param uniform defines the webGL uniform location where to store the value
  10693. * @param array defines the array of float32 to store
  10694. */
  10695. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  10696. /**
  10697. * Set the value of an uniform to an array of float32 (stored as vec3)
  10698. * @param uniform defines the webGL uniform location where to store the value
  10699. * @param array defines the array of float32 to store
  10700. */
  10701. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  10702. /**
  10703. * Set the value of an uniform to an array of float32 (stored as vec4)
  10704. * @param uniform defines the webGL uniform location where to store the value
  10705. * @param array defines the array of float32 to store
  10706. */
  10707. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  10708. /**
  10709. * Set the value of an uniform to an array of number
  10710. * @param uniform defines the webGL uniform location where to store the value
  10711. * @param array defines the array of number to store
  10712. */
  10713. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  10714. /**
  10715. * Set the value of an uniform to an array of number (stored as vec2)
  10716. * @param uniform defines the webGL uniform location where to store the value
  10717. * @param array defines the array of number to store
  10718. */
  10719. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  10720. /**
  10721. * Set the value of an uniform to an array of number (stored as vec3)
  10722. * @param uniform defines the webGL uniform location where to store the value
  10723. * @param array defines the array of number to store
  10724. */
  10725. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  10726. /**
  10727. * Set the value of an uniform to an array of number (stored as vec4)
  10728. * @param uniform defines the webGL uniform location where to store the value
  10729. * @param array defines the array of number to store
  10730. */
  10731. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  10732. /**
  10733. * Set the value of an uniform to an array of float32 (stored as matrices)
  10734. * @param uniform defines the webGL uniform location where to store the value
  10735. * @param matrices defines the array of float32 to store
  10736. */
  10737. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  10738. /**
  10739. * Set the value of an uniform to a matrix
  10740. * @param uniform defines the webGL uniform location where to store the value
  10741. * @param matrix defines the matrix to store
  10742. */
  10743. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  10744. /**
  10745. * Set the value of an uniform to a matrix (3x3)
  10746. * @param uniform defines the webGL uniform location where to store the value
  10747. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  10748. */
  10749. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  10750. /**
  10751. * Set the value of an uniform to a matrix (2x2)
  10752. * @param uniform defines the webGL uniform location where to store the value
  10753. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  10754. */
  10755. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  10756. /**
  10757. * Set the value of an uniform to a number (int)
  10758. * @param uniform defines the webGL uniform location where to store the value
  10759. * @param value defines the int number to store
  10760. */
  10761. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  10762. /**
  10763. * Set the value of an uniform to a number (float)
  10764. * @param uniform defines the webGL uniform location where to store the value
  10765. * @param value defines the float number to store
  10766. */
  10767. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  10768. /**
  10769. * Set the value of an uniform to a vec2
  10770. * @param uniform defines the webGL uniform location where to store the value
  10771. * @param x defines the 1st component of the value
  10772. * @param y defines the 2nd component of the value
  10773. */
  10774. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  10775. /**
  10776. * Set the value of an uniform to a vec3
  10777. * @param uniform defines the webGL uniform location where to store the value
  10778. * @param x defines the 1st component of the value
  10779. * @param y defines the 2nd component of the value
  10780. * @param z defines the 3rd component of the value
  10781. */
  10782. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  10783. /**
  10784. * Set the value of an uniform to a boolean
  10785. * @param uniform defines the webGL uniform location where to store the value
  10786. * @param bool defines the boolean to store
  10787. */
  10788. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  10789. /**
  10790. * Set the value of an uniform to a vec4
  10791. * @param uniform defines the webGL uniform location where to store the value
  10792. * @param x defines the 1st component of the value
  10793. * @param y defines the 2nd component of the value
  10794. * @param z defines the 3rd component of the value
  10795. * @param w defines the 4th component of the value
  10796. */
  10797. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  10798. /**
  10799. * Set the value of an uniform to a Color3
  10800. * @param uniform defines the webGL uniform location where to store the value
  10801. * @param color3 defines the color to store
  10802. */
  10803. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  10804. /**
  10805. * Set the value of an uniform to a Color3 and an alpha value
  10806. * @param uniform defines the webGL uniform location where to store the value
  10807. * @param color3 defines the color to store
  10808. * @param alpha defines the alpha component to store
  10809. */
  10810. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  10811. /**
  10812. * Sets a Color4 on a uniform variable
  10813. * @param uniform defines the uniform location
  10814. * @param color4 defines the value to be set
  10815. */
  10816. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  10817. /**
  10818. * Set various states to the webGL context
  10819. * @param culling defines backface culling state
  10820. * @param zOffset defines the value to apply to zOffset (0 by default)
  10821. * @param force defines if states must be applied even if cache is up to date
  10822. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  10823. */
  10824. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  10825. /**
  10826. * Set the z offset to apply to current rendering
  10827. * @param value defines the offset to apply
  10828. */
  10829. setZOffset(value: number): void;
  10830. /**
  10831. * Gets the current value of the zOffset
  10832. * @returns the current zOffset state
  10833. */
  10834. getZOffset(): number;
  10835. /**
  10836. * Enable or disable depth buffering
  10837. * @param enable defines the state to set
  10838. */
  10839. setDepthBuffer(enable: boolean): void;
  10840. /**
  10841. * Gets a boolean indicating if depth writing is enabled
  10842. * @returns the current depth writing state
  10843. */
  10844. getDepthWrite(): boolean;
  10845. /**
  10846. * Enable or disable depth writing
  10847. * @param enable defines the state to set
  10848. */
  10849. setDepthWrite(enable: boolean): void;
  10850. /**
  10851. * Enable or disable color writing
  10852. * @param enable defines the state to set
  10853. */
  10854. setColorWrite(enable: boolean): void;
  10855. /**
  10856. * Gets a boolean indicating if color writing is enabled
  10857. * @returns the current color writing state
  10858. */
  10859. getColorWrite(): boolean;
  10860. /**
  10861. * Sets alpha constants used by some alpha blending modes
  10862. * @param r defines the red component
  10863. * @param g defines the green component
  10864. * @param b defines the blue component
  10865. * @param a defines the alpha component
  10866. */
  10867. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  10868. /**
  10869. * Sets the current alpha mode
  10870. * @param mode defines the mode to use (one of the BABYLON.Engine.ALPHA_XXX)
  10871. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  10872. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  10873. */
  10874. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  10875. /**
  10876. * Gets the current alpha mode
  10877. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  10878. * @returns the current alpha mode
  10879. */
  10880. getAlphaMode(): number;
  10881. /**
  10882. * Clears the list of texture accessible through engine.
  10883. * This can help preventing texture load conflict due to name collision.
  10884. */
  10885. clearInternalTexturesCache(): void;
  10886. /**
  10887. * Force the entire cache to be cleared
  10888. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  10889. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  10890. */
  10891. wipeCaches(bruteForce?: boolean): void;
  10892. /**
  10893. * Set the compressed texture format to use, based on the formats you have, and the formats
  10894. * supported by the hardware / browser.
  10895. *
  10896. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  10897. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  10898. * to API arguments needed to compressed textures. This puts the burden on the container
  10899. * generator to house the arcane code for determining these for current & future formats.
  10900. *
  10901. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  10902. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  10903. *
  10904. * Note: The result of this call is not taken into account when a texture is base64.
  10905. *
  10906. * @param formatsAvailable defines the list of those format families you have created
  10907. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  10908. *
  10909. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  10910. * @returns The extension selected.
  10911. */
  10912. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  10913. private _getSamplingParameters;
  10914. private _partialLoadImg;
  10915. private _cascadeLoadImgs;
  10916. /** @hidden */
  10917. /**
  10918. * Usually called from BABYLON.Texture.ts.
  10919. * Passed information to create a WebGLTexture
  10920. * @param urlArg defines a value which contains one of the following:
  10921. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  10922. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  10923. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  10924. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  10925. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  10926. * @param scene needed for loading to the correct scene
  10927. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  10928. * @param onLoad optional callback to be called upon successful completion
  10929. * @param onError optional callback to be called upon failure
  10930. * @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
  10931. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  10932. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  10933. * @param forcedExtension defines the extension to use to pick the right loader
  10934. * @returns a InternalTexture for assignment back into BABYLON.Texture
  10935. */
  10936. 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;
  10937. private _rescaleTexture;
  10938. /**
  10939. * Update a raw texture
  10940. * @param texture defines the texture to update
  10941. * @param data defines the data to store in the texture
  10942. * @param format defines the format of the data
  10943. * @param invertY defines if data must be stored with Y axis inverted
  10944. * @param compression defines the compression used (null by default)
  10945. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10946. */
  10947. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  10948. /**
  10949. * Creates a raw texture
  10950. * @param data defines the data to store in the texture
  10951. * @param width defines the width of the texture
  10952. * @param height defines the height of the texture
  10953. * @param format defines the format of the data
  10954. * @param generateMipMaps defines if the engine should generate the mip levels
  10955. * @param invertY defines if data must be stored with Y axis inverted
  10956. * @param samplingMode defines the required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  10957. * @param compression defines the compression used (null by default)
  10958. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10959. * @returns the raw texture inside an InternalTexture
  10960. */
  10961. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  10962. private _unpackFlipYCached;
  10963. /**
  10964. * In case you are sharing the context with other applications, it might
  10965. * be interested to not cache the unpack flip y state to ensure a consistent
  10966. * value would be set.
  10967. */
  10968. enableUnpackFlipYCached: boolean;
  10969. /** @hidden */
  10970. /** @hidden */
  10971. /**
  10972. * Creates a dynamic texture
  10973. * @param width defines the width of the texture
  10974. * @param height defines the height of the texture
  10975. * @param generateMipMaps defines if the engine should generate the mip levels
  10976. * @param samplingMode defines the required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  10977. * @returns the dynamic texture inside an InternalTexture
  10978. */
  10979. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  10980. /**
  10981. * Update the sampling mode of a given texture
  10982. * @param samplingMode defines the required sampling mode
  10983. * @param texture defines the texture to update
  10984. */
  10985. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  10986. /**
  10987. * Update the content of a dynamic texture
  10988. * @param texture defines the texture to update
  10989. * @param canvas defines the canvas containing the source
  10990. * @param invertY defines if data must be stored with Y axis inverted
  10991. * @param premulAlpha defines if alpha is stored as premultiplied
  10992. * @param format defines the format of the data
  10993. */
  10994. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  10995. /**
  10996. * Update a video texture
  10997. * @param texture defines the texture to update
  10998. * @param video defines the video element to use
  10999. * @param invertY defines if data must be stored with Y axis inverted
  11000. */
  11001. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  11002. /**
  11003. * Updates a depth texture Comparison Mode and Function.
  11004. * If the comparison Function is equal to 0, the mode will be set to none.
  11005. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  11006. * @param texture The texture to set the comparison function for
  11007. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  11008. */
  11009. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  11010. private _setupDepthStencilTexture;
  11011. /**
  11012. * Creates a depth stencil texture.
  11013. * This is only available in WebGL 2 or with the depth texture extension available.
  11014. * @param size The size of face edge in the texture.
  11015. * @param options The options defining the texture.
  11016. * @returns The texture
  11017. */
  11018. createDepthStencilTexture(size: number | {
  11019. width: number;
  11020. height: number;
  11021. }, options: DepthTextureCreationOptions): InternalTexture;
  11022. /**
  11023. * Creates a depth stencil texture.
  11024. * This is only available in WebGL 2 or with the depth texture extension available.
  11025. * @param size The size of face edge in the texture.
  11026. * @param options The options defining the texture.
  11027. * @returns The texture
  11028. */
  11029. private _createDepthStencilTexture;
  11030. /**
  11031. * Creates a depth stencil cube texture.
  11032. * This is only available in WebGL 2.
  11033. * @param size The size of face edge in the cube texture.
  11034. * @param options The options defining the cube texture.
  11035. * @returns The cube texture
  11036. */
  11037. private _createDepthStencilCubeTexture;
  11038. /**
  11039. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  11040. * @param renderTarget The render target to set the frame buffer for
  11041. */
  11042. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  11043. /**
  11044. * Creates a new render target texture
  11045. * @param size defines the size of the texture
  11046. * @param options defines the options used to create the texture
  11047. * @returns a new render target texture stored in an InternalTexture
  11048. */
  11049. createRenderTargetTexture(size: number | {
  11050. width: number;
  11051. height: number;
  11052. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  11053. /**
  11054. * Create a multi render target texture
  11055. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  11056. * @param size defines the size of the texture
  11057. * @param options defines the creation options
  11058. * @returns the cube texture as an InternalTexture
  11059. */
  11060. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  11061. private _setupFramebufferDepthAttachments;
  11062. /**
  11063. * Updates the sample count of a render target texture
  11064. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  11065. * @param texture defines the texture to update
  11066. * @param samples defines the sample count to set
  11067. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  11068. */
  11069. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  11070. /**
  11071. * Update the sample count for a given multiple render target texture
  11072. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  11073. * @param textures defines the textures to update
  11074. * @param samples defines the sample count to set
  11075. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  11076. */
  11077. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  11078. /** @hidden */
  11079. /** @hidden */
  11080. /** @hidden */
  11081. /** @hidden */
  11082. /**
  11083. * Creates a new render target cube texture
  11084. * @param size defines the size of the texture
  11085. * @param options defines the options used to create the texture
  11086. * @returns a new render target cube texture stored in an InternalTexture
  11087. */
  11088. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  11089. /**
  11090. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  11091. * @param rootUrl defines the url where the file to load is located
  11092. * @param scene defines the current scene
  11093. * @param lodScale defines scale to apply to the mip map selection
  11094. * @param lodOffset defines offset to apply to the mip map selection
  11095. * @param onLoad defines an optional callback raised when the texture is loaded
  11096. * @param onError defines an optional callback raised if there is an issue to load the texture
  11097. * @param format defines the format of the data
  11098. * @param forcedExtension defines the extension to use to pick the right loader
  11099. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  11100. * @returns the cube texture as an InternalTexture
  11101. */
  11102. 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;
  11103. /**
  11104. * Creates a cube texture
  11105. * @param rootUrl defines the url where the files to load is located
  11106. * @param scene defines the current scene
  11107. * @param files defines the list of files to load (1 per face)
  11108. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  11109. * @param onLoad defines an optional callback raised when the texture is loaded
  11110. * @param onError defines an optional callback raised if there is an issue to load the texture
  11111. * @param format defines the format of the data
  11112. * @param forcedExtension defines the extension to use to pick the right loader
  11113. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  11114. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  11115. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  11116. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  11117. * @returns the cube texture as an InternalTexture
  11118. */
  11119. 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;
  11120. /**
  11121. * @hidden
  11122. */
  11123. /**
  11124. * Update a raw cube texture
  11125. * @param texture defines the texture to udpdate
  11126. * @param data defines the data to store
  11127. * @param format defines the data format
  11128. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11129. * @param invertY defines if data must be stored with Y axis inverted
  11130. * @param compression defines the compression used (null by default)
  11131. * @param level defines which level of the texture to update
  11132. */
  11133. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  11134. /**
  11135. * Creates a new raw cube texture
  11136. * @param data defines the array of data to use to create each face
  11137. * @param size defines the size of the textures
  11138. * @param format defines the format of the data
  11139. * @param type defines the type of the data (like BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT)
  11140. * @param generateMipMaps defines if the engine should generate the mip levels
  11141. * @param invertY defines if data must be stored with Y axis inverted
  11142. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  11143. * @param compression defines the compression used (null by default)
  11144. * @returns the cube texture as an InternalTexture
  11145. */
  11146. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  11147. /**
  11148. * Creates a new raw cube texture from a specified url
  11149. * @param url defines the url where the data is located
  11150. * @param scene defines the current scene
  11151. * @param size defines the size of the textures
  11152. * @param format defines the format of the data
  11153. * @param type defines the type fo the data (like BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT)
  11154. * @param noMipmap defines if the engine should avoid generating the mip levels
  11155. * @param callback defines a callback used to extract texture data from loaded data
  11156. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11157. * @param onLoad defines a callback called when texture is loaded
  11158. * @param onError defines a callback called if there is an error
  11159. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  11160. * @param invertY defines if data must be stored with Y axis inverted
  11161. * @returns the cube texture as an InternalTexture
  11162. */
  11163. 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;
  11164. /**
  11165. * Update a raw 3D texture
  11166. * @param texture defines the texture to update
  11167. * @param data defines the data to store
  11168. * @param format defines the data format
  11169. * @param invertY defines if data must be stored with Y axis inverted
  11170. * @param compression defines the used compression (can be null)
  11171. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11172. */
  11173. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  11174. /**
  11175. * Creates a new raw 3D texture
  11176. * @param data defines the data used to create the texture
  11177. * @param width defines the width of the texture
  11178. * @param height defines the height of the texture
  11179. * @param depth defines the depth of the texture
  11180. * @param format defines the format of the texture
  11181. * @param generateMipMaps defines if the engine must generate mip levels
  11182. * @param invertY defines if data must be stored with Y axis inverted
  11183. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  11184. * @param compression defines the compressed used (can be null)
  11185. * @param textureType defines the compressed used (can be null)
  11186. * @returns a new raw 3D texture (stored in an InternalTexture)
  11187. */
  11188. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  11189. private _prepareWebGLTextureContinuation;
  11190. private _prepareWebGLTexture;
  11191. private _convertRGBtoRGBATextureData;
  11192. /** @hidden */
  11193. /** @hidden */
  11194. private setProgram;
  11195. private _boundUniforms;
  11196. /**
  11197. * Binds an effect to the webGL context
  11198. * @param effect defines the effect to bind
  11199. */
  11200. bindSamplers(effect: Effect): void;
  11201. private _moveBoundTextureOnTop;
  11202. private _getCorrectTextureChannel;
  11203. private _linkTrackers;
  11204. private _removeDesignatedSlot;
  11205. private _activateCurrentTexture;
  11206. /** @hidden */
  11207. protected _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  11208. /** @hidden */
  11209. /**
  11210. * Sets a texture to the webGL context from a postprocess
  11211. * @param channel defines the channel to use
  11212. * @param postProcess defines the source postprocess
  11213. */
  11214. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  11215. /**
  11216. * Binds the output of the passed in post process to the texture channel specified
  11217. * @param channel The channel the texture should be bound to
  11218. * @param postProcess The post process which's output should be bound
  11219. */
  11220. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  11221. /**
  11222. * Unbind all textures from the webGL context
  11223. */
  11224. unbindAllTextures(): void;
  11225. /**
  11226. * Sets a texture to the according uniform.
  11227. * @param channel The texture channel
  11228. * @param uniform The uniform to set
  11229. * @param texture The texture to apply
  11230. */
  11231. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  11232. /**
  11233. * Sets a depth stencil texture from a render target to the according uniform.
  11234. * @param channel The texture channel
  11235. * @param uniform The uniform to set
  11236. * @param texture The render target texture containing the depth stencil texture to apply
  11237. */
  11238. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  11239. private _bindSamplerUniformToChannel;
  11240. private _getTextureWrapMode;
  11241. private _setTexture;
  11242. /**
  11243. * Sets an array of texture to the webGL context
  11244. * @param channel defines the channel where the texture array must be set
  11245. * @param uniform defines the associated uniform location
  11246. * @param textures defines the array of textures to bind
  11247. */
  11248. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  11249. /** @hidden */
  11250. private _setTextureParameterFloat;
  11251. private _setTextureParameterInteger;
  11252. /**
  11253. * Reads pixels from the current frame buffer. Please note that this function can be slow
  11254. * @param x defines the x coordinate of the rectangle where pixels must be read
  11255. * @param y defines the y coordinate of the rectangle where pixels must be read
  11256. * @param width defines the width of the rectangle where pixels must be read
  11257. * @param height defines the height of the rectangle where pixels must be read
  11258. * @returns a Uint8Array containing RGBA colors
  11259. */
  11260. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  11261. /**
  11262. * Add an externaly attached data from its key.
  11263. * This method call will fail and return false, if such key already exists.
  11264. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  11265. * @param key the unique key that identifies the data
  11266. * @param data the data object to associate to the key for this Engine instance
  11267. * @return true if no such key were already present and the data was added successfully, false otherwise
  11268. */
  11269. addExternalData<T>(key: string, data: T): boolean;
  11270. /**
  11271. * Get an externaly attached data from its key
  11272. * @param key the unique key that identifies the data
  11273. * @return the associated data, if present (can be null), or undefined if not present
  11274. */
  11275. getExternalData<T>(key: string): T;
  11276. /**
  11277. * Get an externaly attached data from its key, create it using a factory if it's not already present
  11278. * @param key the unique key that identifies the data
  11279. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  11280. * @return the associated data, can be null if the factory returned null.
  11281. */
  11282. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  11283. /**
  11284. * Remove an externaly attached data from the Engine instance
  11285. * @param key the unique key that identifies the data
  11286. * @return true if the data was successfully removed, false if it doesn't exist
  11287. */
  11288. removeExternalData(key: string): boolean;
  11289. /**
  11290. * Unbind all vertex attributes from the webGL context
  11291. */
  11292. unbindAllAttributes(): void;
  11293. /**
  11294. * 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
  11295. */
  11296. releaseEffects(): void;
  11297. /**
  11298. * Dispose and release all associated resources
  11299. */
  11300. dispose(): void;
  11301. /**
  11302. * Display the loading screen
  11303. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  11304. */
  11305. displayLoadingUI(): void;
  11306. /**
  11307. * Hide the loading screen
  11308. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  11309. */
  11310. hideLoadingUI(): void;
  11311. /**
  11312. * Gets the current loading screen object
  11313. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  11314. */
  11315. /**
  11316. * Sets the current loading screen object
  11317. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  11318. */
  11319. loadingScreen: ILoadingScreen;
  11320. /**
  11321. * Sets the current loading screen text
  11322. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  11323. */
  11324. loadingUIText: string;
  11325. /**
  11326. * Sets the current loading screen background color
  11327. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  11328. */
  11329. loadingUIBackgroundColor: string;
  11330. /**
  11331. * Attach a new callback raised when context lost event is fired
  11332. * @param callback defines the callback to call
  11333. */
  11334. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  11335. /**
  11336. * Attach a new callback raised when context restored event is fired
  11337. * @param callback defines the callback to call
  11338. */
  11339. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  11340. /**
  11341. * Gets the source code of the vertex shader associated with a specific webGL program
  11342. * @param program defines the program to use
  11343. * @returns a string containing the source code of the vertex shader associated with the program
  11344. */
  11345. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  11346. /**
  11347. * Gets the source code of the fragment shader associated with a specific webGL program
  11348. * @param program defines the program to use
  11349. * @returns a string containing the source code of the fragment shader associated with the program
  11350. */
  11351. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  11352. /**
  11353. * Get the current error code of the webGL context
  11354. * @returns the error code
  11355. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  11356. */
  11357. getError(): number;
  11358. /**
  11359. * Gets the current framerate
  11360. * @returns a number representing the framerate
  11361. */
  11362. getFps(): number;
  11363. /**
  11364. * Gets the time spent between current and previous frame
  11365. * @returns a number representing the delta time in ms
  11366. */
  11367. getDeltaTime(): number;
  11368. private _measureFps;
  11369. /** @hidden */
  11370. private _canRenderToFloatFramebuffer;
  11371. private _canRenderToHalfFloatFramebuffer;
  11372. private _canRenderToFramebuffer;
  11373. /** @hidden */
  11374. private _getInternalFormat;
  11375. /** @hidden */
  11376. /** @hidden */
  11377. /** @hidden */
  11378. /** @hidden */
  11379. private _partialLoadFile;
  11380. private _cascadeLoadFiles;
  11381. /**
  11382. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  11383. * @returns true if the engine can be created
  11384. * @ignorenaming
  11385. */
  11386. static isSupported(): boolean;
  11387. }
  11388. }
  11389. declare module BABYLON {
  11390. /**
  11391. * Options to create the null engine
  11392. */
  11393. class NullEngineOptions {
  11394. /**
  11395. * Render width (Default: 512)
  11396. */
  11397. renderWidth: number;
  11398. /**
  11399. * Render height (Default: 256)
  11400. */
  11401. renderHeight: number;
  11402. /**
  11403. * Texture size (Default: 512)
  11404. */
  11405. textureSize: number;
  11406. /**
  11407. * If delta time between frames should be constant
  11408. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  11409. */
  11410. deterministicLockstep: boolean;
  11411. /**
  11412. * Maximum about of steps between frames (Default: 4)
  11413. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  11414. */
  11415. lockstepMaxSteps: number;
  11416. }
  11417. /**
  11418. * The null engine class provides support for headless version of babylon.js.
  11419. * This can be used in server side scenario or for testing purposes
  11420. */
  11421. class NullEngine extends Engine {
  11422. private _options;
  11423. /**
  11424. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  11425. */
  11426. isDeterministicLockStep(): boolean;
  11427. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  11428. getLockstepMaxSteps(): number;
  11429. /**
  11430. * Sets hardware scaling, used to save performance if needed
  11431. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  11432. */
  11433. getHardwareScalingLevel(): number;
  11434. constructor(options?: NullEngineOptions);
  11435. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  11436. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  11437. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  11438. getRenderWidth(useScreen?: boolean): number;
  11439. getRenderHeight(useScreen?: boolean): number;
  11440. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  11441. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  11442. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  11443. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  11444. bindSamplers(effect: Effect): void;
  11445. enableEffect(effect: Effect): void;
  11446. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  11447. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  11448. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  11449. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  11450. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  11451. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  11452. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  11453. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  11454. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  11455. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  11456. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  11457. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  11458. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  11459. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  11460. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  11461. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  11462. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  11463. setFloat(uniform: WebGLUniformLocation, value: number): void;
  11464. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  11465. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  11466. setBool(uniform: WebGLUniformLocation, bool: number): void;
  11467. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  11468. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  11469. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  11470. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  11471. bindBuffers(vertexBuffers: {
  11472. [key: string]: VertexBuffer;
  11473. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  11474. wipeCaches(bruteForce?: boolean): void;
  11475. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  11476. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  11477. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  11478. /** @hidden */
  11479. /** @hidden */
  11480. 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;
  11481. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  11482. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  11483. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  11484. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  11485. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  11486. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  11487. /**
  11488. * @hidden
  11489. * Get the current error code of the webGL context
  11490. * @returns the error code
  11491. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  11492. */
  11493. getError(): number;
  11494. /** @hidden */
  11495. /** @hidden */
  11496. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  11497. /**
  11498. * Updates a dynamic vertex buffer.
  11499. * @param vertexBuffer the vertex buffer to update
  11500. * @param data the data used to update the vertex buffer
  11501. * @param byteOffset the byte offset of the data (optional)
  11502. * @param byteLength the byte length of the data (optional)
  11503. */
  11504. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  11505. protected _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  11506. /** @hidden */
  11507. /** @hidden */
  11508. releaseEffects(): void;
  11509. displayLoadingUI(): void;
  11510. hideLoadingUI(): void;
  11511. /** @hidden */
  11512. /** @hidden */
  11513. /** @hidden */
  11514. /** @hidden */
  11515. }
  11516. }
  11517. interface WebGLRenderingContext {
  11518. readonly RASTERIZER_DISCARD: number;
  11519. readonly DEPTH_COMPONENT24: number;
  11520. readonly TEXTURE_3D: number;
  11521. readonly TEXTURE_2D_ARRAY: number;
  11522. readonly TEXTURE_COMPARE_FUNC: number;
  11523. readonly TEXTURE_COMPARE_MODE: number;
  11524. readonly COMPARE_REF_TO_TEXTURE: number;
  11525. readonly TEXTURE_WRAP_R: number;
  11526. readonly HALF_FLOAT: number;
  11527. readonly RGB8: number;
  11528. readonly RED_INTEGER: number;
  11529. readonly RG_INTEGER: number;
  11530. readonly RGB_INTEGER: number;
  11531. readonly RGBA_INTEGER: number;
  11532. readonly R8_SNORM: number;
  11533. readonly RG8_SNORM: number;
  11534. readonly RGB8_SNORM: number;
  11535. readonly RGBA8_SNORM: number;
  11536. readonly R8I: number;
  11537. readonly RG8I: number;
  11538. readonly RGB8I: number;
  11539. readonly RGBA8I: number;
  11540. readonly R8UI: number;
  11541. readonly RG8UI: number;
  11542. readonly RGB8UI: number;
  11543. readonly RGBA8UI: number;
  11544. readonly R16I: number;
  11545. readonly RG16I: number;
  11546. readonly RGB16I: number;
  11547. readonly RGBA16I: number;
  11548. readonly R16UI: number;
  11549. readonly RG16UI: number;
  11550. readonly RGB16UI: number;
  11551. readonly RGBA16UI: number;
  11552. readonly R32I: number;
  11553. readonly RG32I: number;
  11554. readonly RGB32I: number;
  11555. readonly RGBA32I: number;
  11556. readonly R32UI: number;
  11557. readonly RG32UI: number;
  11558. readonly RGB32UI: number;
  11559. readonly RGBA32UI: number;
  11560. readonly RGB10_A2UI: number;
  11561. readonly R11F_G11F_B10F: number;
  11562. readonly RGB9_E5: number;
  11563. readonly RGB10_A2: number;
  11564. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  11565. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  11566. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  11567. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  11568. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  11569. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  11570. 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;
  11571. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  11572. readonly TRANSFORM_FEEDBACK: number;
  11573. readonly INTERLEAVED_ATTRIBS: number;
  11574. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  11575. createTransformFeedback(): WebGLTransformFeedback;
  11576. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  11577. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  11578. beginTransformFeedback(primitiveMode: number): void;
  11579. endTransformFeedback(): void;
  11580. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  11581. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  11582. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  11583. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  11584. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  11585. }
  11586. interface ImageBitmap {
  11587. readonly width: number;
  11588. readonly height: number;
  11589. close(): void;
  11590. }
  11591. interface WebGLQuery extends WebGLObject {
  11592. }
  11593. declare var WebGLQuery: {
  11594. prototype: WebGLQuery;
  11595. new (): WebGLQuery;
  11596. };
  11597. interface WebGLSampler extends WebGLObject {
  11598. }
  11599. declare var WebGLSampler: {
  11600. prototype: WebGLSampler;
  11601. new (): WebGLSampler;
  11602. };
  11603. interface WebGLSync extends WebGLObject {
  11604. }
  11605. declare var WebGLSync: {
  11606. prototype: WebGLSync;
  11607. new (): WebGLSync;
  11608. };
  11609. interface WebGLTransformFeedback extends WebGLObject {
  11610. }
  11611. declare var WebGLTransformFeedback: {
  11612. prototype: WebGLTransformFeedback;
  11613. new (): WebGLTransformFeedback;
  11614. };
  11615. interface WebGLVertexArrayObject extends WebGLObject {
  11616. }
  11617. declare var WebGLVertexArrayObject: {
  11618. prototype: WebGLVertexArrayObject;
  11619. new (): WebGLVertexArrayObject;
  11620. };
  11621. declare module BABYLON {
  11622. /**
  11623. * Gather the list of keyboard event types as constants.
  11624. */
  11625. class KeyboardEventTypes {
  11626. /**
  11627. * The keydown event is fired when a key becomes active (pressed).
  11628. */
  11629. static readonly KEYDOWN: number;
  11630. /**
  11631. * The keyup event is fired when a key has been released.
  11632. */
  11633. static readonly KEYUP: number;
  11634. }
  11635. /**
  11636. * This class is used to store keyboard related info for the onKeyboardObservable event.
  11637. */
  11638. class KeyboardInfo {
  11639. /**
  11640. * Defines the type of event (BABYLON.KeyboardEventTypes)
  11641. */
  11642. type: number;
  11643. /**
  11644. * Defines the related dom event
  11645. */
  11646. event: KeyboardEvent;
  11647. /**
  11648. * Instantiates a new keyboard info.
  11649. * This class is used to store keyboard related info for the onKeyboardObservable event.
  11650. * @param type Defines the type of event (BABYLON.KeyboardEventTypes)
  11651. * @param event Defines the related dom event
  11652. */
  11653. constructor(
  11654. /**
  11655. * Defines the type of event (BABYLON.KeyboardEventTypes)
  11656. */
  11657. type: number,
  11658. /**
  11659. * Defines the related dom event
  11660. */
  11661. event: KeyboardEvent);
  11662. }
  11663. /**
  11664. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  11665. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  11666. */
  11667. class KeyboardInfoPre extends KeyboardInfo {
  11668. /**
  11669. * Defines the type of event (BABYLON.KeyboardEventTypes)
  11670. */
  11671. type: number;
  11672. /**
  11673. * Defines the related dom event
  11674. */
  11675. event: KeyboardEvent;
  11676. /**
  11677. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  11678. */
  11679. skipOnPointerObservable: boolean;
  11680. /**
  11681. * Instantiates a new keyboard pre info.
  11682. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  11683. * @param type Defines the type of event (BABYLON.KeyboardEventTypes)
  11684. * @param event Defines the related dom event
  11685. */
  11686. constructor(
  11687. /**
  11688. * Defines the type of event (BABYLON.KeyboardEventTypes)
  11689. */
  11690. type: number,
  11691. /**
  11692. * Defines the related dom event
  11693. */
  11694. event: KeyboardEvent);
  11695. }
  11696. }
  11697. declare module BABYLON {
  11698. /**
  11699. * Gather the list of pointer event types as constants.
  11700. */
  11701. class PointerEventTypes {
  11702. /**
  11703. * 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.
  11704. */
  11705. static readonly POINTERDOWN: number;
  11706. /**
  11707. * The pointerup event is fired when a pointer is no longer active.
  11708. */
  11709. static readonly POINTERUP: number;
  11710. /**
  11711. * The pointermove event is fired when a pointer changes coordinates.
  11712. */
  11713. static readonly POINTERMOVE: number;
  11714. /**
  11715. * The pointerwheel event is fired when a mouse wheel has been rotated.
  11716. */
  11717. static readonly POINTERWHEEL: number;
  11718. /**
  11719. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  11720. */
  11721. static readonly POINTERPICK: number;
  11722. /**
  11723. * The pointertap event is fired when a the object has been touched and released without drag.
  11724. */
  11725. static readonly POINTERTAP: number;
  11726. /**
  11727. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  11728. */
  11729. static readonly POINTERDOUBLETAP: number;
  11730. }
  11731. /**
  11732. * Base class of pointer info types.
  11733. */
  11734. class PointerInfoBase {
  11735. /**
  11736. * Defines the type of event (BABYLON.PointerEventTypes)
  11737. */
  11738. type: number;
  11739. /**
  11740. * Defines the related dom event
  11741. */
  11742. event: PointerEvent | MouseWheelEvent;
  11743. /**
  11744. * Instantiates the base class of pointers info.
  11745. * @param type Defines the type of event (BABYLON.PointerEventTypes)
  11746. * @param event Defines the related dom event
  11747. */
  11748. constructor(
  11749. /**
  11750. * Defines the type of event (BABYLON.PointerEventTypes)
  11751. */
  11752. type: number,
  11753. /**
  11754. * Defines the related dom event
  11755. */
  11756. event: PointerEvent | MouseWheelEvent);
  11757. }
  11758. /**
  11759. * This class is used to store pointer related info for the onPrePointerObservable event.
  11760. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  11761. */
  11762. class PointerInfoPre extends PointerInfoBase {
  11763. /**
  11764. * Ray from a pointer if availible (eg. 6dof controller)
  11765. */
  11766. ray: Nullable<Ray>;
  11767. /**
  11768. * Defines the local position of the pointer on the canvas.
  11769. */
  11770. localPosition: Vector2;
  11771. /**
  11772. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  11773. */
  11774. skipOnPointerObservable: boolean;
  11775. /**
  11776. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  11777. * @param type Defines the type of event (BABYLON.PointerEventTypes)
  11778. * @param event Defines the related dom event
  11779. * @param localX Defines the local x coordinates of the pointer when the event occured
  11780. * @param localY Defines the local y coordinates of the pointer when the event occured
  11781. */
  11782. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  11783. }
  11784. /**
  11785. * This type contains all the data related to a pointer event in Babylon.js.
  11786. * 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.
  11787. */
  11788. class PointerInfo extends PointerInfoBase {
  11789. /**
  11790. * Defines the picking info associated to the info (if any)\
  11791. */
  11792. pickInfo: Nullable<PickingInfo>;
  11793. /**
  11794. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  11795. * @param type Defines the type of event (BABYLON.PointerEventTypes)
  11796. * @param event Defines the related dom event
  11797. * @param pickInfo Defines the picking info associated to the info (if any)\
  11798. */
  11799. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  11800. /**
  11801. * Defines the picking info associated to the info (if any)\
  11802. */
  11803. pickInfo: Nullable<PickingInfo>);
  11804. }
  11805. }
  11806. declare module BABYLON {
  11807. /**
  11808. * Represents a gamepad control stick position
  11809. */
  11810. class StickValues {
  11811. /**
  11812. * The x component of the control stick
  11813. */
  11814. x: number;
  11815. /**
  11816. * The y component of the control stick
  11817. */
  11818. y: number;
  11819. /**
  11820. * Initializes the gamepad x and y control stick values
  11821. * @param x The x component of the gamepad control stick value
  11822. * @param y The y component of the gamepad control stick value
  11823. */
  11824. constructor(
  11825. /**
  11826. * The x component of the control stick
  11827. */
  11828. x: number,
  11829. /**
  11830. * The y component of the control stick
  11831. */
  11832. y: number);
  11833. }
  11834. /**
  11835. * An interface which manages callbacks for gamepad button changes
  11836. */
  11837. interface GamepadButtonChanges {
  11838. /**
  11839. * Called when a gamepad has been changed
  11840. */
  11841. changed: boolean;
  11842. /**
  11843. * Called when a gamepad press event has been triggered
  11844. */
  11845. pressChanged: boolean;
  11846. /**
  11847. * Called when a touch event has been triggered
  11848. */
  11849. touchChanged: boolean;
  11850. /**
  11851. * Called when a value has changed
  11852. */
  11853. valueChanged: boolean;
  11854. }
  11855. /**
  11856. * Represents a gamepad
  11857. */
  11858. class Gamepad {
  11859. /**
  11860. * The id of the gamepad
  11861. */
  11862. id: string;
  11863. /**
  11864. * The index of the gamepad
  11865. */
  11866. index: number;
  11867. /**
  11868. * The browser gamepad
  11869. */
  11870. browserGamepad: any;
  11871. /**
  11872. * Specifies what type of gamepad this represents
  11873. */
  11874. type: number;
  11875. private _leftStick;
  11876. private _rightStick;
  11877. /** @hidden */
  11878. private _leftStickAxisX;
  11879. private _leftStickAxisY;
  11880. private _rightStickAxisX;
  11881. private _rightStickAxisY;
  11882. /**
  11883. * Triggered when the left control stick has been changed
  11884. */
  11885. private _onleftstickchanged;
  11886. /**
  11887. * Triggered when the right control stick has been changed
  11888. */
  11889. private _onrightstickchanged;
  11890. /**
  11891. * Represents a gamepad controller
  11892. */
  11893. static GAMEPAD: number;
  11894. /**
  11895. * Represents a generic controller
  11896. */
  11897. static GENERIC: number;
  11898. /**
  11899. * Represents an XBox controller
  11900. */
  11901. static XBOX: number;
  11902. /**
  11903. * Represents a pose-enabled controller
  11904. */
  11905. static POSE_ENABLED: number;
  11906. /**
  11907. * Specifies whether the left control stick should be Y-inverted
  11908. */
  11909. protected _invertLeftStickY: boolean;
  11910. /**
  11911. * Specifies if the gamepad has been connected
  11912. */
  11913. readonly isConnected: boolean;
  11914. /**
  11915. * Initializes the gamepad
  11916. * @param id The id of the gamepad
  11917. * @param index The index of the gamepad
  11918. * @param browserGamepad The browser gamepad
  11919. * @param leftStickX The x component of the left joystick
  11920. * @param leftStickY The y component of the left joystick
  11921. * @param rightStickX The x component of the right joystick
  11922. * @param rightStickY The y component of the right joystick
  11923. */
  11924. constructor(
  11925. /**
  11926. * The id of the gamepad
  11927. */
  11928. id: string,
  11929. /**
  11930. * The index of the gamepad
  11931. */
  11932. index: number,
  11933. /**
  11934. * The browser gamepad
  11935. */
  11936. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  11937. /**
  11938. * Callback triggered when the left joystick has changed
  11939. * @param callback
  11940. */
  11941. onleftstickchanged(callback: (values: StickValues) => void): void;
  11942. /**
  11943. * Callback triggered when the right joystick has changed
  11944. * @param callback
  11945. */
  11946. onrightstickchanged(callback: (values: StickValues) => void): void;
  11947. /**
  11948. * Gets the left joystick
  11949. */
  11950. /**
  11951. * Sets the left joystick values
  11952. */
  11953. leftStick: StickValues;
  11954. /**
  11955. * Gets the right joystick
  11956. */
  11957. /**
  11958. * Sets the right joystick value
  11959. */
  11960. rightStick: StickValues;
  11961. /**
  11962. * Updates the gamepad joystick positions
  11963. */
  11964. update(): void;
  11965. /**
  11966. * Disposes the gamepad
  11967. */
  11968. dispose(): void;
  11969. }
  11970. /**
  11971. * Represents a generic gamepad
  11972. */
  11973. class GenericPad extends Gamepad {
  11974. private _buttons;
  11975. private _onbuttondown;
  11976. private _onbuttonup;
  11977. /**
  11978. * Observable triggered when a button has been pressed
  11979. */
  11980. onButtonDownObservable: Observable<number>;
  11981. /**
  11982. * Observable triggered when a button has been released
  11983. */
  11984. onButtonUpObservable: Observable<number>;
  11985. /**
  11986. * Callback triggered when a button has been pressed
  11987. * @param callback Called when a button has been pressed
  11988. */
  11989. onbuttondown(callback: (buttonPressed: number) => void): void;
  11990. /**
  11991. * Callback triggered when a button has been released
  11992. * @param callback Called when a button has been released
  11993. */
  11994. onbuttonup(callback: (buttonReleased: number) => void): void;
  11995. /**
  11996. * Initializes the generic gamepad
  11997. * @param id The id of the generic gamepad
  11998. * @param index The index of the generic gamepad
  11999. * @param browserGamepad The browser gamepad
  12000. */
  12001. constructor(id: string, index: number, browserGamepad: any);
  12002. private _setButtonValue;
  12003. /**
  12004. * Updates the generic gamepad
  12005. */
  12006. update(): void;
  12007. /**
  12008. * Disposes the generic gamepad
  12009. */
  12010. dispose(): void;
  12011. }
  12012. }
  12013. declare module BABYLON {
  12014. /**
  12015. * Manager for handling gamepads
  12016. */
  12017. class GamepadManager {
  12018. private _scene?;
  12019. private _babylonGamepads;
  12020. private _oneGamepadConnected;
  12021. /** @hidden */
  12022. private _gamepadEventSupported;
  12023. private _gamepadSupport;
  12024. /**
  12025. * observable to be triggered when the gamepad controller has been connected
  12026. */
  12027. onGamepadConnectedObservable: Observable<Gamepad>;
  12028. /**
  12029. * observable to be triggered when the gamepad controller has been disconnected
  12030. */
  12031. onGamepadDisconnectedObservable: Observable<Gamepad>;
  12032. private _onGamepadConnectedEvent;
  12033. private _onGamepadDisconnectedEvent;
  12034. /**
  12035. * Initializes the gamepad manager
  12036. * @param _scene BabylonJS scene
  12037. */
  12038. constructor(_scene?: Scene | undefined);
  12039. /**
  12040. * The gamepads in the game pad manager
  12041. */
  12042. readonly gamepads: Gamepad[];
  12043. /**
  12044. * Get the gamepad controllers based on type
  12045. * @param type The type of gamepad controller
  12046. * @returns Nullable gamepad
  12047. */
  12048. getGamepadByType(type?: number): Nullable<Gamepad>;
  12049. /**
  12050. * Disposes the gamepad manager
  12051. */
  12052. dispose(): void;
  12053. private _addNewGamepad;
  12054. private _startMonitoringGamepads;
  12055. private _stopMonitoringGamepads;
  12056. /** @hidden */
  12057. private _updateGamepadObjects;
  12058. }
  12059. }
  12060. declare module BABYLON {
  12061. interface Scene {
  12062. /** @hidden */
  12063. /**
  12064. * Gets the gamepad manager associated with the scene
  12065. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  12066. */
  12067. gamepadManager: GamepadManager;
  12068. }
  12069. /**
  12070. * Interface representing a free camera inputs manager
  12071. */
  12072. interface FreeCameraInputsManager {
  12073. /**
  12074. * Adds gamepad input support to the FreeCameraInputsManager.
  12075. * @returns the FreeCameraInputsManager
  12076. */
  12077. addGamepad(): FreeCameraInputsManager;
  12078. }
  12079. /**
  12080. * Interface representing an arc rotate camera inputs manager
  12081. */
  12082. interface ArcRotateCameraInputsManager {
  12083. /**
  12084. * Adds gamepad input support to the ArcRotateCamera InputManager.
  12085. * @returns the camera inputs manager
  12086. */
  12087. addGamepad(): ArcRotateCameraInputsManager;
  12088. }
  12089. /**
  12090. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  12091. */
  12092. class GamepadSystemSceneComponent implements ISceneComponent {
  12093. /**
  12094. * The component name helpfull to identify the component in the list of scene components.
  12095. */
  12096. readonly name: string;
  12097. /**
  12098. * The scene the component belongs to.
  12099. */
  12100. scene: Scene;
  12101. /**
  12102. * Creates a new instance of the component for the given scene
  12103. * @param scene Defines the scene to register the component in
  12104. */
  12105. constructor(scene: Scene);
  12106. /**
  12107. * Registers the component in a given scene
  12108. */
  12109. register(): void;
  12110. /**
  12111. * Rebuilds the elements related to this component in case of
  12112. * context lost for instance.
  12113. */
  12114. rebuild(): void;
  12115. /**
  12116. * Disposes the component and the associated ressources
  12117. */
  12118. dispose(): void;
  12119. private _beforeCameraUpdate;
  12120. }
  12121. }
  12122. declare module BABYLON {
  12123. /**
  12124. * Defines supported buttons for XBox360 compatible gamepads
  12125. */
  12126. enum Xbox360Button {
  12127. /** A */
  12128. A = 0,
  12129. /** B */
  12130. B = 1,
  12131. /** X */
  12132. X = 2,
  12133. /** Y */
  12134. Y = 3,
  12135. /** Start */
  12136. Start = 4,
  12137. /** Back */
  12138. Back = 5,
  12139. /** Left button */
  12140. LB = 6,
  12141. /** Right button */
  12142. RB = 7,
  12143. /** Left stick */
  12144. LeftStick = 8,
  12145. /** Right stick */
  12146. RightStick = 9
  12147. }
  12148. /** Defines values for XBox360 DPad */
  12149. enum Xbox360Dpad {
  12150. /** Up */
  12151. Up = 0,
  12152. /** Down */
  12153. Down = 1,
  12154. /** Left */
  12155. Left = 2,
  12156. /** Right */
  12157. Right = 3
  12158. }
  12159. /**
  12160. * Defines a XBox360 gamepad
  12161. */
  12162. class Xbox360Pad extends Gamepad {
  12163. private _leftTrigger;
  12164. private _rightTrigger;
  12165. private _onlefttriggerchanged;
  12166. private _onrighttriggerchanged;
  12167. private _onbuttondown;
  12168. private _onbuttonup;
  12169. private _ondpaddown;
  12170. private _ondpadup;
  12171. /** Observable raised when a button is pressed */
  12172. onButtonDownObservable: Observable<Xbox360Button>;
  12173. /** Observable raised when a button is released */
  12174. onButtonUpObservable: Observable<Xbox360Button>;
  12175. /** Observable raised when a pad is pressed */
  12176. onPadDownObservable: Observable<Xbox360Dpad>;
  12177. /** Observable raised when a pad is released */
  12178. onPadUpObservable: Observable<Xbox360Dpad>;
  12179. private _buttonA;
  12180. private _buttonB;
  12181. private _buttonX;
  12182. private _buttonY;
  12183. private _buttonBack;
  12184. private _buttonStart;
  12185. private _buttonLB;
  12186. private _buttonRB;
  12187. private _buttonLeftStick;
  12188. private _buttonRightStick;
  12189. private _dPadUp;
  12190. private _dPadDown;
  12191. private _dPadLeft;
  12192. private _dPadRight;
  12193. private _isXboxOnePad;
  12194. /**
  12195. * Creates a new XBox360 gamepad object
  12196. * @param id defines the id of this gamepad
  12197. * @param index defines its index
  12198. * @param gamepad defines the internal HTML gamepad object
  12199. * @param xboxOne defines if it is a XBox One gamepad
  12200. */
  12201. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  12202. /**
  12203. * Defines the callback to call when left trigger is pressed
  12204. * @param callback defines the callback to use
  12205. */
  12206. onlefttriggerchanged(callback: (value: number) => void): void;
  12207. /**
  12208. * Defines the callback to call when right trigger is pressed
  12209. * @param callback defines the callback to use
  12210. */
  12211. onrighttriggerchanged(callback: (value: number) => void): void;
  12212. /**
  12213. * Gets the left trigger value
  12214. */
  12215. /**
  12216. * Sets the left trigger value
  12217. */
  12218. leftTrigger: number;
  12219. /**
  12220. * Gets the right trigger value
  12221. */
  12222. /**
  12223. * Sets the right trigger value
  12224. */
  12225. rightTrigger: number;
  12226. /**
  12227. * Defines the callback to call when a button is pressed
  12228. * @param callback defines the callback to use
  12229. */
  12230. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  12231. /**
  12232. * Defines the callback to call when a button is released
  12233. * @param callback defines the callback to use
  12234. */
  12235. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  12236. /**
  12237. * Defines the callback to call when a pad is pressed
  12238. * @param callback defines the callback to use
  12239. */
  12240. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  12241. /**
  12242. * Defines the callback to call when a pad is released
  12243. * @param callback defines the callback to use
  12244. */
  12245. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  12246. private _setButtonValue;
  12247. private _setDPadValue;
  12248. /**
  12249. * Gets the value of the `A` button
  12250. */
  12251. /**
  12252. * Sets the value of the `A` button
  12253. */
  12254. buttonA: number;
  12255. /**
  12256. * Gets the value of the `B` button
  12257. */
  12258. /**
  12259. * Sets the value of the `B` button
  12260. */
  12261. buttonB: number;
  12262. /**
  12263. * Gets the value of the `X` button
  12264. */
  12265. /**
  12266. * Sets the value of the `X` button
  12267. */
  12268. buttonX: number;
  12269. /**
  12270. * Gets the value of the `Y` button
  12271. */
  12272. /**
  12273. * Sets the value of the `Y` button
  12274. */
  12275. buttonY: number;
  12276. /**
  12277. * Gets the value of the `Start` button
  12278. */
  12279. /**
  12280. * Sets the value of the `Start` button
  12281. */
  12282. buttonStart: number;
  12283. /**
  12284. * Gets the value of the `Back` button
  12285. */
  12286. /**
  12287. * Sets the value of the `Back` button
  12288. */
  12289. buttonBack: number;
  12290. /**
  12291. * Gets the value of the `Left` button
  12292. */
  12293. /**
  12294. * Sets the value of the `Left` button
  12295. */
  12296. buttonLB: number;
  12297. /**
  12298. * Gets the value of the `Right` button
  12299. */
  12300. /**
  12301. * Sets the value of the `Right` button
  12302. */
  12303. buttonRB: number;
  12304. /**
  12305. * Gets the value of the Left joystick
  12306. */
  12307. /**
  12308. * Sets the value of the Left joystick
  12309. */
  12310. buttonLeftStick: number;
  12311. /**
  12312. * Gets the value of the Right joystick
  12313. */
  12314. /**
  12315. * Sets the value of the Right joystick
  12316. */
  12317. buttonRightStick: number;
  12318. /**
  12319. * Gets the value of D-pad up
  12320. */
  12321. /**
  12322. * Sets the value of D-pad up
  12323. */
  12324. dPadUp: number;
  12325. /**
  12326. * Gets the value of D-pad down
  12327. */
  12328. /**
  12329. * Sets the value of D-pad down
  12330. */
  12331. dPadDown: number;
  12332. /**
  12333. * Gets the value of D-pad left
  12334. */
  12335. /**
  12336. * Sets the value of D-pad left
  12337. */
  12338. dPadLeft: number;
  12339. /**
  12340. * Gets the value of D-pad right
  12341. */
  12342. /**
  12343. * Sets the value of D-pad right
  12344. */
  12345. dPadRight: number;
  12346. /**
  12347. * Force the gamepad to synchronize with device values
  12348. */
  12349. update(): void;
  12350. /**
  12351. * Disposes the gamepad
  12352. */
  12353. dispose(): void;
  12354. }
  12355. }
  12356. declare module BABYLON {
  12357. /**
  12358. * Single axis drag gizmo
  12359. */
  12360. class AxisDragGizmo extends Gizmo {
  12361. /**
  12362. * Drag behavior responsible for the gizmos dragging interactions
  12363. */
  12364. dragBehavior: PointerDragBehavior;
  12365. private _pointerObserver;
  12366. /**
  12367. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  12368. */
  12369. snapDistance: number;
  12370. /**
  12371. * Event that fires each time the gizmo snaps to a new location.
  12372. * * snapDistance is the the change in distance
  12373. */
  12374. onSnapObservable: Observable<{
  12375. snapDistance: number;
  12376. }>;
  12377. /**
  12378. * Creates an AxisDragGizmo
  12379. * @param gizmoLayer The utility layer the gizmo will be added to
  12380. * @param dragAxis The axis which the gizmo will be able to drag on
  12381. * @param color The color of the gizmo
  12382. */
  12383. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  12384. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  12385. /**
  12386. * Disposes of the gizmo
  12387. */
  12388. dispose(): void;
  12389. }
  12390. }
  12391. declare module BABYLON {
  12392. /**
  12393. * Single axis scale gizmo
  12394. */
  12395. class AxisScaleGizmo extends Gizmo {
  12396. private _coloredMaterial;
  12397. /**
  12398. * Drag behavior responsible for the gizmos dragging interactions
  12399. */
  12400. dragBehavior: PointerDragBehavior;
  12401. private _pointerObserver;
  12402. /**
  12403. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  12404. */
  12405. snapDistance: number;
  12406. /**
  12407. * Event that fires each time the gizmo snaps to a new location.
  12408. * * snapDistance is the the change in distance
  12409. */
  12410. onSnapObservable: Observable<{
  12411. snapDistance: number;
  12412. }>;
  12413. /**
  12414. * If the scaling operation should be done on all axis (default: false)
  12415. */
  12416. uniformScaling: boolean;
  12417. /**
  12418. * Creates an AxisScaleGizmo
  12419. * @param gizmoLayer The utility layer the gizmo will be added to
  12420. * @param dragAxis The axis which the gizmo will be able to scale on
  12421. * @param color The color of the gizmo
  12422. */
  12423. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  12424. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  12425. /**
  12426. * Disposes of the gizmo
  12427. */
  12428. dispose(): void;
  12429. /**
  12430. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  12431. * @param mesh The mesh to replace the default mesh of the gizmo
  12432. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  12433. */
  12434. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  12435. }
  12436. }
  12437. declare module BABYLON {
  12438. /**
  12439. * Bounding box gizmo
  12440. */
  12441. class BoundingBoxGizmo extends Gizmo {
  12442. private _lineBoundingBox;
  12443. private _rotateSpheresParent;
  12444. private _scaleBoxesParent;
  12445. private _boundingDimensions;
  12446. private _renderObserver;
  12447. private _pointerObserver;
  12448. private _scaleDragSpeed;
  12449. private _tmpQuaternion;
  12450. private _tmpVector;
  12451. private _tmpRotationMatrix;
  12452. /**
  12453. * 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)
  12454. */
  12455. ignoreChildren: boolean;
  12456. /**
  12457. * 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)
  12458. */
  12459. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  12460. /**
  12461. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  12462. */
  12463. rotationSphereSize: number;
  12464. /**
  12465. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  12466. */
  12467. scaleBoxSize: number;
  12468. /**
  12469. * 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)
  12470. */
  12471. fixedDragMeshScreenSize: boolean;
  12472. /**
  12473. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  12474. */
  12475. fixedDragMeshScreenSizeDistanceFactor: number;
  12476. /**
  12477. * Fired when a rotation sphere or scale box is dragged
  12478. */
  12479. onDragStartObservable: Observable<{}>;
  12480. /**
  12481. * Fired when a scale box is dragged
  12482. */
  12483. onScaleBoxDragObservable: Observable<{}>;
  12484. /**
  12485. * Fired when a scale box drag is ended
  12486. */
  12487. onScaleBoxDragEndObservable: Observable<{}>;
  12488. /**
  12489. * Fired when a rotation sphere is dragged
  12490. */
  12491. onRotationSphereDragObservable: Observable<{}>;
  12492. /**
  12493. * Fired when a rotation sphere drag is ended
  12494. */
  12495. onRotationSphereDragEndObservable: Observable<{}>;
  12496. /**
  12497. * 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)
  12498. */
  12499. scalePivot: Nullable<Vector3>;
  12500. private _anchorMesh;
  12501. private _existingMeshScale;
  12502. private static _PivotCached;
  12503. private static _OldPivotPoint;
  12504. private static _PivotTranslation;
  12505. private static _PivotTmpVector;
  12506. /** @hidden */
  12507. private static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  12508. /** @hidden */
  12509. private static _RestorePivotPoint(mesh: AbstractMesh): void;
  12510. /**
  12511. * Creates an BoundingBoxGizmo
  12512. * @param gizmoLayer The utility layer the gizmo will be added to
  12513. * @param color The color of the gizmo
  12514. */
  12515. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  12516. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  12517. private _selectNode;
  12518. /**
  12519. * Updates the bounding box information for the Gizmo
  12520. */
  12521. updateBoundingBox(): void;
  12522. /**
  12523. * Enables rotation on the specified axis and disables rotation on the others
  12524. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  12525. */
  12526. setEnabledRotationAxis(axis: string): void;
  12527. /**
  12528. * Disposes of the gizmo
  12529. */
  12530. dispose(): void;
  12531. /**
  12532. * 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)
  12533. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  12534. * @returns the bounding box mesh with the passed in mesh as a child
  12535. */
  12536. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  12537. /**
  12538. * CustomMeshes are not supported by this gizmo
  12539. * @param mesh The mesh to replace the default mesh of the gizmo
  12540. */
  12541. setCustomMesh(mesh: Mesh): void;
  12542. }
  12543. }
  12544. declare module BABYLON {
  12545. /**
  12546. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  12547. */
  12548. class Gizmo implements IDisposable {
  12549. /** The utility layer the gizmo will be added to */
  12550. gizmoLayer: UtilityLayerRenderer;
  12551. /**
  12552. * The root mesh of the gizmo
  12553. */
  12554. protected _rootMesh: Mesh;
  12555. private _attachedMesh;
  12556. /**
  12557. * Ratio for the scale of the gizmo (Default: 1)
  12558. */
  12559. scaleRatio: number;
  12560. private _tmpMatrix;
  12561. /**
  12562. * If a custom mesh has been set (Default: false)
  12563. */
  12564. protected _customMeshSet: boolean;
  12565. /**
  12566. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  12567. * * When set, interactions will be enabled
  12568. */
  12569. attachedMesh: Nullable<AbstractMesh>;
  12570. /**
  12571. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  12572. * @param mesh The mesh to replace the default mesh of the gizmo
  12573. */
  12574. setCustomMesh(mesh: Mesh): void;
  12575. /**
  12576. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  12577. */
  12578. updateGizmoRotationToMatchAttachedMesh: boolean;
  12579. /**
  12580. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  12581. */
  12582. updateGizmoPositionToMatchAttachedMesh: boolean;
  12583. /**
  12584. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  12585. */
  12586. protected _updateScale: boolean;
  12587. protected _interactionsEnabled: boolean;
  12588. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  12589. private _beforeRenderObserver;
  12590. /**
  12591. * Creates a gizmo
  12592. * @param gizmoLayer The utility layer the gizmo will be added to
  12593. */
  12594. constructor(
  12595. /** The utility layer the gizmo will be added to */
  12596. gizmoLayer?: UtilityLayerRenderer);
  12597. private _tempVector;
  12598. /**
  12599. * @hidden
  12600. * Updates the gizmo to match the attached mesh's position/rotation
  12601. */
  12602. protected _update(): void;
  12603. /**
  12604. * Disposes of the gizmo
  12605. */
  12606. dispose(): void;
  12607. }
  12608. }
  12609. declare module BABYLON {
  12610. /**
  12611. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  12612. */
  12613. class GizmoManager implements IDisposable {
  12614. private scene;
  12615. /**
  12616. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  12617. */
  12618. gizmos: {
  12619. positionGizmo: Nullable<PositionGizmo>;
  12620. rotationGizmo: Nullable<RotationGizmo>;
  12621. scaleGizmo: Nullable<ScaleGizmo>;
  12622. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  12623. };
  12624. private _gizmosEnabled;
  12625. private _pointerObserver;
  12626. private _attachedMesh;
  12627. private _boundingBoxColor;
  12628. private _defaultUtilityLayer;
  12629. private _defaultKeepDepthUtilityLayer;
  12630. /**
  12631. * When bounding box gizmo is enabled, this can be used to track drag/end events
  12632. */
  12633. boundingBoxDragBehavior: SixDofDragBehavior;
  12634. /**
  12635. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  12636. */
  12637. attachableMeshes: Nullable<Array<AbstractMesh>>;
  12638. /**
  12639. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  12640. */
  12641. usePointerToAttachGizmos: boolean;
  12642. /**
  12643. * Instatiates a gizmo manager
  12644. * @param scene the scene to overlay the gizmos on top of
  12645. */
  12646. constructor(scene: Scene);
  12647. /**
  12648. * Attaches a set of gizmos to the specified mesh
  12649. * @param mesh The mesh the gizmo's should be attached to
  12650. */
  12651. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  12652. /**
  12653. * If the position gizmo is enabled
  12654. */
  12655. positionGizmoEnabled: boolean;
  12656. /**
  12657. * If the rotation gizmo is enabled
  12658. */
  12659. rotationGizmoEnabled: boolean;
  12660. /**
  12661. * If the scale gizmo is enabled
  12662. */
  12663. scaleGizmoEnabled: boolean;
  12664. /**
  12665. * If the boundingBox gizmo is enabled
  12666. */
  12667. boundingBoxGizmoEnabled: boolean;
  12668. /**
  12669. * Disposes of the gizmo manager
  12670. */
  12671. dispose(): void;
  12672. }
  12673. }
  12674. declare module BABYLON {
  12675. /**
  12676. * Single plane rotation gizmo
  12677. */
  12678. class PlaneRotationGizmo extends Gizmo {
  12679. /**
  12680. * Drag behavior responsible for the gizmos dragging interactions
  12681. */
  12682. dragBehavior: PointerDragBehavior;
  12683. private _pointerObserver;
  12684. /**
  12685. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  12686. */
  12687. snapDistance: number;
  12688. /**
  12689. * Event that fires each time the gizmo snaps to a new location.
  12690. * * snapDistance is the the change in distance
  12691. */
  12692. onSnapObservable: Observable<{
  12693. snapDistance: number;
  12694. }>;
  12695. /**
  12696. * Creates a PlaneRotationGizmo
  12697. * @param gizmoLayer The utility layer the gizmo will be added to
  12698. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  12699. * @param color The color of the gizmo
  12700. * @param tessellation Amount of tessellation to be used when creating rotation circles
  12701. */
  12702. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  12703. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  12704. /**
  12705. * Disposes of the gizmo
  12706. */
  12707. dispose(): void;
  12708. }
  12709. }
  12710. declare module BABYLON {
  12711. /**
  12712. * Gizmo that enables dragging a mesh along 3 axis
  12713. */
  12714. class PositionGizmo extends Gizmo {
  12715. /**
  12716. * Internal gizmo used for interactions on the x axis
  12717. */
  12718. xGizmo: AxisDragGizmo;
  12719. /**
  12720. * Internal gizmo used for interactions on the y axis
  12721. */
  12722. yGizmo: AxisDragGizmo;
  12723. /**
  12724. * Internal gizmo used for interactions on the z axis
  12725. */
  12726. zGizmo: AxisDragGizmo;
  12727. /** Fires an event when any of it's sub gizmos are dragged */
  12728. onDragStartObservable: Observable<{}>;
  12729. /** Fires an event when any of it's sub gizmos are released from dragging */
  12730. onDragEndObservable: Observable<{}>;
  12731. attachedMesh: Nullable<AbstractMesh>;
  12732. /**
  12733. * Creates a PositionGizmo
  12734. * @param gizmoLayer The utility layer the gizmo will be added to
  12735. */
  12736. constructor(gizmoLayer?: UtilityLayerRenderer);
  12737. updateGizmoRotationToMatchAttachedMesh: boolean;
  12738. /**
  12739. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  12740. */
  12741. snapDistance: number;
  12742. /**
  12743. * Ratio for the scale of the gizmo (Default: 1)
  12744. */
  12745. scaleRatio: number;
  12746. /**
  12747. * Disposes of the gizmo
  12748. */
  12749. dispose(): void;
  12750. /**
  12751. * CustomMeshes are not supported by this gizmo
  12752. * @param mesh The mesh to replace the default mesh of the gizmo
  12753. */
  12754. setCustomMesh(mesh: Mesh): void;
  12755. }
  12756. }
  12757. declare module BABYLON {
  12758. /**
  12759. * Gizmo that enables rotating a mesh along 3 axis
  12760. */
  12761. class RotationGizmo extends Gizmo {
  12762. /**
  12763. * Internal gizmo used for interactions on the x axis
  12764. */
  12765. xGizmo: PlaneRotationGizmo;
  12766. /**
  12767. * Internal gizmo used for interactions on the y axis
  12768. */
  12769. yGizmo: PlaneRotationGizmo;
  12770. /**
  12771. * Internal gizmo used for interactions on the z axis
  12772. */
  12773. zGizmo: PlaneRotationGizmo;
  12774. /** Fires an event when any of it's sub gizmos are dragged */
  12775. onDragStartObservable: Observable<{}>;
  12776. /** Fires an event when any of it's sub gizmos are released from dragging */
  12777. onDragEndObservable: Observable<{}>;
  12778. attachedMesh: Nullable<AbstractMesh>;
  12779. /**
  12780. * Creates a RotationGizmo
  12781. * @param gizmoLayer The utility layer the gizmo will be added to
  12782. * @param tessellation Amount of tessellation to be used when creating rotation circles
  12783. */
  12784. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  12785. updateGizmoRotationToMatchAttachedMesh: boolean;
  12786. /**
  12787. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  12788. */
  12789. snapDistance: number;
  12790. /**
  12791. * Ratio for the scale of the gizmo (Default: 1)
  12792. */
  12793. scaleRatio: number;
  12794. /**
  12795. * Disposes of the gizmo
  12796. */
  12797. dispose(): void;
  12798. /**
  12799. * CustomMeshes are not supported by this gizmo
  12800. * @param mesh The mesh to replace the default mesh of the gizmo
  12801. */
  12802. setCustomMesh(mesh: Mesh): void;
  12803. }
  12804. }
  12805. declare module BABYLON {
  12806. /**
  12807. * Gizmo that enables scaling a mesh along 3 axis
  12808. */
  12809. class ScaleGizmo extends Gizmo {
  12810. /**
  12811. * Internal gizmo used for interactions on the x axis
  12812. */
  12813. xGizmo: AxisScaleGizmo;
  12814. /**
  12815. * Internal gizmo used for interactions on the y axis
  12816. */
  12817. yGizmo: AxisScaleGizmo;
  12818. /**
  12819. * Internal gizmo used for interactions on the z axis
  12820. */
  12821. zGizmo: AxisScaleGizmo;
  12822. /**
  12823. * Internal gizmo used to scale all axis equally
  12824. */
  12825. uniformScaleGizmo: AxisScaleGizmo;
  12826. /** Fires an event when any of it's sub gizmos are dragged */
  12827. onDragStartObservable: Observable<{}>;
  12828. /** Fires an event when any of it's sub gizmos are released from dragging */
  12829. onDragEndObservable: Observable<{}>;
  12830. attachedMesh: Nullable<AbstractMesh>;
  12831. /**
  12832. * Creates a ScaleGizmo
  12833. * @param gizmoLayer The utility layer the gizmo will be added to
  12834. */
  12835. constructor(gizmoLayer?: UtilityLayerRenderer);
  12836. updateGizmoRotationToMatchAttachedMesh: boolean;
  12837. /**
  12838. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  12839. */
  12840. snapDistance: number;
  12841. /**
  12842. * Ratio for the scale of the gizmo (Default: 1)
  12843. */
  12844. scaleRatio: number;
  12845. /**
  12846. * Disposes of the gizmo
  12847. */
  12848. dispose(): void;
  12849. }
  12850. }
  12851. declare module BABYLON {
  12852. /**
  12853. * Represents the different options available during the creation of
  12854. * a Environment helper.
  12855. *
  12856. * This can control the default ground, skybox and image processing setup of your scene.
  12857. */
  12858. interface IEnvironmentHelperOptions {
  12859. /**
  12860. * Specifies wether or not to create a ground.
  12861. * True by default.
  12862. */
  12863. createGround: boolean;
  12864. /**
  12865. * Specifies the ground size.
  12866. * 15 by default.
  12867. */
  12868. groundSize: number;
  12869. /**
  12870. * The texture used on the ground for the main color.
  12871. * Comes from the BabylonJS CDN by default.
  12872. *
  12873. * Remarks: Can be either a texture or a url.
  12874. */
  12875. groundTexture: string | BaseTexture;
  12876. /**
  12877. * The color mixed in the ground texture by default.
  12878. * BabylonJS clearColor by default.
  12879. */
  12880. groundColor: Color3;
  12881. /**
  12882. * Specifies the ground opacity.
  12883. * 1 by default.
  12884. */
  12885. groundOpacity: number;
  12886. /**
  12887. * Enables the ground to receive shadows.
  12888. * True by default.
  12889. */
  12890. enableGroundShadow: boolean;
  12891. /**
  12892. * Helps preventing the shadow to be fully black on the ground.
  12893. * 0.5 by default.
  12894. */
  12895. groundShadowLevel: number;
  12896. /**
  12897. * Creates a mirror texture attach to the ground.
  12898. * false by default.
  12899. */
  12900. enableGroundMirror: boolean;
  12901. /**
  12902. * Specifies the ground mirror size ratio.
  12903. * 0.3 by default as the default kernel is 64.
  12904. */
  12905. groundMirrorSizeRatio: number;
  12906. /**
  12907. * Specifies the ground mirror blur kernel size.
  12908. * 64 by default.
  12909. */
  12910. groundMirrorBlurKernel: number;
  12911. /**
  12912. * Specifies the ground mirror visibility amount.
  12913. * 1 by default
  12914. */
  12915. groundMirrorAmount: number;
  12916. /**
  12917. * Specifies the ground mirror reflectance weight.
  12918. * This uses the standard weight of the background material to setup the fresnel effect
  12919. * of the mirror.
  12920. * 1 by default.
  12921. */
  12922. groundMirrorFresnelWeight: number;
  12923. /**
  12924. * Specifies the ground mirror Falloff distance.
  12925. * This can helps reducing the size of the reflection.
  12926. * 0 by Default.
  12927. */
  12928. groundMirrorFallOffDistance: number;
  12929. /**
  12930. * Specifies the ground mirror texture type.
  12931. * Unsigned Int by Default.
  12932. */
  12933. groundMirrorTextureType: number;
  12934. /**
  12935. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  12936. * the shown objects.
  12937. */
  12938. groundYBias: number;
  12939. /**
  12940. * Specifies wether or not to create a skybox.
  12941. * True by default.
  12942. */
  12943. createSkybox: boolean;
  12944. /**
  12945. * Specifies the skybox size.
  12946. * 20 by default.
  12947. */
  12948. skyboxSize: number;
  12949. /**
  12950. * The texture used on the skybox for the main color.
  12951. * Comes from the BabylonJS CDN by default.
  12952. *
  12953. * Remarks: Can be either a texture or a url.
  12954. */
  12955. skyboxTexture: string | BaseTexture;
  12956. /**
  12957. * The color mixed in the skybox texture by default.
  12958. * BabylonJS clearColor by default.
  12959. */
  12960. skyboxColor: Color3;
  12961. /**
  12962. * The background rotation around the Y axis of the scene.
  12963. * This helps aligning the key lights of your scene with the background.
  12964. * 0 by default.
  12965. */
  12966. backgroundYRotation: number;
  12967. /**
  12968. * Compute automatically the size of the elements to best fit with the scene.
  12969. */
  12970. sizeAuto: boolean;
  12971. /**
  12972. * Default position of the rootMesh if autoSize is not true.
  12973. */
  12974. rootPosition: Vector3;
  12975. /**
  12976. * Sets up the image processing in the scene.
  12977. * true by default.
  12978. */
  12979. setupImageProcessing: boolean;
  12980. /**
  12981. * The texture used as your environment texture in the scene.
  12982. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  12983. *
  12984. * Remarks: Can be either a texture or a url.
  12985. */
  12986. environmentTexture: string | BaseTexture;
  12987. /**
  12988. * The value of the exposure to apply to the scene.
  12989. * 0.6 by default if setupImageProcessing is true.
  12990. */
  12991. cameraExposure: number;
  12992. /**
  12993. * The value of the contrast to apply to the scene.
  12994. * 1.6 by default if setupImageProcessing is true.
  12995. */
  12996. cameraContrast: number;
  12997. /**
  12998. * Specifies wether or not tonemapping should be enabled in the scene.
  12999. * true by default if setupImageProcessing is true.
  13000. */
  13001. toneMappingEnabled: boolean;
  13002. }
  13003. /**
  13004. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  13005. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  13006. * It also helps with the default setup of your imageProcessing configuration.
  13007. */
  13008. class EnvironmentHelper {
  13009. /**
  13010. * Default ground texture URL.
  13011. */
  13012. private static _groundTextureCDNUrl;
  13013. /**
  13014. * Default skybox texture URL.
  13015. */
  13016. private static _skyboxTextureCDNUrl;
  13017. /**
  13018. * Default environment texture URL.
  13019. */
  13020. private static _environmentTextureCDNUrl;
  13021. /**
  13022. * Creates the default options for the helper.
  13023. */
  13024. private static _getDefaultOptions;
  13025. private _rootMesh;
  13026. /**
  13027. * Gets the root mesh created by the helper.
  13028. */
  13029. readonly rootMesh: Mesh;
  13030. private _skybox;
  13031. /**
  13032. * Gets the skybox created by the helper.
  13033. */
  13034. readonly skybox: Nullable<Mesh>;
  13035. private _skyboxTexture;
  13036. /**
  13037. * Gets the skybox texture created by the helper.
  13038. */
  13039. readonly skyboxTexture: Nullable<BaseTexture>;
  13040. private _skyboxMaterial;
  13041. /**
  13042. * Gets the skybox material created by the helper.
  13043. */
  13044. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  13045. private _ground;
  13046. /**
  13047. * Gets the ground mesh created by the helper.
  13048. */
  13049. readonly ground: Nullable<Mesh>;
  13050. private _groundTexture;
  13051. /**
  13052. * Gets the ground texture created by the helper.
  13053. */
  13054. readonly groundTexture: Nullable<BaseTexture>;
  13055. private _groundMirror;
  13056. /**
  13057. * Gets the ground mirror created by the helper.
  13058. */
  13059. readonly groundMirror: Nullable<MirrorTexture>;
  13060. /**
  13061. * Gets the ground mirror render list to helps pushing the meshes
  13062. * you wish in the ground reflection.
  13063. */
  13064. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  13065. private _groundMaterial;
  13066. /**
  13067. * Gets the ground material created by the helper.
  13068. */
  13069. readonly groundMaterial: Nullable<BackgroundMaterial>;
  13070. /**
  13071. * Stores the creation options.
  13072. */
  13073. private readonly _scene;
  13074. private _options;
  13075. /**
  13076. * This observable will be notified with any error during the creation of the environment,
  13077. * mainly texture creation errors.
  13078. */
  13079. onErrorObservable: Observable<{
  13080. message?: string;
  13081. exception?: any;
  13082. }>;
  13083. /**
  13084. * constructor
  13085. * @param options
  13086. * @param scene The scene to add the material to
  13087. */
  13088. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  13089. /**
  13090. * Updates the background according to the new options
  13091. * @param options
  13092. */
  13093. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  13094. /**
  13095. * Sets the primary color of all the available elements.
  13096. * @param color the main color to affect to the ground and the background
  13097. */
  13098. setMainColor(color: Color3): void;
  13099. /**
  13100. * Setup the image processing according to the specified options.
  13101. */
  13102. private _setupImageProcessing;
  13103. /**
  13104. * Setup the environment texture according to the specified options.
  13105. */
  13106. private _setupEnvironmentTexture;
  13107. /**
  13108. * Setup the background according to the specified options.
  13109. */
  13110. private _setupBackground;
  13111. /**
  13112. * Get the scene sizes according to the setup.
  13113. */
  13114. private _getSceneSize;
  13115. /**
  13116. * Setup the ground according to the specified options.
  13117. */
  13118. private _setupGround;
  13119. /**
  13120. * Setup the ground material according to the specified options.
  13121. */
  13122. private _setupGroundMaterial;
  13123. /**
  13124. * Setup the ground diffuse texture according to the specified options.
  13125. */
  13126. private _setupGroundDiffuseTexture;
  13127. /**
  13128. * Setup the ground mirror texture according to the specified options.
  13129. */
  13130. private _setupGroundMirrorTexture;
  13131. /**
  13132. * Setup the ground to receive the mirror texture.
  13133. */
  13134. private _setupMirrorInGroundMaterial;
  13135. /**
  13136. * Setup the skybox according to the specified options.
  13137. */
  13138. private _setupSkybox;
  13139. /**
  13140. * Setup the skybox material according to the specified options.
  13141. */
  13142. private _setupSkyboxMaterial;
  13143. /**
  13144. * Setup the skybox reflection texture according to the specified options.
  13145. */
  13146. private _setupSkyboxReflectionTexture;
  13147. private _errorHandler;
  13148. /**
  13149. * Dispose all the elements created by the Helper.
  13150. */
  13151. dispose(): void;
  13152. }
  13153. }
  13154. declare module BABYLON {
  13155. /**
  13156. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  13157. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  13158. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  13159. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  13160. */
  13161. class PhotoDome extends TransformNode {
  13162. private _useDirectMapping;
  13163. /**
  13164. * The texture being displayed on the sphere
  13165. */
  13166. protected _photoTexture: Texture;
  13167. /**
  13168. * Gets or sets the texture being displayed on the sphere
  13169. */
  13170. photoTexture: Texture;
  13171. /**
  13172. * Observable raised when an error occured while loading the 360 image
  13173. */
  13174. onLoadErrorObservable: Observable<string>;
  13175. /**
  13176. * The skybox material
  13177. */
  13178. protected _material: BackgroundMaterial;
  13179. /**
  13180. * The surface used for the skybox
  13181. */
  13182. protected _mesh: Mesh;
  13183. /**
  13184. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  13185. * Also see the options.resolution property.
  13186. */
  13187. fovMultiplier: number;
  13188. /**
  13189. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  13190. * @param name Element's name, child elements will append suffixes for their own names.
  13191. * @param urlsOfPhoto defines the url of the photo to display
  13192. * @param options defines an object containing optional or exposed sub element properties
  13193. * @param onError defines a callback called when an error occured while loading the texture
  13194. */
  13195. constructor(name: string, urlOfPhoto: string, options: {
  13196. resolution?: number;
  13197. size?: number;
  13198. useDirectMapping?: boolean;
  13199. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  13200. /**
  13201. * Releases resources associated with this node.
  13202. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  13203. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  13204. */
  13205. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  13206. }
  13207. }
  13208. declare module BABYLON {
  13209. interface Scene {
  13210. /**
  13211. * Creates a default light for the scene.
  13212. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  13213. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  13214. */
  13215. createDefaultLight(replace?: boolean): void;
  13216. /**
  13217. * Creates a default camera for the scene.
  13218. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  13219. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  13220. * @param replace has default false, when true replaces the active camera in the scene
  13221. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  13222. */
  13223. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  13224. /**
  13225. * Creates a default camera and a default light.
  13226. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  13227. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  13228. * @param replace has the default false, when true replaces the active camera/light in the scene
  13229. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  13230. */
  13231. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  13232. /**
  13233. * Creates a new sky box
  13234. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  13235. * @param environmentTexture defines the texture to use as environment texture
  13236. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  13237. * @param scale defines the overall scale of the skybox
  13238. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  13239. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  13240. * @returns a new mesh holding the sky box
  13241. */
  13242. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  13243. /**
  13244. * Creates a new environment
  13245. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  13246. * @param options defines the options you can use to configure the environment
  13247. * @returns the new EnvironmentHelper
  13248. */
  13249. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  13250. /**
  13251. * Creates a new VREXperienceHelper
  13252. * @see http://doc.babylonjs.com/how_to/webvr_helper
  13253. * @param webVROptions defines the options used to create the new VREXperienceHelper
  13254. * @returns a new VREXperienceHelper
  13255. */
  13256. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  13257. }
  13258. }
  13259. declare module BABYLON {
  13260. /**
  13261. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  13262. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  13263. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  13264. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  13265. */
  13266. class VideoDome extends TransformNode {
  13267. private _useDirectMapping;
  13268. /**
  13269. * The video texture being displayed on the sphere
  13270. */
  13271. protected _videoTexture: VideoTexture;
  13272. /**
  13273. * Gets the video texture being displayed on the sphere
  13274. */
  13275. readonly videoTexture: VideoTexture;
  13276. /**
  13277. * The skybox material
  13278. */
  13279. protected _material: BackgroundMaterial;
  13280. /**
  13281. * The surface used for the skybox
  13282. */
  13283. protected _mesh: Mesh;
  13284. /**
  13285. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  13286. * Also see the options.resolution property.
  13287. */
  13288. fovMultiplier: number;
  13289. /**
  13290. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  13291. * @param name Element's name, child elements will append suffixes for their own names.
  13292. * @param urlsOrVideo defines the url(s) or the video element to use
  13293. * @param options An object containing optional or exposed sub element properties
  13294. */
  13295. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  13296. resolution?: number;
  13297. clickToPlay?: boolean;
  13298. autoPlay?: boolean;
  13299. loop?: boolean;
  13300. size?: number;
  13301. poster?: string;
  13302. useDirectMapping?: boolean;
  13303. }, scene: Scene);
  13304. /**
  13305. * Releases resources associated with this node.
  13306. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  13307. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  13308. */
  13309. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  13310. }
  13311. }
  13312. declare module BABYLON {
  13313. /**
  13314. * Effect layer options. This helps customizing the behaviour
  13315. * of the effect layer.
  13316. */
  13317. interface IEffectLayerOptions {
  13318. /**
  13319. * Multiplication factor apply to the canvas size to compute the render target size
  13320. * used to generated the objects (the smaller the faster).
  13321. */
  13322. mainTextureRatio: number;
  13323. /**
  13324. * Enforces a fixed size texture to ensure effect stability across devices.
  13325. */
  13326. mainTextureFixedSize?: number;
  13327. /**
  13328. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  13329. */
  13330. alphaBlendingMode: number;
  13331. /**
  13332. * The camera attached to the layer.
  13333. */
  13334. camera: Nullable<Camera>;
  13335. /**
  13336. * The rendering group to draw the layer in.
  13337. */
  13338. renderingGroupId: number;
  13339. }
  13340. /**
  13341. * The effect layer Helps adding post process effect blended with the main pass.
  13342. *
  13343. * This can be for instance use to generate glow or higlight effects on the scene.
  13344. *
  13345. * The effect layer class can not be used directly and is intented to inherited from to be
  13346. * customized per effects.
  13347. */
  13348. abstract class EffectLayer {
  13349. private _vertexBuffers;
  13350. private _indexBuffer;
  13351. private _cachedDefines;
  13352. private _effectLayerMapGenerationEffect;
  13353. private _effectLayerOptions;
  13354. private _mergeEffect;
  13355. protected _scene: Scene;
  13356. protected _engine: Engine;
  13357. protected _maxSize: number;
  13358. protected _mainTextureDesiredSize: ISize;
  13359. protected _mainTexture: RenderTargetTexture;
  13360. protected _shouldRender: boolean;
  13361. protected _postProcesses: PostProcess[];
  13362. protected _textures: BaseTexture[];
  13363. protected _emissiveTextureAndColor: {
  13364. texture: Nullable<BaseTexture>;
  13365. color: Color4;
  13366. };
  13367. /**
  13368. * The name of the layer
  13369. */
  13370. name: string;
  13371. /**
  13372. * The clear color of the texture used to generate the glow map.
  13373. */
  13374. neutralColor: Color4;
  13375. /**
  13376. * Specifies wether the highlight layer is enabled or not.
  13377. */
  13378. isEnabled: boolean;
  13379. /**
  13380. * Gets the camera attached to the layer.
  13381. */
  13382. readonly camera: Nullable<Camera>;
  13383. /**
  13384. * Gets the rendering group id the layer should render in.
  13385. */
  13386. readonly renderingGroupId: number;
  13387. /**
  13388. * An event triggered when the effect layer has been disposed.
  13389. */
  13390. onDisposeObservable: Observable<EffectLayer>;
  13391. /**
  13392. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  13393. */
  13394. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  13395. /**
  13396. * An event triggered when the generated texture is being merged in the scene.
  13397. */
  13398. onBeforeComposeObservable: Observable<EffectLayer>;
  13399. /**
  13400. * An event triggered when the generated texture has been merged in the scene.
  13401. */
  13402. onAfterComposeObservable: Observable<EffectLayer>;
  13403. /**
  13404. * An event triggered when the efffect layer changes its size.
  13405. */
  13406. onSizeChangedObservable: Observable<EffectLayer>;
  13407. /**
  13408. * Instantiates a new effect Layer and references it in the scene.
  13409. * @param name The name of the layer
  13410. * @param scene The scene to use the layer in
  13411. */
  13412. constructor(
  13413. /** The Friendly of the effect in the scene */
  13414. name: string, scene: Scene);
  13415. /**
  13416. * Get the effect name of the layer.
  13417. * @return The effect name
  13418. */
  13419. abstract getEffectName(): string;
  13420. /**
  13421. * Checks for the readiness of the element composing the layer.
  13422. * @param subMesh the mesh to check for
  13423. * @param useInstances specify wether or not to use instances to render the mesh
  13424. * @return true if ready otherwise, false
  13425. */
  13426. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  13427. /**
  13428. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  13429. * @returns true if the effect requires stencil during the main canvas render pass.
  13430. */
  13431. abstract needStencil(): boolean;
  13432. /**
  13433. * Create the merge effect. This is the shader use to blit the information back
  13434. * to the main canvas at the end of the scene rendering.
  13435. * @returns The effect containing the shader used to merge the effect on the main canvas
  13436. */
  13437. protected abstract _createMergeEffect(): Effect;
  13438. /**
  13439. * Creates the render target textures and post processes used in the effect layer.
  13440. */
  13441. protected abstract _createTextureAndPostProcesses(): void;
  13442. /**
  13443. * Implementation specific of rendering the generating effect on the main canvas.
  13444. * @param effect The effect used to render through
  13445. */
  13446. protected abstract _internalRender(effect: Effect): void;
  13447. /**
  13448. * Sets the required values for both the emissive texture and and the main color.
  13449. */
  13450. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  13451. /**
  13452. * Free any resources and references associated to a mesh.
  13453. * Internal use
  13454. * @param mesh The mesh to free.
  13455. */
  13456. disposeMesh(mesh: Mesh): void;
  13457. /**
  13458. * Serializes this layer (Glow or Highlight for example)
  13459. * @returns a serialized layer object
  13460. */
  13461. abstract serialize?(): any;
  13462. /**
  13463. * Initializes the effect layer with the required options.
  13464. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  13465. */
  13466. protected _init(options: Partial<IEffectLayerOptions>): void;
  13467. /**
  13468. * Generates the index buffer of the full screen quad blending to the main canvas.
  13469. */
  13470. private _generateIndexBuffer;
  13471. /**
  13472. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  13473. */
  13474. private _genrateVertexBuffer;
  13475. /**
  13476. * Sets the main texture desired size which is the closest power of two
  13477. * of the engine canvas size.
  13478. */
  13479. private _setMainTextureSize;
  13480. /**
  13481. * Creates the main texture for the effect layer.
  13482. */
  13483. protected _createMainTexture(): void;
  13484. /**
  13485. * Checks for the readiness of the element composing the layer.
  13486. * @param subMesh the mesh to check for
  13487. * @param useInstances specify wether or not to use instances to render the mesh
  13488. * @param emissiveTexture the associated emissive texture used to generate the glow
  13489. * @return true if ready otherwise, false
  13490. */
  13491. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  13492. /**
  13493. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  13494. */
  13495. render(): void;
  13496. /**
  13497. * Determine if a given mesh will be used in the current effect.
  13498. * @param mesh mesh to test
  13499. * @returns true if the mesh will be used
  13500. */
  13501. hasMesh(mesh: AbstractMesh): boolean;
  13502. /**
  13503. * Returns true if the layer contains information to display, otherwise false.
  13504. * @returns true if the glow layer should be rendered
  13505. */
  13506. shouldRender(): boolean;
  13507. /**
  13508. * Returns true if the mesh should render, otherwise false.
  13509. * @param mesh The mesh to render
  13510. * @returns true if it should render otherwise false
  13511. */
  13512. protected _shouldRenderMesh(mesh: Mesh): boolean;
  13513. /**
  13514. * Returns true if the mesh should render, otherwise false.
  13515. * @param mesh The mesh to render
  13516. * @returns true if it should render otherwise false
  13517. */
  13518. protected _shouldRenderEmissiveTextureForMesh(mesh: Mesh): boolean;
  13519. /**
  13520. * Renders the submesh passed in parameter to the generation map.
  13521. */
  13522. protected _renderSubMesh(subMesh: SubMesh): void;
  13523. /**
  13524. * Rebuild the required buffers.
  13525. * @hidden Internal use only.
  13526. */
  13527. /**
  13528. * Dispose only the render target textures and post process.
  13529. */
  13530. private _disposeTextureAndPostProcesses;
  13531. /**
  13532. * Dispose the highlight layer and free resources.
  13533. */
  13534. dispose(): void;
  13535. /**
  13536. * Gets the class name of the effect layer
  13537. * @returns the string with the class name of the effect layer
  13538. */
  13539. getClassName(): string;
  13540. /**
  13541. * Creates an effect layer from parsed effect layer data
  13542. * @param parsedEffectLayer defines effect layer data
  13543. * @param scene defines the current scene
  13544. * @param rootUrl defines the root URL containing the effect layer information
  13545. * @returns a parsed effect Layer
  13546. */
  13547. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  13548. }
  13549. }
  13550. declare module BABYLON {
  13551. interface AbstractScene {
  13552. /**
  13553. * The list of effect layers (highlights/glow) added to the scene
  13554. * @see http://doc.babylonjs.com/how_to/highlight_layer
  13555. * @see http://doc.babylonjs.com/how_to/glow_layer
  13556. */
  13557. effectLayers: Array<EffectLayer>;
  13558. /**
  13559. * Removes the given effect layer from this scene.
  13560. * @param toRemove defines the effect layer to remove
  13561. * @returns the index of the removed effect layer
  13562. */
  13563. removeEffectLayer(toRemove: EffectLayer): number;
  13564. /**
  13565. * Adds the given effect layer to this scene
  13566. * @param newEffectLayer defines the effect layer to add
  13567. */
  13568. addEffectLayer(newEffectLayer: EffectLayer): void;
  13569. }
  13570. /**
  13571. * Defines the layer scene component responsible to manage any effect layers
  13572. * in a given scene.
  13573. */
  13574. class EffectLayerSceneComponent implements ISceneSerializableComponent {
  13575. /**
  13576. * The component name helpfull to identify the component in the list of scene components.
  13577. */
  13578. readonly name: string;
  13579. /**
  13580. * The scene the component belongs to.
  13581. */
  13582. scene: Scene;
  13583. private _engine;
  13584. private _renderEffects;
  13585. private _needStencil;
  13586. private _previousStencilState;
  13587. /**
  13588. * Creates a new instance of the component for the given scene
  13589. * @param scene Defines the scene to register the component in
  13590. */
  13591. constructor(scene: Scene);
  13592. /**
  13593. * Registers the component in a given scene
  13594. */
  13595. register(): void;
  13596. /**
  13597. * Rebuilds the elements related to this component in case of
  13598. * context lost for instance.
  13599. */
  13600. rebuild(): void;
  13601. /**
  13602. * Serializes the component data to the specified json object
  13603. * @param serializationObject The object to serialize to
  13604. */
  13605. serialize(serializationObject: any): void;
  13606. /**
  13607. * Adds all the element from the container to the scene
  13608. * @param container the container holding the elements
  13609. */
  13610. addFromContainer(container: AbstractScene): void;
  13611. /**
  13612. * Removes all the elements in the container from the scene
  13613. * @param container contains the elements to remove
  13614. */
  13615. removeFromContainer(container: AbstractScene): void;
  13616. /**
  13617. * Disposes the component and the associated ressources.
  13618. */
  13619. dispose(): void;
  13620. private _isReadyForMesh;
  13621. private _renderMainTexture;
  13622. private _setStencil;
  13623. private _setStencilBack;
  13624. private _draw;
  13625. private _drawCamera;
  13626. private _drawRenderingGroup;
  13627. }
  13628. }
  13629. declare module BABYLON {
  13630. interface AbstractScene {
  13631. /**
  13632. * Return a the first highlight layer of the scene with a given name.
  13633. * @param name The name of the highlight layer to look for.
  13634. * @return The highlight layer if found otherwise null.
  13635. */
  13636. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  13637. }
  13638. /**
  13639. * Glow layer options. This helps customizing the behaviour
  13640. * of the glow layer.
  13641. */
  13642. interface IGlowLayerOptions {
  13643. /**
  13644. * Multiplication factor apply to the canvas size to compute the render target size
  13645. * used to generated the glowing objects (the smaller the faster).
  13646. */
  13647. mainTextureRatio: number;
  13648. /**
  13649. * Enforces a fixed size texture to ensure resize independant blur.
  13650. */
  13651. mainTextureFixedSize?: number;
  13652. /**
  13653. * How big is the kernel of the blur texture.
  13654. */
  13655. blurKernelSize: number;
  13656. /**
  13657. * The camera attached to the layer.
  13658. */
  13659. camera: Nullable<Camera>;
  13660. /**
  13661. * Enable MSAA by chosing the number of samples.
  13662. */
  13663. mainTextureSamples?: number;
  13664. /**
  13665. * The rendering group to draw the layer in.
  13666. */
  13667. renderingGroupId: number;
  13668. }
  13669. /**
  13670. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  13671. *
  13672. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  13673. * glowy meshes to your scene.
  13674. *
  13675. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  13676. */
  13677. class GlowLayer extends EffectLayer {
  13678. /**
  13679. * Effect Name of the layer.
  13680. */
  13681. static readonly EffectName: string;
  13682. /**
  13683. * The default blur kernel size used for the glow.
  13684. */
  13685. static DefaultBlurKernelSize: number;
  13686. /**
  13687. * The default texture size ratio used for the glow.
  13688. */
  13689. static DefaultTextureRatio: number;
  13690. /**
  13691. * Sets the kernel size of the blur.
  13692. */
  13693. /**
  13694. * Gets the kernel size of the blur.
  13695. */
  13696. blurKernelSize: number;
  13697. /**
  13698. * Sets the glow intensity.
  13699. */
  13700. /**
  13701. * Gets the glow intensity.
  13702. */
  13703. intensity: number;
  13704. private _options;
  13705. private _intensity;
  13706. private _horizontalBlurPostprocess1;
  13707. private _verticalBlurPostprocess1;
  13708. private _horizontalBlurPostprocess2;
  13709. private _verticalBlurPostprocess2;
  13710. private _blurTexture1;
  13711. private _blurTexture2;
  13712. private _postProcesses1;
  13713. private _postProcesses2;
  13714. private _includedOnlyMeshes;
  13715. private _excludedMeshes;
  13716. /**
  13717. * Callback used to let the user override the color selection on a per mesh basis
  13718. */
  13719. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  13720. /**
  13721. * Callback used to let the user override the texture selection on a per mesh basis
  13722. */
  13723. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  13724. /**
  13725. * Instantiates a new glow Layer and references it to the scene.
  13726. * @param name The name of the layer
  13727. * @param scene The scene to use the layer in
  13728. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  13729. */
  13730. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  13731. /**
  13732. * Get the effect name of the layer.
  13733. * @return The effect name
  13734. */
  13735. getEffectName(): string;
  13736. /**
  13737. * Create the merge effect. This is the shader use to blit the information back
  13738. * to the main canvas at the end of the scene rendering.
  13739. */
  13740. protected _createMergeEffect(): Effect;
  13741. /**
  13742. * Creates the render target textures and post processes used in the glow layer.
  13743. */
  13744. protected _createTextureAndPostProcesses(): void;
  13745. /**
  13746. * Checks for the readiness of the element composing the layer.
  13747. * @param subMesh the mesh to check for
  13748. * @param useInstances specify wether or not to use instances to render the mesh
  13749. * @param emissiveTexture the associated emissive texture used to generate the glow
  13750. * @return true if ready otherwise, false
  13751. */
  13752. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  13753. /**
  13754. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  13755. */
  13756. needStencil(): boolean;
  13757. /**
  13758. * Implementation specific of rendering the generating effect on the main canvas.
  13759. * @param effect The effect used to render through
  13760. */
  13761. protected _internalRender(effect: Effect): void;
  13762. /**
  13763. * Sets the required values for both the emissive texture and and the main color.
  13764. */
  13765. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  13766. /**
  13767. * Returns true if the mesh should render, otherwise false.
  13768. * @param mesh The mesh to render
  13769. * @returns true if it should render otherwise false
  13770. */
  13771. protected _shouldRenderMesh(mesh: Mesh): boolean;
  13772. /**
  13773. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  13774. * @param mesh The mesh to exclude from the glow layer
  13775. */
  13776. addExcludedMesh(mesh: Mesh): void;
  13777. /**
  13778. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  13779. * @param mesh The mesh to remove
  13780. */
  13781. removeExcludedMesh(mesh: Mesh): void;
  13782. /**
  13783. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  13784. * @param mesh The mesh to include in the glow layer
  13785. */
  13786. addIncludedOnlyMesh(mesh: Mesh): void;
  13787. /**
  13788. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  13789. * @param mesh The mesh to remove
  13790. */
  13791. removeIncludedOnlyMesh(mesh: Mesh): void;
  13792. /**
  13793. * Determine if a given mesh will be used in the glow layer
  13794. * @param mesh The mesh to test
  13795. * @returns true if the mesh will be highlighted by the current glow layer
  13796. */
  13797. hasMesh(mesh: AbstractMesh): boolean;
  13798. /**
  13799. * Free any resources and references associated to a mesh.
  13800. * Internal use
  13801. * @param mesh The mesh to free.
  13802. * @hidden
  13803. */
  13804. /**
  13805. * Gets the class name of the effect layer
  13806. * @returns the string with the class name of the effect layer
  13807. */
  13808. getClassName(): string;
  13809. /**
  13810. * Serializes this glow layer
  13811. * @returns a serialized glow layer object
  13812. */
  13813. serialize(): any;
  13814. /**
  13815. * Creates a Glow Layer from parsed glow layer data
  13816. * @param parsedGlowLayer defines glow layer data
  13817. * @param scene defines the current scene
  13818. * @param rootUrl defines the root URL containing the glow layer information
  13819. * @returns a parsed Glow Layer
  13820. */
  13821. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  13822. }
  13823. }
  13824. declare module BABYLON {
  13825. interface AbstractScene {
  13826. /**
  13827. * Return a the first highlight layer of the scene with a given name.
  13828. * @param name The name of the highlight layer to look for.
  13829. * @return The highlight layer if found otherwise null.
  13830. */
  13831. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  13832. }
  13833. /**
  13834. * Highlight layer options. This helps customizing the behaviour
  13835. * of the highlight layer.
  13836. */
  13837. interface IHighlightLayerOptions {
  13838. /**
  13839. * Multiplication factor apply to the canvas size to compute the render target size
  13840. * used to generated the glowing objects (the smaller the faster).
  13841. */
  13842. mainTextureRatio: number;
  13843. /**
  13844. * Enforces a fixed size texture to ensure resize independant blur.
  13845. */
  13846. mainTextureFixedSize?: number;
  13847. /**
  13848. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  13849. * of the picture to blur (the smaller the faster).
  13850. */
  13851. blurTextureSizeRatio: number;
  13852. /**
  13853. * How big in texel of the blur texture is the vertical blur.
  13854. */
  13855. blurVerticalSize: number;
  13856. /**
  13857. * How big in texel of the blur texture is the horizontal blur.
  13858. */
  13859. blurHorizontalSize: number;
  13860. /**
  13861. * Alpha blending mode used to apply the blur. Default is combine.
  13862. */
  13863. alphaBlendingMode: number;
  13864. /**
  13865. * The camera attached to the layer.
  13866. */
  13867. camera: Nullable<Camera>;
  13868. /**
  13869. * Should we display highlight as a solid stroke?
  13870. */
  13871. isStroke?: boolean;
  13872. /**
  13873. * The rendering group to draw the layer in.
  13874. */
  13875. renderingGroupId: number;
  13876. }
  13877. /**
  13878. * The highlight layer Helps adding a glow effect around a mesh.
  13879. *
  13880. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  13881. * glowy meshes to your scene.
  13882. *
  13883. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  13884. */
  13885. class HighlightLayer extends EffectLayer {
  13886. name: string;
  13887. /**
  13888. * Effect Name of the highlight layer.
  13889. */
  13890. static readonly EffectName: string;
  13891. /**
  13892. * The neutral color used during the preparation of the glow effect.
  13893. * This is black by default as the blend operation is a blend operation.
  13894. */
  13895. static NeutralColor: Color4;
  13896. /**
  13897. * Stencil value used for glowing meshes.
  13898. */
  13899. static GlowingMeshStencilReference: number;
  13900. /**
  13901. * Stencil value used for the other meshes in the scene.
  13902. */
  13903. static NormalMeshStencilReference: number;
  13904. /**
  13905. * Specifies whether or not the inner glow is ACTIVE in the layer.
  13906. */
  13907. innerGlow: boolean;
  13908. /**
  13909. * Specifies whether or not the outer glow is ACTIVE in the layer.
  13910. */
  13911. outerGlow: boolean;
  13912. /**
  13913. * Specifies the horizontal size of the blur.
  13914. */
  13915. /**
  13916. * Gets the horizontal size of the blur.
  13917. */
  13918. blurHorizontalSize: number;
  13919. /**
  13920. * Specifies the vertical size of the blur.
  13921. */
  13922. /**
  13923. * Gets the vertical size of the blur.
  13924. */
  13925. blurVerticalSize: number;
  13926. /**
  13927. * An event triggered when the highlight layer is being blurred.
  13928. */
  13929. onBeforeBlurObservable: Observable<HighlightLayer>;
  13930. /**
  13931. * An event triggered when the highlight layer has been blurred.
  13932. */
  13933. onAfterBlurObservable: Observable<HighlightLayer>;
  13934. private _instanceGlowingMeshStencilReference;
  13935. private _options;
  13936. private _downSamplePostprocess;
  13937. private _horizontalBlurPostprocess;
  13938. private _verticalBlurPostprocess;
  13939. private _blurTexture;
  13940. private _meshes;
  13941. private _excludedMeshes;
  13942. /**
  13943. * Instantiates a new highlight Layer and references it to the scene..
  13944. * @param name The name of the layer
  13945. * @param scene The scene to use the layer in
  13946. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  13947. */
  13948. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  13949. /**
  13950. * Get the effect name of the layer.
  13951. * @return The effect name
  13952. */
  13953. getEffectName(): string;
  13954. /**
  13955. * Create the merge effect. This is the shader use to blit the information back
  13956. * to the main canvas at the end of the scene rendering.
  13957. */
  13958. protected _createMergeEffect(): Effect;
  13959. /**
  13960. * Creates the render target textures and post processes used in the highlight layer.
  13961. */
  13962. protected _createTextureAndPostProcesses(): void;
  13963. /**
  13964. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  13965. */
  13966. needStencil(): boolean;
  13967. /**
  13968. * Checks for the readiness of the element composing the layer.
  13969. * @param subMesh the mesh to check for
  13970. * @param useInstances specify wether or not to use instances to render the mesh
  13971. * @param emissiveTexture the associated emissive texture used to generate the glow
  13972. * @return true if ready otherwise, false
  13973. */
  13974. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  13975. /**
  13976. * Implementation specific of rendering the generating effect on the main canvas.
  13977. * @param effect The effect used to render through
  13978. */
  13979. protected _internalRender(effect: Effect): void;
  13980. /**
  13981. * Returns true if the layer contains information to display, otherwise false.
  13982. */
  13983. shouldRender(): boolean;
  13984. /**
  13985. * Returns true if the mesh should render, otherwise false.
  13986. * @param mesh The mesh to render
  13987. * @returns true if it should render otherwise false
  13988. */
  13989. protected _shouldRenderMesh(mesh: Mesh): boolean;
  13990. /**
  13991. * Sets the required values for both the emissive texture and and the main color.
  13992. */
  13993. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  13994. /**
  13995. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  13996. * @param mesh The mesh to exclude from the highlight layer
  13997. */
  13998. addExcludedMesh(mesh: Mesh): void;
  13999. /**
  14000. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  14001. * @param mesh The mesh to highlight
  14002. */
  14003. removeExcludedMesh(mesh: Mesh): void;
  14004. /**
  14005. * Determine if a given mesh will be highlighted by the current HighlightLayer
  14006. * @param mesh mesh to test
  14007. * @returns true if the mesh will be highlighted by the current HighlightLayer
  14008. */
  14009. hasMesh(mesh: AbstractMesh): boolean;
  14010. /**
  14011. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  14012. * @param mesh The mesh to highlight
  14013. * @param color The color of the highlight
  14014. * @param glowEmissiveOnly Extract the glow from the emissive texture
  14015. */
  14016. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  14017. /**
  14018. * Remove a mesh from the highlight layer in order to make it stop glowing.
  14019. * @param mesh The mesh to highlight
  14020. */
  14021. removeMesh(mesh: Mesh): void;
  14022. /**
  14023. * Force the stencil to the normal expected value for none glowing parts
  14024. */
  14025. private _defaultStencilReference;
  14026. /**
  14027. * Free any resources and references associated to a mesh.
  14028. * Internal use
  14029. * @param mesh The mesh to free.
  14030. * @hidden
  14031. */
  14032. /**
  14033. * Dispose the highlight layer and free resources.
  14034. */
  14035. dispose(): void;
  14036. /**
  14037. * Gets the class name of the effect layer
  14038. * @returns the string with the class name of the effect layer
  14039. */
  14040. getClassName(): string;
  14041. /**
  14042. * Serializes this Highlight layer
  14043. * @returns a serialized Highlight layer object
  14044. */
  14045. serialize(): any;
  14046. /**
  14047. * Creates a Highlight layer from parsed Highlight layer data
  14048. * @param parsedHightlightLayer defines the Highlight layer data
  14049. * @param scene defines the current scene
  14050. * @param rootUrl defines the root URL containing the Highlight layer information
  14051. * @returns a parsed Highlight layer
  14052. */
  14053. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  14054. }
  14055. }
  14056. declare module BABYLON {
  14057. /**
  14058. * This represents a full screen 2d layer.
  14059. * This can be usefull to display a picture in the background of your scene for instance.
  14060. * @see https://www.babylonjs-playground.com/#08A2BS#1
  14061. */
  14062. class Layer {
  14063. /**
  14064. * Define the name of the layer.
  14065. */
  14066. name: string;
  14067. /**
  14068. * Define the texture the layer should display.
  14069. */
  14070. texture: Nullable<Texture>;
  14071. /**
  14072. * Is the layer in background or foreground.
  14073. */
  14074. isBackground: boolean;
  14075. /**
  14076. * Define the color of the layer (instead of texture).
  14077. */
  14078. color: Color4;
  14079. /**
  14080. * Define the scale of the layer in order to zoom in out of the texture.
  14081. */
  14082. scale: Vector2;
  14083. /**
  14084. * Define an offset for the layer in order to shift the texture.
  14085. */
  14086. offset: Vector2;
  14087. /**
  14088. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  14089. */
  14090. alphaBlendingMode: number;
  14091. /**
  14092. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  14093. * Alpha test will not mix with the background color in case of transparency.
  14094. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  14095. */
  14096. alphaTest: boolean;
  14097. /**
  14098. * Define a mask to restrict the layer to only some of the scene cameras.
  14099. */
  14100. layerMask: number;
  14101. private _scene;
  14102. private _vertexBuffers;
  14103. private _indexBuffer;
  14104. private _effect;
  14105. private _alphaTestEffect;
  14106. /**
  14107. * An event triggered when the layer is disposed.
  14108. */
  14109. onDisposeObservable: Observable<Layer>;
  14110. private _onDisposeObserver;
  14111. /**
  14112. * Back compatibility with callback before the onDisposeObservable existed.
  14113. * The set callback will be triggered when the layer has been disposed.
  14114. */
  14115. onDispose: () => void;
  14116. /**
  14117. * An event triggered before rendering the scene
  14118. */
  14119. onBeforeRenderObservable: Observable<Layer>;
  14120. private _onBeforeRenderObserver;
  14121. /**
  14122. * Back compatibility with callback before the onBeforeRenderObservable existed.
  14123. * The set callback will be triggered just before rendering the layer.
  14124. */
  14125. onBeforeRender: () => void;
  14126. /**
  14127. * An event triggered after rendering the scene
  14128. */
  14129. onAfterRenderObservable: Observable<Layer>;
  14130. private _onAfterRenderObserver;
  14131. /**
  14132. * Back compatibility with callback before the onAfterRenderObservable existed.
  14133. * The set callback will be triggered just after rendering the layer.
  14134. */
  14135. onAfterRender: () => void;
  14136. /**
  14137. * Instantiates a new layer.
  14138. * This represents a full screen 2d layer.
  14139. * This can be usefull to display a picture in the background of your scene for instance.
  14140. * @see https://www.babylonjs-playground.com/#08A2BS#1
  14141. * @param name Define the name of the layer in the scene
  14142. * @param imgUrl Define the url of the texture to display in the layer
  14143. * @param scene Define the scene the layer belongs to
  14144. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  14145. * @param color Defines a color for the layer
  14146. */
  14147. constructor(
  14148. /**
  14149. * Define the name of the layer.
  14150. */
  14151. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  14152. private _createIndexBuffer;
  14153. /** @hidden */
  14154. /**
  14155. * Renders the layer in the scene.
  14156. */
  14157. render(): void;
  14158. /**
  14159. * Disposes and releases the associated ressources.
  14160. */
  14161. dispose(): void;
  14162. }
  14163. }
  14164. declare module BABYLON {
  14165. interface AbstractScene {
  14166. /**
  14167. * The list of layers (background and foreground) of the scene
  14168. */
  14169. layers: Array<Layer>;
  14170. }
  14171. /**
  14172. * Defines the layer scene component responsible to manage any layers
  14173. * in a given scene.
  14174. */
  14175. class LayerSceneComponent implements ISceneComponent {
  14176. /**
  14177. * The component name helpfull to identify the component in the list of scene components.
  14178. */
  14179. readonly name: string;
  14180. /**
  14181. * The scene the component belongs to.
  14182. */
  14183. scene: Scene;
  14184. private _engine;
  14185. /**
  14186. * Creates a new instance of the component for the given scene
  14187. * @param scene Defines the scene to register the component in
  14188. */
  14189. constructor(scene: Scene);
  14190. /**
  14191. * Registers the component in a given scene
  14192. */
  14193. register(): void;
  14194. /**
  14195. * Rebuilds the elements related to this component in case of
  14196. * context lost for instance.
  14197. */
  14198. rebuild(): void;
  14199. /**
  14200. * Disposes the component and the associated ressources.
  14201. */
  14202. dispose(): void;
  14203. private _draw;
  14204. private _drawBackground;
  14205. private _drawForeground;
  14206. }
  14207. }
  14208. declare module BABYLON {
  14209. /**
  14210. * This class can be used to get instrumentation data from a Babylon engine
  14211. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  14212. */
  14213. class EngineInstrumentation implements IDisposable {
  14214. /**
  14215. * Define the instrumented engine.
  14216. */
  14217. engine: Engine;
  14218. private _captureGPUFrameTime;
  14219. private _gpuFrameTimeToken;
  14220. private _gpuFrameTime;
  14221. private _captureShaderCompilationTime;
  14222. private _shaderCompilationTime;
  14223. private _onBeginFrameObserver;
  14224. private _onEndFrameObserver;
  14225. private _onBeforeShaderCompilationObserver;
  14226. private _onAfterShaderCompilationObserver;
  14227. /**
  14228. * Gets the perf counter used for GPU frame time
  14229. */
  14230. readonly gpuFrameTimeCounter: PerfCounter;
  14231. /**
  14232. * Gets the GPU frame time capture status
  14233. */
  14234. /**
  14235. * Enable or disable the GPU frame time capture
  14236. */
  14237. captureGPUFrameTime: boolean;
  14238. /**
  14239. * Gets the perf counter used for shader compilation time
  14240. */
  14241. readonly shaderCompilationTimeCounter: PerfCounter;
  14242. /**
  14243. * Gets the shader compilation time capture status
  14244. */
  14245. /**
  14246. * Enable or disable the shader compilation time capture
  14247. */
  14248. captureShaderCompilationTime: boolean;
  14249. /**
  14250. * Instantiates a new engine instrumentation.
  14251. * This class can be used to get instrumentation data from a Babylon engine
  14252. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  14253. * @param engine Defines the engine to instrument
  14254. */
  14255. constructor(
  14256. /**
  14257. * Define the instrumented engine.
  14258. */
  14259. engine: Engine);
  14260. /**
  14261. * Dispose and release associated resources.
  14262. */
  14263. dispose(): void;
  14264. }
  14265. }
  14266. declare module BABYLON {
  14267. /**
  14268. * This class can be used to get instrumentation data from a Babylon engine
  14269. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  14270. */
  14271. class SceneInstrumentation implements IDisposable {
  14272. /**
  14273. * Defines the scene to instrument
  14274. */
  14275. scene: Scene;
  14276. private _captureActiveMeshesEvaluationTime;
  14277. private _activeMeshesEvaluationTime;
  14278. private _captureRenderTargetsRenderTime;
  14279. private _renderTargetsRenderTime;
  14280. private _captureFrameTime;
  14281. private _frameTime;
  14282. private _captureRenderTime;
  14283. private _renderTime;
  14284. private _captureInterFrameTime;
  14285. private _interFrameTime;
  14286. private _captureParticlesRenderTime;
  14287. private _particlesRenderTime;
  14288. private _captureSpritesRenderTime;
  14289. private _spritesRenderTime;
  14290. private _capturePhysicsTime;
  14291. private _physicsTime;
  14292. private _captureAnimationsTime;
  14293. private _animationsTime;
  14294. private _captureCameraRenderTime;
  14295. private _cameraRenderTime;
  14296. private _onBeforeActiveMeshesEvaluationObserver;
  14297. private _onAfterActiveMeshesEvaluationObserver;
  14298. private _onBeforeRenderTargetsRenderObserver;
  14299. private _onAfterRenderTargetsRenderObserver;
  14300. private _onAfterRenderObserver;
  14301. private _onBeforeDrawPhaseObserver;
  14302. private _onAfterDrawPhaseObserver;
  14303. private _onBeforeAnimationsObserver;
  14304. private _onBeforeParticlesRenderingObserver;
  14305. private _onAfterParticlesRenderingObserver;
  14306. private _onBeforeSpritesRenderingObserver;
  14307. private _onAfterSpritesRenderingObserver;
  14308. private _onBeforePhysicsObserver;
  14309. private _onAfterPhysicsObserver;
  14310. private _onAfterAnimationsObserver;
  14311. private _onBeforeCameraRenderObserver;
  14312. private _onAfterCameraRenderObserver;
  14313. /**
  14314. * Gets the perf counter used for active meshes evaluation time
  14315. */
  14316. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  14317. /**
  14318. * Gets the active meshes evaluation time capture status
  14319. */
  14320. /**
  14321. * Enable or disable the active meshes evaluation time capture
  14322. */
  14323. captureActiveMeshesEvaluationTime: boolean;
  14324. /**
  14325. * Gets the perf counter used for render targets render time
  14326. */
  14327. readonly renderTargetsRenderTimeCounter: PerfCounter;
  14328. /**
  14329. * Gets the render targets render time capture status
  14330. */
  14331. /**
  14332. * Enable or disable the render targets render time capture
  14333. */
  14334. captureRenderTargetsRenderTime: boolean;
  14335. /**
  14336. * Gets the perf counter used for particles render time
  14337. */
  14338. readonly particlesRenderTimeCounter: PerfCounter;
  14339. /**
  14340. * Gets the particles render time capture status
  14341. */
  14342. /**
  14343. * Enable or disable the particles render time capture
  14344. */
  14345. captureParticlesRenderTime: boolean;
  14346. /**
  14347. * Gets the perf counter used for sprites render time
  14348. */
  14349. readonly spritesRenderTimeCounter: PerfCounter;
  14350. /**
  14351. * Gets the sprites render time capture status
  14352. */
  14353. /**
  14354. * Enable or disable the sprites render time capture
  14355. */
  14356. captureSpritesRenderTime: boolean;
  14357. /**
  14358. * Gets the perf counter used for physics time
  14359. */
  14360. readonly physicsTimeCounter: PerfCounter;
  14361. /**
  14362. * Gets the physics time capture status
  14363. */
  14364. /**
  14365. * Enable or disable the physics time capture
  14366. */
  14367. capturePhysicsTime: boolean;
  14368. /**
  14369. * Gets the perf counter used for animations time
  14370. */
  14371. readonly animationsTimeCounter: PerfCounter;
  14372. /**
  14373. * Gets the animations time capture status
  14374. */
  14375. /**
  14376. * Enable or disable the animations time capture
  14377. */
  14378. captureAnimationsTime: boolean;
  14379. /**
  14380. * Gets the perf counter used for frame time capture
  14381. */
  14382. readonly frameTimeCounter: PerfCounter;
  14383. /**
  14384. * Gets the frame time capture status
  14385. */
  14386. /**
  14387. * Enable or disable the frame time capture
  14388. */
  14389. captureFrameTime: boolean;
  14390. /**
  14391. * Gets the perf counter used for inter-frames time capture
  14392. */
  14393. readonly interFrameTimeCounter: PerfCounter;
  14394. /**
  14395. * Gets the inter-frames time capture status
  14396. */
  14397. /**
  14398. * Enable or disable the inter-frames time capture
  14399. */
  14400. captureInterFrameTime: boolean;
  14401. /**
  14402. * Gets the perf counter used for render time capture
  14403. */
  14404. readonly renderTimeCounter: PerfCounter;
  14405. /**
  14406. * Gets the render time capture status
  14407. */
  14408. /**
  14409. * Enable or disable the render time capture
  14410. */
  14411. captureRenderTime: boolean;
  14412. /**
  14413. * Gets the perf counter used for camera render time capture
  14414. */
  14415. readonly cameraRenderTimeCounter: PerfCounter;
  14416. /**
  14417. * Gets the camera render time capture status
  14418. */
  14419. /**
  14420. * Enable or disable the camera render time capture
  14421. */
  14422. captureCameraRenderTime: boolean;
  14423. /**
  14424. * Gets the perf counter used for draw calls
  14425. */
  14426. readonly drawCallsCounter: PerfCounter;
  14427. /**
  14428. * Gets the perf counter used for texture collisions
  14429. */
  14430. readonly textureCollisionsCounter: PerfCounter;
  14431. /**
  14432. * Instantiates a new scene instrumentation.
  14433. * This class can be used to get instrumentation data from a Babylon engine
  14434. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  14435. * @param scene Defines the scene to instrument
  14436. */
  14437. constructor(
  14438. /**
  14439. * Defines the scene to instrument
  14440. */
  14441. scene: Scene);
  14442. /**
  14443. * Dispose and release associated resources.
  14444. */
  14445. dispose(): void;
  14446. }
  14447. }
  14448. declare module BABYLON {
  14449. /**
  14450. * @hidden
  14451. **/
  14452. class _TimeToken {
  14453. }
  14454. }
  14455. declare module BABYLON {
  14456. /**
  14457. * A directional light is defined by a direction (what a surprise!).
  14458. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  14459. * 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.
  14460. * Documentation: https://doc.babylonjs.com/babylon101/lights
  14461. */
  14462. class DirectionalLight extends ShadowLight {
  14463. private _shadowFrustumSize;
  14464. /**
  14465. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  14466. */
  14467. /**
  14468. * Specifies a fix frustum size for the shadow generation.
  14469. */
  14470. shadowFrustumSize: number;
  14471. private _shadowOrthoScale;
  14472. /**
  14473. * Gets the shadow projection scale against the optimal computed one.
  14474. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  14475. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  14476. */
  14477. /**
  14478. * Sets the shadow projection scale against the optimal computed one.
  14479. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  14480. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  14481. */
  14482. shadowOrthoScale: number;
  14483. /**
  14484. * Automatically compute the projection matrix to best fit (including all the casters)
  14485. * on each frame.
  14486. */
  14487. autoUpdateExtends: boolean;
  14488. private _orthoLeft;
  14489. private _orthoRight;
  14490. private _orthoTop;
  14491. private _orthoBottom;
  14492. /**
  14493. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  14494. * The directional light is emitted from everywhere in the given direction.
  14495. * It can cast shadows.
  14496. * Documentation : http://doc.babylonjs.com/tutorials/lights
  14497. * @param name The friendly name of the light
  14498. * @param direction The direction of the light
  14499. * @param scene The scene the light belongs to
  14500. */
  14501. constructor(name: string, direction: Vector3, scene: Scene);
  14502. /**
  14503. * Returns the string "DirectionalLight".
  14504. * @return The class name
  14505. */
  14506. getClassName(): string;
  14507. /**
  14508. * Returns the integer 1.
  14509. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  14510. */
  14511. getTypeID(): number;
  14512. /**
  14513. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  14514. * Returns the DirectionalLight Shadow projection matrix.
  14515. */
  14516. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  14517. /**
  14518. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  14519. * Returns the DirectionalLight Shadow projection matrix.
  14520. */
  14521. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix): void;
  14522. /**
  14523. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  14524. * Returns the DirectionalLight Shadow projection matrix.
  14525. */
  14526. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  14527. protected _buildUniformLayout(): void;
  14528. /**
  14529. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  14530. * @param effect The effect to update
  14531. * @param lightIndex The index of the light in the effect to update
  14532. * @returns The directional light
  14533. */
  14534. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  14535. /**
  14536. * Gets the minZ used for shadow according to both the scene and the light.
  14537. *
  14538. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  14539. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  14540. * @param activeCamera The camera we are returning the min for
  14541. * @returns the depth min z
  14542. */
  14543. getDepthMinZ(activeCamera: Camera): number;
  14544. /**
  14545. * Gets the maxZ used for shadow according to both the scene and the light.
  14546. *
  14547. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  14548. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  14549. * @param activeCamera The camera we are returning the max for
  14550. * @returns the depth max z
  14551. */
  14552. getDepthMaxZ(activeCamera: Camera): number;
  14553. /**
  14554. * Prepares the list of defines specific to the light type.
  14555. * @param defines the list of defines
  14556. * @param lightIndex defines the index of the light for the effect
  14557. */
  14558. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  14559. }
  14560. }
  14561. declare module BABYLON {
  14562. /**
  14563. * The HemisphericLight simulates the ambient environment light,
  14564. * so the passed direction is the light reflection direction, not the incoming direction.
  14565. */
  14566. class HemisphericLight extends Light {
  14567. /**
  14568. * The groundColor is the light in the opposite direction to the one specified during creation.
  14569. * 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.
  14570. */
  14571. groundColor: Color3;
  14572. /**
  14573. * The light reflection direction, not the incoming direction.
  14574. */
  14575. direction: Vector3;
  14576. /**
  14577. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  14578. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  14579. * The HemisphericLight can't cast shadows.
  14580. * Documentation : http://doc.babylonjs.com/tutorials/lights
  14581. * @param name The friendly name of the light
  14582. * @param direction The direction of the light reflection
  14583. * @param scene The scene the light belongs to
  14584. */
  14585. constructor(name: string, direction: Vector3, scene: Scene);
  14586. protected _buildUniformLayout(): void;
  14587. /**
  14588. * Returns the string "HemisphericLight".
  14589. * @return The class name
  14590. */
  14591. getClassName(): string;
  14592. /**
  14593. * Sets the HemisphericLight direction towards the passed target (Vector3).
  14594. * Returns the updated direction.
  14595. * @param target The target the direction should point to
  14596. * @return The computed direction
  14597. */
  14598. setDirectionToTarget(target: Vector3): Vector3;
  14599. /**
  14600. * Returns the shadow generator associated to the light.
  14601. * @returns Always null for hemispheric lights because it does not support shadows.
  14602. */
  14603. getShadowGenerator(): Nullable<IShadowGenerator>;
  14604. /**
  14605. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  14606. * @param effect The effect to update
  14607. * @param lightIndex The index of the light in the effect to update
  14608. * @returns The hemispheric light
  14609. */
  14610. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  14611. /**
  14612. * Computes the world matrix of the node
  14613. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14614. * @param useWasUpdatedFlag defines a reserved property
  14615. * @returns the world matrix
  14616. */
  14617. computeWorldMatrix(force?: boolean, useWasUpdatedFlag?: boolean): Matrix;
  14618. /**
  14619. * Returns the integer 3.
  14620. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  14621. */
  14622. getTypeID(): number;
  14623. /**
  14624. * Prepares the list of defines specific to the light type.
  14625. * @param defines the list of defines
  14626. * @param lightIndex defines the index of the light for the effect
  14627. */
  14628. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  14629. }
  14630. }
  14631. declare module BABYLON {
  14632. /**
  14633. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  14634. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  14635. * 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.
  14636. */
  14637. abstract class Light extends Node {
  14638. /**
  14639. * Falloff Default: light is falling off following the material specification:
  14640. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  14641. */
  14642. static readonly FALLOFF_DEFAULT: number;
  14643. /**
  14644. * Falloff Physical: light is falling off following the inverse squared distance law.
  14645. */
  14646. static readonly FALLOFF_PHYSICAL: number;
  14647. /**
  14648. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  14649. * to enhance interoperability with other engines.
  14650. */
  14651. static readonly FALLOFF_GLTF: number;
  14652. /**
  14653. * Falloff Standard: light is falling off like in the standard material
  14654. * to enhance interoperability with other materials.
  14655. */
  14656. static readonly FALLOFF_STANDARD: number;
  14657. /**
  14658. * If every light affecting the material is in this lightmapMode,
  14659. * material.lightmapTexture adds or multiplies
  14660. * (depends on material.useLightmapAsShadowmap)
  14661. * after every other light calculations.
  14662. */
  14663. static readonly LIGHTMAP_DEFAULT: number;
  14664. /**
  14665. * material.lightmapTexture as only diffuse lighting from this light
  14666. * adds only specular lighting from this light
  14667. * adds dynamic shadows
  14668. */
  14669. static readonly LIGHTMAP_SPECULAR: number;
  14670. /**
  14671. * material.lightmapTexture as only lighting
  14672. * no light calculation from this light
  14673. * only adds dynamic shadows from this light
  14674. */
  14675. static readonly LIGHTMAP_SHADOWSONLY: number;
  14676. /**
  14677. * Each light type uses the default quantity according to its type:
  14678. * point/spot lights use luminous intensity
  14679. * directional lights use illuminance
  14680. */
  14681. static readonly INTENSITYMODE_AUTOMATIC: number;
  14682. /**
  14683. * lumen (lm)
  14684. */
  14685. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  14686. /**
  14687. * candela (lm/sr)
  14688. */
  14689. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  14690. /**
  14691. * lux (lm/m^2)
  14692. */
  14693. static readonly INTENSITYMODE_ILLUMINANCE: number;
  14694. /**
  14695. * nit (cd/m^2)
  14696. */
  14697. static readonly INTENSITYMODE_LUMINANCE: number;
  14698. /**
  14699. * Light type const id of the point light.
  14700. */
  14701. static readonly LIGHTTYPEID_POINTLIGHT: number;
  14702. /**
  14703. * Light type const id of the directional light.
  14704. */
  14705. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  14706. /**
  14707. * Light type const id of the spot light.
  14708. */
  14709. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  14710. /**
  14711. * Light type const id of the hemispheric light.
  14712. */
  14713. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  14714. /**
  14715. * Diffuse gives the basic color to an object.
  14716. */
  14717. diffuse: Color3;
  14718. /**
  14719. * Specular produces a highlight color on an object.
  14720. * Note: This is note affecting PBR materials.
  14721. */
  14722. specular: Color3;
  14723. /**
  14724. * Defines the falloff type for this light. This lets overrriding how punctual light are
  14725. * falling off base on range or angle.
  14726. * This can be set to any values in Light.FALLOFF_x.
  14727. *
  14728. * Note: This is only usefull for PBR Materials at the moment. This could be extended if required to
  14729. * other types of materials.
  14730. */
  14731. falloffType: number;
  14732. /**
  14733. * Strength of the light.
  14734. * Note: By default it is define in the framework own unit.
  14735. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  14736. */
  14737. intensity: number;
  14738. private _range;
  14739. protected _inverseSquaredRange: number;
  14740. /**
  14741. * Defines how far from the source the light is impacting in scene units.
  14742. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  14743. */
  14744. /**
  14745. * Defines how far from the source the light is impacting in scene units.
  14746. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  14747. */
  14748. range: number;
  14749. /**
  14750. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  14751. * of light.
  14752. */
  14753. private _photometricScale;
  14754. private _intensityMode;
  14755. /**
  14756. * Gets the photometric scale used to interpret the intensity.
  14757. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  14758. */
  14759. /**
  14760. * Sets the photometric scale used to interpret the intensity.
  14761. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  14762. */
  14763. intensityMode: number;
  14764. private _radius;
  14765. /**
  14766. * Gets the light radius used by PBR Materials to simulate soft area lights.
  14767. */
  14768. /**
  14769. * sets the light radius used by PBR Materials to simulate soft area lights.
  14770. */
  14771. radius: number;
  14772. private _renderPriority;
  14773. /**
  14774. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  14775. * exceeding the number allowed of the materials.
  14776. */
  14777. renderPriority: number;
  14778. private _shadowEnabled;
  14779. /**
  14780. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  14781. * the current shadow generator.
  14782. */
  14783. /**
  14784. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  14785. * the current shadow generator.
  14786. */
  14787. shadowEnabled: boolean;
  14788. private _includedOnlyMeshes;
  14789. /**
  14790. * Gets the only meshes impacted by this light.
  14791. */
  14792. /**
  14793. * Sets the only meshes impacted by this light.
  14794. */
  14795. includedOnlyMeshes: AbstractMesh[];
  14796. private _excludedMeshes;
  14797. /**
  14798. * Gets the meshes not impacted by this light.
  14799. */
  14800. /**
  14801. * Sets the meshes not impacted by this light.
  14802. */
  14803. excludedMeshes: AbstractMesh[];
  14804. private _excludeWithLayerMask;
  14805. /**
  14806. * Gets the layer id use to find what meshes are not impacted by the light.
  14807. * Inactive if 0
  14808. */
  14809. /**
  14810. * Sets the layer id use to find what meshes are not impacted by the light.
  14811. * Inactive if 0
  14812. */
  14813. excludeWithLayerMask: number;
  14814. private _includeOnlyWithLayerMask;
  14815. /**
  14816. * Gets the layer id use to find what meshes are impacted by the light.
  14817. * Inactive if 0
  14818. */
  14819. /**
  14820. * Sets the layer id use to find what meshes are impacted by the light.
  14821. * Inactive if 0
  14822. */
  14823. includeOnlyWithLayerMask: number;
  14824. private _lightmapMode;
  14825. /**
  14826. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  14827. */
  14828. /**
  14829. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  14830. */
  14831. lightmapMode: number;
  14832. /**
  14833. * Shadow generator associted to the light.
  14834. * @hidden Internal use only.
  14835. */
  14836. /**
  14837. * @hidden Internal use only.
  14838. */
  14839. /**
  14840. * @hidden Internal use only.
  14841. */
  14842. /**
  14843. * The current light unifom buffer.
  14844. * @hidden Internal use only.
  14845. */
  14846. /**
  14847. * Creates a Light object in the scene.
  14848. * Documentation : http://doc.babylonjs.com/tutorials/lights
  14849. * @param name The firendly name of the light
  14850. * @param scene The scene the light belongs too
  14851. */
  14852. constructor(name: string, scene: Scene);
  14853. protected abstract _buildUniformLayout(): void;
  14854. /**
  14855. * Sets the passed Effect "effect" with the Light information.
  14856. * @param effect The effect to update
  14857. * @param lightIndex The index of the light in the effect to update
  14858. * @returns The light
  14859. */
  14860. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  14861. /**
  14862. * Returns the string "Light".
  14863. * @returns the class name
  14864. */
  14865. getClassName(): string;
  14866. /**
  14867. * Converts the light information to a readable string for debug purpose.
  14868. * @param fullDetails Supports for multiple levels of logging within scene loading
  14869. * @returns the human readable light info
  14870. */
  14871. toString(fullDetails?: boolean): string;
  14872. /** @hidden */
  14873. protected _syncParentEnabledState(): void;
  14874. /**
  14875. * Set the enabled state of this node.
  14876. * @param value - the new enabled state
  14877. */
  14878. setEnabled(value: boolean): void;
  14879. /**
  14880. * Returns the Light associated shadow generator if any.
  14881. * @return the associated shadow generator.
  14882. */
  14883. getShadowGenerator(): Nullable<IShadowGenerator>;
  14884. /**
  14885. * Returns a Vector3, the absolute light position in the World.
  14886. * @returns the world space position of the light
  14887. */
  14888. getAbsolutePosition(): Vector3;
  14889. /**
  14890. * Specifies if the light will affect the passed mesh.
  14891. * @param mesh The mesh to test against the light
  14892. * @return true the mesh is affected otherwise, false.
  14893. */
  14894. canAffectMesh(mesh: AbstractMesh): boolean;
  14895. /**
  14896. * Sort function to order lights for rendering.
  14897. * @param a First Light object to compare to second.
  14898. * @param b Second Light object to compare first.
  14899. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  14900. */
  14901. static CompareLightsPriority(a: Light, b: Light): number;
  14902. /**
  14903. * Releases resources associated with this node.
  14904. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14905. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14906. */
  14907. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14908. /**
  14909. * Returns the light type ID (integer).
  14910. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  14911. */
  14912. getTypeID(): number;
  14913. /**
  14914. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  14915. * @returns the scaled intensity in intensity mode unit
  14916. */
  14917. getScaledIntensity(): number;
  14918. /**
  14919. * Returns a new Light object, named "name", from the current one.
  14920. * @param name The name of the cloned light
  14921. * @returns the new created light
  14922. */
  14923. clone(name: string): Nullable<Light>;
  14924. /**
  14925. * Serializes the current light into a Serialization object.
  14926. * @returns the serialized object.
  14927. */
  14928. serialize(): any;
  14929. /**
  14930. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  14931. * This new light is named "name" and added to the passed scene.
  14932. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  14933. * @param name The friendly name of the light
  14934. * @param scene The scene the new light will belong to
  14935. * @returns the constructor function
  14936. */
  14937. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  14938. /**
  14939. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  14940. * @param parsedLight The JSON representation of the light
  14941. * @param scene The scene to create the parsed light in
  14942. * @returns the created light after parsing
  14943. */
  14944. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  14945. private _hookArrayForExcluded;
  14946. private _hookArrayForIncludedOnly;
  14947. private _resyncMeshes;
  14948. /**
  14949. * Forces the meshes to update their light related information in their rendering used effects
  14950. * @hidden Internal Use Only
  14951. */
  14952. /**
  14953. * Recomputes the cached photometric scale if needed.
  14954. */
  14955. private _computePhotometricScale;
  14956. /**
  14957. * Returns the Photometric Scale according to the light type and intensity mode.
  14958. */
  14959. private _getPhotometricScale;
  14960. /**
  14961. * Reorder the light in the scene according to their defined priority.
  14962. * @hidden Internal Use Only
  14963. */
  14964. /**
  14965. * Prepares the list of defines specific to the light type.
  14966. * @param defines the list of defines
  14967. * @param lightIndex defines the index of the light for the effect
  14968. */
  14969. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  14970. }
  14971. }
  14972. declare module BABYLON {
  14973. /**
  14974. * A point light is a light defined by an unique point in world space.
  14975. * The light is emitted in every direction from this point.
  14976. * A good example of a point light is a standard light bulb.
  14977. * Documentation: https://doc.babylonjs.com/babylon101/lights
  14978. */
  14979. class PointLight extends ShadowLight {
  14980. private _shadowAngle;
  14981. /**
  14982. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  14983. * This specifies what angle the shadow will use to be created.
  14984. *
  14985. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  14986. */
  14987. /**
  14988. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  14989. * This specifies what angle the shadow will use to be created.
  14990. *
  14991. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  14992. */
  14993. shadowAngle: number;
  14994. /**
  14995. * Gets the direction if it has been set.
  14996. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  14997. */
  14998. /**
  14999. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  15000. */
  15001. direction: Vector3;
  15002. /**
  15003. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  15004. * A PointLight emits the light in every direction.
  15005. * It can cast shadows.
  15006. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  15007. * ```javascript
  15008. * var pointLight = new BABYLON.PointLight("pl", camera.position, scene);
  15009. * ```
  15010. * Documentation : http://doc.babylonjs.com/tutorials/lights
  15011. * @param name The light friendly name
  15012. * @param position The position of the point light in the scene
  15013. * @param scene The scene the lights belongs to
  15014. */
  15015. constructor(name: string, position: Vector3, scene: Scene);
  15016. /**
  15017. * Returns the string "PointLight"
  15018. * @returns the class name
  15019. */
  15020. getClassName(): string;
  15021. /**
  15022. * Returns the integer 0.
  15023. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  15024. */
  15025. getTypeID(): number;
  15026. /**
  15027. * Specifies wether or not the shadowmap should be a cube texture.
  15028. * @returns true if the shadowmap needs to be a cube texture.
  15029. */
  15030. needCube(): boolean;
  15031. /**
  15032. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  15033. * @param faceIndex The index of the face we are computed the direction to generate shadow
  15034. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  15035. */
  15036. getShadowDirection(faceIndex?: number): Vector3;
  15037. /**
  15038. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  15039. * - fov = PI / 2
  15040. * - aspect ratio : 1.0
  15041. * - z-near and far equal to the active camera minZ and maxZ.
  15042. * Returns the PointLight.
  15043. */
  15044. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  15045. protected _buildUniformLayout(): void;
  15046. /**
  15047. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  15048. * @param effect The effect to update
  15049. * @param lightIndex The index of the light in the effect to update
  15050. * @returns The point light
  15051. */
  15052. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  15053. /**
  15054. * Prepares the list of defines specific to the light type.
  15055. * @param defines the list of defines
  15056. * @param lightIndex defines the index of the light for the effect
  15057. */
  15058. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  15059. }
  15060. }
  15061. declare module BABYLON {
  15062. /**
  15063. * Interface describing all the common properties and methods a shadow light needs to implement.
  15064. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  15065. * as well as binding the different shadow properties to the effects.
  15066. */
  15067. interface IShadowLight extends Light {
  15068. /**
  15069. * The light id in the scene (used in scene.findLighById for instance)
  15070. */
  15071. id: string;
  15072. /**
  15073. * The position the shdow will be casted from.
  15074. */
  15075. position: Vector3;
  15076. /**
  15077. * In 2d mode (needCube being false), the direction used to cast the shadow.
  15078. */
  15079. direction: Vector3;
  15080. /**
  15081. * The transformed position. Position of the light in world space taking parenting in account.
  15082. */
  15083. transformedPosition: Vector3;
  15084. /**
  15085. * The transformed direction. Direction of the light in world space taking parenting in account.
  15086. */
  15087. transformedDirection: Vector3;
  15088. /**
  15089. * The friendly name of the light in the scene.
  15090. */
  15091. name: string;
  15092. /**
  15093. * Defines the shadow projection clipping minimum z value.
  15094. */
  15095. shadowMinZ: number;
  15096. /**
  15097. * Defines the shadow projection clipping maximum z value.
  15098. */
  15099. shadowMaxZ: number;
  15100. /**
  15101. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  15102. * @returns true if the information has been computed, false if it does not need to (no parenting)
  15103. */
  15104. computeTransformedInformation(): boolean;
  15105. /**
  15106. * Gets the scene the light belongs to.
  15107. * @returns The scene
  15108. */
  15109. getScene(): Scene;
  15110. /**
  15111. * Callback defining a custom Projection Matrix Builder.
  15112. * This can be used to override the default projection matrix computation.
  15113. */
  15114. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  15115. /**
  15116. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  15117. * @param matrix The materix to updated with the projection information
  15118. * @param viewMatrix The transform matrix of the light
  15119. * @param renderList The list of mesh to render in the map
  15120. * @returns The current light
  15121. */
  15122. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  15123. /**
  15124. * Gets the current depth scale used in ESM.
  15125. * @returns The scale
  15126. */
  15127. getDepthScale(): number;
  15128. /**
  15129. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  15130. * @returns true if a cube texture needs to be use
  15131. */
  15132. needCube(): boolean;
  15133. /**
  15134. * Detects if the projection matrix requires to be recomputed this frame.
  15135. * @returns true if it requires to be recomputed otherwise, false.
  15136. */
  15137. needProjectionMatrixCompute(): boolean;
  15138. /**
  15139. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  15140. */
  15141. forceProjectionMatrixCompute(): void;
  15142. /**
  15143. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  15144. * @param faceIndex The index of the face we are computed the direction to generate shadow
  15145. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  15146. */
  15147. getShadowDirection(faceIndex?: number): Vector3;
  15148. /**
  15149. * Gets the minZ used for shadow according to both the scene and the light.
  15150. * @param activeCamera The camera we are returning the min for
  15151. * @returns the depth min z
  15152. */
  15153. getDepthMinZ(activeCamera: Camera): number;
  15154. /**
  15155. * Gets the maxZ used for shadow according to both the scene and the light.
  15156. * @param activeCamera The camera we are returning the max for
  15157. * @returns the depth max z
  15158. */
  15159. getDepthMaxZ(activeCamera: Camera): number;
  15160. }
  15161. /**
  15162. * Base implementation IShadowLight
  15163. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  15164. */
  15165. abstract class ShadowLight extends Light implements IShadowLight {
  15166. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  15167. protected _position: Vector3;
  15168. protected _setPosition(value: Vector3): void;
  15169. /**
  15170. * Sets the position the shadow will be casted from. Also use as the light position for both
  15171. * point and spot lights.
  15172. */
  15173. /**
  15174. * Sets the position the shadow will be casted from. Also use as the light position for both
  15175. * point and spot lights.
  15176. */
  15177. position: Vector3;
  15178. protected _direction: Vector3;
  15179. protected _setDirection(value: Vector3): void;
  15180. /**
  15181. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  15182. * Also use as the light direction on spot and directional lights.
  15183. */
  15184. /**
  15185. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  15186. * Also use as the light direction on spot and directional lights.
  15187. */
  15188. direction: Vector3;
  15189. private _shadowMinZ;
  15190. /**
  15191. * Gets the shadow projection clipping minimum z value.
  15192. */
  15193. /**
  15194. * Sets the shadow projection clipping minimum z value.
  15195. */
  15196. shadowMinZ: number;
  15197. private _shadowMaxZ;
  15198. /**
  15199. * Sets the shadow projection clipping maximum z value.
  15200. */
  15201. /**
  15202. * Gets the shadow projection clipping maximum z value.
  15203. */
  15204. shadowMaxZ: number;
  15205. /**
  15206. * Callback defining a custom Projection Matrix Builder.
  15207. * This can be used to override the default projection matrix computation.
  15208. */
  15209. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  15210. /**
  15211. * The transformed position. Position of the light in world space taking parenting in account.
  15212. */
  15213. transformedPosition: Vector3;
  15214. /**
  15215. * The transformed direction. Direction of the light in world space taking parenting in account.
  15216. */
  15217. transformedDirection: Vector3;
  15218. private _needProjectionMatrixCompute;
  15219. /**
  15220. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  15221. * @returns true if the information has been computed, false if it does not need to (no parenting)
  15222. */
  15223. computeTransformedInformation(): boolean;
  15224. /**
  15225. * Return the depth scale used for the shadow map.
  15226. * @returns the depth scale.
  15227. */
  15228. getDepthScale(): number;
  15229. /**
  15230. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  15231. * @param faceIndex The index of the face we are computed the direction to generate shadow
  15232. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  15233. */
  15234. getShadowDirection(faceIndex?: number): Vector3;
  15235. /**
  15236. * Returns the ShadowLight absolute position in the World.
  15237. * @returns the position vector in world space
  15238. */
  15239. getAbsolutePosition(): Vector3;
  15240. /**
  15241. * Sets the ShadowLight direction toward the passed target.
  15242. * @param target The point tot target in local space
  15243. * @returns the updated ShadowLight direction
  15244. */
  15245. setDirectionToTarget(target: Vector3): Vector3;
  15246. /**
  15247. * Returns the light rotation in euler definition.
  15248. * @returns the x y z rotation in local space.
  15249. */
  15250. getRotation(): Vector3;
  15251. /**
  15252. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  15253. * @returns true if a cube texture needs to be use
  15254. */
  15255. needCube(): boolean;
  15256. /**
  15257. * Detects if the projection matrix requires to be recomputed this frame.
  15258. * @returns true if it requires to be recomputed otherwise, false.
  15259. */
  15260. needProjectionMatrixCompute(): boolean;
  15261. /**
  15262. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  15263. */
  15264. forceProjectionMatrixCompute(): void;
  15265. /** @hidden */
  15266. /** @hidden */
  15267. /**
  15268. * Computes the world matrix of the node
  15269. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  15270. * @returns the world matrix
  15271. */
  15272. computeWorldMatrix(force?: boolean): Matrix;
  15273. /**
  15274. * Gets the minZ used for shadow according to both the scene and the light.
  15275. * @param activeCamera The camera we are returning the min for
  15276. * @returns the depth min z
  15277. */
  15278. getDepthMinZ(activeCamera: Camera): number;
  15279. /**
  15280. * Gets the maxZ used for shadow according to both the scene and the light.
  15281. * @param activeCamera The camera we are returning the max for
  15282. * @returns the depth max z
  15283. */
  15284. getDepthMaxZ(activeCamera: Camera): number;
  15285. /**
  15286. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  15287. * @param matrix The materix to updated with the projection information
  15288. * @param viewMatrix The transform matrix of the light
  15289. * @param renderList The list of mesh to render in the map
  15290. * @returns The current light
  15291. */
  15292. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  15293. }
  15294. }
  15295. declare module BABYLON {
  15296. /**
  15297. * A spot light is defined by a position, a direction, an angle, and an exponent.
  15298. * These values define a cone of light starting from the position, emitting toward the direction.
  15299. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  15300. * and the exponent defines the speed of the decay of the light with distance (reach).
  15301. * Documentation: https://doc.babylonjs.com/babylon101/lights
  15302. */
  15303. class SpotLight extends ShadowLight {
  15304. private _angle;
  15305. private _innerAngle;
  15306. private _cosHalfAngle;
  15307. private _lightAngleScale;
  15308. private _lightAngleOffset;
  15309. /**
  15310. * Gets the cone angle of the spot light in Radians.
  15311. */
  15312. /**
  15313. * Sets the cone angle of the spot light in Radians.
  15314. */
  15315. angle: number;
  15316. /**
  15317. * Only used in gltf falloff mode, this defines the angle where
  15318. * the directional falloff will start before cutting at angle which could be seen
  15319. * as outer angle.
  15320. */
  15321. /**
  15322. * Only used in gltf falloff mode, this defines the angle where
  15323. * the directional falloff will start before cutting at angle which could be seen
  15324. * as outer angle.
  15325. */
  15326. innerAngle: number;
  15327. private _shadowAngleScale;
  15328. /**
  15329. * Allows scaling the angle of the light for shadow generation only.
  15330. */
  15331. /**
  15332. * Allows scaling the angle of the light for shadow generation only.
  15333. */
  15334. shadowAngleScale: number;
  15335. /**
  15336. * The light decay speed with the distance from the emission spot.
  15337. */
  15338. exponent: number;
  15339. private _projectionTextureMatrix;
  15340. /**
  15341. * Allows reading the projecton texture
  15342. */
  15343. readonly projectionTextureMatrix: Matrix;
  15344. protected _projectionTextureLightNear: number;
  15345. /**
  15346. * Gets the near clip of the Spotlight for texture projection.
  15347. */
  15348. /**
  15349. * Sets the near clip of the Spotlight for texture projection.
  15350. */
  15351. projectionTextureLightNear: number;
  15352. protected _projectionTextureLightFar: number;
  15353. /**
  15354. * Gets the far clip of the Spotlight for texture projection.
  15355. */
  15356. /**
  15357. * Sets the far clip of the Spotlight for texture projection.
  15358. */
  15359. projectionTextureLightFar: number;
  15360. protected _projectionTextureUpDirection: Vector3;
  15361. /**
  15362. * Gets the Up vector of the Spotlight for texture projection.
  15363. */
  15364. /**
  15365. * Sets the Up vector of the Spotlight for texture projection.
  15366. */
  15367. projectionTextureUpDirection: Vector3;
  15368. private _projectionTexture;
  15369. /**
  15370. * Gets the projection texture of the light.
  15371. */
  15372. /**
  15373. * Sets the projection texture of the light.
  15374. */
  15375. projectionTexture: Nullable<BaseTexture>;
  15376. private _projectionTextureViewLightDirty;
  15377. private _projectionTextureProjectionLightDirty;
  15378. private _projectionTextureDirty;
  15379. private _projectionTextureViewTargetVector;
  15380. private _projectionTextureViewLightMatrix;
  15381. private _projectionTextureProjectionLightMatrix;
  15382. private _projectionTextureScalingMatrix;
  15383. /**
  15384. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  15385. * It can cast shadows.
  15386. * Documentation : http://doc.babylonjs.com/tutorials/lights
  15387. * @param name The light friendly name
  15388. * @param position The position of the spot light in the scene
  15389. * @param direction The direction of the light in the scene
  15390. * @param angle The cone angle of the light in Radians
  15391. * @param exponent The light decay speed with the distance from the emission spot
  15392. * @param scene The scene the lights belongs to
  15393. */
  15394. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  15395. /**
  15396. * Returns the string "SpotLight".
  15397. * @returns the class name
  15398. */
  15399. getClassName(): string;
  15400. /**
  15401. * Returns the integer 2.
  15402. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  15403. */
  15404. getTypeID(): number;
  15405. /**
  15406. * Overrides the direction setter to recompute the projection texture view light Matrix.
  15407. */
  15408. protected _setDirection(value: Vector3): void;
  15409. /**
  15410. * Overrides the position setter to recompute the projection texture view light Matrix.
  15411. */
  15412. protected _setPosition(value: Vector3): void;
  15413. /**
  15414. * 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.
  15415. * Returns the SpotLight.
  15416. */
  15417. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  15418. protected _computeProjectionTextureViewLightMatrix(): void;
  15419. protected _computeProjectionTextureProjectionLightMatrix(): void;
  15420. /**
  15421. * Main function for light texture projection matrix computing.
  15422. */
  15423. protected _computeProjectionTextureMatrix(): void;
  15424. protected _buildUniformLayout(): void;
  15425. private _computeAngleValues;
  15426. /**
  15427. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  15428. * @param effect The effect to update
  15429. * @param lightIndex The index of the light in the effect to update
  15430. * @returns The spot light
  15431. */
  15432. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  15433. /**
  15434. * Disposes the light and the associated resources.
  15435. */
  15436. dispose(): void;
  15437. /**
  15438. * Prepares the list of defines specific to the light type.
  15439. * @param defines the list of defines
  15440. * @param lightIndex defines the index of the light for the effect
  15441. */
  15442. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  15443. }
  15444. }
  15445. declare module BABYLON {
  15446. /**
  15447. * Interface used to present a loading screen while loading a scene
  15448. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  15449. */
  15450. interface ILoadingScreen {
  15451. /**
  15452. * Function called to display the loading screen
  15453. */
  15454. displayLoadingUI: () => void;
  15455. /**
  15456. * Function called to hide the loading screen
  15457. */
  15458. hideLoadingUI: () => void;
  15459. /**
  15460. * Gets or sets the color to use for the background
  15461. */
  15462. loadingUIBackgroundColor: string;
  15463. /**
  15464. * Gets or sets the text to display while loading
  15465. */
  15466. loadingUIText: string;
  15467. }
  15468. /**
  15469. * Class used for the default loading screen
  15470. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  15471. */
  15472. class DefaultLoadingScreen implements ILoadingScreen {
  15473. private _renderingCanvas;
  15474. private _loadingText;
  15475. private _loadingDivBackgroundColor;
  15476. private _loadingDiv;
  15477. private _loadingTextDiv;
  15478. /**
  15479. * Creates a new default loading screen
  15480. * @param _renderingCanvas defines the canvas used to render the scene
  15481. * @param _loadingText defines the default text to display
  15482. * @param _loadingDivBackgroundColor defines the default background color
  15483. */
  15484. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  15485. /**
  15486. * Function called to display the loading screen
  15487. */
  15488. displayLoadingUI(): void;
  15489. /**
  15490. * Function called to hide the loading screen
  15491. */
  15492. hideLoadingUI(): void;
  15493. /**
  15494. * Gets or sets the text to display while loading
  15495. */
  15496. loadingUIText: string;
  15497. /**
  15498. * Gets or sets the color to use for the background
  15499. */
  15500. loadingUIBackgroundColor: string;
  15501. private _resizeLoadingUI;
  15502. }
  15503. }
  15504. declare module BABYLON {
  15505. /**
  15506. * Class used to represent data loading progression
  15507. */
  15508. class SceneLoaderProgressEvent {
  15509. /** defines if data length to load can be evaluated */
  15510. readonly lengthComputable: boolean;
  15511. /** defines the loaded data length */
  15512. readonly loaded: number;
  15513. /** defines the data length to load */
  15514. readonly total: number;
  15515. /**
  15516. * Create a new progress event
  15517. * @param lengthComputable defines if data length to load can be evaluated
  15518. * @param loaded defines the loaded data length
  15519. * @param total defines the data length to load
  15520. */
  15521. constructor(
  15522. /** defines if data length to load can be evaluated */
  15523. lengthComputable: boolean,
  15524. /** defines the loaded data length */
  15525. loaded: number,
  15526. /** defines the data length to load */
  15527. total: number);
  15528. /**
  15529. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  15530. * @param event defines the source event
  15531. * @returns a new SceneLoaderProgressEvent
  15532. */
  15533. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  15534. }
  15535. /**
  15536. * Interface used by SceneLoader plugins to define supported file extensions
  15537. */
  15538. interface ISceneLoaderPluginExtensions {
  15539. /**
  15540. * Defines the list of supported extensions
  15541. */
  15542. [extension: string]: {
  15543. isBinary: boolean;
  15544. };
  15545. }
  15546. /**
  15547. * Interface used by SceneLoader plugin factory
  15548. */
  15549. interface ISceneLoaderPluginFactory {
  15550. /**
  15551. * Defines the name of the factory
  15552. */
  15553. name: string;
  15554. /**
  15555. * Function called to create a new plugin
  15556. * @return the new plugin
  15557. */
  15558. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  15559. /**
  15560. * Boolean indicating if the plugin can direct load specific data
  15561. */
  15562. canDirectLoad?: (data: string) => boolean;
  15563. }
  15564. /**
  15565. * Interface used to define a SceneLoader plugin
  15566. */
  15567. interface ISceneLoaderPlugin {
  15568. /**
  15569. * The friendly name of this plugin.
  15570. */
  15571. name: string;
  15572. /**
  15573. * The file extensions supported by this plugin.
  15574. */
  15575. extensions: string | ISceneLoaderPluginExtensions;
  15576. /**
  15577. * Import meshes into a scene.
  15578. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  15579. * @param scene The scene to import into
  15580. * @param data The data to import
  15581. * @param rootUrl The root url for scene and resources
  15582. * @param meshes The meshes array to import into
  15583. * @param particleSystems The particle systems array to import into
  15584. * @param skeletons The skeletons array to import into
  15585. * @param onError The callback when import fails
  15586. * @returns True if successful or false otherwise
  15587. */
  15588. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  15589. /**
  15590. * Load into a scene.
  15591. * @param scene The scene to load into
  15592. * @param data The data to import
  15593. * @param rootUrl The root url for scene and resources
  15594. * @param onError The callback when import fails
  15595. * @returns true if successful or false otherwise
  15596. */
  15597. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  15598. /**
  15599. * The callback that returns true if the data can be directly loaded.
  15600. */
  15601. canDirectLoad?: (data: string) => boolean;
  15602. /**
  15603. * The callback that allows custom handling of the root url based on the response url.
  15604. */
  15605. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  15606. /**
  15607. * Load into an asset container.
  15608. * @param scene The scene to load into
  15609. * @param data The data to import
  15610. * @param rootUrl The root url for scene and resources
  15611. * @param onError The callback when import fails
  15612. * @returns The loaded asset container
  15613. */
  15614. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  15615. }
  15616. /**
  15617. * Interface used to define an async SceneLoader plugin
  15618. */
  15619. interface ISceneLoaderPluginAsync {
  15620. /**
  15621. * The friendly name of this plugin.
  15622. */
  15623. name: string;
  15624. /**
  15625. * The file extensions supported by this plugin.
  15626. */
  15627. extensions: string | ISceneLoaderPluginExtensions;
  15628. /**
  15629. * Import meshes into a scene.
  15630. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  15631. * @param scene The scene to import into
  15632. * @param data The data to import
  15633. * @param rootUrl The root url for scene and resources
  15634. * @param onProgress The callback when the load progresses
  15635. * @param fileName Defines the name of the file to load
  15636. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  15637. */
  15638. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  15639. meshes: AbstractMesh[];
  15640. particleSystems: IParticleSystem[];
  15641. skeletons: Skeleton[];
  15642. animationGroups: AnimationGroup[];
  15643. }>;
  15644. /**
  15645. * Load into a scene.
  15646. * @param scene The scene to load into
  15647. * @param data The data to import
  15648. * @param rootUrl The root url for scene and resources
  15649. * @param onProgress The callback when the load progresses
  15650. * @param fileName Defines the name of the file to load
  15651. * @returns Nothing
  15652. */
  15653. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  15654. /**
  15655. * The callback that returns true if the data can be directly loaded.
  15656. */
  15657. canDirectLoad?: (data: string) => boolean;
  15658. /**
  15659. * The callback that allows custom handling of the root url based on the response url.
  15660. */
  15661. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  15662. /**
  15663. * Load into an asset container.
  15664. * @param scene The scene to load into
  15665. * @param data The data to import
  15666. * @param rootUrl The root url for scene and resources
  15667. * @param onProgress The callback when the load progresses
  15668. * @param fileName Defines the name of the file to load
  15669. * @returns The loaded asset container
  15670. */
  15671. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  15672. }
  15673. /**
  15674. * Class used to load scene from various file formats using registered plugins
  15675. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  15676. */
  15677. class SceneLoader {
  15678. private static _ForceFullSceneLoadingForIncremental;
  15679. private static _ShowLoadingScreen;
  15680. private static _CleanBoneMatrixWeights;
  15681. /**
  15682. * No logging while loading
  15683. */
  15684. static readonly NO_LOGGING: number;
  15685. /**
  15686. * Minimal logging while loading
  15687. */
  15688. static readonly MINIMAL_LOGGING: number;
  15689. /**
  15690. * Summary logging while loading
  15691. */
  15692. static readonly SUMMARY_LOGGING: number;
  15693. /**
  15694. * Detailled logging while loading
  15695. */
  15696. static readonly DETAILED_LOGGING: number;
  15697. private static _loggingLevel;
  15698. /**
  15699. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  15700. */
  15701. static ForceFullSceneLoadingForIncremental: boolean;
  15702. /**
  15703. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  15704. */
  15705. static ShowLoadingScreen: boolean;
  15706. /**
  15707. * Defines the current logging level (while loading the scene)
  15708. * @ignorenaming
  15709. */
  15710. static loggingLevel: number;
  15711. /**
  15712. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  15713. */
  15714. static CleanBoneMatrixWeights: boolean;
  15715. /**
  15716. * Event raised when a plugin is used to load a scene
  15717. */
  15718. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  15719. private static _registeredPlugins;
  15720. private static _getDefaultPlugin;
  15721. private static _getPluginForExtension;
  15722. private static _getPluginForDirectLoad;
  15723. private static _getPluginForFilename;
  15724. private static _getDirectLoad;
  15725. private static _loadData;
  15726. private static _getFileInfo;
  15727. /**
  15728. * Gets a plugin that can load the given extension
  15729. * @param extension defines the extension to load
  15730. * @returns a plugin or null if none works
  15731. */
  15732. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  15733. /**
  15734. * Gets a boolean indicating that the given extension can be loaded
  15735. * @param extension defines the extension to load
  15736. * @returns true if the extension is supported
  15737. */
  15738. static IsPluginForExtensionAvailable(extension: string): boolean;
  15739. /**
  15740. * Adds a new plugin to the list of registered plugins
  15741. * @param plugin defines the plugin to add
  15742. */
  15743. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  15744. /**
  15745. * Import meshes into a scene
  15746. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  15747. * @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)
  15748. * @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)
  15749. * @param scene the instance of BABYLON.Scene to append to
  15750. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  15751. * @param onProgress a callback with a progress event for each file being loaded
  15752. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  15753. * @param pluginExtension the extension used to determine the plugin
  15754. * @returns The loaded plugin
  15755. */
  15756. 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>;
  15757. /**
  15758. * Import meshes into a scene
  15759. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  15760. * @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)
  15761. * @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)
  15762. * @param scene the instance of BABYLON.Scene to append to
  15763. * @param onProgress a callback with a progress event for each file being loaded
  15764. * @param pluginExtension the extension used to determine the plugin
  15765. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  15766. */
  15767. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  15768. meshes: AbstractMesh[];
  15769. particleSystems: IParticleSystem[];
  15770. skeletons: Skeleton[];
  15771. animationGroups: AnimationGroup[];
  15772. }>;
  15773. /**
  15774. * Load a scene
  15775. * @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)
  15776. * @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)
  15777. * @param engine is the instance of BABYLON.Engine to use to create the scene
  15778. * @param onSuccess a callback with the scene when import succeeds
  15779. * @param onProgress a callback with a progress event for each file being loaded
  15780. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  15781. * @param pluginExtension the extension used to determine the plugin
  15782. * @returns The loaded plugin
  15783. */
  15784. 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>;
  15785. /**
  15786. * Load a scene
  15787. * @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)
  15788. * @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)
  15789. * @param engine is the instance of BABYLON.Engine to use to create the scene
  15790. * @param onProgress a callback with a progress event for each file being loaded
  15791. * @param pluginExtension the extension used to determine the plugin
  15792. * @returns The loaded scene
  15793. */
  15794. static LoadAsync(rootUrl: string, sceneFilename: string, engine: Engine, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  15795. /**
  15796. * Append a scene
  15797. * @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)
  15798. * @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)
  15799. * @param scene is the instance of BABYLON.Scene to append to
  15800. * @param onSuccess a callback with the scene when import succeeds
  15801. * @param onProgress a callback with a progress event for each file being loaded
  15802. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  15803. * @param pluginExtension the extension used to determine the plugin
  15804. * @returns The loaded plugin
  15805. */
  15806. 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>;
  15807. /**
  15808. * Append a scene
  15809. * @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)
  15810. * @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)
  15811. * @param scene is the instance of BABYLON.Scene to append to
  15812. * @param onProgress a callback with a progress event for each file being loaded
  15813. * @param pluginExtension the extension used to determine the plugin
  15814. * @returns The given scene
  15815. */
  15816. static AppendAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  15817. /**
  15818. * Load a scene into an asset container
  15819. * @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)
  15820. * @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)
  15821. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  15822. * @param onSuccess a callback with the scene when import succeeds
  15823. * @param onProgress a callback with a progress event for each file being loaded
  15824. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  15825. * @param pluginExtension the extension used to determine the plugin
  15826. * @returns The loaded plugin
  15827. */
  15828. 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>;
  15829. /**
  15830. * Load a scene into an asset container
  15831. * @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)
  15832. * @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)
  15833. * @param scene is the instance of BABYLON.Scene to append to
  15834. * @param onProgress a callback with a progress event for each file being loaded
  15835. * @param pluginExtension the extension used to determine the plugin
  15836. * @returns The loaded asset container
  15837. */
  15838. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  15839. }
  15840. }
  15841. declare module BABYLON {
  15842. /**
  15843. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  15844. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  15845. * 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;
  15846. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  15847. */
  15848. class ColorCurves {
  15849. private _dirty;
  15850. private _tempColor;
  15851. private _globalCurve;
  15852. private _highlightsCurve;
  15853. private _midtonesCurve;
  15854. private _shadowsCurve;
  15855. private _positiveCurve;
  15856. private _negativeCurve;
  15857. private _globalHue;
  15858. private _globalDensity;
  15859. private _globalSaturation;
  15860. private _globalExposure;
  15861. /**
  15862. * Gets the global Hue value.
  15863. * 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).
  15864. */
  15865. /**
  15866. * Sets the global Hue value.
  15867. * 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).
  15868. */
  15869. globalHue: number;
  15870. /**
  15871. * Gets the global Density value.
  15872. * 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.
  15873. * Values less than zero provide a filter of opposite hue.
  15874. */
  15875. /**
  15876. * Sets the global Density value.
  15877. * 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.
  15878. * Values less than zero provide a filter of opposite hue.
  15879. */
  15880. globalDensity: number;
  15881. /**
  15882. * Gets the global Saturation value.
  15883. * 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.
  15884. */
  15885. /**
  15886. * Sets the global Saturation value.
  15887. * 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.
  15888. */
  15889. globalSaturation: number;
  15890. /**
  15891. * Gets the global Exposure value.
  15892. * 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.
  15893. */
  15894. /**
  15895. * Sets the global Exposure value.
  15896. * 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.
  15897. */
  15898. globalExposure: number;
  15899. private _highlightsHue;
  15900. private _highlightsDensity;
  15901. private _highlightsSaturation;
  15902. private _highlightsExposure;
  15903. /**
  15904. * Gets the highlights Hue value.
  15905. * 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).
  15906. */
  15907. /**
  15908. * Sets the highlights Hue value.
  15909. * 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).
  15910. */
  15911. highlightsHue: number;
  15912. /**
  15913. * Gets the highlights Density value.
  15914. * 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.
  15915. * Values less than zero provide a filter of opposite hue.
  15916. */
  15917. /**
  15918. * Sets the highlights Density value.
  15919. * 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.
  15920. * Values less than zero provide a filter of opposite hue.
  15921. */
  15922. highlightsDensity: number;
  15923. /**
  15924. * Gets the highlights Saturation value.
  15925. * 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.
  15926. */
  15927. /**
  15928. * Sets the highlights Saturation value.
  15929. * 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.
  15930. */
  15931. highlightsSaturation: number;
  15932. /**
  15933. * Gets the highlights Exposure value.
  15934. * 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.
  15935. */
  15936. /**
  15937. * Sets the highlights Exposure value.
  15938. * 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.
  15939. */
  15940. highlightsExposure: number;
  15941. private _midtonesHue;
  15942. private _midtonesDensity;
  15943. private _midtonesSaturation;
  15944. private _midtonesExposure;
  15945. /**
  15946. * Gets the midtones Hue value.
  15947. * 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).
  15948. */
  15949. /**
  15950. * Sets the midtones Hue value.
  15951. * 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).
  15952. */
  15953. midtonesHue: number;
  15954. /**
  15955. * Gets the midtones Density value.
  15956. * 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.
  15957. * Values less than zero provide a filter of opposite hue.
  15958. */
  15959. /**
  15960. * Sets the midtones Density value.
  15961. * 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.
  15962. * Values less than zero provide a filter of opposite hue.
  15963. */
  15964. midtonesDensity: number;
  15965. /**
  15966. * Gets the midtones Saturation value.
  15967. * 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.
  15968. */
  15969. /**
  15970. * Sets the midtones Saturation value.
  15971. * 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.
  15972. */
  15973. midtonesSaturation: number;
  15974. /**
  15975. * Gets the midtones Exposure value.
  15976. * 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.
  15977. */
  15978. /**
  15979. * Sets the midtones Exposure value.
  15980. * 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.
  15981. */
  15982. midtonesExposure: number;
  15983. private _shadowsHue;
  15984. private _shadowsDensity;
  15985. private _shadowsSaturation;
  15986. private _shadowsExposure;
  15987. /**
  15988. * Gets the shadows Hue value.
  15989. * 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).
  15990. */
  15991. /**
  15992. * Sets the shadows Hue value.
  15993. * 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).
  15994. */
  15995. shadowsHue: number;
  15996. /**
  15997. * Gets the shadows Density value.
  15998. * 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.
  15999. * Values less than zero provide a filter of opposite hue.
  16000. */
  16001. /**
  16002. * Sets the shadows Density value.
  16003. * 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.
  16004. * Values less than zero provide a filter of opposite hue.
  16005. */
  16006. shadowsDensity: number;
  16007. /**
  16008. * Gets the shadows Saturation value.
  16009. * 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.
  16010. */
  16011. /**
  16012. * Sets the shadows Saturation value.
  16013. * 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.
  16014. */
  16015. shadowsSaturation: number;
  16016. /**
  16017. * Gets the shadows Exposure value.
  16018. * 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.
  16019. */
  16020. /**
  16021. * Sets the shadows Exposure value.
  16022. * 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.
  16023. */
  16024. shadowsExposure: number;
  16025. /**
  16026. * Returns the class name
  16027. * @returns The class name
  16028. */
  16029. getClassName(): string;
  16030. /**
  16031. * Binds the color curves to the shader.
  16032. * @param colorCurves The color curve to bind
  16033. * @param effect The effect to bind to
  16034. * @param positiveUniform The positive uniform shader parameter
  16035. * @param neutralUniform The neutral uniform shader parameter
  16036. * @param negativeUniform The negative uniform shader parameter
  16037. */
  16038. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  16039. /**
  16040. * Prepare the list of uniforms associated with the ColorCurves effects.
  16041. * @param uniformsList The list of uniforms used in the effect
  16042. */
  16043. static PrepareUniforms(uniformsList: string[]): void;
  16044. /**
  16045. * Returns color grading data based on a hue, density, saturation and exposure value.
  16046. * @param filterHue The hue of the color filter.
  16047. * @param filterDensity The density of the color filter.
  16048. * @param saturation The saturation.
  16049. * @param exposure The exposure.
  16050. * @param result The result data container.
  16051. */
  16052. private getColorGradingDataToRef;
  16053. /**
  16054. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  16055. * @param value The input slider value in range [-100,100].
  16056. * @returns Adjusted value.
  16057. */
  16058. private static applyColorGradingSliderNonlinear;
  16059. /**
  16060. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  16061. * @param hue The hue (H) input.
  16062. * @param saturation The saturation (S) input.
  16063. * @param brightness The brightness (B) input.
  16064. * @result An RGBA color represented as Vector4.
  16065. */
  16066. private static fromHSBToRef;
  16067. /**
  16068. * Returns a value clamped between min and max
  16069. * @param value The value to clamp
  16070. * @param min The minimum of value
  16071. * @param max The maximum of value
  16072. * @returns The clamped value.
  16073. */
  16074. private static clamp;
  16075. /**
  16076. * Clones the current color curve instance.
  16077. * @return The cloned curves
  16078. */
  16079. clone(): ColorCurves;
  16080. /**
  16081. * Serializes the current color curve instance to a json representation.
  16082. * @return a JSON representation
  16083. */
  16084. serialize(): any;
  16085. /**
  16086. * Parses the color curve from a json representation.
  16087. * @param source the JSON source to parse
  16088. * @return The parsed curves
  16089. */
  16090. static Parse(source: any): ColorCurves;
  16091. }
  16092. }
  16093. declare module BABYLON {
  16094. /**
  16095. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  16096. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  16097. */
  16098. class EffectFallbacks {
  16099. private _defines;
  16100. private _currentRank;
  16101. private _maxRank;
  16102. private _mesh;
  16103. /**
  16104. * Removes the fallback from the bound mesh.
  16105. */
  16106. unBindMesh(): void;
  16107. /**
  16108. * Adds a fallback on the specified property.
  16109. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  16110. * @param define The name of the define in the shader
  16111. */
  16112. addFallback(rank: number, define: string): void;
  16113. /**
  16114. * Sets the mesh to use CPU skinning when needing to fallback.
  16115. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  16116. * @param mesh The mesh to use the fallbacks.
  16117. */
  16118. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  16119. /**
  16120. * Checks to see if more fallbacks are still availible.
  16121. */
  16122. readonly isMoreFallbacks: boolean;
  16123. /**
  16124. * Removes the defines that shoould be removed when falling back.
  16125. * @param currentDefines defines the current define statements for the shader.
  16126. * @param effect defines the current effect we try to compile
  16127. * @returns The resulting defines with defines of the current rank removed.
  16128. */
  16129. reduce(currentDefines: string, effect: Effect): string;
  16130. }
  16131. /**
  16132. * Options to be used when creating an effect.
  16133. */
  16134. class EffectCreationOptions {
  16135. /**
  16136. * Atrributes that will be used in the shader.
  16137. */
  16138. attributes: string[];
  16139. /**
  16140. * Uniform varible names that will be set in the shader.
  16141. */
  16142. uniformsNames: string[];
  16143. /**
  16144. * Uniform buffer varible names that will be set in the shader.
  16145. */
  16146. uniformBuffersNames: string[];
  16147. /**
  16148. * Sampler texture variable names that will be set in the shader.
  16149. */
  16150. samplers: string[];
  16151. /**
  16152. * Define statements that will be set in the shader.
  16153. */
  16154. defines: any;
  16155. /**
  16156. * Possible fallbacks for this effect to improve performance when needed.
  16157. */
  16158. fallbacks: Nullable<EffectFallbacks>;
  16159. /**
  16160. * Callback that will be called when the shader is compiled.
  16161. */
  16162. onCompiled: Nullable<(effect: Effect) => void>;
  16163. /**
  16164. * Callback that will be called if an error occurs during shader compilation.
  16165. */
  16166. onError: Nullable<(effect: Effect, errors: string) => void>;
  16167. /**
  16168. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  16169. */
  16170. indexParameters: any;
  16171. /**
  16172. * Max number of lights that can be used in the shader.
  16173. */
  16174. maxSimultaneousLights: number;
  16175. /**
  16176. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  16177. */
  16178. transformFeedbackVaryings: Nullable<string[]>;
  16179. }
  16180. /**
  16181. * Effect containing vertex and fragment shader that can be executed on an object.
  16182. */
  16183. class Effect {
  16184. /**
  16185. * Name of the effect.
  16186. */
  16187. name: any;
  16188. /**
  16189. * String container all the define statements that should be set on the shader.
  16190. */
  16191. defines: string;
  16192. /**
  16193. * Callback that will be called when the shader is compiled.
  16194. */
  16195. onCompiled: Nullable<(effect: Effect) => void>;
  16196. /**
  16197. * Callback that will be called if an error occurs during shader compilation.
  16198. */
  16199. onError: Nullable<(effect: Effect, errors: string) => void>;
  16200. /**
  16201. * Callback that will be called when effect is bound.
  16202. */
  16203. onBind: Nullable<(effect: Effect) => void>;
  16204. /**
  16205. * Unique ID of the effect.
  16206. */
  16207. uniqueId: number;
  16208. /**
  16209. * Observable that will be called when the shader is compiled.
  16210. */
  16211. onCompileObservable: Observable<Effect>;
  16212. /**
  16213. * Observable that will be called if an error occurs during shader compilation.
  16214. */
  16215. onErrorObservable: Observable<Effect>;
  16216. /** @hidden */
  16217. /**
  16218. * Observable that will be called when effect is bound.
  16219. */
  16220. readonly onBindObservable: Observable<Effect>;
  16221. /** @hidden */
  16222. private static _uniqueIdSeed;
  16223. private _engine;
  16224. private _uniformBuffersNames;
  16225. private _uniformsNames;
  16226. private _samplers;
  16227. private _isReady;
  16228. private _compilationError;
  16229. private _attributesNames;
  16230. private _attributes;
  16231. private _uniforms;
  16232. /**
  16233. * Key for the effect.
  16234. * @hidden
  16235. */
  16236. private _indexParameters;
  16237. private _fallbacks;
  16238. private _vertexSourceCode;
  16239. private _fragmentSourceCode;
  16240. private _vertexSourceCodeOverride;
  16241. private _fragmentSourceCodeOverride;
  16242. private _transformFeedbackVaryings;
  16243. /**
  16244. * Compiled shader to webGL program.
  16245. * @hidden
  16246. */
  16247. private _valueCache;
  16248. private static _baseCache;
  16249. /**
  16250. * Instantiates an effect.
  16251. * An effect can be used to create/manage/execute vertex and fragment shaders.
  16252. * @param baseName Name of the effect.
  16253. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  16254. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  16255. * @param samplers List of sampler variables that will be passed to the shader.
  16256. * @param engine Engine to be used to render the effect
  16257. * @param defines Define statements to be added to the shader.
  16258. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  16259. * @param onCompiled Callback that will be called when the shader is compiled.
  16260. * @param onError Callback that will be called if an error occurs during shader compilation.
  16261. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  16262. */
  16263. 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);
  16264. /**
  16265. * Unique key for this effect
  16266. */
  16267. readonly key: string;
  16268. /**
  16269. * If the effect has been compiled and prepared.
  16270. * @returns if the effect is compiled and prepared.
  16271. */
  16272. isReady(): boolean;
  16273. /**
  16274. * The engine the effect was initialized with.
  16275. * @returns the engine.
  16276. */
  16277. getEngine(): Engine;
  16278. /**
  16279. * The compiled webGL program for the effect
  16280. * @returns the webGL program.
  16281. */
  16282. getProgram(): WebGLProgram;
  16283. /**
  16284. * The set of names of attribute variables for the shader.
  16285. * @returns An array of attribute names.
  16286. */
  16287. getAttributesNames(): string[];
  16288. /**
  16289. * Returns the attribute at the given index.
  16290. * @param index The index of the attribute.
  16291. * @returns The location of the attribute.
  16292. */
  16293. getAttributeLocation(index: number): number;
  16294. /**
  16295. * Returns the attribute based on the name of the variable.
  16296. * @param name of the attribute to look up.
  16297. * @returns the attribute location.
  16298. */
  16299. getAttributeLocationByName(name: string): number;
  16300. /**
  16301. * The number of attributes.
  16302. * @returns the numnber of attributes.
  16303. */
  16304. getAttributesCount(): number;
  16305. /**
  16306. * Gets the index of a uniform variable.
  16307. * @param uniformName of the uniform to look up.
  16308. * @returns the index.
  16309. */
  16310. getUniformIndex(uniformName: string): number;
  16311. /**
  16312. * Returns the attribute based on the name of the variable.
  16313. * @param uniformName of the uniform to look up.
  16314. * @returns the location of the uniform.
  16315. */
  16316. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  16317. /**
  16318. * Returns an array of sampler variable names
  16319. * @returns The array of sampler variable neames.
  16320. */
  16321. getSamplers(): string[];
  16322. /**
  16323. * The error from the last compilation.
  16324. * @returns the error string.
  16325. */
  16326. getCompilationError(): string;
  16327. /**
  16328. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  16329. * @param func The callback to be used.
  16330. */
  16331. executeWhenCompiled(func: (effect: Effect) => void): void;
  16332. /** @hidden */
  16333. /** @hidden */
  16334. /** @hidden */
  16335. private _processShaderConversion;
  16336. private _processIncludes;
  16337. private _processPrecision;
  16338. /**
  16339. * Recompiles the webGL program
  16340. * @param vertexSourceCode The source code for the vertex shader.
  16341. * @param fragmentSourceCode The source code for the fragment shader.
  16342. * @param onCompiled Callback called when completed.
  16343. * @param onError Callback called on error.
  16344. * @hidden
  16345. */
  16346. /**
  16347. * Gets the uniform locations of the the specified variable names
  16348. * @param names THe names of the variables to lookup.
  16349. * @returns Array of locations in the same order as variable names.
  16350. */
  16351. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  16352. /**
  16353. * Prepares the effect
  16354. * @hidden
  16355. */
  16356. /**
  16357. * Checks if the effect is supported. (Must be called after compilation)
  16358. */
  16359. readonly isSupported: boolean;
  16360. /**
  16361. * Binds a texture to the engine to be used as output of the shader.
  16362. * @param channel Name of the output variable.
  16363. * @param texture Texture to bind.
  16364. * @hidden
  16365. */
  16366. /**
  16367. * Sets a texture on the engine to be used in the shader.
  16368. * @param channel Name of the sampler variable.
  16369. * @param texture Texture to set.
  16370. */
  16371. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  16372. /**
  16373. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  16374. * @param channel Name of the sampler variable.
  16375. * @param texture Texture to set.
  16376. */
  16377. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  16378. /**
  16379. * Sets an array of textures on the engine to be used in the shader.
  16380. * @param channel Name of the variable.
  16381. * @param textures Textures to set.
  16382. */
  16383. setTextureArray(channel: string, textures: BaseTexture[]): void;
  16384. /**
  16385. * 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)
  16386. * @param channel Name of the sampler variable.
  16387. * @param postProcess Post process to get the input texture from.
  16388. */
  16389. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  16390. /**
  16391. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  16392. * 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)
  16393. * @param channel Name of the sampler variable.
  16394. * @param postProcess Post process to get the output texture from.
  16395. */
  16396. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  16397. /** @hidden */
  16398. /** @hidden */
  16399. /** @hidden */
  16400. /** @hidden */
  16401. /**
  16402. * Binds a buffer to a uniform.
  16403. * @param buffer Buffer to bind.
  16404. * @param name Name of the uniform variable to bind to.
  16405. */
  16406. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  16407. /**
  16408. * Binds block to a uniform.
  16409. * @param blockName Name of the block to bind.
  16410. * @param index Index to bind.
  16411. */
  16412. bindUniformBlock(blockName: string, index: number): void;
  16413. /**
  16414. * Sets an interger value on a uniform variable.
  16415. * @param uniformName Name of the variable.
  16416. * @param value Value to be set.
  16417. * @returns this effect.
  16418. */
  16419. setInt(uniformName: string, value: number): Effect;
  16420. /**
  16421. * Sets an int array on a uniform variable.
  16422. * @param uniformName Name of the variable.
  16423. * @param array array to be set.
  16424. * @returns this effect.
  16425. */
  16426. setIntArray(uniformName: string, array: Int32Array): Effect;
  16427. /**
  16428. * 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)
  16429. * @param uniformName Name of the variable.
  16430. * @param array array to be set.
  16431. * @returns this effect.
  16432. */
  16433. setIntArray2(uniformName: string, array: Int32Array): Effect;
  16434. /**
  16435. * 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)
  16436. * @param uniformName Name of the variable.
  16437. * @param array array to be set.
  16438. * @returns this effect.
  16439. */
  16440. setIntArray3(uniformName: string, array: Int32Array): Effect;
  16441. /**
  16442. * 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)
  16443. * @param uniformName Name of the variable.
  16444. * @param array array to be set.
  16445. * @returns this effect.
  16446. */
  16447. setIntArray4(uniformName: string, array: Int32Array): Effect;
  16448. /**
  16449. * Sets an float array on a uniform variable.
  16450. * @param uniformName Name of the variable.
  16451. * @param array array to be set.
  16452. * @returns this effect.
  16453. */
  16454. setFloatArray(uniformName: string, array: Float32Array): Effect;
  16455. /**
  16456. * 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)
  16457. * @param uniformName Name of the variable.
  16458. * @param array array to be set.
  16459. * @returns this effect.
  16460. */
  16461. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  16462. /**
  16463. * 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)
  16464. * @param uniformName Name of the variable.
  16465. * @param array array to be set.
  16466. * @returns this effect.
  16467. */
  16468. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  16469. /**
  16470. * 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)
  16471. * @param uniformName Name of the variable.
  16472. * @param array array to be set.
  16473. * @returns this effect.
  16474. */
  16475. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  16476. /**
  16477. * Sets an array on a uniform variable.
  16478. * @param uniformName Name of the variable.
  16479. * @param array array to be set.
  16480. * @returns this effect.
  16481. */
  16482. setArray(uniformName: string, array: number[]): Effect;
  16483. /**
  16484. * 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)
  16485. * @param uniformName Name of the variable.
  16486. * @param array array to be set.
  16487. * @returns this effect.
  16488. */
  16489. setArray2(uniformName: string, array: number[]): Effect;
  16490. /**
  16491. * 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)
  16492. * @param uniformName Name of the variable.
  16493. * @param array array to be set.
  16494. * @returns this effect.
  16495. */
  16496. setArray3(uniformName: string, array: number[]): Effect;
  16497. /**
  16498. * 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)
  16499. * @param uniformName Name of the variable.
  16500. * @param array array to be set.
  16501. * @returns this effect.
  16502. */
  16503. setArray4(uniformName: string, array: number[]): Effect;
  16504. /**
  16505. * Sets matrices on a uniform variable.
  16506. * @param uniformName Name of the variable.
  16507. * @param matrices matrices to be set.
  16508. * @returns this effect.
  16509. */
  16510. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  16511. /**
  16512. * Sets matrix on a uniform variable.
  16513. * @param uniformName Name of the variable.
  16514. * @param matrix matrix to be set.
  16515. * @returns this effect.
  16516. */
  16517. setMatrix(uniformName: string, matrix: Matrix): Effect;
  16518. /**
  16519. * 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)
  16520. * @param uniformName Name of the variable.
  16521. * @param matrix matrix to be set.
  16522. * @returns this effect.
  16523. */
  16524. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  16525. /**
  16526. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  16527. * @param uniformName Name of the variable.
  16528. * @param matrix matrix to be set.
  16529. * @returns this effect.
  16530. */
  16531. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  16532. /**
  16533. * Sets a float on a uniform variable.
  16534. * @param uniformName Name of the variable.
  16535. * @param value value to be set.
  16536. * @returns this effect.
  16537. */
  16538. setFloat(uniformName: string, value: number): Effect;
  16539. /**
  16540. * Sets a boolean on a uniform variable.
  16541. * @param uniformName Name of the variable.
  16542. * @param bool value to be set.
  16543. * @returns this effect.
  16544. */
  16545. setBool(uniformName: string, bool: boolean): Effect;
  16546. /**
  16547. * Sets a Vector2 on a uniform variable.
  16548. * @param uniformName Name of the variable.
  16549. * @param vector2 vector2 to be set.
  16550. * @returns this effect.
  16551. */
  16552. setVector2(uniformName: string, vector2: Vector2): Effect;
  16553. /**
  16554. * Sets a float2 on a uniform variable.
  16555. * @param uniformName Name of the variable.
  16556. * @param x First float in float2.
  16557. * @param y Second float in float2.
  16558. * @returns this effect.
  16559. */
  16560. setFloat2(uniformName: string, x: number, y: number): Effect;
  16561. /**
  16562. * Sets a Vector3 on a uniform variable.
  16563. * @param uniformName Name of the variable.
  16564. * @param vector3 Value to be set.
  16565. * @returns this effect.
  16566. */
  16567. setVector3(uniformName: string, vector3: Vector3): Effect;
  16568. /**
  16569. * Sets a float3 on a uniform variable.
  16570. * @param uniformName Name of the variable.
  16571. * @param x First float in float3.
  16572. * @param y Second float in float3.
  16573. * @param z Third float in float3.
  16574. * @returns this effect.
  16575. */
  16576. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  16577. /**
  16578. * Sets a Vector4 on a uniform variable.
  16579. * @param uniformName Name of the variable.
  16580. * @param vector4 Value to be set.
  16581. * @returns this effect.
  16582. */
  16583. setVector4(uniformName: string, vector4: Vector4): Effect;
  16584. /**
  16585. * Sets a float4 on a uniform variable.
  16586. * @param uniformName Name of the variable.
  16587. * @param x First float in float4.
  16588. * @param y Second float in float4.
  16589. * @param z Third float in float4.
  16590. * @param w Fourth float in float4.
  16591. * @returns this effect.
  16592. */
  16593. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  16594. /**
  16595. * Sets a Color3 on a uniform variable.
  16596. * @param uniformName Name of the variable.
  16597. * @param color3 Value to be set.
  16598. * @returns this effect.
  16599. */
  16600. setColor3(uniformName: string, color3: Color3): Effect;
  16601. /**
  16602. * Sets a Color4 on a uniform variable.
  16603. * @param uniformName Name of the variable.
  16604. * @param color3 Value to be set.
  16605. * @param alpha Alpha value to be set.
  16606. * @returns this effect.
  16607. */
  16608. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  16609. /**
  16610. * Sets a Color4 on a uniform variable
  16611. * @param uniformName defines the name of the variable
  16612. * @param color4 defines the value to be set
  16613. * @returns this effect.
  16614. */
  16615. setDirectColor4(uniformName: string, color4: Color4): Effect;
  16616. /**
  16617. * This function will add a new shader to the shader store
  16618. * @param name the name of the shader
  16619. * @param pixelShader optional pixel shader content
  16620. * @param vertexShader optional vertex shader content
  16621. */
  16622. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  16623. /**
  16624. * Store of each shader (The can be looked up using effect.key)
  16625. */
  16626. static ShadersStore: {
  16627. [key: string]: string;
  16628. };
  16629. /**
  16630. * Store of each included file for a shader (The can be looked up using effect.key)
  16631. */
  16632. static IncludesShadersStore: {
  16633. [key: string]: string;
  16634. };
  16635. /**
  16636. * Resets the cache of effects.
  16637. */
  16638. static ResetCache(): void;
  16639. }
  16640. }
  16641. declare module BABYLON {
  16642. /**
  16643. * This represents all the required information to add a fresnel effect on a material:
  16644. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  16645. */
  16646. class FresnelParameters {
  16647. private _isEnabled;
  16648. /**
  16649. * Define if the fresnel effect is enable or not.
  16650. */
  16651. isEnabled: boolean;
  16652. /**
  16653. * Define the color used on edges (grazing angle)
  16654. */
  16655. leftColor: Color3;
  16656. /**
  16657. * Define the color used on center
  16658. */
  16659. rightColor: Color3;
  16660. /**
  16661. * Define bias applied to computed fresnel term
  16662. */
  16663. bias: number;
  16664. /**
  16665. * Defined the power exponent applied to fresnel term
  16666. */
  16667. power: number;
  16668. /**
  16669. * Clones the current fresnel and its valuues
  16670. * @returns a clone fresnel configuration
  16671. */
  16672. clone(): FresnelParameters;
  16673. /**
  16674. * Serializes the current fresnel parameters to a JSON representation.
  16675. * @return the JSON serialization
  16676. */
  16677. serialize(): any;
  16678. /**
  16679. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  16680. * @param parsedFresnelParameters Define the JSON representation
  16681. * @returns the parsed parameters
  16682. */
  16683. static Parse(parsedFresnelParameters: any): FresnelParameters;
  16684. }
  16685. }
  16686. declare module BABYLON {
  16687. /**
  16688. * Interface to follow in your material defines to integrate easily the
  16689. * Image proccessing functions.
  16690. * @hidden
  16691. */
  16692. interface IImageProcessingConfigurationDefines {
  16693. IMAGEPROCESSING: boolean;
  16694. VIGNETTE: boolean;
  16695. VIGNETTEBLENDMODEMULTIPLY: boolean;
  16696. VIGNETTEBLENDMODEOPAQUE: boolean;
  16697. TONEMAPPING: boolean;
  16698. TONEMAPPING_ACES: boolean;
  16699. CONTRAST: boolean;
  16700. EXPOSURE: boolean;
  16701. COLORCURVES: boolean;
  16702. COLORGRADING: boolean;
  16703. COLORGRADING3D: boolean;
  16704. SAMPLER3DGREENDEPTH: boolean;
  16705. SAMPLER3DBGRMAP: boolean;
  16706. IMAGEPROCESSINGPOSTPROCESS: boolean;
  16707. }
  16708. /**
  16709. * @hidden
  16710. */
  16711. class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  16712. IMAGEPROCESSING: boolean;
  16713. VIGNETTE: boolean;
  16714. VIGNETTEBLENDMODEMULTIPLY: boolean;
  16715. VIGNETTEBLENDMODEOPAQUE: boolean;
  16716. TONEMAPPING: boolean;
  16717. TONEMAPPING_ACES: boolean;
  16718. CONTRAST: boolean;
  16719. COLORCURVES: boolean;
  16720. COLORGRADING: boolean;
  16721. COLORGRADING3D: boolean;
  16722. SAMPLER3DGREENDEPTH: boolean;
  16723. SAMPLER3DBGRMAP: boolean;
  16724. IMAGEPROCESSINGPOSTPROCESS: boolean;
  16725. EXPOSURE: boolean;
  16726. constructor();
  16727. }
  16728. /**
  16729. * This groups together the common properties used for image processing either in direct forward pass
  16730. * or through post processing effect depending on the use of the image processing pipeline in your scene
  16731. * or not.
  16732. */
  16733. class ImageProcessingConfiguration {
  16734. /**
  16735. * Default tone mapping applied in BabylonJS.
  16736. */
  16737. static readonly TONEMAPPING_STANDARD: number;
  16738. /**
  16739. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  16740. * to other engines rendering to increase portability.
  16741. */
  16742. static readonly TONEMAPPING_ACES: number;
  16743. /**
  16744. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  16745. */
  16746. colorCurves: Nullable<ColorCurves>;
  16747. private _colorCurvesEnabled;
  16748. /**
  16749. * Gets wether the color curves effect is enabled.
  16750. */
  16751. /**
  16752. * Sets wether the color curves effect is enabled.
  16753. */
  16754. colorCurvesEnabled: boolean;
  16755. private _colorGradingTexture;
  16756. /**
  16757. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  16758. */
  16759. /**
  16760. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  16761. */
  16762. colorGradingTexture: Nullable<BaseTexture>;
  16763. private _colorGradingEnabled;
  16764. /**
  16765. * Gets wether the color grading effect is enabled.
  16766. */
  16767. /**
  16768. * Sets wether the color grading effect is enabled.
  16769. */
  16770. colorGradingEnabled: boolean;
  16771. private _colorGradingWithGreenDepth;
  16772. /**
  16773. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  16774. */
  16775. /**
  16776. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  16777. */
  16778. colorGradingWithGreenDepth: boolean;
  16779. private _colorGradingBGR;
  16780. /**
  16781. * Gets wether the color grading texture contains BGR values.
  16782. */
  16783. /**
  16784. * Sets wether the color grading texture contains BGR values.
  16785. */
  16786. colorGradingBGR: boolean;
  16787. /** @hidden */
  16788. /**
  16789. * Gets the Exposure used in the effect.
  16790. */
  16791. /**
  16792. * Sets the Exposure used in the effect.
  16793. */
  16794. exposure: number;
  16795. private _toneMappingEnabled;
  16796. /**
  16797. * Gets wether the tone mapping effect is enabled.
  16798. */
  16799. /**
  16800. * Sets wether the tone mapping effect is enabled.
  16801. */
  16802. toneMappingEnabled: boolean;
  16803. private _toneMappingType;
  16804. /**
  16805. * Gets the type of tone mapping effect.
  16806. */
  16807. /**
  16808. * Sets the type of tone mapping effect used in BabylonJS.
  16809. */
  16810. toneMappingType: number;
  16811. protected _contrast: number;
  16812. /**
  16813. * Gets the contrast used in the effect.
  16814. */
  16815. /**
  16816. * Sets the contrast used in the effect.
  16817. */
  16818. contrast: number;
  16819. /**
  16820. * Vignette stretch size.
  16821. */
  16822. vignetteStretch: number;
  16823. /**
  16824. * Vignette centre X Offset.
  16825. */
  16826. vignetteCentreX: number;
  16827. /**
  16828. * Vignette centre Y Offset.
  16829. */
  16830. vignetteCentreY: number;
  16831. /**
  16832. * Vignette weight or intensity of the vignette effect.
  16833. */
  16834. vignetteWeight: number;
  16835. /**
  16836. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  16837. * if vignetteEnabled is set to true.
  16838. */
  16839. vignetteColor: Color4;
  16840. /**
  16841. * Camera field of view used by the Vignette effect.
  16842. */
  16843. vignetteCameraFov: number;
  16844. private _vignetteBlendMode;
  16845. /**
  16846. * Gets the vignette blend mode allowing different kind of effect.
  16847. */
  16848. /**
  16849. * Sets the vignette blend mode allowing different kind of effect.
  16850. */
  16851. vignetteBlendMode: number;
  16852. private _vignetteEnabled;
  16853. /**
  16854. * Gets wether the vignette effect is enabled.
  16855. */
  16856. /**
  16857. * Sets wether the vignette effect is enabled.
  16858. */
  16859. vignetteEnabled: boolean;
  16860. private _applyByPostProcess;
  16861. /**
  16862. * Gets wether the image processing is applied through a post process or not.
  16863. */
  16864. /**
  16865. * Sets wether the image processing is applied through a post process or not.
  16866. */
  16867. applyByPostProcess: boolean;
  16868. private _isEnabled;
  16869. /**
  16870. * Gets wether the image processing is enabled or not.
  16871. */
  16872. /**
  16873. * Sets wether the image processing is enabled or not.
  16874. */
  16875. isEnabled: boolean;
  16876. /**
  16877. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  16878. */
  16879. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  16880. /**
  16881. * Method called each time the image processing information changes requires to recompile the effect.
  16882. */
  16883. protected _updateParameters(): void;
  16884. /**
  16885. * Gets the current class name.
  16886. * @return "ImageProcessingConfiguration"
  16887. */
  16888. getClassName(): string;
  16889. /**
  16890. * Prepare the list of uniforms associated with the Image Processing effects.
  16891. * @param uniforms The list of uniforms used in the effect
  16892. * @param defines the list of defines currently in use
  16893. */
  16894. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  16895. /**
  16896. * Prepare the list of samplers associated with the Image Processing effects.
  16897. * @param samplersList The list of uniforms used in the effect
  16898. * @param defines the list of defines currently in use
  16899. */
  16900. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  16901. /**
  16902. * Prepare the list of defines associated to the shader.
  16903. * @param defines the list of defines to complete
  16904. * @param forPostProcess Define if we are currently in post process mode or not
  16905. */
  16906. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  16907. /**
  16908. * Returns true if all the image processing information are ready.
  16909. * @returns True if ready, otherwise, false
  16910. */
  16911. isReady(): boolean;
  16912. /**
  16913. * Binds the image processing to the shader.
  16914. * @param effect The effect to bind to
  16915. * @param aspectRatio Define the current aspect ratio of the effect
  16916. */
  16917. bind(effect: Effect, aspectRatio?: number): void;
  16918. /**
  16919. * Clones the current image processing instance.
  16920. * @return The cloned image processing
  16921. */
  16922. clone(): ImageProcessingConfiguration;
  16923. /**
  16924. * Serializes the current image processing instance to a json representation.
  16925. * @return a JSON representation
  16926. */
  16927. serialize(): any;
  16928. /**
  16929. * Parses the image processing from a json representation.
  16930. * @param source the JSON source to parse
  16931. * @return The parsed image processing
  16932. */
  16933. static Parse(source: any): ImageProcessingConfiguration;
  16934. private static _VIGNETTEMODE_MULTIPLY;
  16935. private static _VIGNETTEMODE_OPAQUE;
  16936. /**
  16937. * Used to apply the vignette as a mix with the pixel color.
  16938. */
  16939. static readonly VIGNETTEMODE_MULTIPLY: number;
  16940. /**
  16941. * Used to apply the vignette as a replacement of the pixel color.
  16942. */
  16943. static readonly VIGNETTEMODE_OPAQUE: number;
  16944. }
  16945. }
  16946. declare module BABYLON {
  16947. /**
  16948. * Manages the defines for the Material
  16949. */
  16950. class MaterialDefines {
  16951. private _keys;
  16952. private _isDirty;
  16953. /** @hidden */
  16954. /** @hidden */
  16955. /** @hidden */
  16956. /** @hidden */
  16957. /** @hidden */
  16958. /** @hidden */
  16959. /** @hidden */
  16960. /** @hidden */
  16961. /** @hidden */
  16962. /** @hidden */
  16963. /** @hidden */
  16964. /**
  16965. * Specifies if the material needs to be re-calculated
  16966. */
  16967. readonly isDirty: boolean;
  16968. /**
  16969. * Marks the material to indicate that it has been re-calculated
  16970. */
  16971. markAsProcessed(): void;
  16972. /**
  16973. * Marks the material to indicate that it needs to be re-calculated
  16974. */
  16975. markAsUnprocessed(): void;
  16976. /**
  16977. * Marks the material to indicate all of its defines need to be re-calculated
  16978. */
  16979. markAllAsDirty(): void;
  16980. /**
  16981. * Marks the material to indicate that image processing needs to be re-calculated
  16982. */
  16983. markAsImageProcessingDirty(): void;
  16984. /**
  16985. * Marks the material to indicate the lights need to be re-calculated
  16986. */
  16987. markAsLightDirty(): void;
  16988. /**
  16989. * Marks the attribute state as changed
  16990. */
  16991. markAsAttributesDirty(): void;
  16992. /**
  16993. * Marks the texture state as changed
  16994. */
  16995. markAsTexturesDirty(): void;
  16996. /**
  16997. * Marks the fresnel state as changed
  16998. */
  16999. markAsFresnelDirty(): void;
  17000. /**
  17001. * Marks the misc state as changed
  17002. */
  17003. markAsMiscDirty(): void;
  17004. /**
  17005. * Rebuilds the material defines
  17006. */
  17007. rebuild(): void;
  17008. /**
  17009. * Specifies if two material defines are equal
  17010. * @param other - A material define instance to compare to
  17011. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  17012. */
  17013. isEqual(other: MaterialDefines): boolean;
  17014. /**
  17015. * Clones this instance's defines to another instance
  17016. * @param other - material defines to clone values to
  17017. */
  17018. cloneTo(other: MaterialDefines): void;
  17019. /**
  17020. * Resets the material define values
  17021. */
  17022. reset(): void;
  17023. /**
  17024. * Converts the material define values to a string
  17025. * @returns - String of material define information
  17026. */
  17027. toString(): string;
  17028. }
  17029. /**
  17030. * Base class for the main features of a material in Babylon.js
  17031. */
  17032. class Material implements IAnimatable {
  17033. private static _TriangleFillMode;
  17034. private static _WireFrameFillMode;
  17035. private static _PointFillMode;
  17036. private static _PointListDrawMode;
  17037. private static _LineListDrawMode;
  17038. private static _LineLoopDrawMode;
  17039. private static _LineStripDrawMode;
  17040. private static _TriangleStripDrawMode;
  17041. private static _TriangleFanDrawMode;
  17042. /**
  17043. * Returns the triangle fill mode
  17044. */
  17045. static readonly TriangleFillMode: number;
  17046. /**
  17047. * Returns the wireframe mode
  17048. */
  17049. static readonly WireFrameFillMode: number;
  17050. /**
  17051. * Returns the point fill mode
  17052. */
  17053. static readonly PointFillMode: number;
  17054. /**
  17055. * Returns the point list draw mode
  17056. */
  17057. static readonly PointListDrawMode: number;
  17058. /**
  17059. * Returns the line list draw mode
  17060. */
  17061. static readonly LineListDrawMode: number;
  17062. /**
  17063. * Returns the line loop draw mode
  17064. */
  17065. static readonly LineLoopDrawMode: number;
  17066. /**
  17067. * Returns the line strip draw mode
  17068. */
  17069. static readonly LineStripDrawMode: number;
  17070. /**
  17071. * Returns the triangle strip draw mode
  17072. */
  17073. static readonly TriangleStripDrawMode: number;
  17074. /**
  17075. * Returns the triangle fan draw mode
  17076. */
  17077. static readonly TriangleFanDrawMode: number;
  17078. /**
  17079. * Stores the clock-wise side orientation
  17080. */
  17081. private static _ClockWiseSideOrientation;
  17082. /**
  17083. * Stores the counter clock-wise side orientation
  17084. */
  17085. private static _CounterClockWiseSideOrientation;
  17086. /**
  17087. * Returns the clock-wise side orientation
  17088. */
  17089. static readonly ClockWiseSideOrientation: number;
  17090. /**
  17091. * Returns the counter clock-wise side orientation
  17092. */
  17093. static readonly CounterClockWiseSideOrientation: number;
  17094. /**
  17095. * The dirty texture flag value
  17096. */
  17097. static readonly TextureDirtyFlag: number;
  17098. /**
  17099. * The dirty light flag value
  17100. */
  17101. static readonly LightDirtyFlag: number;
  17102. /**
  17103. * The dirty fresnel flag value
  17104. */
  17105. static readonly FresnelDirtyFlag: number;
  17106. /**
  17107. * The dirty attribute flag value
  17108. */
  17109. static readonly AttributesDirtyFlag: number;
  17110. /**
  17111. * The dirty misc flag value
  17112. */
  17113. static readonly MiscDirtyFlag: number;
  17114. /**
  17115. * The all dirty flag value
  17116. */
  17117. static readonly AllDirtyFlag: number;
  17118. /**
  17119. * The ID of the material
  17120. */
  17121. id: string;
  17122. /**
  17123. * Gets or sets the unique id of the material
  17124. */
  17125. uniqueId: number;
  17126. /**
  17127. * The name of the material
  17128. */
  17129. name: string;
  17130. /**
  17131. * Specifies if the ready state should be checked on each call
  17132. */
  17133. checkReadyOnEveryCall: boolean;
  17134. /**
  17135. * Specifies if the ready state should be checked once
  17136. */
  17137. checkReadyOnlyOnce: boolean;
  17138. /**
  17139. * The state of the material
  17140. */
  17141. state: string;
  17142. /**
  17143. * The alpha value of the material
  17144. */
  17145. protected _alpha: number;
  17146. /**
  17147. * Sets the alpha value of the material
  17148. */
  17149. /**
  17150. * Gets the alpha value of the material
  17151. */
  17152. alpha: number;
  17153. /**
  17154. * Specifies if back face culling is enabled
  17155. */
  17156. protected _backFaceCulling: boolean;
  17157. /**
  17158. * Sets the back-face culling state
  17159. */
  17160. /**
  17161. * Gets the back-face culling state
  17162. */
  17163. backFaceCulling: boolean;
  17164. /**
  17165. * Stores the value for side orientation
  17166. */
  17167. sideOrientation: number;
  17168. /**
  17169. * Callback triggered when the material is compiled
  17170. */
  17171. onCompiled: (effect: Effect) => void;
  17172. /**
  17173. * Callback triggered when an error occurs
  17174. */
  17175. onError: (effect: Effect, errors: string) => void;
  17176. /**
  17177. * Callback triggered to get the render target textures
  17178. */
  17179. getRenderTargetTextures: () => SmartArray<RenderTargetTexture>;
  17180. /**
  17181. * Gets a boolean indicating that current material needs to register RTT
  17182. */
  17183. readonly hasRenderTargetTextures: boolean;
  17184. /**
  17185. * Specifies if the material should be serialized
  17186. */
  17187. doNotSerialize: boolean;
  17188. /**
  17189. * Specifies if the effect should be stored on sub meshes
  17190. */
  17191. storeEffectOnSubMeshes: boolean;
  17192. /**
  17193. * Stores the animations for the material
  17194. */
  17195. animations: Array<Animation>;
  17196. /**
  17197. * An event triggered when the material is disposed
  17198. */
  17199. onDisposeObservable: Observable<Material>;
  17200. /**
  17201. * An observer which watches for dispose events
  17202. */
  17203. private _onDisposeObserver;
  17204. private _onUnBindObservable;
  17205. /**
  17206. * Called during a dispose event
  17207. */
  17208. onDispose: () => void;
  17209. private _onBindObservable;
  17210. /**
  17211. * An event triggered when the material is bound
  17212. */
  17213. readonly onBindObservable: Observable<AbstractMesh>;
  17214. /**
  17215. * An observer which watches for bind events
  17216. */
  17217. private _onBindObserver;
  17218. /**
  17219. * Called during a bind event
  17220. */
  17221. onBind: (Mesh: AbstractMesh) => void;
  17222. /**
  17223. * An event triggered when the material is unbound
  17224. */
  17225. readonly onUnBindObservable: Observable<Material>;
  17226. /**
  17227. * Stores the value of the alpha mode
  17228. */
  17229. private _alphaMode;
  17230. /**
  17231. * Sets the value of the alpha mode.
  17232. *
  17233. * | Value | Type | Description |
  17234. * | --- | --- | --- |
  17235. * | 0 | ALPHA_DISABLE | |
  17236. * | 1 | ALPHA_ADD | |
  17237. * | 2 | ALPHA_COMBINE | |
  17238. * | 3 | ALPHA_SUBTRACT | |
  17239. * | 4 | ALPHA_MULTIPLY | |
  17240. * | 5 | ALPHA_MAXIMIZED | |
  17241. * | 6 | ALPHA_ONEONE | |
  17242. * | 7 | ALPHA_PREMULTIPLIED | |
  17243. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  17244. * | 9 | ALPHA_INTERPOLATE | |
  17245. * | 10 | ALPHA_SCREENMODE | |
  17246. *
  17247. */
  17248. /**
  17249. * Gets the value of the alpha mode
  17250. */
  17251. alphaMode: number;
  17252. /**
  17253. * Stores the state of the need depth pre-pass value
  17254. */
  17255. private _needDepthPrePass;
  17256. /**
  17257. * Sets the need depth pre-pass value
  17258. */
  17259. /**
  17260. * Gets the depth pre-pass value
  17261. */
  17262. needDepthPrePass: boolean;
  17263. /**
  17264. * Specifies if depth writing should be disabled
  17265. */
  17266. disableDepthWrite: boolean;
  17267. /**
  17268. * Specifies if depth writing should be forced
  17269. */
  17270. forceDepthWrite: boolean;
  17271. /**
  17272. * Specifies if there should be a separate pass for culling
  17273. */
  17274. separateCullingPass: boolean;
  17275. /**
  17276. * Stores the state specifing if fog should be enabled
  17277. */
  17278. private _fogEnabled;
  17279. /**
  17280. * Sets the state for enabling fog
  17281. */
  17282. /**
  17283. * Gets the value of the fog enabled state
  17284. */
  17285. fogEnabled: boolean;
  17286. /**
  17287. * Stores the size of points
  17288. */
  17289. pointSize: number;
  17290. /**
  17291. * Stores the z offset value
  17292. */
  17293. zOffset: number;
  17294. /**
  17295. * Gets a value specifying if wireframe mode is enabled
  17296. */
  17297. /**
  17298. * Sets the state of wireframe mode
  17299. */
  17300. wireframe: boolean;
  17301. /**
  17302. * Gets the value specifying if point clouds are enabled
  17303. */
  17304. /**
  17305. * Sets the state of point cloud mode
  17306. */
  17307. pointsCloud: boolean;
  17308. /**
  17309. * Gets the material fill mode
  17310. */
  17311. /**
  17312. * Sets the material fill mode
  17313. */
  17314. fillMode: number;
  17315. /**
  17316. * @hidden
  17317. * Stores the effects for the material
  17318. */
  17319. /**
  17320. * @hidden
  17321. * Specifies if the material was previously ready
  17322. */
  17323. /**
  17324. * Specifies if uniform buffers should be used
  17325. */
  17326. private _useUBO;
  17327. /**
  17328. * Stores a reference to the scene
  17329. */
  17330. private _scene;
  17331. /**
  17332. * Stores the fill mode state
  17333. */
  17334. private _fillMode;
  17335. /**
  17336. * Specifies if the depth write state should be cached
  17337. */
  17338. private _cachedDepthWriteState;
  17339. /**
  17340. * Stores the uniform buffer
  17341. */
  17342. protected _uniformBuffer: UniformBuffer;
  17343. /**
  17344. * Creates a material instance
  17345. * @param name defines the name of the material
  17346. * @param scene defines the scene to reference
  17347. * @param doNotAdd specifies if the material should be added to the scene
  17348. */
  17349. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  17350. /**
  17351. * Returns a string representation of the current material
  17352. * @param fullDetails defines a boolean indicating which levels of logging is desired
  17353. * @returns a string with material information
  17354. */
  17355. toString(fullDetails?: boolean): string;
  17356. /**
  17357. * Gets the class name of the material
  17358. * @returns a string with the class name of the material
  17359. */
  17360. getClassName(): string;
  17361. /**
  17362. * Specifies if updates for the material been locked
  17363. */
  17364. readonly isFrozen: boolean;
  17365. /**
  17366. * Locks updates for the material
  17367. */
  17368. freeze(): void;
  17369. /**
  17370. * Unlocks updates for the material
  17371. */
  17372. unfreeze(): void;
  17373. /**
  17374. * Specifies if the material is ready to be used
  17375. * @param mesh defines the mesh to check
  17376. * @param useInstances specifies if instances should be used
  17377. * @returns a boolean indicating if the material is ready to be used
  17378. */
  17379. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  17380. /**
  17381. * Specifies that the submesh is ready to be used
  17382. * @param mesh defines the mesh to check
  17383. * @param subMesh defines which submesh to check
  17384. * @param useInstances specifies that instances should be used
  17385. * @returns a boolean indicating that the submesh is ready or not
  17386. */
  17387. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  17388. /**
  17389. * Returns the material effect
  17390. * @returns the effect associated with the material
  17391. */
  17392. getEffect(): Nullable<Effect>;
  17393. /**
  17394. * Returns the current scene
  17395. * @returns a Scene
  17396. */
  17397. getScene(): Scene;
  17398. /**
  17399. * Specifies if the material will require alpha blending
  17400. * @returns a boolean specifying if alpha blending is needed
  17401. */
  17402. needAlphaBlending(): boolean;
  17403. /**
  17404. * Specifies if the mesh will require alpha blending
  17405. * @param mesh defines the mesh to check
  17406. * @returns a boolean specifying if alpha blending is needed for the mesh
  17407. */
  17408. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  17409. /**
  17410. * Specifies if this material should be rendered in alpha test mode
  17411. * @returns a boolean specifying if an alpha test is needed.
  17412. */
  17413. needAlphaTesting(): boolean;
  17414. /**
  17415. * Gets the texture used for the alpha test
  17416. * @returns the texture to use for alpha testing
  17417. */
  17418. getAlphaTestTexture(): Nullable<BaseTexture>;
  17419. /**
  17420. * Marks the material to indicate that it needs to be re-calculated
  17421. */
  17422. markDirty(): void;
  17423. /** @hidden */
  17424. /**
  17425. * Binds the material to the mesh
  17426. * @param world defines the world transformation matrix
  17427. * @param mesh defines the mesh to bind the material to
  17428. */
  17429. bind(world: Matrix, mesh?: Mesh): void;
  17430. /**
  17431. * Binds the submesh to the material
  17432. * @param world defines the world transformation matrix
  17433. * @param mesh defines the mesh containing the submesh
  17434. * @param subMesh defines the submesh to bind the material to
  17435. */
  17436. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  17437. /**
  17438. * Binds the world matrix to the material
  17439. * @param world defines the world transformation matrix
  17440. */
  17441. bindOnlyWorldMatrix(world: Matrix): void;
  17442. /**
  17443. * Binds the scene's uniform buffer to the effect.
  17444. * @param effect defines the effect to bind to the scene uniform buffer
  17445. * @param sceneUbo defines the uniform buffer storing scene data
  17446. */
  17447. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  17448. /**
  17449. * Binds the view matrix to the effect
  17450. * @param effect defines the effect to bind the view matrix to
  17451. */
  17452. bindView(effect: Effect): void;
  17453. /**
  17454. * Binds the view projection matrix to the effect
  17455. * @param effect defines the effect to bind the view projection matrix to
  17456. */
  17457. bindViewProjection(effect: Effect): void;
  17458. /**
  17459. * Specifies if material alpha testing should be turned on for the mesh
  17460. * @param mesh defines the mesh to check
  17461. */
  17462. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  17463. /**
  17464. * Processes to execute after binding the material to a mesh
  17465. * @param mesh defines the rendered mesh
  17466. */
  17467. protected _afterBind(mesh?: Mesh): void;
  17468. /**
  17469. * Unbinds the material from the mesh
  17470. */
  17471. unbind(): void;
  17472. /**
  17473. * Gets the active textures from the material
  17474. * @returns an array of textures
  17475. */
  17476. getActiveTextures(): BaseTexture[];
  17477. /**
  17478. * Specifies if the material uses a texture
  17479. * @param texture defines the texture to check against the material
  17480. * @returns a boolean specifying if the material uses the texture
  17481. */
  17482. hasTexture(texture: BaseTexture): boolean;
  17483. /**
  17484. * Makes a duplicate of the material, and gives it a new name
  17485. * @param name defines the new name for the duplicated material
  17486. * @returns the cloned material
  17487. */
  17488. clone(name: string): Nullable<Material>;
  17489. /**
  17490. * Gets the meshes bound to the material
  17491. * @returns an array of meshes bound to the material
  17492. */
  17493. getBindedMeshes(): AbstractMesh[];
  17494. /**
  17495. * Force shader compilation
  17496. * @param mesh defines the mesh associated with this material
  17497. * @param onCompiled defines a function to execute once the material is compiled
  17498. * @param options defines the options to configure the compilation
  17499. */
  17500. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  17501. clipPlane: boolean;
  17502. }>): void;
  17503. /**
  17504. * Force shader compilation
  17505. * @param mesh defines the mesh that will use this material
  17506. * @param options defines additional options for compiling the shaders
  17507. * @returns a promise that resolves when the compilation completes
  17508. */
  17509. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  17510. clipPlane: boolean;
  17511. }>): Promise<void>;
  17512. /**
  17513. * Marks a define in the material to indicate that it needs to be re-computed
  17514. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  17515. */
  17516. markAsDirty(flag: number): void;
  17517. /**
  17518. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  17519. * @param func defines a function which checks material defines against the submeshes
  17520. */
  17521. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  17522. /**
  17523. * Indicates that image processing needs to be re-calculated for all submeshes
  17524. */
  17525. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  17526. /**
  17527. * Indicates that textures need to be re-calculated for all submeshes
  17528. */
  17529. protected _markAllSubMeshesAsTexturesDirty(): void;
  17530. /**
  17531. * Indicates that fresnel needs to be re-calculated for all submeshes
  17532. */
  17533. protected _markAllSubMeshesAsFresnelDirty(): void;
  17534. /**
  17535. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  17536. */
  17537. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  17538. /**
  17539. * Indicates that lights need to be re-calculated for all submeshes
  17540. */
  17541. protected _markAllSubMeshesAsLightsDirty(): void;
  17542. /**
  17543. * Indicates that attributes need to be re-calculated for all submeshes
  17544. */
  17545. protected _markAllSubMeshesAsAttributesDirty(): void;
  17546. /**
  17547. * Indicates that misc needs to be re-calculated for all submeshes
  17548. */
  17549. protected _markAllSubMeshesAsMiscDirty(): void;
  17550. /**
  17551. * Indicates that textures and misc need to be re-calculated for all submeshes
  17552. */
  17553. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  17554. /**
  17555. * Disposes the material
  17556. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  17557. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  17558. */
  17559. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  17560. /**
  17561. * Serializes this material
  17562. * @returns the serialized material object
  17563. */
  17564. serialize(): any;
  17565. /**
  17566. * Creates a MultiMaterial from parsed MultiMaterial data.
  17567. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  17568. * @param scene defines the hosting scene
  17569. * @returns a new MultiMaterial
  17570. */
  17571. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  17572. /**
  17573. * Creates a material from parsed material data
  17574. * @param parsedMaterial defines parsed material data
  17575. * @param scene defines the hosting scene
  17576. * @param rootUrl defines the root URL to use to load textures
  17577. * @returns a new material
  17578. */
  17579. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): any;
  17580. }
  17581. }
  17582. declare module BABYLON {
  17583. /**
  17584. * "Static Class" containing the most commonly used helper while dealing with material for
  17585. * rendering purpose.
  17586. *
  17587. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  17588. *
  17589. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  17590. */
  17591. class MaterialHelper {
  17592. /**
  17593. * Bind the current view position to an effect.
  17594. * @param effect The effect to be bound
  17595. * @param scene The scene the eyes position is used from
  17596. */
  17597. static BindEyePosition(effect: Effect, scene: Scene): void;
  17598. /**
  17599. * Helps preparing the defines values about the UVs in used in the effect.
  17600. * UVs are shared as much as we can accross channels in the shaders.
  17601. * @param texture The texture we are preparing the UVs for
  17602. * @param defines The defines to update
  17603. * @param key The channel key "diffuse", "specular"... used in the shader
  17604. */
  17605. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  17606. /**
  17607. * Binds a texture matrix value to its corrsponding uniform
  17608. * @param texture The texture to bind the matrix for
  17609. * @param uniformBuffer The uniform buffer receivin the data
  17610. * @param key The channel key "diffuse", "specular"... used in the shader
  17611. */
  17612. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  17613. /**
  17614. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  17615. * @param mesh defines the current mesh
  17616. * @param scene defines the current scene
  17617. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  17618. * @param pointsCloud defines if point cloud rendering has to be turned on
  17619. * @param fogEnabled defines if fog has to be turned on
  17620. * @param alphaTest defines if alpha testing has to be turned on
  17621. * @param defines defines the current list of defines
  17622. */
  17623. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  17624. /**
  17625. * Helper used to prepare the list of defines associated with frame values for shader compilation
  17626. * @param scene defines the current scene
  17627. * @param engine defines the current engine
  17628. * @param defines specifies the list of active defines
  17629. * @param useInstances defines if instances have to be turned on
  17630. * @param useClipPlane defines if clip plane have to be turned on
  17631. */
  17632. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  17633. /**
  17634. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  17635. * @param mesh The mesh containing the geometry data we will draw
  17636. * @param defines The defines to update
  17637. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  17638. * @param useBones Precise whether bones should be used or not (override mesh info)
  17639. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  17640. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  17641. * @returns false if defines are considered not dirty and have not been checked
  17642. */
  17643. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  17644. /**
  17645. * Prepares the defines related to the light information passed in parameter
  17646. * @param scene The scene we are intending to draw
  17647. * @param mesh The mesh the effect is compiling for
  17648. * @param defines The defines to update
  17649. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  17650. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  17651. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  17652. * @returns true if normals will be required for the rest of the effect
  17653. */
  17654. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  17655. /**
  17656. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  17657. * that won t be acctive due to defines being turned off.
  17658. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  17659. * @param samplersList The samplers list
  17660. * @param defines The defines helping in the list generation
  17661. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  17662. */
  17663. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  17664. /**
  17665. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  17666. * @param defines The defines to update while falling back
  17667. * @param fallbacks The authorized effect fallbacks
  17668. * @param maxSimultaneousLights The maximum number of lights allowed
  17669. * @param rank the current rank of the Effect
  17670. * @returns The newly affected rank
  17671. */
  17672. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  17673. /**
  17674. * Prepares the list of attributes required for morph targets according to the effect defines.
  17675. * @param attribs The current list of supported attribs
  17676. * @param mesh The mesh to prepare the morph targets attributes for
  17677. * @param defines The current Defines of the effect
  17678. */
  17679. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  17680. /**
  17681. * Prepares the list of attributes required for bones according to the effect defines.
  17682. * @param attribs The current list of supported attribs
  17683. * @param mesh The mesh to prepare the bones attributes for
  17684. * @param defines The current Defines of the effect
  17685. * @param fallbacks The current efffect fallback strategy
  17686. */
  17687. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  17688. /**
  17689. * Prepares the list of attributes required for instances according to the effect defines.
  17690. * @param attribs The current list of supported attribs
  17691. * @param defines The current Defines of the effect
  17692. */
  17693. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  17694. /**
  17695. * Binds the light shadow information to the effect for the given mesh.
  17696. * @param light The light containing the generator
  17697. * @param scene The scene the lights belongs to
  17698. * @param mesh The mesh we are binding the information to render
  17699. * @param lightIndex The light index in the effect used to render the mesh
  17700. * @param effect The effect we are binding the data to
  17701. */
  17702. static BindLightShadow(light: Light, scene: Scene, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  17703. /**
  17704. * Binds the light information to the effect.
  17705. * @param light The light containing the generator
  17706. * @param effect The effect we are binding the data to
  17707. * @param lightIndex The light index in the effect used to render
  17708. */
  17709. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  17710. /**
  17711. * Binds the lights information from the scene to the effect for the given mesh.
  17712. * @param scene The scene the lights belongs to
  17713. * @param mesh The mesh we are binding the information to render
  17714. * @param effect The effect we are binding the data to
  17715. * @param defines The generated defines for the effect
  17716. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  17717. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  17718. */
  17719. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  17720. private static _tempFogColor;
  17721. /**
  17722. * Binds the fog information from the scene to the effect for the given mesh.
  17723. * @param scene The scene the lights belongs to
  17724. * @param mesh The mesh we are binding the information to render
  17725. * @param effect The effect we are binding the data to
  17726. * @param linearSpace Defines if the fog effect is applied in linear space
  17727. */
  17728. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  17729. /**
  17730. * Binds the bones information from the mesh to the effect.
  17731. * @param mesh The mesh we are binding the information to render
  17732. * @param effect The effect we are binding the data to
  17733. */
  17734. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  17735. /**
  17736. * Binds the morph targets information from the mesh to the effect.
  17737. * @param abstractMesh The mesh we are binding the information to render
  17738. * @param effect The effect we are binding the data to
  17739. */
  17740. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  17741. /**
  17742. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  17743. * @param defines The generated defines used in the effect
  17744. * @param effect The effect we are binding the data to
  17745. * @param scene The scene we are willing to render with logarithmic scale for
  17746. */
  17747. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  17748. /**
  17749. * Binds the clip plane information from the scene to the effect.
  17750. * @param scene The scene the clip plane information are extracted from
  17751. * @param effect The effect we are binding the data to
  17752. */
  17753. static BindClipPlane(effect: Effect, scene: Scene): void;
  17754. }
  17755. }
  17756. declare module BABYLON {
  17757. /**
  17758. * A multi-material is used to apply different materials to different parts of the same object without the need of
  17759. * separate meshes. This can be use to improve performances.
  17760. * @see http://doc.babylonjs.com/how_to/multi_materials
  17761. */
  17762. class MultiMaterial extends Material {
  17763. private _subMaterials;
  17764. /**
  17765. * Gets or Sets the list of Materials used within the multi material.
  17766. * They need to be ordered according to the submeshes order in the associated mesh
  17767. */
  17768. subMaterials: Nullable<Material>[];
  17769. /**
  17770. * Instantiates a new Multi Material
  17771. * A multi-material is used to apply different materials to different parts of the same object without the need of
  17772. * separate meshes. This can be use to improve performances.
  17773. * @see http://doc.babylonjs.com/how_to/multi_materials
  17774. * @param name Define the name in the scene
  17775. * @param scene Define the scene the material belongs to
  17776. */
  17777. constructor(name: string, scene: Scene);
  17778. private _hookArray;
  17779. /**
  17780. * Get one of the submaterial by its index in the submaterials array
  17781. * @param index The index to look the sub material at
  17782. * @returns The Material if the index has been defined
  17783. */
  17784. getSubMaterial(index: number): Nullable<Material>;
  17785. /**
  17786. * Get the list of active textures for the whole sub materials list.
  17787. * @returns All the textures that will be used during the rendering
  17788. */
  17789. getActiveTextures(): BaseTexture[];
  17790. /**
  17791. * Gets the current class name of the material e.g. "MultiMaterial"
  17792. * Mainly use in serialization.
  17793. * @returns the class name
  17794. */
  17795. getClassName(): string;
  17796. /**
  17797. * Checks if the material is ready to render the requested sub mesh
  17798. * @param mesh Define the mesh the submesh belongs to
  17799. * @param subMesh Define the sub mesh to look readyness for
  17800. * @param useInstances Define whether or not the material is used with instances
  17801. * @returns true if ready, otherwise false
  17802. */
  17803. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  17804. /**
  17805. * Clones the current material and its related sub materials
  17806. * @param name Define the name of the newly cloned material
  17807. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  17808. * @returns the cloned material
  17809. */
  17810. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  17811. /**
  17812. * Serializes the materials into a JSON representation.
  17813. * @returns the JSON representation
  17814. */
  17815. serialize(): any;
  17816. /**
  17817. * Dispose the material and release its associated resources
  17818. * @param forceDisposeEffect Define if we want to force disposing the associated effect (if false the shader is not released and could be reuse later on)
  17819. * @param forceDisposeTextures Define if we want to force disposing the associated textures (if false, they will not be disposed and can still be use elsewhere in the app)
  17820. */
  17821. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  17822. }
  17823. }
  17824. declare module BABYLON {
  17825. /**
  17826. * Base class of materials working in push mode in babylon JS
  17827. * @hidden
  17828. */
  17829. class PushMaterial extends Material {
  17830. protected _activeEffect: Effect;
  17831. protected _normalMatrix: Matrix;
  17832. constructor(name: string, scene: Scene);
  17833. getEffect(): Effect;
  17834. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  17835. /**
  17836. * Binds the given world matrix to the active effect
  17837. *
  17838. * @param world the matrix to bind
  17839. */
  17840. bindOnlyWorldMatrix(world: Matrix): void;
  17841. /**
  17842. * Binds the given normal matrix to the active effect
  17843. *
  17844. * @param normalMatrix the matrix to bind
  17845. */
  17846. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  17847. bind(world: Matrix, mesh?: Mesh): void;
  17848. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  17849. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  17850. }
  17851. }
  17852. declare module BABYLON {
  17853. /**
  17854. * Defines the options associated with the creation of a shader material.
  17855. */
  17856. interface IShaderMaterialOptions {
  17857. /**
  17858. * Does the material work in alpha blend mode
  17859. */
  17860. needAlphaBlending: boolean;
  17861. /**
  17862. * Does the material work in alpha test mode
  17863. */
  17864. needAlphaTesting: boolean;
  17865. /**
  17866. * The list of attribute names used in the shader
  17867. */
  17868. attributes: string[];
  17869. /**
  17870. * The list of unifrom names used in the shader
  17871. */
  17872. uniforms: string[];
  17873. /**
  17874. * The list of UBO names used in the shader
  17875. */
  17876. uniformBuffers: string[];
  17877. /**
  17878. * The list of sampler names used in the shader
  17879. */
  17880. samplers: string[];
  17881. /**
  17882. * The list of defines used in the shader
  17883. */
  17884. defines: string[];
  17885. }
  17886. /**
  17887. * The ShaderMaterial object has the necessary methods to pass data from your scene to the Vertex and Fragment Shaders and returns a material that can be applied to any mesh.
  17888. *
  17889. * This returned material effects how the mesh will look based on the code in the shaders.
  17890. *
  17891. * @see http://doc.babylonjs.com/how_to/shader_material
  17892. */
  17893. class ShaderMaterial extends Material {
  17894. private _shaderPath;
  17895. private _options;
  17896. private _textures;
  17897. private _textureArrays;
  17898. private _floats;
  17899. private _ints;
  17900. private _floatsArrays;
  17901. private _colors3;
  17902. private _colors3Arrays;
  17903. private _colors4;
  17904. private _vectors2;
  17905. private _vectors3;
  17906. private _vectors4;
  17907. private _matrices;
  17908. private _matrices3x3;
  17909. private _matrices2x2;
  17910. private _vectors2Arrays;
  17911. private _vectors3Arrays;
  17912. private _cachedWorldViewMatrix;
  17913. private _renderId;
  17914. /**
  17915. * Instantiate a new shader material.
  17916. * The ShaderMaterial object has the necessary methods to pass data from your scene to the Vertex and Fragment Shaders and returns a material that can be applied to any mesh.
  17917. * This returned material effects how the mesh will look based on the code in the shaders.
  17918. * @see http://doc.babylonjs.com/how_to/shader_material
  17919. * @param name Define the name of the material in the scene
  17920. * @param scene Define the scene the material belongs to
  17921. * @param shaderPath Defines the route to the shader code in one of three ways:
  17922. * - object - { vertex: "custom", fragment: "custom" }, used with BABYLON.Effect.ShadersStore["customVertexShader"] and BABYLON.Effect.ShadersStore["customFragmentShader"]
  17923. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  17924. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  17925. * @param options Define the options used to create the shader
  17926. */
  17927. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  17928. /**
  17929. * Gets the current class name of the material e.g. "ShaderMaterial"
  17930. * Mainly use in serialization.
  17931. * @returns the class name
  17932. */
  17933. getClassName(): string;
  17934. /**
  17935. * Specifies if the material will require alpha blending
  17936. * @returns a boolean specifying if alpha blending is needed
  17937. */
  17938. needAlphaBlending(): boolean;
  17939. /**
  17940. * Specifies if this material should be rendered in alpha test mode
  17941. * @returns a boolean specifying if an alpha test is needed.
  17942. */
  17943. needAlphaTesting(): boolean;
  17944. private _checkUniform;
  17945. /**
  17946. * Set a texture in the shader.
  17947. * @param name Define the name of the uniform samplers as defined in the shader
  17948. * @param texture Define the texture to bind to this sampler
  17949. * @return the material itself allowing "fluent" like uniform updates
  17950. */
  17951. setTexture(name: string, texture: Texture): ShaderMaterial;
  17952. /**
  17953. * Set a texture array in the shader.
  17954. * @param name Define the name of the uniform sampler array as defined in the shader
  17955. * @param textures Define the list of textures to bind to this sampler
  17956. * @return the material itself allowing "fluent" like uniform updates
  17957. */
  17958. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  17959. /**
  17960. * Set a float in the shader.
  17961. * @param name Define the name of the uniform as defined in the shader
  17962. * @param value Define the value to give to the uniform
  17963. * @return the material itself allowing "fluent" like uniform updates
  17964. */
  17965. setFloat(name: string, value: number): ShaderMaterial;
  17966. /**
  17967. * Set a int in the shader.
  17968. * @param name Define the name of the uniform as defined in the shader
  17969. * @param value Define the value to give to the uniform
  17970. * @return the material itself allowing "fluent" like uniform updates
  17971. */
  17972. setInt(name: string, value: number): ShaderMaterial;
  17973. /**
  17974. * Set an array of floats in the shader.
  17975. * @param name Define the name of the uniform as defined in the shader
  17976. * @param value Define the value to give to the uniform
  17977. * @return the material itself allowing "fluent" like uniform updates
  17978. */
  17979. setFloats(name: string, value: number[]): ShaderMaterial;
  17980. /**
  17981. * Set a vec3 in the shader from a Color3.
  17982. * @param name Define the name of the uniform as defined in the shader
  17983. * @param value Define the value to give to the uniform
  17984. * @return the material itself allowing "fluent" like uniform updates
  17985. */
  17986. setColor3(name: string, value: Color3): ShaderMaterial;
  17987. /**
  17988. * Set a vec3 array in the shader from a Color3 array.
  17989. * @param name Define the name of the uniform as defined in the shader
  17990. * @param value Define the value to give to the uniform
  17991. * @return the material itself allowing "fluent" like uniform updates
  17992. */
  17993. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  17994. /**
  17995. * Set a vec4 in the shader from a Color4.
  17996. * @param name Define the name of the uniform as defined in the shader
  17997. * @param value Define the value to give to the uniform
  17998. * @return the material itself allowing "fluent" like uniform updates
  17999. */
  18000. setColor4(name: string, value: Color4): ShaderMaterial;
  18001. /**
  18002. * Set a vec2 in the shader from a Vector2.
  18003. * @param name Define the name of the uniform as defined in the shader
  18004. * @param value Define the value to give to the uniform
  18005. * @return the material itself allowing "fluent" like uniform updates
  18006. */
  18007. setVector2(name: string, value: Vector2): ShaderMaterial;
  18008. /**
  18009. * Set a vec3 in the shader from a Vector3.
  18010. * @param name Define the name of the uniform as defined in the shader
  18011. * @param value Define the value to give to the uniform
  18012. * @return the material itself allowing "fluent" like uniform updates
  18013. */
  18014. setVector3(name: string, value: Vector3): ShaderMaterial;
  18015. /**
  18016. * Set a vec4 in the shader from a Vector4.
  18017. * @param name Define the name of the uniform as defined in the shader
  18018. * @param value Define the value to give to the uniform
  18019. * @return the material itself allowing "fluent" like uniform updates
  18020. */
  18021. setVector4(name: string, value: Vector4): ShaderMaterial;
  18022. /**
  18023. * Set a mat4 in the shader from a Matrix.
  18024. * @param name Define the name of the uniform as defined in the shader
  18025. * @param value Define the value to give to the uniform
  18026. * @return the material itself allowing "fluent" like uniform updates
  18027. */
  18028. setMatrix(name: string, value: Matrix): ShaderMaterial;
  18029. /**
  18030. * Set a mat3 in the shader from a Float32Array.
  18031. * @param name Define the name of the uniform as defined in the shader
  18032. * @param value Define the value to give to the uniform
  18033. * @return the material itself allowing "fluent" like uniform updates
  18034. */
  18035. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  18036. /**
  18037. * Set a mat2 in the shader from a Float32Array.
  18038. * @param name Define the name of the uniform as defined in the shader
  18039. * @param value Define the value to give to the uniform
  18040. * @return the material itself allowing "fluent" like uniform updates
  18041. */
  18042. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  18043. /**
  18044. * Set a vec2 array in the shader from a number array.
  18045. * @param name Define the name of the uniform as defined in the shader
  18046. * @param value Define the value to give to the uniform
  18047. * @return the material itself allowing "fluent" like uniform updates
  18048. */
  18049. setArray2(name: string, value: number[]): ShaderMaterial;
  18050. /**
  18051. * Set a vec3 array in the shader from a number array.
  18052. * @param name Define the name of the uniform as defined in the shader
  18053. * @param value Define the value to give to the uniform
  18054. * @return the material itself allowing "fluent" like uniform updates
  18055. */
  18056. setArray3(name: string, value: number[]): ShaderMaterial;
  18057. private _checkCache;
  18058. /**
  18059. * Checks if the material is ready to render the requested mesh
  18060. * @param mesh Define the mesh to render
  18061. * @param useInstances Define whether or not the material is used with instances
  18062. * @returns true if ready, otherwise false
  18063. */
  18064. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  18065. /**
  18066. * Binds the world matrix to the material
  18067. * @param world defines the world transformation matrix
  18068. */
  18069. bindOnlyWorldMatrix(world: Matrix): void;
  18070. /**
  18071. * Binds the material to the mesh
  18072. * @param world defines the world transformation matrix
  18073. * @param mesh defines the mesh to bind the material to
  18074. */
  18075. bind(world: Matrix, mesh?: Mesh): void;
  18076. /**
  18077. * Gets the active textures from the material
  18078. * @returns an array of textures
  18079. */
  18080. getActiveTextures(): BaseTexture[];
  18081. /**
  18082. * Specifies if the material uses a texture
  18083. * @param texture defines the texture to check against the material
  18084. * @returns a boolean specifying if the material uses the texture
  18085. */
  18086. hasTexture(texture: BaseTexture): boolean;
  18087. /**
  18088. * Makes a duplicate of the material, and gives it a new name
  18089. * @param name defines the new name for the duplicated material
  18090. * @returns the cloned material
  18091. */
  18092. clone(name: string): ShaderMaterial;
  18093. /**
  18094. * Disposes the material
  18095. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  18096. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  18097. */
  18098. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  18099. /**
  18100. * Serializes this material in a JSON representation
  18101. * @returns the serialized material object
  18102. */
  18103. serialize(): any;
  18104. /**
  18105. * Creates a shader material from parsed shader material data
  18106. * @param source defines the JSON represnetation of the material
  18107. * @param scene defines the hosting scene
  18108. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  18109. * @returns a new material
  18110. */
  18111. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  18112. }
  18113. }
  18114. declare module BABYLON {
  18115. /** @hidden */
  18116. class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  18117. MAINUV1: boolean;
  18118. MAINUV2: boolean;
  18119. DIFFUSE: boolean;
  18120. DIFFUSEDIRECTUV: number;
  18121. AMBIENT: boolean;
  18122. AMBIENTDIRECTUV: number;
  18123. OPACITY: boolean;
  18124. OPACITYDIRECTUV: number;
  18125. OPACITYRGB: boolean;
  18126. REFLECTION: boolean;
  18127. EMISSIVE: boolean;
  18128. EMISSIVEDIRECTUV: number;
  18129. SPECULAR: boolean;
  18130. SPECULARDIRECTUV: number;
  18131. BUMP: boolean;
  18132. BUMPDIRECTUV: number;
  18133. PARALLAX: boolean;
  18134. PARALLAXOCCLUSION: boolean;
  18135. SPECULAROVERALPHA: boolean;
  18136. CLIPPLANE: boolean;
  18137. CLIPPLANE2: boolean;
  18138. CLIPPLANE3: boolean;
  18139. CLIPPLANE4: boolean;
  18140. ALPHATEST: boolean;
  18141. DEPTHPREPASS: boolean;
  18142. ALPHAFROMDIFFUSE: boolean;
  18143. POINTSIZE: boolean;
  18144. FOG: boolean;
  18145. SPECULARTERM: boolean;
  18146. DIFFUSEFRESNEL: boolean;
  18147. OPACITYFRESNEL: boolean;
  18148. REFLECTIONFRESNEL: boolean;
  18149. REFRACTIONFRESNEL: boolean;
  18150. EMISSIVEFRESNEL: boolean;
  18151. FRESNEL: boolean;
  18152. NORMAL: boolean;
  18153. UV1: boolean;
  18154. UV2: boolean;
  18155. VERTEXCOLOR: boolean;
  18156. VERTEXALPHA: boolean;
  18157. NUM_BONE_INFLUENCERS: number;
  18158. BonesPerMesh: number;
  18159. INSTANCES: boolean;
  18160. GLOSSINESS: boolean;
  18161. ROUGHNESS: boolean;
  18162. EMISSIVEASILLUMINATION: boolean;
  18163. LINKEMISSIVEWITHDIFFUSE: boolean;
  18164. REFLECTIONFRESNELFROMSPECULAR: boolean;
  18165. LIGHTMAP: boolean;
  18166. LIGHTMAPDIRECTUV: number;
  18167. OBJECTSPACE_NORMALMAP: boolean;
  18168. USELIGHTMAPASSHADOWMAP: boolean;
  18169. REFLECTIONMAP_3D: boolean;
  18170. REFLECTIONMAP_SPHERICAL: boolean;
  18171. REFLECTIONMAP_PLANAR: boolean;
  18172. REFLECTIONMAP_CUBIC: boolean;
  18173. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  18174. REFLECTIONMAP_PROJECTION: boolean;
  18175. REFLECTIONMAP_SKYBOX: boolean;
  18176. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  18177. REFLECTIONMAP_EXPLICIT: boolean;
  18178. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  18179. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  18180. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  18181. INVERTCUBICMAP: boolean;
  18182. LOGARITHMICDEPTH: boolean;
  18183. REFRACTION: boolean;
  18184. REFRACTIONMAP_3D: boolean;
  18185. REFLECTIONOVERALPHA: boolean;
  18186. TWOSIDEDLIGHTING: boolean;
  18187. SHADOWFLOAT: boolean;
  18188. MORPHTARGETS: boolean;
  18189. MORPHTARGETS_NORMAL: boolean;
  18190. MORPHTARGETS_TANGENT: boolean;
  18191. NUM_MORPH_INFLUENCERS: number;
  18192. NONUNIFORMSCALING: boolean;
  18193. PREMULTIPLYALPHA: boolean;
  18194. IMAGEPROCESSING: boolean;
  18195. VIGNETTE: boolean;
  18196. VIGNETTEBLENDMODEMULTIPLY: boolean;
  18197. VIGNETTEBLENDMODEOPAQUE: boolean;
  18198. TONEMAPPING: boolean;
  18199. TONEMAPPING_ACES: boolean;
  18200. CONTRAST: boolean;
  18201. COLORCURVES: boolean;
  18202. COLORGRADING: boolean;
  18203. COLORGRADING3D: boolean;
  18204. SAMPLER3DGREENDEPTH: boolean;
  18205. SAMPLER3DBGRMAP: boolean;
  18206. IMAGEPROCESSINGPOSTPROCESS: boolean;
  18207. /**
  18208. * If the reflection texture on this material is in linear color space
  18209. * @hidden
  18210. */
  18211. IS_REFLECTION_LINEAR: boolean;
  18212. /**
  18213. * If the refraction texture on this material is in linear color space
  18214. * @hidden
  18215. */
  18216. IS_REFRACTION_LINEAR: boolean;
  18217. EXPOSURE: boolean;
  18218. constructor();
  18219. setReflectionMode(modeToEnable: string): void;
  18220. }
  18221. /**
  18222. * This is the default material used in Babylon. It is the best trade off between quality
  18223. * and performances.
  18224. * @see http://doc.babylonjs.com/babylon101/materials
  18225. */
  18226. class StandardMaterial extends PushMaterial {
  18227. private _diffuseTexture;
  18228. /**
  18229. * The basic texture of the material as viewed under a light.
  18230. */
  18231. diffuseTexture: Nullable<BaseTexture>;
  18232. private _ambientTexture;
  18233. /**
  18234. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  18235. */
  18236. ambientTexture: Nullable<BaseTexture>;
  18237. private _opacityTexture;
  18238. /**
  18239. * Define the transparency of the material from a texture.
  18240. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  18241. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  18242. */
  18243. opacityTexture: Nullable<BaseTexture>;
  18244. private _reflectionTexture;
  18245. /**
  18246. * Define the texture used to display the reflection.
  18247. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  18248. */
  18249. reflectionTexture: Nullable<BaseTexture>;
  18250. private _emissiveTexture;
  18251. /**
  18252. * Define texture of the material as if self lit.
  18253. * This will be mixed in the final result even in the absence of light.
  18254. */
  18255. emissiveTexture: Nullable<BaseTexture>;
  18256. private _specularTexture;
  18257. /**
  18258. * Define how the color and intensity of the highlight given by the light in the material.
  18259. */
  18260. specularTexture: Nullable<BaseTexture>;
  18261. private _bumpTexture;
  18262. /**
  18263. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  18264. * These are made by creating a normal map from an image. The means to do this can be found on the web, a search for 'normal map generator' will bring up free and paid for methods of doing this.
  18265. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  18266. */
  18267. bumpTexture: Nullable<BaseTexture>;
  18268. private _lightmapTexture;
  18269. /**
  18270. * Complex lighting can be computationally expensive to compute at runtime.
  18271. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  18272. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  18273. */
  18274. lightmapTexture: Nullable<BaseTexture>;
  18275. private _refractionTexture;
  18276. /**
  18277. * Define the texture used to display the refraction.
  18278. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  18279. */
  18280. refractionTexture: Nullable<BaseTexture>;
  18281. /**
  18282. * The color of the material lit by the environmental background lighting.
  18283. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  18284. */
  18285. ambientColor: Color3;
  18286. /**
  18287. * The basic color of the material as viewed under a light.
  18288. */
  18289. diffuseColor: Color3;
  18290. /**
  18291. * Define how the color and intensity of the highlight given by the light in the material.
  18292. */
  18293. specularColor: Color3;
  18294. /**
  18295. * Define the color of the material as if self lit.
  18296. * This will be mixed in the final result even in the absence of light.
  18297. */
  18298. emissiveColor: Color3;
  18299. /**
  18300. * Defines how sharp are the highlights in the material.
  18301. * The bigger the value the sharper giving a more glossy feeling to the result.
  18302. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  18303. */
  18304. specularPower: number;
  18305. private _useAlphaFromDiffuseTexture;
  18306. /**
  18307. * Does the transparency come from the diffuse texture alpha channel.
  18308. */
  18309. useAlphaFromDiffuseTexture: boolean;
  18310. private _useEmissiveAsIllumination;
  18311. /**
  18312. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  18313. */
  18314. useEmissiveAsIllumination: boolean;
  18315. private _linkEmissiveWithDiffuse;
  18316. /**
  18317. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  18318. * the emissive level when the final color is close to one.
  18319. */
  18320. linkEmissiveWithDiffuse: boolean;
  18321. private _useSpecularOverAlpha;
  18322. /**
  18323. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  18324. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  18325. */
  18326. useSpecularOverAlpha: boolean;
  18327. private _useReflectionOverAlpha;
  18328. /**
  18329. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  18330. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  18331. */
  18332. useReflectionOverAlpha: boolean;
  18333. private _disableLighting;
  18334. /**
  18335. * Does lights from the scene impacts this material.
  18336. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  18337. */
  18338. disableLighting: boolean;
  18339. private _useObjectSpaceNormalMap;
  18340. /**
  18341. * Allows using an object space normal map (instead of tangent space).
  18342. */
  18343. useObjectSpaceNormalMap: boolean;
  18344. private _useParallax;
  18345. /**
  18346. * Is parallax enabled or not.
  18347. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  18348. */
  18349. useParallax: boolean;
  18350. private _useParallaxOcclusion;
  18351. /**
  18352. * Is parallax occlusion enabled or not.
  18353. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  18354. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  18355. */
  18356. useParallaxOcclusion: boolean;
  18357. /**
  18358. * Apply a scaling factor that determine which "depth" the height map should reprensent. A value between 0.05 and 0.1 is reasonnable in Parallax, you can reach 0.2 using Parallax Occlusion.
  18359. */
  18360. parallaxScaleBias: number;
  18361. private _roughness;
  18362. /**
  18363. * Helps to define how blurry the reflections should appears in the material.
  18364. */
  18365. roughness: number;
  18366. /**
  18367. * In case of refraction, define the value of the indice of refraction.
  18368. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  18369. */
  18370. indexOfRefraction: number;
  18371. /**
  18372. * Invert the refraction texture alongside the y axis.
  18373. * It can be usefull with procedural textures or probe for instance.
  18374. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  18375. */
  18376. invertRefractionY: boolean;
  18377. /**
  18378. * Defines the alpha limits in alpha test mode.
  18379. */
  18380. alphaCutOff: number;
  18381. private _useLightmapAsShadowmap;
  18382. /**
  18383. * In case of light mapping, define whether the map contains light or shadow informations.
  18384. */
  18385. useLightmapAsShadowmap: boolean;
  18386. private _diffuseFresnelParameters;
  18387. /**
  18388. * Define the diffuse fresnel parameters of the material.
  18389. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  18390. */
  18391. diffuseFresnelParameters: FresnelParameters;
  18392. private _opacityFresnelParameters;
  18393. /**
  18394. * Define the opacity fresnel parameters of the material.
  18395. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  18396. */
  18397. opacityFresnelParameters: FresnelParameters;
  18398. private _reflectionFresnelParameters;
  18399. /**
  18400. * Define the reflection fresnel parameters of the material.
  18401. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  18402. */
  18403. reflectionFresnelParameters: FresnelParameters;
  18404. private _refractionFresnelParameters;
  18405. /**
  18406. * Define the refraction fresnel parameters of the material.
  18407. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  18408. */
  18409. refractionFresnelParameters: FresnelParameters;
  18410. private _emissiveFresnelParameters;
  18411. /**
  18412. * Define the emissive fresnel parameters of the material.
  18413. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  18414. */
  18415. emissiveFresnelParameters: FresnelParameters;
  18416. private _useReflectionFresnelFromSpecular;
  18417. /**
  18418. * If true automatically deducts the fresnels values from the material specularity.
  18419. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  18420. */
  18421. useReflectionFresnelFromSpecular: boolean;
  18422. private _useGlossinessFromSpecularMapAlpha;
  18423. /**
  18424. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  18425. */
  18426. useGlossinessFromSpecularMapAlpha: boolean;
  18427. private _maxSimultaneousLights;
  18428. /**
  18429. * Defines the maximum number of lights that can be used in the material
  18430. */
  18431. maxSimultaneousLights: number;
  18432. private _invertNormalMapX;
  18433. /**
  18434. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  18435. */
  18436. invertNormalMapX: boolean;
  18437. private _invertNormalMapY;
  18438. /**
  18439. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  18440. */
  18441. invertNormalMapY: boolean;
  18442. private _twoSidedLighting;
  18443. /**
  18444. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  18445. */
  18446. twoSidedLighting: boolean;
  18447. /**
  18448. * Default configuration related to image processing available in the standard Material.
  18449. */
  18450. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  18451. /**
  18452. * Gets the image processing configuration used either in this material.
  18453. */
  18454. /**
  18455. * Sets the Default image processing configuration used either in the this material.
  18456. *
  18457. * If sets to null, the scene one is in use.
  18458. */
  18459. imageProcessingConfiguration: ImageProcessingConfiguration;
  18460. /**
  18461. * Keep track of the image processing observer to allow dispose and replace.
  18462. */
  18463. private _imageProcessingObserver;
  18464. /**
  18465. * Attaches a new image processing configuration to the Standard Material.
  18466. * @param configuration
  18467. */
  18468. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  18469. /**
  18470. * Gets wether the color curves effect is enabled.
  18471. */
  18472. /**
  18473. * Sets wether the color curves effect is enabled.
  18474. */
  18475. cameraColorCurvesEnabled: boolean;
  18476. /**
  18477. * Gets wether the color grading effect is enabled.
  18478. */
  18479. /**
  18480. * Gets wether the color grading effect is enabled.
  18481. */
  18482. cameraColorGradingEnabled: boolean;
  18483. /**
  18484. * Gets wether tonemapping is enabled or not.
  18485. */
  18486. /**
  18487. * Sets wether tonemapping is enabled or not
  18488. */
  18489. cameraToneMappingEnabled: boolean;
  18490. /**
  18491. * The camera exposure used on this material.
  18492. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  18493. * This corresponds to a photographic exposure.
  18494. */
  18495. /**
  18496. * The camera exposure used on this material.
  18497. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  18498. * This corresponds to a photographic exposure.
  18499. */
  18500. cameraExposure: number;
  18501. /**
  18502. * Gets The camera contrast used on this material.
  18503. */
  18504. /**
  18505. * Sets The camera contrast used on this material.
  18506. */
  18507. cameraContrast: number;
  18508. /**
  18509. * Gets the Color Grading 2D Lookup Texture.
  18510. */
  18511. /**
  18512. * Sets the Color Grading 2D Lookup Texture.
  18513. */
  18514. cameraColorGradingTexture: Nullable<BaseTexture>;
  18515. /**
  18516. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  18517. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  18518. * 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;
  18519. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  18520. */
  18521. /**
  18522. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  18523. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  18524. * 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;
  18525. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  18526. */
  18527. cameraColorCurves: Nullable<ColorCurves>;
  18528. /**
  18529. * Custom callback helping to override the default shader used in the material.
  18530. */
  18531. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  18532. protected _renderTargets: SmartArray<RenderTargetTexture>;
  18533. protected _worldViewProjectionMatrix: Matrix;
  18534. protected _globalAmbientColor: Color3;
  18535. protected _useLogarithmicDepth: boolean;
  18536. /**
  18537. * Instantiates a new standard material.
  18538. * This is the default material used in Babylon. It is the best trade off between quality
  18539. * and performances.
  18540. * @see http://doc.babylonjs.com/babylon101/materials
  18541. * @param name Define the name of the material in the scene
  18542. * @param scene Define the scene the material belong to
  18543. */
  18544. constructor(name: string, scene: Scene);
  18545. /**
  18546. * Gets a boolean indicating that current material needs to register RTT
  18547. */
  18548. readonly hasRenderTargetTextures: boolean;
  18549. /**
  18550. * Gets the current class name of the material e.g. "StandardMaterial"
  18551. * Mainly use in serialization.
  18552. * @returns the class name
  18553. */
  18554. getClassName(): string;
  18555. /**
  18556. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  18557. * You can try switching to logarithmic depth.
  18558. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  18559. */
  18560. useLogarithmicDepth: boolean;
  18561. /**
  18562. * Specifies if the material will require alpha blending
  18563. * @returns a boolean specifying if alpha blending is needed
  18564. */
  18565. needAlphaBlending(): boolean;
  18566. /**
  18567. * Specifies if this material should be rendered in alpha test mode
  18568. * @returns a boolean specifying if an alpha test is needed.
  18569. */
  18570. needAlphaTesting(): boolean;
  18571. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  18572. /**
  18573. * Get the texture used for alpha test purpose.
  18574. * @returns the diffuse texture in case of the standard material.
  18575. */
  18576. getAlphaTestTexture(): Nullable<BaseTexture>;
  18577. /**
  18578. * Get if the submesh is ready to be used and all its information available.
  18579. * Child classes can use it to update shaders
  18580. * @param mesh defines the mesh to check
  18581. * @param subMesh defines which submesh to check
  18582. * @param useInstances specifies that instances should be used
  18583. * @returns a boolean indicating that the submesh is ready or not
  18584. */
  18585. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  18586. /**
  18587. * Builds the material UBO layouts.
  18588. * Used internally during the effect preparation.
  18589. */
  18590. buildUniformLayout(): void;
  18591. /**
  18592. * Unbinds the material from the mesh
  18593. */
  18594. unbind(): void;
  18595. /**
  18596. * Binds the submesh to this material by preparing the effect and shader to draw
  18597. * @param world defines the world transformation matrix
  18598. * @param mesh defines the mesh containing the submesh
  18599. * @param subMesh defines the submesh to bind the material to
  18600. */
  18601. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  18602. /**
  18603. * Get the list of animatables in the material.
  18604. * @returns the list of animatables object used in the material
  18605. */
  18606. getAnimatables(): IAnimatable[];
  18607. /**
  18608. * Gets the active textures from the material
  18609. * @returns an array of textures
  18610. */
  18611. getActiveTextures(): BaseTexture[];
  18612. /**
  18613. * Specifies if the material uses a texture
  18614. * @param texture defines the texture to check against the material
  18615. * @returns a boolean specifying if the material uses the texture
  18616. */
  18617. hasTexture(texture: BaseTexture): boolean;
  18618. /**
  18619. * Disposes the material
  18620. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  18621. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  18622. */
  18623. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  18624. /**
  18625. * Makes a duplicate of the material, and gives it a new name
  18626. * @param name defines the new name for the duplicated material
  18627. * @returns the cloned material
  18628. */
  18629. clone(name: string): StandardMaterial;
  18630. /**
  18631. * Serializes this material in a JSON representation
  18632. * @returns the serialized material object
  18633. */
  18634. serialize(): any;
  18635. /**
  18636. * Creates a standard material from parsed material data
  18637. * @param source defines the JSON represnetation of the material
  18638. * @param scene defines the hosting scene
  18639. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  18640. * @returns a new material
  18641. */
  18642. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  18643. private static _DiffuseTextureEnabled;
  18644. /**
  18645. * Are diffuse textures enabled in the application.
  18646. */
  18647. static DiffuseTextureEnabled: boolean;
  18648. private static _AmbientTextureEnabled;
  18649. /**
  18650. * Are ambient textures enabled in the application.
  18651. */
  18652. static AmbientTextureEnabled: boolean;
  18653. private static _OpacityTextureEnabled;
  18654. /**
  18655. * Are opacity textures enabled in the application.
  18656. */
  18657. static OpacityTextureEnabled: boolean;
  18658. private static _ReflectionTextureEnabled;
  18659. /**
  18660. * Are reflection textures enabled in the application.
  18661. */
  18662. static ReflectionTextureEnabled: boolean;
  18663. private static _EmissiveTextureEnabled;
  18664. /**
  18665. * Are emissive textures enabled in the application.
  18666. */
  18667. static EmissiveTextureEnabled: boolean;
  18668. private static _SpecularTextureEnabled;
  18669. /**
  18670. * Are specular textures enabled in the application.
  18671. */
  18672. static SpecularTextureEnabled: boolean;
  18673. private static _BumpTextureEnabled;
  18674. /**
  18675. * Are bump textures enabled in the application.
  18676. */
  18677. static BumpTextureEnabled: boolean;
  18678. private static _LightmapTextureEnabled;
  18679. /**
  18680. * Are lightmap textures enabled in the application.
  18681. */
  18682. static LightmapTextureEnabled: boolean;
  18683. private static _RefractionTextureEnabled;
  18684. /**
  18685. * Are refraction textures enabled in the application.
  18686. */
  18687. static RefractionTextureEnabled: boolean;
  18688. private static _ColorGradingTextureEnabled;
  18689. /**
  18690. * Are color grading textures enabled in the application.
  18691. */
  18692. static ColorGradingTextureEnabled: boolean;
  18693. private static _FresnelEnabled;
  18694. /**
  18695. * Are fresnels enabled in the application.
  18696. */
  18697. static FresnelEnabled: boolean;
  18698. }
  18699. }
  18700. declare module BABYLON {
  18701. /**
  18702. * Uniform buffer objects.
  18703. *
  18704. * Handles blocks of uniform on the GPU.
  18705. *
  18706. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  18707. *
  18708. * For more information, please refer to :
  18709. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  18710. */
  18711. class UniformBuffer {
  18712. private _engine;
  18713. private _buffer;
  18714. private _data;
  18715. private _bufferData;
  18716. private _dynamic?;
  18717. private _uniformLocations;
  18718. private _uniformSizes;
  18719. private _uniformLocationPointer;
  18720. private _needSync;
  18721. private _noUBO;
  18722. private _currentEffect;
  18723. private static _MAX_UNIFORM_SIZE;
  18724. private static _tempBuffer;
  18725. /**
  18726. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  18727. * This is dynamic to allow compat with webgl 1 and 2.
  18728. * You will need to pass the name of the uniform as well as the value.
  18729. */
  18730. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  18731. /**
  18732. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  18733. * This is dynamic to allow compat with webgl 1 and 2.
  18734. * You will need to pass the name of the uniform as well as the value.
  18735. */
  18736. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  18737. /**
  18738. * Lambda to Update a single float in a uniform buffer.
  18739. * This is dynamic to allow compat with webgl 1 and 2.
  18740. * You will need to pass the name of the uniform as well as the value.
  18741. */
  18742. updateFloat: (name: string, x: number) => void;
  18743. /**
  18744. * Lambda to Update a vec2 of float in a uniform buffer.
  18745. * This is dynamic to allow compat with webgl 1 and 2.
  18746. * You will need to pass the name of the uniform as well as the value.
  18747. */
  18748. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  18749. /**
  18750. * Lambda to Update a vec3 of float in a uniform buffer.
  18751. * This is dynamic to allow compat with webgl 1 and 2.
  18752. * You will need to pass the name of the uniform as well as the value.
  18753. */
  18754. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  18755. /**
  18756. * Lambda to Update a vec4 of float in a uniform buffer.
  18757. * This is dynamic to allow compat with webgl 1 and 2.
  18758. * You will need to pass the name of the uniform as well as the value.
  18759. */
  18760. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  18761. /**
  18762. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  18763. * This is dynamic to allow compat with webgl 1 and 2.
  18764. * You will need to pass the name of the uniform as well as the value.
  18765. */
  18766. updateMatrix: (name: string, mat: Matrix) => void;
  18767. /**
  18768. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  18769. * This is dynamic to allow compat with webgl 1 and 2.
  18770. * You will need to pass the name of the uniform as well as the value.
  18771. */
  18772. updateVector3: (name: string, vector: Vector3) => void;
  18773. /**
  18774. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  18775. * This is dynamic to allow compat with webgl 1 and 2.
  18776. * You will need to pass the name of the uniform as well as the value.
  18777. */
  18778. updateVector4: (name: string, vector: Vector4) => void;
  18779. /**
  18780. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  18781. * This is dynamic to allow compat with webgl 1 and 2.
  18782. * You will need to pass the name of the uniform as well as the value.
  18783. */
  18784. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  18785. /**
  18786. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  18787. * This is dynamic to allow compat with webgl 1 and 2.
  18788. * You will need to pass the name of the uniform as well as the value.
  18789. */
  18790. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  18791. /**
  18792. * Instantiates a new Uniform buffer objects.
  18793. *
  18794. * Handles blocks of uniform on the GPU.
  18795. *
  18796. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  18797. *
  18798. * For more information, please refer to :
  18799. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  18800. * @param engine Define the engine the buffer is associated with
  18801. * @param data Define the data contained in the buffer
  18802. * @param dynamic Define if the buffer is updatable
  18803. */
  18804. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  18805. /**
  18806. * Indicates if the buffer is using the WebGL2 UBO implementation,
  18807. * or just falling back on setUniformXXX calls.
  18808. */
  18809. readonly useUbo: boolean;
  18810. /**
  18811. * Indicates if the WebGL underlying uniform buffer is in sync
  18812. * with the javascript cache data.
  18813. */
  18814. readonly isSync: boolean;
  18815. /**
  18816. * Indicates if the WebGL underlying uniform buffer is dynamic.
  18817. * Also, a dynamic UniformBuffer will disable cache verification and always
  18818. * update the underlying WebGL uniform buffer to the GPU.
  18819. * @returns if Dynamic, otherwise false
  18820. */
  18821. isDynamic(): boolean;
  18822. /**
  18823. * The data cache on JS side.
  18824. * @returns the underlying data as a float array
  18825. */
  18826. getData(): Float32Array;
  18827. /**
  18828. * The underlying WebGL Uniform buffer.
  18829. * @returns the webgl buffer
  18830. */
  18831. getBuffer(): Nullable<WebGLBuffer>;
  18832. /**
  18833. * std140 layout specifies how to align data within an UBO structure.
  18834. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  18835. * for specs.
  18836. */
  18837. private _fillAlignment;
  18838. /**
  18839. * Adds an uniform in the buffer.
  18840. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  18841. * for the layout to be correct !
  18842. * @param name Name of the uniform, as used in the uniform block in the shader.
  18843. * @param size Data size, or data directly.
  18844. */
  18845. addUniform(name: string, size: number | number[]): void;
  18846. /**
  18847. * Adds a Matrix 4x4 to the uniform buffer.
  18848. * @param name Name of the uniform, as used in the uniform block in the shader.
  18849. * @param mat A 4x4 matrix.
  18850. */
  18851. addMatrix(name: string, mat: Matrix): void;
  18852. /**
  18853. * Adds a vec2 to the uniform buffer.
  18854. * @param name Name of the uniform, as used in the uniform block in the shader.
  18855. * @param x Define the x component value of the vec2
  18856. * @param y Define the y component value of the vec2
  18857. */
  18858. addFloat2(name: string, x: number, y: number): void;
  18859. /**
  18860. * Adds a vec3 to the uniform buffer.
  18861. * @param name Name of the uniform, as used in the uniform block in the shader.
  18862. * @param x Define the x component value of the vec3
  18863. * @param y Define the y component value of the vec3
  18864. * @param z Define the z component value of the vec3
  18865. */
  18866. addFloat3(name: string, x: number, y: number, z: number): void;
  18867. /**
  18868. * Adds a vec3 to the uniform buffer.
  18869. * @param name Name of the uniform, as used in the uniform block in the shader.
  18870. * @param color Define the vec3 from a Color
  18871. */
  18872. addColor3(name: string, color: Color3): void;
  18873. /**
  18874. * Adds a vec4 to the uniform buffer.
  18875. * @param name Name of the uniform, as used in the uniform block in the shader.
  18876. * @param color Define the rgb components from a Color
  18877. * @param alpha Define the a component of the vec4
  18878. */
  18879. addColor4(name: string, color: Color3, alpha: number): void;
  18880. /**
  18881. * Adds a vec3 to the uniform buffer.
  18882. * @param name Name of the uniform, as used in the uniform block in the shader.
  18883. * @param vector Define the vec3 components from a Vector
  18884. */
  18885. addVector3(name: string, vector: Vector3): void;
  18886. /**
  18887. * Adds a Matrix 3x3 to the uniform buffer.
  18888. * @param name Name of the uniform, as used in the uniform block in the shader.
  18889. */
  18890. addMatrix3x3(name: string): void;
  18891. /**
  18892. * Adds a Matrix 2x2 to the uniform buffer.
  18893. * @param name Name of the uniform, as used in the uniform block in the shader.
  18894. */
  18895. addMatrix2x2(name: string): void;
  18896. /**
  18897. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  18898. */
  18899. create(): void;
  18900. /** @hidden */
  18901. /**
  18902. * Updates the WebGL Uniform Buffer on the GPU.
  18903. * If the `dynamic` flag is set to true, no cache comparison is done.
  18904. * Otherwise, the buffer will be updated only if the cache differs.
  18905. */
  18906. update(): void;
  18907. /**
  18908. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  18909. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  18910. * @param data Define the flattened data
  18911. * @param size Define the size of the data.
  18912. */
  18913. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  18914. private _updateMatrix3x3ForUniform;
  18915. private _updateMatrix3x3ForEffect;
  18916. private _updateMatrix2x2ForEffect;
  18917. private _updateMatrix2x2ForUniform;
  18918. private _updateFloatForEffect;
  18919. private _updateFloatForUniform;
  18920. private _updateFloat2ForEffect;
  18921. private _updateFloat2ForUniform;
  18922. private _updateFloat3ForEffect;
  18923. private _updateFloat3ForUniform;
  18924. private _updateFloat4ForEffect;
  18925. private _updateFloat4ForUniform;
  18926. private _updateMatrixForEffect;
  18927. private _updateMatrixForUniform;
  18928. private _updateVector3ForEffect;
  18929. private _updateVector3ForUniform;
  18930. private _updateVector4ForEffect;
  18931. private _updateVector4ForUniform;
  18932. private _updateColor3ForEffect;
  18933. private _updateColor3ForUniform;
  18934. private _updateColor4ForEffect;
  18935. private _updateColor4ForUniform;
  18936. /**
  18937. * Sets a sampler uniform on the effect.
  18938. * @param name Define the name of the sampler.
  18939. * @param texture Define the texture to set in the sampler
  18940. */
  18941. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  18942. /**
  18943. * Directly updates the value of the uniform in the cache AND on the GPU.
  18944. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  18945. * @param data Define the flattened data
  18946. */
  18947. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  18948. /**
  18949. * Binds this uniform buffer to an effect.
  18950. * @param effect Define the effect to bind the buffer to
  18951. * @param name Name of the uniform block in the shader.
  18952. */
  18953. bindToEffect(effect: Effect, name: string): void;
  18954. /**
  18955. * Disposes the uniform buffer.
  18956. */
  18957. dispose(): void;
  18958. }
  18959. }
  18960. declare module BABYLON {
  18961. /**
  18962. * Scalar computation library
  18963. */
  18964. class Scalar {
  18965. /**
  18966. * Two pi constants convenient for computation.
  18967. */
  18968. static TwoPi: number;
  18969. /**
  18970. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  18971. * @param a number
  18972. * @param b number
  18973. * @param epsilon (default = 1.401298E-45)
  18974. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  18975. */
  18976. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  18977. /**
  18978. * Returns a string : the upper case translation of the number i to hexadecimal.
  18979. * @param i number
  18980. * @returns the upper case translation of the number i to hexadecimal.
  18981. */
  18982. static ToHex(i: number): string;
  18983. /**
  18984. * Returns -1 if value is negative and +1 is value is positive.
  18985. * @param value the value
  18986. * @returns the value itself if it's equal to zero.
  18987. */
  18988. static Sign(value: number): number;
  18989. /**
  18990. * Returns the value itself if it's between min and max.
  18991. * Returns min if the value is lower than min.
  18992. * Returns max if the value is greater than max.
  18993. * @param value the value to clmap
  18994. * @param min the min value to clamp to (default: 0)
  18995. * @param max the max value to clamp to (default: 1)
  18996. * @returns the clamped value
  18997. */
  18998. static Clamp(value: number, min?: number, max?: number): number;
  18999. /**
  19000. * the log2 of value.
  19001. * @param value the value to compute log2 of
  19002. * @returns the log2 of value.
  19003. */
  19004. static Log2(value: number): number;
  19005. /**
  19006. * Loops the value, so that it is never larger than length and never smaller than 0.
  19007. *
  19008. * This is similar to the modulo operator but it works with floating point numbers.
  19009. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  19010. * With t = 5 and length = 2.5, the result would be 0.0.
  19011. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  19012. * @param value the value
  19013. * @param length the length
  19014. * @returns the looped value
  19015. */
  19016. static Repeat(value: number, length: number): number;
  19017. /**
  19018. * Normalize the value between 0.0 and 1.0 using min and max values
  19019. * @param value value to normalize
  19020. * @param min max to normalize between
  19021. * @param max min to normalize between
  19022. * @returns the normalized value
  19023. */
  19024. static Normalize(value: number, min: number, max: number): number;
  19025. /**
  19026. * Denormalize the value from 0.0 and 1.0 using min and max values
  19027. * @param normalized value to denormalize
  19028. * @param min max to denormalize between
  19029. * @param max min to denormalize between
  19030. * @returns the denormalized value
  19031. */
  19032. static Denormalize(normalized: number, min: number, max: number): number;
  19033. /**
  19034. * Calculates the shortest difference between two given angles given in degrees.
  19035. * @param current current angle in degrees
  19036. * @param target target angle in degrees
  19037. * @returns the delta
  19038. */
  19039. static DeltaAngle(current: number, target: number): number;
  19040. /**
  19041. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  19042. * @param tx value
  19043. * @param length length
  19044. * @returns The returned value will move back and forth between 0 and length
  19045. */
  19046. static PingPong(tx: number, length: number): number;
  19047. /**
  19048. * Interpolates between min and max with smoothing at the limits.
  19049. *
  19050. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  19051. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  19052. * @param from from
  19053. * @param to to
  19054. * @param tx value
  19055. * @returns the smooth stepped value
  19056. */
  19057. static SmoothStep(from: number, to: number, tx: number): number;
  19058. /**
  19059. * Moves a value current towards target.
  19060. *
  19061. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  19062. * Negative values of maxDelta pushes the value away from target.
  19063. * @param current current value
  19064. * @param target target value
  19065. * @param maxDelta max distance to move
  19066. * @returns resulting value
  19067. */
  19068. static MoveTowards(current: number, target: number, maxDelta: number): number;
  19069. /**
  19070. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  19071. *
  19072. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  19073. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  19074. * @param current current value
  19075. * @param target target value
  19076. * @param maxDelta max distance to move
  19077. * @returns resulting angle
  19078. */
  19079. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  19080. /**
  19081. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  19082. * @param start start value
  19083. * @param end target value
  19084. * @param amount amount to lerp between
  19085. * @returns the lerped value
  19086. */
  19087. static Lerp(start: number, end: number, amount: number): number;
  19088. /**
  19089. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  19090. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  19091. * @param start start value
  19092. * @param end target value
  19093. * @param amount amount to lerp between
  19094. * @returns the lerped value
  19095. */
  19096. static LerpAngle(start: number, end: number, amount: number): number;
  19097. /**
  19098. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  19099. * @param a start value
  19100. * @param b target value
  19101. * @param value value between a and b
  19102. * @returns the inverseLerp value
  19103. */
  19104. static InverseLerp(a: number, b: number, value: number): number;
  19105. /**
  19106. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  19107. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  19108. * @param value1 spline value
  19109. * @param tangent1 spline value
  19110. * @param value2 spline value
  19111. * @param tangent2 spline value
  19112. * @param amount input value
  19113. * @returns hermite result
  19114. */
  19115. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  19116. /**
  19117. * Returns a random float number between and min and max values
  19118. * @param min min value of random
  19119. * @param max max value of random
  19120. * @returns random value
  19121. */
  19122. static RandomRange(min: number, max: number): number;
  19123. /**
  19124. * This function returns percentage of a number in a given range.
  19125. *
  19126. * RangeToPercent(40,20,60) will return 0.5 (50%)
  19127. * RangeToPercent(34,0,100) will return 0.34 (34%)
  19128. * @param number to convert to percentage
  19129. * @param min min range
  19130. * @param max max range
  19131. * @returns the percentage
  19132. */
  19133. static RangeToPercent(number: number, min: number, max: number): number;
  19134. /**
  19135. * This function returns number that corresponds to the percentage in a given range.
  19136. *
  19137. * PercentToRange(0.34,0,100) will return 34.
  19138. * @param percent to convert to number
  19139. * @param min min range
  19140. * @param max max range
  19141. * @returns the number
  19142. */
  19143. static PercentToRange(percent: number, min: number, max: number): number;
  19144. /**
  19145. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  19146. * @param angle The angle to normalize in radian.
  19147. * @return The converted angle.
  19148. */
  19149. static NormalizeRadians(angle: number): number;
  19150. }
  19151. }
  19152. declare module BABYLON {
  19153. /**
  19154. * Constant used to convert a value to gamma space
  19155. * @ignorenaming
  19156. */
  19157. const ToGammaSpace: number;
  19158. /**
  19159. * Constant used to convert a value to linear space
  19160. * @ignorenaming
  19161. */
  19162. const ToLinearSpace = 2.2;
  19163. /**
  19164. * Constant used to define the minimal number value in Babylon.js
  19165. * @ignorenaming
  19166. */
  19167. const Epsilon = 0.001;
  19168. /**
  19169. * Class used to hold a RBG color
  19170. */
  19171. class Color3 {
  19172. /**
  19173. * Defines the red component (between 0 and 1, default is 0)
  19174. */
  19175. r: number;
  19176. /**
  19177. * Defines the green component (between 0 and 1, default is 0)
  19178. */
  19179. g: number;
  19180. /**
  19181. * Defines the blue component (between 0 and 1, default is 0)
  19182. */
  19183. b: number;
  19184. /**
  19185. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  19186. * @param r defines the red component (between 0 and 1, default is 0)
  19187. * @param g defines the green component (between 0 and 1, default is 0)
  19188. * @param b defines the blue component (between 0 and 1, default is 0)
  19189. */
  19190. constructor(
  19191. /**
  19192. * Defines the red component (between 0 and 1, default is 0)
  19193. */
  19194. r?: number,
  19195. /**
  19196. * Defines the green component (between 0 and 1, default is 0)
  19197. */
  19198. g?: number,
  19199. /**
  19200. * Defines the blue component (between 0 and 1, default is 0)
  19201. */
  19202. b?: number);
  19203. /**
  19204. * Creates a string with the Color3 current values
  19205. * @returns the string representation of the Color3 object
  19206. */
  19207. toString(): string;
  19208. /**
  19209. * Returns the string "Color3"
  19210. * @returns "Color3"
  19211. */
  19212. getClassName(): string;
  19213. /**
  19214. * Compute the Color3 hash code
  19215. * @returns an unique number that can be used to hash Color3 objects
  19216. */
  19217. getHashCode(): number;
  19218. /**
  19219. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  19220. * @param array defines the array where to store the r,g,b components
  19221. * @param index defines an optional index in the target array to define where to start storing values
  19222. * @returns the current Color3 object
  19223. */
  19224. toArray(array: FloatArray, index?: number): Color3;
  19225. /**
  19226. * Returns a new Color4 object from the current Color3 and the given alpha
  19227. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  19228. * @returns a new Color4 object
  19229. */
  19230. toColor4(alpha?: number): Color4;
  19231. /**
  19232. * Returns a new array populated with 3 numeric elements : red, green and blue values
  19233. * @returns the new array
  19234. */
  19235. asArray(): number[];
  19236. /**
  19237. * Returns the luminance value
  19238. * @returns a float value
  19239. */
  19240. toLuminance(): number;
  19241. /**
  19242. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  19243. * @param otherColor defines the second operand
  19244. * @returns the new Color3 object
  19245. */
  19246. multiply(otherColor: Color3): Color3;
  19247. /**
  19248. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  19249. * @param otherColor defines the second operand
  19250. * @param result defines the Color3 object where to store the result
  19251. * @returns the current Color3
  19252. */
  19253. multiplyToRef(otherColor: Color3, result: Color3): Color3;
  19254. /**
  19255. * Determines equality between Color3 objects
  19256. * @param otherColor defines the second operand
  19257. * @returns true if the rgb values are equal to the given ones
  19258. */
  19259. equals(otherColor: Color3): boolean;
  19260. /**
  19261. * Determines equality between the current Color3 object and a set of r,b,g values
  19262. * @param r defines the red component to check
  19263. * @param g defines the green component to check
  19264. * @param b defines the blue component to check
  19265. * @returns true if the rgb values are equal to the given ones
  19266. */
  19267. equalsFloats(r: number, g: number, b: number): boolean;
  19268. /**
  19269. * Multiplies in place each rgb value by scale
  19270. * @param scale defines the scaling factor
  19271. * @returns the updated Color3
  19272. */
  19273. scale(scale: number): Color3;
  19274. /**
  19275. * Multiplies the rgb values by scale and stores the result into "result"
  19276. * @param scale defines the scaling factor
  19277. * @param result defines the Color3 object where to store the result
  19278. * @returns the unmodified current Color3
  19279. */
  19280. scaleToRef(scale: number, result: Color3): Color3;
  19281. /**
  19282. * Scale the current Color3 values by a factor and add the result to a given Color3
  19283. * @param scale defines the scale factor
  19284. * @param result defines color to store the result into
  19285. * @returns the unmodified current Color3
  19286. */
  19287. scaleAndAddToRef(scale: number, result: Color3): Color3;
  19288. /**
  19289. * Clamps the rgb values by the min and max values and stores the result into "result"
  19290. * @param min defines minimum clamping value (default is 0)
  19291. * @param max defines maximum clamping value (default is 1)
  19292. * @param result defines color to store the result into
  19293. * @returns the original Color3
  19294. */
  19295. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  19296. /**
  19297. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  19298. * @param otherColor defines the second operand
  19299. * @returns the new Color3
  19300. */
  19301. add(otherColor: Color3): Color3;
  19302. /**
  19303. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  19304. * @param otherColor defines the second operand
  19305. * @param result defines Color3 object to store the result into
  19306. * @returns the unmodified current Color3
  19307. */
  19308. addToRef(otherColor: Color3, result: Color3): Color3;
  19309. /**
  19310. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  19311. * @param otherColor defines the second operand
  19312. * @returns the new Color3
  19313. */
  19314. subtract(otherColor: Color3): Color3;
  19315. /**
  19316. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  19317. * @param otherColor defines the second operand
  19318. * @param result defines Color3 object to store the result into
  19319. * @returns the unmodified current Color3
  19320. */
  19321. subtractToRef(otherColor: Color3, result: Color3): Color3;
  19322. /**
  19323. * Copy the current object
  19324. * @returns a new Color3 copied the current one
  19325. */
  19326. clone(): Color3;
  19327. /**
  19328. * Copies the rgb values from the source in the current Color3
  19329. * @param source defines the source Color3 object
  19330. * @returns the updated Color3 object
  19331. */
  19332. copyFrom(source: Color3): Color3;
  19333. /**
  19334. * Updates the Color3 rgb values from the given floats
  19335. * @param r defines the red component to read from
  19336. * @param g defines the green component to read from
  19337. * @param b defines the blue component to read from
  19338. * @returns the current Color3 object
  19339. */
  19340. copyFromFloats(r: number, g: number, b: number): Color3;
  19341. /**
  19342. * Updates the Color3 rgb values from the given floats
  19343. * @param r defines the red component to read from
  19344. * @param g defines the green component to read from
  19345. * @param b defines the blue component to read from
  19346. * @returns the current Color3 object
  19347. */
  19348. set(r: number, g: number, b: number): Color3;
  19349. /**
  19350. * Compute the Color3 hexadecimal code as a string
  19351. * @returns a string containing the hexadecimal representation of the Color3 object
  19352. */
  19353. toHexString(): string;
  19354. /**
  19355. * Computes a new Color3 converted from the current one to linear space
  19356. * @returns a new Color3 object
  19357. */
  19358. toLinearSpace(): Color3;
  19359. /**
  19360. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  19361. * @param convertedColor defines the Color3 object where to store the linear space version
  19362. * @returns the unmodified Color3
  19363. */
  19364. toLinearSpaceToRef(convertedColor: Color3): Color3;
  19365. /**
  19366. * Computes a new Color3 converted from the current one to gamma space
  19367. * @returns a new Color3 object
  19368. */
  19369. toGammaSpace(): Color3;
  19370. /**
  19371. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  19372. * @param convertedColor defines the Color3 object where to store the gamma space version
  19373. * @returns the unmodified Color3
  19374. */
  19375. toGammaSpaceToRef(convertedColor: Color3): Color3;
  19376. /**
  19377. * Creates a new Color3 from the string containing valid hexadecimal values
  19378. * @param hex defines a string containing valid hexadecimal values
  19379. * @returns a new Color3 object
  19380. */
  19381. static FromHexString(hex: string): Color3;
  19382. /**
  19383. * Creates a new Vector3 from the starting index of the given array
  19384. * @param array defines the source array
  19385. * @param offset defines an offset in the source array
  19386. * @returns a new Color3 object
  19387. */
  19388. static FromArray(array: ArrayLike<number>, offset?: number): Color3;
  19389. /**
  19390. * Creates a new Color3 from integer values (< 256)
  19391. * @param r defines the red component to read from (value between 0 and 255)
  19392. * @param g defines the green component to read from (value between 0 and 255)
  19393. * @param b defines the blue component to read from (value between 0 and 255)
  19394. * @returns a new Color3 object
  19395. */
  19396. static FromInts(r: number, g: number, b: number): Color3;
  19397. /**
  19398. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  19399. * @param start defines the start Color3 value
  19400. * @param end defines the end Color3 value
  19401. * @param amount defines the gradient value between start and end
  19402. * @returns a new Color3 object
  19403. */
  19404. static Lerp(start: Color3, end: Color3, amount: number): Color3;
  19405. /**
  19406. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  19407. * @param left defines the start value
  19408. * @param right defines the end value
  19409. * @param amount defines the gradient factor
  19410. * @param result defines the Color3 object where to store the result
  19411. */
  19412. static LerpToRef(left: Color3, right: Color3, amount: number, result: Color3): void;
  19413. /**
  19414. * Returns a Color3 value containing a red color
  19415. * @returns a new Color3 object
  19416. */
  19417. static Red(): Color3;
  19418. /**
  19419. * Returns a Color3 value containing a green color
  19420. * @returns a new Color3 object
  19421. */
  19422. static Green(): Color3;
  19423. /**
  19424. * Returns a Color3 value containing a blue color
  19425. * @returns a new Color3 object
  19426. */
  19427. static Blue(): Color3;
  19428. /**
  19429. * Returns a Color3 value containing a black color
  19430. * @returns a new Color3 object
  19431. */
  19432. static Black(): Color3;
  19433. /**
  19434. * Returns a Color3 value containing a white color
  19435. * @returns a new Color3 object
  19436. */
  19437. static White(): Color3;
  19438. /**
  19439. * Returns a Color3 value containing a purple color
  19440. * @returns a new Color3 object
  19441. */
  19442. static Purple(): Color3;
  19443. /**
  19444. * Returns a Color3 value containing a magenta color
  19445. * @returns a new Color3 object
  19446. */
  19447. static Magenta(): Color3;
  19448. /**
  19449. * Returns a Color3 value containing a yellow color
  19450. * @returns a new Color3 object
  19451. */
  19452. static Yellow(): Color3;
  19453. /**
  19454. * Returns a Color3 value containing a gray color
  19455. * @returns a new Color3 object
  19456. */
  19457. static Gray(): Color3;
  19458. /**
  19459. * Returns a Color3 value containing a teal color
  19460. * @returns a new Color3 object
  19461. */
  19462. static Teal(): Color3;
  19463. /**
  19464. * Returns a Color3 value containing a random color
  19465. * @returns a new Color3 object
  19466. */
  19467. static Random(): Color3;
  19468. }
  19469. /**
  19470. * Class used to hold a RBGA color
  19471. */
  19472. class Color4 {
  19473. /**
  19474. * Defines the red component (between 0 and 1, default is 0)
  19475. */
  19476. r: number;
  19477. /**
  19478. * Defines the green component (between 0 and 1, default is 0)
  19479. */
  19480. g: number;
  19481. /**
  19482. * Defines the blue component (between 0 and 1, default is 0)
  19483. */
  19484. b: number;
  19485. /**
  19486. * Defines the alpha component (between 0 and 1, default is 1)
  19487. */
  19488. a: number;
  19489. /**
  19490. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  19491. * @param r defines the red component (between 0 and 1, default is 0)
  19492. * @param g defines the green component (between 0 and 1, default is 0)
  19493. * @param b defines the blue component (between 0 and 1, default is 0)
  19494. * @param a defines the alpha component (between 0 and 1, default is 1)
  19495. */
  19496. constructor(
  19497. /**
  19498. * Defines the red component (between 0 and 1, default is 0)
  19499. */
  19500. r?: number,
  19501. /**
  19502. * Defines the green component (between 0 and 1, default is 0)
  19503. */
  19504. g?: number,
  19505. /**
  19506. * Defines the blue component (between 0 and 1, default is 0)
  19507. */
  19508. b?: number,
  19509. /**
  19510. * Defines the alpha component (between 0 and 1, default is 1)
  19511. */
  19512. a?: number);
  19513. /**
  19514. * Adds in place the given Color4 values to the current Color4 object
  19515. * @param right defines the second operand
  19516. * @returns the current updated Color4 object
  19517. */
  19518. addInPlace(right: Color4): Color4;
  19519. /**
  19520. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  19521. * @returns the new array
  19522. */
  19523. asArray(): number[];
  19524. /**
  19525. * Stores from the starting index in the given array the Color4 successive values
  19526. * @param array defines the array where to store the r,g,b components
  19527. * @param index defines an optional index in the target array to define where to start storing values
  19528. * @returns the current Color4 object
  19529. */
  19530. toArray(array: number[], index?: number): Color4;
  19531. /**
  19532. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  19533. * @param right defines the second operand
  19534. * @returns a new Color4 object
  19535. */
  19536. add(right: Color4): Color4;
  19537. /**
  19538. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  19539. * @param right defines the second operand
  19540. * @returns a new Color4 object
  19541. */
  19542. subtract(right: Color4): Color4;
  19543. /**
  19544. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  19545. * @param right defines the second operand
  19546. * @param result defines the Color4 object where to store the result
  19547. * @returns the current Color4 object
  19548. */
  19549. subtractToRef(right: Color4, result: Color4): Color4;
  19550. /**
  19551. * Creates a new Color4 with the current Color4 values multiplied by scale
  19552. * @param scale defines the scaling factor to apply
  19553. * @returns a new Color4 object
  19554. */
  19555. scale(scale: number): Color4;
  19556. /**
  19557. * Multiplies the current Color4 values by scale and stores the result in "result"
  19558. * @param scale defines the scaling factor to apply
  19559. * @param result defines the Color4 object where to store the result
  19560. * @returns the current unmodified Color4
  19561. */
  19562. scaleToRef(scale: number, result: Color4): Color4;
  19563. /**
  19564. * Scale the current Color4 values by a factor and add the result to a given Color4
  19565. * @param scale defines the scale factor
  19566. * @param result defines the Color4 object where to store the result
  19567. * @returns the unmodified current Color4
  19568. */
  19569. scaleAndAddToRef(scale: number, result: Color4): Color4;
  19570. /**
  19571. * Clamps the rgb values by the min and max values and stores the result into "result"
  19572. * @param min defines minimum clamping value (default is 0)
  19573. * @param max defines maximum clamping value (default is 1)
  19574. * @param result defines color to store the result into.
  19575. * @returns the cuurent Color4
  19576. */
  19577. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  19578. /**
  19579. * Multipy an Color4 value by another and return a new Color4 object
  19580. * @param color defines the Color4 value to multiply by
  19581. * @returns a new Color4 object
  19582. */
  19583. multiply(color: Color4): Color4;
  19584. /**
  19585. * Multipy a Color4 value by another and push the result in a reference value
  19586. * @param color defines the Color4 value to multiply by
  19587. * @param result defines the Color4 to fill the result in
  19588. * @returns the result Color4
  19589. */
  19590. multiplyToRef(color: Color4, result: Color4): Color4;
  19591. /**
  19592. * Creates a string with the Color4 current values
  19593. * @returns the string representation of the Color4 object
  19594. */
  19595. toString(): string;
  19596. /**
  19597. * Returns the string "Color4"
  19598. * @returns "Color4"
  19599. */
  19600. getClassName(): string;
  19601. /**
  19602. * Compute the Color4 hash code
  19603. * @returns an unique number that can be used to hash Color4 objects
  19604. */
  19605. getHashCode(): number;
  19606. /**
  19607. * Creates a new Color4 copied from the current one
  19608. * @returns a new Color4 object
  19609. */
  19610. clone(): Color4;
  19611. /**
  19612. * Copies the given Color4 values into the current one
  19613. * @param source defines the source Color4 object
  19614. * @returns the current updated Color4 object
  19615. */
  19616. copyFrom(source: Color4): Color4;
  19617. /**
  19618. * Copies the given float values into the current one
  19619. * @param r defines the red component to read from
  19620. * @param g defines the green component to read from
  19621. * @param b defines the blue component to read from
  19622. * @param a defines the alpha component to read from
  19623. * @returns the current updated Color4 object
  19624. */
  19625. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  19626. /**
  19627. * Copies the given float values into the current one
  19628. * @param r defines the red component to read from
  19629. * @param g defines the green component to read from
  19630. * @param b defines the blue component to read from
  19631. * @param a defines the alpha component to read from
  19632. * @returns the current updated Color4 object
  19633. */
  19634. set(r: number, g: number, b: number, a: number): Color4;
  19635. /**
  19636. * Compute the Color4 hexadecimal code as a string
  19637. * @returns a string containing the hexadecimal representation of the Color4 object
  19638. */
  19639. toHexString(): string;
  19640. /**
  19641. * Computes a new Color4 converted from the current one to linear space
  19642. * @returns a new Color4 object
  19643. */
  19644. toLinearSpace(): Color4;
  19645. /**
  19646. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  19647. * @param convertedColor defines the Color4 object where to store the linear space version
  19648. * @returns the unmodified Color4
  19649. */
  19650. toLinearSpaceToRef(convertedColor: Color4): Color4;
  19651. /**
  19652. * Computes a new Color4 converted from the current one to gamma space
  19653. * @returns a new Color4 object
  19654. */
  19655. toGammaSpace(): Color4;
  19656. /**
  19657. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  19658. * @param convertedColor defines the Color4 object where to store the gamma space version
  19659. * @returns the unmodified Color4
  19660. */
  19661. toGammaSpaceToRef(convertedColor: Color4): Color4;
  19662. /**
  19663. * Creates a new Color4 from the string containing valid hexadecimal values
  19664. * @param hex defines a string containing valid hexadecimal values
  19665. * @returns a new Color4 object
  19666. */
  19667. static FromHexString(hex: string): Color4;
  19668. /**
  19669. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  19670. * @param left defines the start value
  19671. * @param right defines the end value
  19672. * @param amount defines the gradient factor
  19673. * @returns a new Color4 object
  19674. */
  19675. static Lerp(left: Color4, right: Color4, amount: number): Color4;
  19676. /**
  19677. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  19678. * @param left defines the start value
  19679. * @param right defines the end value
  19680. * @param amount defines the gradient factor
  19681. * @param result defines the Color4 object where to store data
  19682. */
  19683. static LerpToRef(left: Color4, right: Color4, amount: number, result: Color4): void;
  19684. /**
  19685. * Creates a new Color4 from a Color3 and an alpha value
  19686. * @param color3 defines the source Color3 to read from
  19687. * @param alpha defines the alpha component (1.0 by default)
  19688. * @returns a new Color4 object
  19689. */
  19690. static FromColor3(color3: Color3, alpha?: number): Color4;
  19691. /**
  19692. * Creates a new Color4 from the starting index element of the given array
  19693. * @param array defines the source array to read from
  19694. * @param offset defines the offset in the source array
  19695. * @returns a new Color4 object
  19696. */
  19697. static FromArray(array: ArrayLike<number>, offset?: number): Color4;
  19698. /**
  19699. * Creates a new Color3 from integer values (< 256)
  19700. * @param r defines the red component to read from (value between 0 and 255)
  19701. * @param g defines the green component to read from (value between 0 and 255)
  19702. * @param b defines the blue component to read from (value between 0 and 255)
  19703. * @param a defines the alpha component to read from (value between 0 and 255)
  19704. * @returns a new Color3 object
  19705. */
  19706. static FromInts(r: number, g: number, b: number, a: number): Color4;
  19707. /**
  19708. * Check the content of a given array and convert it to an array containing RGBA data
  19709. * If the original array was already containing count * 4 values then it is returned directly
  19710. * @param colors defines the array to check
  19711. * @param count defines the number of RGBA data to expect
  19712. * @returns an array containing count * 4 values (RGBA)
  19713. */
  19714. static CheckColors4(colors: number[], count: number): number[];
  19715. }
  19716. /**
  19717. * Class representing a vector containing 2 coordinates
  19718. */
  19719. class Vector2 {
  19720. /** defines the first coordinate */
  19721. x: number;
  19722. /** defines the second coordinate */
  19723. y: number;
  19724. /**
  19725. * Creates a new Vector2 from the given x and y coordinates
  19726. * @param x defines the first coordinate
  19727. * @param y defines the second coordinate
  19728. */
  19729. constructor(
  19730. /** defines the first coordinate */
  19731. x?: number,
  19732. /** defines the second coordinate */
  19733. y?: number);
  19734. /**
  19735. * Gets a string with the Vector2 coordinates
  19736. * @returns a string with the Vector2 coordinates
  19737. */
  19738. toString(): string;
  19739. /**
  19740. * Gets class name
  19741. * @returns the string "Vector2"
  19742. */
  19743. getClassName(): string;
  19744. /**
  19745. * Gets current vector hash code
  19746. * @returns the Vector2 hash code as a number
  19747. */
  19748. getHashCode(): number;
  19749. /**
  19750. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  19751. * @param array defines the source array
  19752. * @param index defines the offset in source array
  19753. * @returns the current Vector2
  19754. */
  19755. toArray(array: FloatArray, index?: number): Vector2;
  19756. /**
  19757. * Copy the current vector to an array
  19758. * @returns a new array with 2 elements: the Vector2 coordinates.
  19759. */
  19760. asArray(): number[];
  19761. /**
  19762. * Sets the Vector2 coordinates with the given Vector2 coordinates
  19763. * @param source defines the source Vector2
  19764. * @returns the current updated Vector2
  19765. */
  19766. copyFrom(source: Vector2): Vector2;
  19767. /**
  19768. * Sets the Vector2 coordinates with the given floats
  19769. * @param x defines the first coordinate
  19770. * @param y defines the second coordinate
  19771. * @returns the current updated Vector2
  19772. */
  19773. copyFromFloats(x: number, y: number): Vector2;
  19774. /**
  19775. * Sets the Vector2 coordinates with the given floats
  19776. * @param x defines the first coordinate
  19777. * @param y defines the second coordinate
  19778. * @returns the current updated Vector2
  19779. */
  19780. set(x: number, y: number): Vector2;
  19781. /**
  19782. * Add another vector with the current one
  19783. * @param otherVector defines the other vector
  19784. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  19785. */
  19786. add(otherVector: Vector2): Vector2;
  19787. /**
  19788. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  19789. * @param otherVector defines the other vector
  19790. * @param result defines the target vector
  19791. * @returns the unmodified current Vector2
  19792. */
  19793. addToRef(otherVector: Vector2, result: Vector2): Vector2;
  19794. /**
  19795. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  19796. * @param otherVector defines the other vector
  19797. * @returns the current updated Vector2
  19798. */
  19799. addInPlace(otherVector: Vector2): Vector2;
  19800. /**
  19801. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  19802. * @param otherVector defines the other vector
  19803. * @returns a new Vector2
  19804. */
  19805. addVector3(otherVector: Vector3): Vector2;
  19806. /**
  19807. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  19808. * @param otherVector defines the other vector
  19809. * @returns a new Vector2
  19810. */
  19811. subtract(otherVector: Vector2): Vector2;
  19812. /**
  19813. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  19814. * @param otherVector defines the other vector
  19815. * @param result defines the target vector
  19816. * @returns the unmodified current Vector2
  19817. */
  19818. subtractToRef(otherVector: Vector2, result: Vector2): Vector2;
  19819. /**
  19820. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  19821. * @param otherVector defines the other vector
  19822. * @returns the current updated Vector2
  19823. */
  19824. subtractInPlace(otherVector: Vector2): Vector2;
  19825. /**
  19826. * Multiplies in place the current Vector2 coordinates by the given ones
  19827. * @param otherVector defines the other vector
  19828. * @returns the current updated Vector2
  19829. */
  19830. multiplyInPlace(otherVector: Vector2): Vector2;
  19831. /**
  19832. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  19833. * @param otherVector defines the other vector
  19834. * @returns a new Vector2
  19835. */
  19836. multiply(otherVector: Vector2): Vector2;
  19837. /**
  19838. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  19839. * @param otherVector defines the other vector
  19840. * @param result defines the target vector
  19841. * @returns the unmodified current Vector2
  19842. */
  19843. multiplyToRef(otherVector: Vector2, result: Vector2): Vector2;
  19844. /**
  19845. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  19846. * @param x defines the first coordinate
  19847. * @param y defines the second coordinate
  19848. * @returns a new Vector2
  19849. */
  19850. multiplyByFloats(x: number, y: number): Vector2;
  19851. /**
  19852. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  19853. * @param otherVector defines the other vector
  19854. * @returns a new Vector2
  19855. */
  19856. divide(otherVector: Vector2): Vector2;
  19857. /**
  19858. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  19859. * @param otherVector defines the other vector
  19860. * @param result defines the target vector
  19861. * @returns the unmodified current Vector2
  19862. */
  19863. divideToRef(otherVector: Vector2, result: Vector2): Vector2;
  19864. /**
  19865. * Divides the current Vector2 coordinates by the given ones
  19866. * @param otherVector defines the other vector
  19867. * @returns the current updated Vector2
  19868. */
  19869. divideInPlace(otherVector: Vector2): Vector2;
  19870. /**
  19871. * Gets a new Vector2 with current Vector2 negated coordinates
  19872. * @returns a new Vector2
  19873. */
  19874. negate(): Vector2;
  19875. /**
  19876. * Multiply the Vector2 coordinates by scale
  19877. * @param scale defines the scaling factor
  19878. * @returns the current updated Vector2
  19879. */
  19880. scaleInPlace(scale: number): Vector2;
  19881. /**
  19882. * Returns a new Vector2 scaled by "scale" from the current Vector2
  19883. * @param scale defines the scaling factor
  19884. * @returns a new Vector2
  19885. */
  19886. scale(scale: number): Vector2;
  19887. /**
  19888. * Scale the current Vector2 values by a factor to a given Vector2
  19889. * @param scale defines the scale factor
  19890. * @param result defines the Vector2 object where to store the result
  19891. * @returns the unmodified current Vector2
  19892. */
  19893. scaleToRef(scale: number, result: Vector2): Vector2;
  19894. /**
  19895. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  19896. * @param scale defines the scale factor
  19897. * @param result defines the Vector2 object where to store the result
  19898. * @returns the unmodified current Vector2
  19899. */
  19900. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  19901. /**
  19902. * Gets a boolean if two vectors are equals
  19903. * @param otherVector defines the other vector
  19904. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  19905. */
  19906. equals(otherVector: Vector2): boolean;
  19907. /**
  19908. * Gets a boolean if two vectors are equals (using an epsilon value)
  19909. * @param otherVector defines the other vector
  19910. * @param epsilon defines the minimal distance to consider equality
  19911. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  19912. */
  19913. equalsWithEpsilon(otherVector: Vector2, epsilon?: number): boolean;
  19914. /**
  19915. * Gets a new Vector2 from current Vector2 floored values
  19916. * @returns a new Vector2
  19917. */
  19918. floor(): Vector2;
  19919. /**
  19920. * Gets a new Vector2 from current Vector2 floored values
  19921. * @returns a new Vector2
  19922. */
  19923. fract(): Vector2;
  19924. /**
  19925. * Gets the length of the vector
  19926. * @returns the vector length (float)
  19927. */
  19928. length(): number;
  19929. /**
  19930. * Gets the vector squared length
  19931. * @returns the vector squared length (float)
  19932. */
  19933. lengthSquared(): number;
  19934. /**
  19935. * Normalize the vector
  19936. * @returns the current updated Vector2
  19937. */
  19938. normalize(): Vector2;
  19939. /**
  19940. * Gets a new Vector2 copied from the Vector2
  19941. * @returns a new Vector2
  19942. */
  19943. clone(): Vector2;
  19944. /**
  19945. * Gets a new Vector2(0, 0)
  19946. * @returns a new Vector2
  19947. */
  19948. static Zero(): Vector2;
  19949. /**
  19950. * Gets a new Vector2(1, 1)
  19951. * @returns a new Vector2
  19952. */
  19953. static One(): Vector2;
  19954. /**
  19955. * Gets a new Vector2 set from the given index element of the given array
  19956. * @param array defines the data source
  19957. * @param offset defines the offset in the data source
  19958. * @returns a new Vector2
  19959. */
  19960. static FromArray(array: ArrayLike<number>, offset?: number): Vector2;
  19961. /**
  19962. * Sets "result" from the given index element of the given array
  19963. * @param array defines the data source
  19964. * @param offset defines the offset in the data source
  19965. * @param result defines the target vector
  19966. */
  19967. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Vector2): void;
  19968. /**
  19969. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  19970. * @param value1 defines 1st point of control
  19971. * @param value2 defines 2nd point of control
  19972. * @param value3 defines 3rd point of control
  19973. * @param value4 defines 4th point of control
  19974. * @param amount defines the interpolation factor
  19975. * @returns a new Vector2
  19976. */
  19977. static CatmullRom(value1: Vector2, value2: Vector2, value3: Vector2, value4: Vector2, amount: number): Vector2;
  19978. /**
  19979. * 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".
  19980. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  19981. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  19982. * @param value defines the value to clamp
  19983. * @param min defines the lower limit
  19984. * @param max defines the upper limit
  19985. * @returns a new Vector2
  19986. */
  19987. static Clamp(value: Vector2, min: Vector2, max: Vector2): Vector2;
  19988. /**
  19989. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  19990. * @param value1 defines the 1st control point
  19991. * @param tangent1 defines the outgoing tangent
  19992. * @param value2 defines the 2nd control point
  19993. * @param tangent2 defines the incoming tangent
  19994. * @param amount defines the interpolation factor
  19995. * @returns a new Vector2
  19996. */
  19997. static Hermite(value1: Vector2, tangent1: Vector2, value2: Vector2, tangent2: Vector2, amount: number): Vector2;
  19998. /**
  19999. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  20000. * @param start defines the start vector
  20001. * @param end defines the end vector
  20002. * @param amount defines the interpolation factor
  20003. * @returns a new Vector2
  20004. */
  20005. static Lerp(start: Vector2, end: Vector2, amount: number): Vector2;
  20006. /**
  20007. * Gets the dot product of the vector "left" and the vector "right"
  20008. * @param left defines first vector
  20009. * @param right defines second vector
  20010. * @returns the dot product (float)
  20011. */
  20012. static Dot(left: Vector2, right: Vector2): number;
  20013. /**
  20014. * Returns a new Vector2 equal to the normalized given vector
  20015. * @param vector defines the vector to normalize
  20016. * @returns a new Vector2
  20017. */
  20018. static Normalize(vector: Vector2): Vector2;
  20019. /**
  20020. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  20021. * @param left defines 1st vector
  20022. * @param right defines 2nd vector
  20023. * @returns a new Vector2
  20024. */
  20025. static Minimize(left: Vector2, right: Vector2): Vector2;
  20026. /**
  20027. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  20028. * @param left defines 1st vector
  20029. * @param right defines 2nd vector
  20030. * @returns a new Vector2
  20031. */
  20032. static Maximize(left: Vector2, right: Vector2): Vector2;
  20033. /**
  20034. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  20035. * @param vector defines the vector to transform
  20036. * @param transformation defines the matrix to apply
  20037. * @returns a new Vector2
  20038. */
  20039. static Transform(vector: Vector2, transformation: Matrix): Vector2;
  20040. /**
  20041. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  20042. * @param vector defines the vector to transform
  20043. * @param transformation defines the matrix to apply
  20044. * @param result defines the target vector
  20045. */
  20046. static TransformToRef(vector: Vector2, transformation: Matrix, result: Vector2): void;
  20047. /**
  20048. * Determines if a given vector is included in a triangle
  20049. * @param p defines the vector to test
  20050. * @param p0 defines 1st triangle point
  20051. * @param p1 defines 2nd triangle point
  20052. * @param p2 defines 3rd triangle point
  20053. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  20054. */
  20055. static PointInTriangle(p: Vector2, p0: Vector2, p1: Vector2, p2: Vector2): boolean;
  20056. /**
  20057. * Gets the distance between the vectors "value1" and "value2"
  20058. * @param value1 defines first vector
  20059. * @param value2 defines second vector
  20060. * @returns the distance between vectors
  20061. */
  20062. static Distance(value1: Vector2, value2: Vector2): number;
  20063. /**
  20064. * Returns the squared distance between the vectors "value1" and "value2"
  20065. * @param value1 defines first vector
  20066. * @param value2 defines second vector
  20067. * @returns the squared distance between vectors
  20068. */
  20069. static DistanceSquared(value1: Vector2, value2: Vector2): number;
  20070. /**
  20071. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  20072. * @param value1 defines first vector
  20073. * @param value2 defines second vector
  20074. * @returns a new Vector2
  20075. */
  20076. static Center(value1: Vector2, value2: Vector2): Vector2;
  20077. /**
  20078. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  20079. * @param p defines the middle point
  20080. * @param segA defines one point of the segment
  20081. * @param segB defines the other point of the segment
  20082. * @returns the shortest distance
  20083. */
  20084. static DistanceOfPointFromSegment(p: Vector2, segA: Vector2, segB: Vector2): number;
  20085. }
  20086. /**
  20087. * Classed used to store (x,y,z) vector representation
  20088. * A Vector3 is the main object used in 3D geometry
  20089. * It can represent etiher the coordinates of a point the space, either a direction
  20090. * Reminder: Babylon.js uses a left handed forward facing system
  20091. */
  20092. class Vector3 {
  20093. /**
  20094. * Defines the first coordinates (on X axis)
  20095. */
  20096. x: number;
  20097. /**
  20098. * Defines the second coordinates (on Y axis)
  20099. */
  20100. y: number;
  20101. /**
  20102. * Defines the third coordinates (on Z axis)
  20103. */
  20104. z: number;
  20105. /**
  20106. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  20107. * @param x defines the first coordinates (on X axis)
  20108. * @param y defines the second coordinates (on Y axis)
  20109. * @param z defines the third coordinates (on Z axis)
  20110. */
  20111. constructor(
  20112. /**
  20113. * Defines the first coordinates (on X axis)
  20114. */
  20115. x?: number,
  20116. /**
  20117. * Defines the second coordinates (on Y axis)
  20118. */
  20119. y?: number,
  20120. /**
  20121. * Defines the third coordinates (on Z axis)
  20122. */
  20123. z?: number);
  20124. /**
  20125. * Creates a string representation of the Vector3
  20126. * @returns a string with the Vector3 coordinates.
  20127. */
  20128. toString(): string;
  20129. /**
  20130. * Gets the class name
  20131. * @returns the string "Vector3"
  20132. */
  20133. getClassName(): string;
  20134. /**
  20135. * Creates the Vector3 hash code
  20136. * @returns a number which tends to be unique between Vector3 instances
  20137. */
  20138. getHashCode(): number;
  20139. /**
  20140. * Creates an array containing three elements : the coordinates of the Vector3
  20141. * @returns a new array of numbers
  20142. */
  20143. asArray(): number[];
  20144. /**
  20145. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  20146. * @param array defines the destination array
  20147. * @param index defines the offset in the destination array
  20148. * @returns the current Vector3
  20149. */
  20150. toArray(array: FloatArray, index?: number): Vector3;
  20151. /**
  20152. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  20153. * @returns a new Quaternion object, computed from the Vector3 coordinates
  20154. */
  20155. toQuaternion(): Quaternion;
  20156. /**
  20157. * Adds the given vector to the current Vector3
  20158. * @param otherVector defines the second operand
  20159. * @returns the current updated Vector3
  20160. */
  20161. addInPlace(otherVector: Vector3): Vector3;
  20162. /**
  20163. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  20164. * @param otherVector defines the second operand
  20165. * @returns the resulting Vector3
  20166. */
  20167. add(otherVector: Vector3): Vector3;
  20168. /**
  20169. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  20170. * @param otherVector defines the second operand
  20171. * @param result defines the Vector3 object where to store the result
  20172. * @returns the current Vector3
  20173. */
  20174. addToRef(otherVector: Vector3, result: Vector3): Vector3;
  20175. /**
  20176. * Subtract the given vector from the current Vector3
  20177. * @param otherVector defines the second operand
  20178. * @returns the current updated Vector3
  20179. */
  20180. subtractInPlace(otherVector: Vector3): Vector3;
  20181. /**
  20182. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  20183. * @param otherVector defines the second operand
  20184. * @returns the resulting Vector3
  20185. */
  20186. subtract(otherVector: Vector3): Vector3;
  20187. /**
  20188. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  20189. * @param otherVector defines the second operand
  20190. * @param result defines the Vector3 object where to store the result
  20191. * @returns the current Vector3
  20192. */
  20193. subtractToRef(otherVector: Vector3, result: Vector3): Vector3;
  20194. /**
  20195. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  20196. * @param x defines the x coordinate of the operand
  20197. * @param y defines the y coordinate of the operand
  20198. * @param z defines the z coordinate of the operand
  20199. * @returns the resulting Vector3
  20200. */
  20201. subtractFromFloats(x: number, y: number, z: number): Vector3;
  20202. /**
  20203. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  20204. * @param x defines the x coordinate of the operand
  20205. * @param y defines the y coordinate of the operand
  20206. * @param z defines the z coordinate of the operand
  20207. * @param result defines the Vector3 object where to store the result
  20208. * @returns the current Vector3
  20209. */
  20210. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  20211. /**
  20212. * Gets a new Vector3 set with the current Vector3 negated coordinates
  20213. * @returns a new Vector3
  20214. */
  20215. negate(): Vector3;
  20216. /**
  20217. * Multiplies the Vector3 coordinates by the float "scale"
  20218. * @param scale defines the multiplier factor
  20219. * @returns the current updated Vector3
  20220. */
  20221. scaleInPlace(scale: number): Vector3;
  20222. /**
  20223. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  20224. * @param scale defines the multiplier factor
  20225. * @returns a new Vector3
  20226. */
  20227. scale(scale: number): Vector3;
  20228. /**
  20229. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  20230. * @param scale defines the multiplier factor
  20231. * @param result defines the Vector3 object where to store the result
  20232. * @returns the current Vector3
  20233. */
  20234. scaleToRef(scale: number, result: Vector3): Vector3;
  20235. /**
  20236. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  20237. * @param scale defines the scale factor
  20238. * @param result defines the Vector3 object where to store the result
  20239. * @returns the unmodified current Vector3
  20240. */
  20241. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  20242. /**
  20243. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  20244. * @param otherVector defines the second operand
  20245. * @returns true if both vectors are equals
  20246. */
  20247. equals(otherVector: Vector3): boolean;
  20248. /**
  20249. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  20250. * @param otherVector defines the second operand
  20251. * @param epsilon defines the minimal distance to define values as equals
  20252. * @returns true if both vectors are distant less than epsilon
  20253. */
  20254. equalsWithEpsilon(otherVector: Vector3, epsilon?: number): boolean;
  20255. /**
  20256. * Returns true if the current Vector3 coordinates equals the given floats
  20257. * @param x defines the x coordinate of the operand
  20258. * @param y defines the y coordinate of the operand
  20259. * @param z defines the z coordinate of the operand
  20260. * @returns true if both vectors are equals
  20261. */
  20262. equalsToFloats(x: number, y: number, z: number): boolean;
  20263. /**
  20264. * Multiplies the current Vector3 coordinates by the given ones
  20265. * @param otherVector defines the second operand
  20266. * @returns the current updated Vector3
  20267. */
  20268. multiplyInPlace(otherVector: Vector3): Vector3;
  20269. /**
  20270. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  20271. * @param otherVector defines the second operand
  20272. * @returns the new Vector3
  20273. */
  20274. multiply(otherVector: Vector3): Vector3;
  20275. /**
  20276. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  20277. * @param otherVector defines the second operand
  20278. * @param result defines the Vector3 object where to store the result
  20279. * @returns the current Vector3
  20280. */
  20281. multiplyToRef(otherVector: Vector3, result: Vector3): Vector3;
  20282. /**
  20283. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  20284. * @param x defines the x coordinate of the operand
  20285. * @param y defines the y coordinate of the operand
  20286. * @param z defines the z coordinate of the operand
  20287. * @returns the new Vector3
  20288. */
  20289. multiplyByFloats(x: number, y: number, z: number): Vector3;
  20290. /**
  20291. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  20292. * @param otherVector defines the second operand
  20293. * @returns the new Vector3
  20294. */
  20295. divide(otherVector: Vector3): Vector3;
  20296. /**
  20297. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  20298. * @param otherVector defines the second operand
  20299. * @param result defines the Vector3 object where to store the result
  20300. * @returns the current Vector3
  20301. */
  20302. divideToRef(otherVector: Vector3, result: Vector3): Vector3;
  20303. /**
  20304. * Divides the current Vector3 coordinates by the given ones.
  20305. * @param otherVector defines the second operand
  20306. * @returns the current updated Vector3
  20307. */
  20308. divideInPlace(otherVector: Vector3): Vector3;
  20309. /**
  20310. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  20311. * @param other defines the second operand
  20312. * @returns the current updated Vector3
  20313. */
  20314. minimizeInPlace(other: Vector3): Vector3;
  20315. /**
  20316. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  20317. * @param other defines the second operand
  20318. * @returns the current updated Vector3
  20319. */
  20320. maximizeInPlace(other: Vector3): Vector3;
  20321. /**
  20322. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  20323. * @param x defines the x coordinate of the operand
  20324. * @param y defines the y coordinate of the operand
  20325. * @param z defines the z coordinate of the operand
  20326. * @returns the current updated Vector3
  20327. */
  20328. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  20329. /**
  20330. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  20331. * @param x defines the x coordinate of the operand
  20332. * @param y defines the y coordinate of the operand
  20333. * @param z defines the z coordinate of the operand
  20334. * @returns the current updated Vector3
  20335. */
  20336. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  20337. /**
  20338. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  20339. */
  20340. readonly isNonUniform: boolean;
  20341. /**
  20342. * Gets a new Vector3 from current Vector3 floored values
  20343. * @returns a new Vector3
  20344. */
  20345. floor(): Vector3;
  20346. /**
  20347. * Gets a new Vector3 from current Vector3 floored values
  20348. * @returns a new Vector3
  20349. */
  20350. fract(): Vector3;
  20351. /**
  20352. * Gets the length of the Vector3
  20353. * @returns the length of the Vecto3
  20354. */
  20355. length(): number;
  20356. /**
  20357. * Gets the squared length of the Vector3
  20358. * @returns squared length of the Vector3
  20359. */
  20360. lengthSquared(): number;
  20361. /**
  20362. * Normalize the current Vector3.
  20363. * Please note that this is an in place operation.
  20364. * @returns the current updated Vector3
  20365. */
  20366. normalize(): Vector3;
  20367. /**
  20368. * Normalize the current Vector3 to a new vector
  20369. * @returns the new Vector3
  20370. */
  20371. normalizeToNew(): Vector3;
  20372. /**
  20373. * Normalize the current Vector3 to the reference
  20374. * @param reference define the Vector3 to update
  20375. * @returns the updated Vector3
  20376. */
  20377. normalizeToRef(reference: Vector3): Vector3;
  20378. /**
  20379. * Creates a new Vector3 copied from the current Vector3
  20380. * @returns the new Vector3
  20381. */
  20382. clone(): Vector3;
  20383. /**
  20384. * Copies the given vector coordinates to the current Vector3 ones
  20385. * @param source defines the source Vector3
  20386. * @returns the current updated Vector3
  20387. */
  20388. copyFrom(source: Vector3): Vector3;
  20389. /**
  20390. * Copies the given floats to the current Vector3 coordinates
  20391. * @param x defines the x coordinate of the operand
  20392. * @param y defines the y coordinate of the operand
  20393. * @param z defines the z coordinate of the operand
  20394. * @returns the current updated Vector3
  20395. */
  20396. copyFromFloats(x: number, y: number, z: number): Vector3;
  20397. /**
  20398. * Copies the given floats to the current Vector3 coordinates
  20399. * @param x defines the x coordinate of the operand
  20400. * @param y defines the y coordinate of the operand
  20401. * @param z defines the z coordinate of the operand
  20402. * @returns the current updated Vector3
  20403. */
  20404. set(x: number, y: number, z: number): Vector3;
  20405. /**
  20406. * Get the clip factor between two vectors
  20407. * @param vector0 defines the first operand
  20408. * @param vector1 defines the second operand
  20409. * @param axis defines the axis to use
  20410. * @param size defines the size along the axis
  20411. * @returns the clip factor
  20412. */
  20413. static GetClipFactor(vector0: Vector3, vector1: Vector3, axis: Vector3, size: number): number;
  20414. /**
  20415. * Get angle between two vectors
  20416. * @param vector0 angle between vector0 and vector1
  20417. * @param vector1 angle between vector0 and vector1
  20418. * @param normal direction of the normal
  20419. * @return the angle between vector0 and vector1
  20420. */
  20421. static GetAngleBetweenVectors(vector0: Vector3, vector1: Vector3, normal: Vector3): number;
  20422. /**
  20423. * Returns a new Vector3 set from the index "offset" of the given array
  20424. * @param array defines the source array
  20425. * @param offset defines the offset in the source array
  20426. * @returns the new Vector3
  20427. */
  20428. static FromArray(array: ArrayLike<number>, offset?: number): Vector3;
  20429. /**
  20430. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  20431. * This function is deprecated. Use FromArray instead
  20432. * @param array defines the source array
  20433. * @param offset defines the offset in the source array
  20434. * @returns the new Vector3
  20435. */
  20436. static FromFloatArray(array: Float32Array, offset?: number): Vector3;
  20437. /**
  20438. * Sets the given vector "result" with the element values from the index "offset" of the given array
  20439. * @param array defines the source array
  20440. * @param offset defines the offset in the source array
  20441. * @param result defines the Vector3 where to store the result
  20442. */
  20443. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Vector3): void;
  20444. /**
  20445. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  20446. * This function is deprecated. Use FromArrayToRef instead.
  20447. * @param array defines the source array
  20448. * @param offset defines the offset in the source array
  20449. * @param result defines the Vector3 where to store the result
  20450. */
  20451. static FromFloatArrayToRef(array: Float32Array, offset: number, result: Vector3): void;
  20452. /**
  20453. * Sets the given vector "result" with the given floats.
  20454. * @param x defines the x coordinate of the source
  20455. * @param y defines the y coordinate of the source
  20456. * @param z defines the z coordinate of the source
  20457. * @param result defines the Vector3 where to store the result
  20458. */
  20459. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  20460. /**
  20461. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  20462. * @returns a new empty Vector3
  20463. */
  20464. static Zero(): Vector3;
  20465. /**
  20466. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  20467. * @returns a new unit Vector3
  20468. */
  20469. static One(): Vector3;
  20470. /**
  20471. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  20472. * @returns a new up Vector3
  20473. */
  20474. static Up(): Vector3;
  20475. /**
  20476. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  20477. * @returns a new down Vector3
  20478. */
  20479. static Down(): Vector3;
  20480. /**
  20481. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  20482. * @returns a new forward Vector3
  20483. */
  20484. static Forward(): Vector3;
  20485. /**
  20486. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  20487. * @returns a new forward Vector3
  20488. */
  20489. static Backward(): Vector3;
  20490. /**
  20491. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  20492. * @returns a new right Vector3
  20493. */
  20494. static Right(): Vector3;
  20495. /**
  20496. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  20497. * @returns a new left Vector3
  20498. */
  20499. static Left(): Vector3;
  20500. /**
  20501. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  20502. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  20503. * @param vector defines the Vector3 to transform
  20504. * @param transformation defines the transformation matrix
  20505. * @returns the transformed Vector3
  20506. */
  20507. static TransformCoordinates(vector: Vector3, transformation: Matrix): Vector3;
  20508. /**
  20509. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  20510. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  20511. * @param vector defines the Vector3 to transform
  20512. * @param transformation defines the transformation matrix
  20513. * @param result defines the Vector3 where to store the result
  20514. */
  20515. static TransformCoordinatesToRef(vector: Vector3, transformation: Matrix, result: Vector3): void;
  20516. /**
  20517. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  20518. * This method computes tranformed coordinates only, not transformed direction vectors
  20519. * @param x define the x coordinate of the source vector
  20520. * @param y define the y coordinate of the source vector
  20521. * @param z define the z coordinate of the source vector
  20522. * @param transformation defines the transformation matrix
  20523. * @param result defines the Vector3 where to store the result
  20524. */
  20525. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: Matrix, result: Vector3): void;
  20526. /**
  20527. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  20528. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  20529. * @param vector defines the Vector3 to transform
  20530. * @param transformation defines the transformation matrix
  20531. * @returns the new Vector3
  20532. */
  20533. static TransformNormal(vector: Vector3, transformation: Matrix): Vector3;
  20534. /**
  20535. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  20536. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  20537. * @param vector defines the Vector3 to transform
  20538. * @param transformation defines the transformation matrix
  20539. * @param result defines the Vector3 where to store the result
  20540. */
  20541. static TransformNormalToRef(vector: Vector3, transformation: Matrix, result: Vector3): void;
  20542. /**
  20543. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  20544. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  20545. * @param x define the x coordinate of the source vector
  20546. * @param y define the y coordinate of the source vector
  20547. * @param z define the z coordinate of the source vector
  20548. * @param transformation defines the transformation matrix
  20549. * @param result defines the Vector3 where to store the result
  20550. */
  20551. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: Matrix, result: Vector3): void;
  20552. /**
  20553. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  20554. * @param value1 defines the first control point
  20555. * @param value2 defines the second control point
  20556. * @param value3 defines the third control point
  20557. * @param value4 defines the fourth control point
  20558. * @param amount defines the amount on the spline to use
  20559. * @returns the new Vector3
  20560. */
  20561. static CatmullRom(value1: Vector3, value2: Vector3, value3: Vector3, value4: Vector3, amount: number): Vector3;
  20562. /**
  20563. * 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"
  20564. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  20565. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  20566. * @param value defines the current value
  20567. * @param min defines the lower range value
  20568. * @param max defines the upper range value
  20569. * @returns the new Vector3
  20570. */
  20571. static Clamp(value: Vector3, min: Vector3, max: Vector3): Vector3;
  20572. /**
  20573. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  20574. * @param value1 defines the first control point
  20575. * @param tangent1 defines the first tangent vector
  20576. * @param value2 defines the second control point
  20577. * @param tangent2 defines the second tangent vector
  20578. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  20579. * @returns the new Vector3
  20580. */
  20581. static Hermite(value1: Vector3, tangent1: Vector3, value2: Vector3, tangent2: Vector3, amount: number): Vector3;
  20582. /**
  20583. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  20584. * @param start defines the start value
  20585. * @param end defines the end value
  20586. * @param amount max defines amount between both (between 0 and 1)
  20587. * @returns the new Vector3
  20588. */
  20589. static Lerp(start: Vector3, end: Vector3, amount: number): Vector3;
  20590. /**
  20591. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  20592. * @param start defines the start value
  20593. * @param end defines the end value
  20594. * @param amount max defines amount between both (between 0 and 1)
  20595. * @param result defines the Vector3 where to store the result
  20596. */
  20597. static LerpToRef(start: Vector3, end: Vector3, amount: number, result: Vector3): void;
  20598. /**
  20599. * Returns the dot product (float) between the vectors "left" and "right"
  20600. * @param left defines the left operand
  20601. * @param right defines the right operand
  20602. * @returns the dot product
  20603. */
  20604. static Dot(left: Vector3, right: Vector3): number;
  20605. /**
  20606. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  20607. * The cross product is then orthogonal to both "left" and "right"
  20608. * @param left defines the left operand
  20609. * @param right defines the right operand
  20610. * @returns the cross product
  20611. */
  20612. static Cross(left: Vector3, right: Vector3): Vector3;
  20613. /**
  20614. * Sets the given vector "result" with the cross product of "left" and "right"
  20615. * The cross product is then orthogonal to both "left" and "right"
  20616. * @param left defines the left operand
  20617. * @param right defines the right operand
  20618. * @param result defines the Vector3 where to store the result
  20619. */
  20620. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  20621. /**
  20622. * Returns a new Vector3 as the normalization of the given vector
  20623. * @param vector defines the Vector3 to normalize
  20624. * @returns the new Vector3
  20625. */
  20626. static Normalize(vector: Vector3): Vector3;
  20627. /**
  20628. * Sets the given vector "result" with the normalization of the given first vector
  20629. * @param vector defines the Vector3 to normalize
  20630. * @param result defines the Vector3 where to store the result
  20631. */
  20632. static NormalizeToRef(vector: Vector3, result: Vector3): void;
  20633. private static _viewportMatrixCache;
  20634. /**
  20635. * Project a Vector3 onto screen space
  20636. * @param vector defines the Vector3 to project
  20637. * @param world defines the world matrix to use
  20638. * @param transform defines the transform (view x projection) matrix to use
  20639. * @param viewport defines the screen viewport to use
  20640. * @returns the new Vector3
  20641. */
  20642. static Project(vector: Vector3, world: Matrix, transform: Matrix, viewport: Viewport): Vector3;
  20643. /**
  20644. * Unproject from screen space to object space
  20645. * @param source defines the screen space Vector3 to use
  20646. * @param viewportWidth defines the current width of the viewport
  20647. * @param viewportHeight defines the current height of the viewport
  20648. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  20649. * @param transform defines the transform (view x projection) matrix to use
  20650. * @returns the new Vector3
  20651. */
  20652. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, transform: Matrix): Vector3;
  20653. /**
  20654. * Unproject from screen space to object space
  20655. * @param source defines the screen space Vector3 to use
  20656. * @param viewportWidth defines the current width of the viewport
  20657. * @param viewportHeight defines the current height of the viewport
  20658. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  20659. * @param view defines the view matrix to use
  20660. * @param projection defines the projection matrix to use
  20661. * @returns the new Vector3
  20662. */
  20663. static Unproject(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Vector3;
  20664. /**
  20665. * Unproject from screen space to object space
  20666. * @param source defines the screen space Vector3 to use
  20667. * @param viewportWidth defines the current width of the viewport
  20668. * @param viewportHeight defines the current height of the viewport
  20669. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  20670. * @param view defines the view matrix to use
  20671. * @param projection defines the projection matrix to use
  20672. * @param result defines the Vector3 where to store the result
  20673. */
  20674. static UnprojectToRef(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix, result: Vector3): void;
  20675. /**
  20676. * Unproject from screen space to object space
  20677. * @param sourceX defines the screen space x coordinate to use
  20678. * @param sourceY defines the screen space y coordinate to use
  20679. * @param sourceZ defines the screen space z coordinate to use
  20680. * @param viewportWidth defines the current width of the viewport
  20681. * @param viewportHeight defines the current height of the viewport
  20682. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  20683. * @param view defines the view matrix to use
  20684. * @param projection defines the projection matrix to use
  20685. * @param result defines the Vector3 where to store the result
  20686. */
  20687. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix, result: Vector3): void;
  20688. /**
  20689. * Gets the minimal coordinate values between two Vector3
  20690. * @param left defines the first operand
  20691. * @param right defines the second operand
  20692. * @returns the new Vector3
  20693. */
  20694. static Minimize(left: Vector3, right: Vector3): Vector3;
  20695. /**
  20696. * Gets the maximal coordinate values between two Vector3
  20697. * @param left defines the first operand
  20698. * @param right defines the second operand
  20699. * @returns the new Vector3
  20700. */
  20701. static Maximize(left: Vector3, right: Vector3): Vector3;
  20702. /**
  20703. * Returns the distance between the vectors "value1" and "value2"
  20704. * @param value1 defines the first operand
  20705. * @param value2 defines the second operand
  20706. * @returns the distance
  20707. */
  20708. static Distance(value1: Vector3, value2: Vector3): number;
  20709. /**
  20710. * Returns the squared distance between the vectors "value1" and "value2"
  20711. * @param value1 defines the first operand
  20712. * @param value2 defines the second operand
  20713. * @returns the squared distance
  20714. */
  20715. static DistanceSquared(value1: Vector3, value2: Vector3): number;
  20716. /**
  20717. * Returns a new Vector3 located at the center between "value1" and "value2"
  20718. * @param value1 defines the first operand
  20719. * @param value2 defines the second operand
  20720. * @returns the new Vector3
  20721. */
  20722. static Center(value1: Vector3, value2: Vector3): Vector3;
  20723. /**
  20724. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  20725. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  20726. * to something in order to rotate it from its local system to the given target system
  20727. * Note: axis1, axis2 and axis3 are normalized during this operation
  20728. * @param axis1 defines the first axis
  20729. * @param axis2 defines the second axis
  20730. * @param axis3 defines the third axis
  20731. * @returns a new Vector3
  20732. */
  20733. static RotationFromAxis(axis1: Vector3, axis2: Vector3, axis3: Vector3): Vector3;
  20734. /**
  20735. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  20736. * @param axis1 defines the first axis
  20737. * @param axis2 defines the second axis
  20738. * @param axis3 defines the third axis
  20739. * @param ref defines the Vector3 where to store the result
  20740. */
  20741. static RotationFromAxisToRef(axis1: Vector3, axis2: Vector3, axis3: Vector3, ref: Vector3): void;
  20742. }
  20743. /**
  20744. * Vector4 class created for EulerAngle class conversion to Quaternion
  20745. */
  20746. class Vector4 {
  20747. /** x value of the vector */
  20748. x: number;
  20749. /** y value of the vector */
  20750. y: number;
  20751. /** z value of the vector */
  20752. z: number;
  20753. /** w value of the vector */
  20754. w: number;
  20755. /**
  20756. * Creates a Vector4 object from the given floats.
  20757. * @param x x value of the vector
  20758. * @param y y value of the vector
  20759. * @param z z value of the vector
  20760. * @param w w value of the vector
  20761. */
  20762. constructor(
  20763. /** x value of the vector */
  20764. x: number,
  20765. /** y value of the vector */
  20766. y: number,
  20767. /** z value of the vector */
  20768. z: number,
  20769. /** w value of the vector */
  20770. w: number);
  20771. /**
  20772. * Returns the string with the Vector4 coordinates.
  20773. * @returns a string containing all the vector values
  20774. */
  20775. toString(): string;
  20776. /**
  20777. * Returns the string "Vector4".
  20778. * @returns "Vector4"
  20779. */
  20780. getClassName(): string;
  20781. /**
  20782. * Returns the Vector4 hash code.
  20783. * @returns a unique hash code
  20784. */
  20785. getHashCode(): number;
  20786. /**
  20787. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  20788. * @returns the resulting array
  20789. */
  20790. asArray(): number[];
  20791. /**
  20792. * Populates the given array from the given index with the Vector4 coordinates.
  20793. * @param array array to populate
  20794. * @param index index of the array to start at (default: 0)
  20795. * @returns the Vector4.
  20796. */
  20797. toArray(array: FloatArray, index?: number): Vector4;
  20798. /**
  20799. * Adds the given vector to the current Vector4.
  20800. * @param otherVector the vector to add
  20801. * @returns the updated Vector4.
  20802. */
  20803. addInPlace(otherVector: Vector4): Vector4;
  20804. /**
  20805. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  20806. * @param otherVector the vector to add
  20807. * @returns the resulting vector
  20808. */
  20809. add(otherVector: Vector4): Vector4;
  20810. /**
  20811. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  20812. * @param otherVector the vector to add
  20813. * @param result the vector to store the result
  20814. * @returns the current Vector4.
  20815. */
  20816. addToRef(otherVector: Vector4, result: Vector4): Vector4;
  20817. /**
  20818. * Subtract in place the given vector from the current Vector4.
  20819. * @param otherVector the vector to subtract
  20820. * @returns the updated Vector4.
  20821. */
  20822. subtractInPlace(otherVector: Vector4): Vector4;
  20823. /**
  20824. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  20825. * @param otherVector the vector to add
  20826. * @returns the new vector with the result
  20827. */
  20828. subtract(otherVector: Vector4): Vector4;
  20829. /**
  20830. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  20831. * @param otherVector the vector to subtract
  20832. * @param result the vector to store the result
  20833. * @returns the current Vector4.
  20834. */
  20835. subtractToRef(otherVector: Vector4, result: Vector4): Vector4;
  20836. /**
  20837. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  20838. */
  20839. /**
  20840. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  20841. * @param x value to subtract
  20842. * @param y value to subtract
  20843. * @param z value to subtract
  20844. * @param w value to subtract
  20845. * @returns new vector containing the result
  20846. */
  20847. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  20848. /**
  20849. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  20850. * @param x value to subtract
  20851. * @param y value to subtract
  20852. * @param z value to subtract
  20853. * @param w value to subtract
  20854. * @param result the vector to store the result in
  20855. * @returns the current Vector4.
  20856. */
  20857. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  20858. /**
  20859. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  20860. * @returns a new vector with the negated values
  20861. */
  20862. negate(): Vector4;
  20863. /**
  20864. * Multiplies the current Vector4 coordinates by scale (float).
  20865. * @param scale the number to scale with
  20866. * @returns the updated Vector4.
  20867. */
  20868. scaleInPlace(scale: number): Vector4;
  20869. /**
  20870. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  20871. * @param scale the number to scale with
  20872. * @returns a new vector with the result
  20873. */
  20874. scale(scale: number): Vector4;
  20875. /**
  20876. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  20877. * @param scale the number to scale with
  20878. * @param result a vector to store the result in
  20879. * @returns the current Vector4.
  20880. */
  20881. scaleToRef(scale: number, result: Vector4): Vector4;
  20882. /**
  20883. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  20884. * @param scale defines the scale factor
  20885. * @param result defines the Vector4 object where to store the result
  20886. * @returns the unmodified current Vector4
  20887. */
  20888. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  20889. /**
  20890. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  20891. * @param otherVector the vector to compare against
  20892. * @returns true if they are equal
  20893. */
  20894. equals(otherVector: Vector4): boolean;
  20895. /**
  20896. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  20897. * @param otherVector vector to compare against
  20898. * @param epsilon (Default: very small number)
  20899. * @returns true if they are equal
  20900. */
  20901. equalsWithEpsilon(otherVector: Vector4, epsilon?: number): boolean;
  20902. /**
  20903. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  20904. * @param x x value to compare against
  20905. * @param y y value to compare against
  20906. * @param z z value to compare against
  20907. * @param w w value to compare against
  20908. * @returns true if equal
  20909. */
  20910. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  20911. /**
  20912. * Multiplies in place the current Vector4 by the given one.
  20913. * @param otherVector vector to multiple with
  20914. * @returns the updated Vector4.
  20915. */
  20916. multiplyInPlace(otherVector: Vector4): Vector4;
  20917. /**
  20918. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  20919. * @param otherVector vector to multiple with
  20920. * @returns resulting new vector
  20921. */
  20922. multiply(otherVector: Vector4): Vector4;
  20923. /**
  20924. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  20925. * @param otherVector vector to multiple with
  20926. * @param result vector to store the result
  20927. * @returns the current Vector4.
  20928. */
  20929. multiplyToRef(otherVector: Vector4, result: Vector4): Vector4;
  20930. /**
  20931. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  20932. * @param x x value multiply with
  20933. * @param y y value multiply with
  20934. * @param z z value multiply with
  20935. * @param w w value multiply with
  20936. * @returns resulting new vector
  20937. */
  20938. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  20939. /**
  20940. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  20941. * @param otherVector vector to devide with
  20942. * @returns resulting new vector
  20943. */
  20944. divide(otherVector: Vector4): Vector4;
  20945. /**
  20946. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  20947. * @param otherVector vector to devide with
  20948. * @param result vector to store the result
  20949. * @returns the current Vector4.
  20950. */
  20951. divideToRef(otherVector: Vector4, result: Vector4): Vector4;
  20952. /**
  20953. * Divides the current Vector3 coordinates by the given ones.
  20954. * @param otherVector vector to devide with
  20955. * @returns the updated Vector3.
  20956. */
  20957. divideInPlace(otherVector: Vector4): Vector4;
  20958. /**
  20959. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  20960. * @param other defines the second operand
  20961. * @returns the current updated Vector4
  20962. */
  20963. minimizeInPlace(other: Vector4): Vector4;
  20964. /**
  20965. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  20966. * @param other defines the second operand
  20967. * @returns the current updated Vector4
  20968. */
  20969. maximizeInPlace(other: Vector4): Vector4;
  20970. /**
  20971. * Gets a new Vector4 from current Vector4 floored values
  20972. * @returns a new Vector4
  20973. */
  20974. floor(): Vector4;
  20975. /**
  20976. * Gets a new Vector4 from current Vector3 floored values
  20977. * @returns a new Vector4
  20978. */
  20979. fract(): Vector4;
  20980. /**
  20981. * Returns the Vector4 length (float).
  20982. * @returns the length
  20983. */
  20984. length(): number;
  20985. /**
  20986. * Returns the Vector4 squared length (float).
  20987. * @returns the length squared
  20988. */
  20989. lengthSquared(): number;
  20990. /**
  20991. * Normalizes in place the Vector4.
  20992. * @returns the updated Vector4.
  20993. */
  20994. normalize(): Vector4;
  20995. /**
  20996. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  20997. * @returns this converted to a new vector3
  20998. */
  20999. toVector3(): Vector3;
  21000. /**
  21001. * Returns a new Vector4 copied from the current one.
  21002. * @returns the new cloned vector
  21003. */
  21004. clone(): Vector4;
  21005. /**
  21006. * Updates the current Vector4 with the given one coordinates.
  21007. * @param source the source vector to copy from
  21008. * @returns the updated Vector4.
  21009. */
  21010. copyFrom(source: Vector4): Vector4;
  21011. /**
  21012. * Updates the current Vector4 coordinates with the given floats.
  21013. * @param x float to copy from
  21014. * @param y float to copy from
  21015. * @param z float to copy from
  21016. * @param w float to copy from
  21017. * @returns the updated Vector4.
  21018. */
  21019. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  21020. /**
  21021. * Updates the current Vector4 coordinates with the given floats.
  21022. * @param x float to set from
  21023. * @param y float to set from
  21024. * @param z float to set from
  21025. * @param w float to set from
  21026. * @returns the updated Vector4.
  21027. */
  21028. set(x: number, y: number, z: number, w: number): Vector4;
  21029. /**
  21030. * Returns a new Vector4 set from the starting index of the given array.
  21031. * @param array the array to pull values from
  21032. * @param offset the offset into the array to start at
  21033. * @returns the new vector
  21034. */
  21035. static FromArray(array: ArrayLike<number>, offset?: number): Vector4;
  21036. /**
  21037. * Updates the given vector "result" from the starting index of the given array.
  21038. * @param array the array to pull values from
  21039. * @param offset the offset into the array to start at
  21040. * @param result the vector to store the result in
  21041. */
  21042. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Vector4): void;
  21043. /**
  21044. * Updates the given vector "result" from the starting index of the given Float32Array.
  21045. * @param array the array to pull values from
  21046. * @param offset the offset into the array to start at
  21047. * @param result the vector to store the result in
  21048. */
  21049. static FromFloatArrayToRef(array: Float32Array, offset: number, result: Vector4): void;
  21050. /**
  21051. * Updates the given vector "result" coordinates from the given floats.
  21052. * @param x float to set from
  21053. * @param y float to set from
  21054. * @param z float to set from
  21055. * @param w float to set from
  21056. * @param result the vector to the floats in
  21057. */
  21058. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  21059. /**
  21060. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  21061. * @returns the new vector
  21062. */
  21063. static Zero(): Vector4;
  21064. /**
  21065. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  21066. * @returns the new vector
  21067. */
  21068. static One(): Vector4;
  21069. /**
  21070. * Returns a new normalized Vector4 from the given one.
  21071. * @param vector the vector to normalize
  21072. * @returns the vector
  21073. */
  21074. static Normalize(vector: Vector4): Vector4;
  21075. /**
  21076. * Updates the given vector "result" from the normalization of the given one.
  21077. * @param vector the vector to normalize
  21078. * @param result the vector to store the result in
  21079. */
  21080. static NormalizeToRef(vector: Vector4, result: Vector4): void;
  21081. /**
  21082. * Returns a vector with the minimum values from the left and right vectors
  21083. * @param left left vector to minimize
  21084. * @param right right vector to minimize
  21085. * @returns a new vector with the minimum of the left and right vector values
  21086. */
  21087. static Minimize(left: Vector4, right: Vector4): Vector4;
  21088. /**
  21089. * Returns a vector with the maximum values from the left and right vectors
  21090. * @param left left vector to maximize
  21091. * @param right right vector to maximize
  21092. * @returns a new vector with the maximum of the left and right vector values
  21093. */
  21094. static Maximize(left: Vector4, right: Vector4): Vector4;
  21095. /**
  21096. * Returns the distance (float) between the vectors "value1" and "value2".
  21097. * @param value1 value to calulate the distance between
  21098. * @param value2 value to calulate the distance between
  21099. * @return the distance between the two vectors
  21100. */
  21101. static Distance(value1: Vector4, value2: Vector4): number;
  21102. /**
  21103. * Returns the squared distance (float) between the vectors "value1" and "value2".
  21104. * @param value1 value to calulate the distance between
  21105. * @param value2 value to calulate the distance between
  21106. * @return the distance between the two vectors squared
  21107. */
  21108. static DistanceSquared(value1: Vector4, value2: Vector4): number;
  21109. /**
  21110. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  21111. * @param value1 value to calulate the center between
  21112. * @param value2 value to calulate the center between
  21113. * @return the center between the two vectors
  21114. */
  21115. static Center(value1: Vector4, value2: Vector4): Vector4;
  21116. /**
  21117. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  21118. * This methods computes transformed normalized direction vectors only.
  21119. * @param vector the vector to transform
  21120. * @param transformation the transformation matrix to apply
  21121. * @returns the new vector
  21122. */
  21123. static TransformNormal(vector: Vector4, transformation: Matrix): Vector4;
  21124. /**
  21125. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  21126. * This methods computes transformed normalized direction vectors only.
  21127. * @param vector the vector to transform
  21128. * @param transformation the transformation matrix to apply
  21129. * @param result the vector to store the result in
  21130. */
  21131. static TransformNormalToRef(vector: Vector4, transformation: Matrix, result: Vector4): void;
  21132. /**
  21133. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  21134. * This methods computes transformed normalized direction vectors only.
  21135. * @param x value to transform
  21136. * @param y value to transform
  21137. * @param z value to transform
  21138. * @param w value to transform
  21139. * @param transformation the transformation matrix to apply
  21140. * @param result the vector to store the results in
  21141. */
  21142. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: Matrix, result: Vector4): void;
  21143. }
  21144. /**
  21145. * Interface for the size containing width and height
  21146. */
  21147. interface ISize {
  21148. /**
  21149. * Width
  21150. */
  21151. width: number;
  21152. /**
  21153. * Heighht
  21154. */
  21155. height: number;
  21156. }
  21157. /**
  21158. * Size containing widht and height
  21159. */
  21160. class Size implements ISize {
  21161. /**
  21162. * Width
  21163. */
  21164. width: number;
  21165. /**
  21166. * Height
  21167. */
  21168. height: number;
  21169. /**
  21170. * Creates a Size object from the given width and height (floats).
  21171. * @param width width of the new size
  21172. * @param height height of the new size
  21173. */
  21174. constructor(width: number, height: number);
  21175. /**
  21176. * Returns a string with the Size width and height
  21177. * @returns a string with the Size width and height
  21178. */
  21179. toString(): string;
  21180. /**
  21181. * "Size"
  21182. * @returns the string "Size"
  21183. */
  21184. getClassName(): string;
  21185. /**
  21186. * Returns the Size hash code.
  21187. * @returns a hash code for a unique width and height
  21188. */
  21189. getHashCode(): number;
  21190. /**
  21191. * Updates the current size from the given one.
  21192. * @param src the given size
  21193. */
  21194. copyFrom(src: Size): void;
  21195. /**
  21196. * Updates in place the current Size from the given floats.
  21197. * @param width width of the new size
  21198. * @param height height of the new size
  21199. * @returns the updated Size.
  21200. */
  21201. copyFromFloats(width: number, height: number): Size;
  21202. /**
  21203. * Updates in place the current Size from the given floats.
  21204. * @param width width to set
  21205. * @param height height to set
  21206. * @returns the updated Size.
  21207. */
  21208. set(width: number, height: number): Size;
  21209. /**
  21210. * Multiplies the width and height by numbers
  21211. * @param w factor to multiple the width by
  21212. * @param h factor to multiple the height by
  21213. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  21214. */
  21215. multiplyByFloats(w: number, h: number): Size;
  21216. /**
  21217. * Clones the size
  21218. * @returns a new Size copied from the given one.
  21219. */
  21220. clone(): Size;
  21221. /**
  21222. * True if the current Size and the given one width and height are strictly equal.
  21223. * @param other the other size to compare against
  21224. * @returns True if the current Size and the given one width and height are strictly equal.
  21225. */
  21226. equals(other: Size): boolean;
  21227. /**
  21228. * The surface of the Size : width * height (float).
  21229. */
  21230. readonly surface: number;
  21231. /**
  21232. * Create a new size of zero
  21233. * @returns a new Size set to (0.0, 0.0)
  21234. */
  21235. static Zero(): Size;
  21236. /**
  21237. * Sums the width and height of two sizes
  21238. * @param otherSize size to add to this size
  21239. * @returns a new Size set as the addition result of the current Size and the given one.
  21240. */
  21241. add(otherSize: Size): Size;
  21242. /**
  21243. * Subtracts the width and height of two
  21244. * @param otherSize size to subtract to this size
  21245. * @returns a new Size set as the subtraction result of the given one from the current Size.
  21246. */
  21247. subtract(otherSize: Size): Size;
  21248. /**
  21249. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  21250. * @param start starting size to lerp between
  21251. * @param end end size to lerp between
  21252. * @param amount amount to lerp between the start and end values
  21253. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  21254. */
  21255. static Lerp(start: Size, end: Size, amount: number): Size;
  21256. }
  21257. /**
  21258. * Class used to store quaternion data
  21259. * @see https://en.wikipedia.org/wiki/Quaternion
  21260. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  21261. */
  21262. class Quaternion {
  21263. /** defines the first component (0 by default) */
  21264. x: number;
  21265. /** defines the second component (0 by default) */
  21266. y: number;
  21267. /** defines the third component (0 by default) */
  21268. z: number;
  21269. /** defines the fourth component (1.0 by default) */
  21270. w: number;
  21271. /**
  21272. * Creates a new Quaternion from the given floats
  21273. * @param x defines the first component (0 by default)
  21274. * @param y defines the second component (0 by default)
  21275. * @param z defines the third component (0 by default)
  21276. * @param w defines the fourth component (1.0 by default)
  21277. */
  21278. constructor(
  21279. /** defines the first component (0 by default) */
  21280. x?: number,
  21281. /** defines the second component (0 by default) */
  21282. y?: number,
  21283. /** defines the third component (0 by default) */
  21284. z?: number,
  21285. /** defines the fourth component (1.0 by default) */
  21286. w?: number);
  21287. /**
  21288. * Gets a string representation for the current quaternion
  21289. * @returns a string with the Quaternion coordinates
  21290. */
  21291. toString(): string;
  21292. /**
  21293. * Gets the class name of the quaternion
  21294. * @returns the string "Quaternion"
  21295. */
  21296. getClassName(): string;
  21297. /**
  21298. * Gets a hash code for this quaternion
  21299. * @returns the quaternion hash code
  21300. */
  21301. getHashCode(): number;
  21302. /**
  21303. * Copy the quaternion to an array
  21304. * @returns a new array populated with 4 elements from the quaternion coordinates
  21305. */
  21306. asArray(): number[];
  21307. /**
  21308. * Check if two quaternions are equals
  21309. * @param otherQuaternion defines the second operand
  21310. * @return true if the current quaternion and the given one coordinates are strictly equals
  21311. */
  21312. equals(otherQuaternion: Quaternion): boolean;
  21313. /**
  21314. * Clone the current quaternion
  21315. * @returns a new quaternion copied from the current one
  21316. */
  21317. clone(): Quaternion;
  21318. /**
  21319. * Copy a quaternion to the current one
  21320. * @param other defines the other quaternion
  21321. * @returns the updated current quaternion
  21322. */
  21323. copyFrom(other: Quaternion): Quaternion;
  21324. /**
  21325. * Updates the current quaternion with the given float coordinates
  21326. * @param x defines the x coordinate
  21327. * @param y defines the y coordinate
  21328. * @param z defines the z coordinate
  21329. * @param w defines the w coordinate
  21330. * @returns the updated current quaternion
  21331. */
  21332. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  21333. /**
  21334. * Updates the current quaternion from the given float coordinates
  21335. * @param x defines the x coordinate
  21336. * @param y defines the y coordinate
  21337. * @param z defines the z coordinate
  21338. * @param w defines the w coordinate
  21339. * @returns the updated current quaternion
  21340. */
  21341. set(x: number, y: number, z: number, w: number): Quaternion;
  21342. /**
  21343. * Adds two quaternions
  21344. * @param other defines the second operand
  21345. * @returns a new quaternion as the addition result of the given one and the current quaternion
  21346. */
  21347. add(other: Quaternion): Quaternion;
  21348. /**
  21349. * Add a quaternion to the current one
  21350. * @param other defines the quaternion to add
  21351. * @returns the current quaternion
  21352. */
  21353. addInPlace(other: Quaternion): Quaternion;
  21354. /**
  21355. * Subtract two quaternions
  21356. * @param other defines the second operand
  21357. * @returns a new quaternion as the subtraction result of the given one from the current one
  21358. */
  21359. subtract(other: Quaternion): Quaternion;
  21360. /**
  21361. * Multiplies the current quaternion by a scale factor
  21362. * @param value defines the scale factor
  21363. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  21364. */
  21365. scale(value: number): Quaternion;
  21366. /**
  21367. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  21368. * @param scale defines the scale factor
  21369. * @param result defines the Quaternion object where to store the result
  21370. * @returns the unmodified current quaternion
  21371. */
  21372. scaleToRef(scale: number, result: Quaternion): Quaternion;
  21373. /**
  21374. * Multiplies in place the current quaternion by a scale factor
  21375. * @param value defines the scale factor
  21376. * @returns the current modified quaternion
  21377. */
  21378. scaleInPlace(value: number): Quaternion;
  21379. /**
  21380. * Scale the current quaternion values by a factor and add the result to a given quaternion
  21381. * @param scale defines the scale factor
  21382. * @param result defines the Quaternion object where to store the result
  21383. * @returns the unmodified current quaternion
  21384. */
  21385. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  21386. /**
  21387. * Multiplies two quaternions
  21388. * @param q1 defines the second operand
  21389. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  21390. */
  21391. multiply(q1: Quaternion): Quaternion;
  21392. /**
  21393. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  21394. * @param q1 defines the second operand
  21395. * @param result defines the target quaternion
  21396. * @returns the current quaternion
  21397. */
  21398. multiplyToRef(q1: Quaternion, result: Quaternion): Quaternion;
  21399. /**
  21400. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  21401. * @param q1 defines the second operand
  21402. * @returns the currentupdated quaternion
  21403. */
  21404. multiplyInPlace(q1: Quaternion): Quaternion;
  21405. /**
  21406. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  21407. * @param ref defines the target quaternion
  21408. * @returns the current quaternion
  21409. */
  21410. conjugateToRef(ref: Quaternion): Quaternion;
  21411. /**
  21412. * Conjugates in place (1-q) the current quaternion
  21413. * @returns the current updated quaternion
  21414. */
  21415. conjugateInPlace(): Quaternion;
  21416. /**
  21417. * Conjugates in place (1-q) the current quaternion
  21418. * @returns a new quaternion
  21419. */
  21420. conjugate(): Quaternion;
  21421. /**
  21422. * Gets length of current quaternion
  21423. * @returns the quaternion length (float)
  21424. */
  21425. length(): number;
  21426. /**
  21427. * Normalize in place the current quaternion
  21428. * @returns the current updated quaternion
  21429. */
  21430. normalize(): Quaternion;
  21431. /**
  21432. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  21433. * @param order is a reserved parameter and is ignore for now
  21434. * @returns a new Vector3 containing the Euler angles
  21435. */
  21436. toEulerAngles(order?: string): Vector3;
  21437. /**
  21438. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  21439. * @param result defines the vector which will be filled with the Euler angles
  21440. * @param order is a reserved parameter and is ignore for now
  21441. * @returns the current unchanged quaternion
  21442. */
  21443. toEulerAnglesToRef(result: Vector3, order?: string): Quaternion;
  21444. /**
  21445. * Updates the given rotation matrix with the current quaternion values
  21446. * @param result defines the target matrix
  21447. * @returns the current unchanged quaternion
  21448. */
  21449. toRotationMatrix(result: Matrix): Quaternion;
  21450. /**
  21451. * Updates the current quaternion from the given rotation matrix values
  21452. * @param matrix defines the source matrix
  21453. * @returns the current updated quaternion
  21454. */
  21455. fromRotationMatrix(matrix: Matrix): Quaternion;
  21456. /**
  21457. * Creates a new quaternion from a rotation matrix
  21458. * @param matrix defines the source matrix
  21459. * @returns a new quaternion created from the given rotation matrix values
  21460. */
  21461. static FromRotationMatrix(matrix: Matrix): Quaternion;
  21462. /**
  21463. * Updates the given quaternion with the given rotation matrix values
  21464. * @param matrix defines the source matrix
  21465. * @param result defines the target quaternion
  21466. */
  21467. static FromRotationMatrixToRef(matrix: Matrix, result: Quaternion): void;
  21468. /**
  21469. * Returns the dot product (float) between the quaternions "left" and "right"
  21470. * @param left defines the left operand
  21471. * @param right defines the right operand
  21472. * @returns the dot product
  21473. */
  21474. static Dot(left: Quaternion, right: Quaternion): number;
  21475. /**
  21476. * Checks if the two quaternions are close to each other
  21477. * @param quat0 defines the first quaternion to check
  21478. * @param quat1 defines the second quaternion to check
  21479. * @returns true if the two quaternions are close to each other
  21480. */
  21481. static AreClose(quat0: Quaternion, quat1: Quaternion): boolean;
  21482. /**
  21483. * Creates an empty quaternion
  21484. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  21485. */
  21486. static Zero(): Quaternion;
  21487. /**
  21488. * Inverse a given quaternion
  21489. * @param q defines the source quaternion
  21490. * @returns a new quaternion as the inverted current quaternion
  21491. */
  21492. static Inverse(q: Quaternion): Quaternion;
  21493. /**
  21494. * Creates an identity quaternion
  21495. * @returns the identity quaternion
  21496. */
  21497. static Identity(): Quaternion;
  21498. /**
  21499. * Gets a boolean indicating if the given quaternion is identity
  21500. * @param quaternion defines the quaternion to check
  21501. * @returns true if the quaternion is identity
  21502. */
  21503. static IsIdentity(quaternion: Quaternion): boolean;
  21504. /**
  21505. * Creates a quaternion from a rotation around an axis
  21506. * @param axis defines the axis to use
  21507. * @param angle defines the angle to use
  21508. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  21509. */
  21510. static RotationAxis(axis: Vector3, angle: number): Quaternion;
  21511. /**
  21512. * Creates a rotation around an axis and stores it into the given quaternion
  21513. * @param axis defines the axis to use
  21514. * @param angle defines the angle to use
  21515. * @param result defines the target quaternion
  21516. * @returns the target quaternion
  21517. */
  21518. static RotationAxisToRef(axis: Vector3, angle: number, result: Quaternion): Quaternion;
  21519. /**
  21520. * Creates a new quaternion from data stored into an array
  21521. * @param array defines the data source
  21522. * @param offset defines the offset in the source array where the data starts
  21523. * @returns a new quaternion
  21524. */
  21525. static FromArray(array: ArrayLike<number>, offset?: number): Quaternion;
  21526. /**
  21527. * Creates a new quaternion from the given Euler float angles (y, x, z)
  21528. * @param yaw defines the rotation around Y axis
  21529. * @param pitch defines the rotation around X axis
  21530. * @param roll defines the rotation around Z axis
  21531. * @returns the new quaternion
  21532. */
  21533. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  21534. /**
  21535. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  21536. * @param yaw defines the rotation around Y axis
  21537. * @param pitch defines the rotation around X axis
  21538. * @param roll defines the rotation around Z axis
  21539. * @param result defines the target quaternion
  21540. */
  21541. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  21542. /**
  21543. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  21544. * @param alpha defines the rotation around first axis
  21545. * @param beta defines the rotation around second axis
  21546. * @param gamma defines the rotation around third axis
  21547. * @returns the new quaternion
  21548. */
  21549. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  21550. /**
  21551. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  21552. * @param alpha defines the rotation around first axis
  21553. * @param beta defines the rotation around second axis
  21554. * @param gamma defines the rotation around third axis
  21555. * @param result defines the target quaternion
  21556. */
  21557. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  21558. /**
  21559. * 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)
  21560. * @param axis1 defines the first axis
  21561. * @param axis2 defines the second axis
  21562. * @param axis3 defines the third axis
  21563. * @returns the new quaternion
  21564. */
  21565. static RotationQuaternionFromAxis(axis1: Vector3, axis2: Vector3, axis3: Vector3): Quaternion;
  21566. /**
  21567. * 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
  21568. * @param axis1 defines the first axis
  21569. * @param axis2 defines the second axis
  21570. * @param axis3 defines the third axis
  21571. * @param ref defines the target quaternion
  21572. */
  21573. static RotationQuaternionFromAxisToRef(axis1: Vector3, axis2: Vector3, axis3: Vector3, ref: Quaternion): void;
  21574. /**
  21575. * Interpolates between two quaternions
  21576. * @param left defines first quaternion
  21577. * @param right defines second quaternion
  21578. * @param amount defines the gradient to use
  21579. * @returns the new interpolated quaternion
  21580. */
  21581. static Slerp(left: Quaternion, right: Quaternion, amount: number): Quaternion;
  21582. /**
  21583. * Interpolates between two quaternions and stores it into a target quaternion
  21584. * @param left defines first quaternion
  21585. * @param right defines second quaternion
  21586. * @param amount defines the gradient to use
  21587. * @param result defines the target quaternion
  21588. */
  21589. static SlerpToRef(left: Quaternion, right: Quaternion, amount: number, result: Quaternion): void;
  21590. /**
  21591. * Interpolate between two quaternions using Hermite interpolation
  21592. * @param value1 defines first quaternion
  21593. * @param tangent1 defines the incoming tangent
  21594. * @param value2 defines second quaternion
  21595. * @param tangent2 defines the outgoing tangent
  21596. * @param amount defines the target quaternion
  21597. * @returns the new interpolated quaternion
  21598. */
  21599. static Hermite(value1: Quaternion, tangent1: Quaternion, value2: Quaternion, tangent2: Quaternion, amount: number): Quaternion;
  21600. }
  21601. /**
  21602. * Class used to store matrix data (4x4)
  21603. */
  21604. class Matrix {
  21605. private static _tempQuaternion;
  21606. private static _xAxis;
  21607. private static _yAxis;
  21608. private static _zAxis;
  21609. private static _updateFlagSeed;
  21610. private static _identityReadOnly;
  21611. private _isIdentity;
  21612. private _isIdentityDirty;
  21613. /**
  21614. * Gets the update flag of the matrix which is an unique number for the matrix.
  21615. * It will be incremented every time the matrix data change.
  21616. * You can use it to speed the comparison between two versions of the same matrix.
  21617. */
  21618. updateFlag: number;
  21619. /**
  21620. * Gets or sets the internal data of the matrix
  21621. */
  21622. m: Float32Array;
  21623. /** @hidden */
  21624. /**
  21625. * Creates an empty matrix (filled with zeros)
  21626. */
  21627. constructor();
  21628. /**
  21629. * Check if the current matrix is indentity
  21630. * @param considerAsTextureMatrix defines if the current matrix must be considered as a texture matrix (3x2)
  21631. * @returns true is the matrix is the identity matrix
  21632. */
  21633. isIdentity(considerAsTextureMatrix?: boolean): boolean;
  21634. /**
  21635. * Gets the determinant of the matrix
  21636. * @returns the matrix determinant
  21637. */
  21638. determinant(): number;
  21639. /**
  21640. * Returns the matrix as a Float32Array
  21641. * @returns the matrix underlying array
  21642. */
  21643. toArray(): Float32Array;
  21644. /**
  21645. * Returns the matrix as a Float32Array
  21646. * @returns the matrix underlying array.
  21647. */
  21648. asArray(): Float32Array;
  21649. /**
  21650. * Inverts the current matrix in place
  21651. * @returns the current inverted matrix
  21652. */
  21653. invert(): Matrix;
  21654. /**
  21655. * Sets all the matrix elements to zero
  21656. * @returns the current matrix
  21657. */
  21658. reset(): Matrix;
  21659. /**
  21660. * Adds the current matrix with a second one
  21661. * @param other defines the matrix to add
  21662. * @returns a new matrix as the addition of the current matrix and the given one
  21663. */
  21664. add(other: Matrix): Matrix;
  21665. /**
  21666. * Sets the given matrix "result" to the addition of the current matrix and the given one
  21667. * @param other defines the matrix to add
  21668. * @param result defines the target matrix
  21669. * @returns the current matrix
  21670. */
  21671. addToRef(other: Matrix, result: Matrix): Matrix;
  21672. /**
  21673. * Adds in place the given matrix to the current matrix
  21674. * @param other defines the second operand
  21675. * @returns the current updated matrix
  21676. */
  21677. addToSelf(other: Matrix): Matrix;
  21678. /**
  21679. * Sets the given matrix to the current inverted Matrix
  21680. * @param other defines the target matrix
  21681. * @returns the unmodified current matrix
  21682. */
  21683. invertToRef(other: Matrix): Matrix;
  21684. /**
  21685. * Inserts the translation vector (using 3 floats) in the current matrix
  21686. * @param x defines the 1st component of the translation
  21687. * @param y defines the 2nd component of the translation
  21688. * @param z defines the 3rd component of the translation
  21689. * @returns the current updated matrix
  21690. */
  21691. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  21692. /**
  21693. * Inserts the translation vector in the current matrix
  21694. * @param vector3 defines the translation to insert
  21695. * @returns the current updated matrix
  21696. */
  21697. setTranslation(vector3: Vector3): Matrix;
  21698. /**
  21699. * Gets the translation value of the current matrix
  21700. * @returns a new Vector3 as the extracted translation from the matrix
  21701. */
  21702. getTranslation(): Vector3;
  21703. /**
  21704. * Fill a Vector3 with the extracted translation from the matrix
  21705. * @param result defines the Vector3 where to store the translation
  21706. * @returns the current matrix
  21707. */
  21708. getTranslationToRef(result: Vector3): Matrix;
  21709. /**
  21710. * Remove rotation and scaling part from the matrix
  21711. * @returns the updated matrix
  21712. */
  21713. removeRotationAndScaling(): Matrix;
  21714. /**
  21715. * Multiply two matrices
  21716. * @param other defines the second operand
  21717. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  21718. */
  21719. multiply(other: Matrix): Matrix;
  21720. /**
  21721. * Copy the current matrix from the given one
  21722. * @param other defines the source matrix
  21723. * @returns the current updated matrix
  21724. */
  21725. copyFrom(other: Matrix): Matrix;
  21726. /**
  21727. * Populates the given array from the starting index with the current matrix values
  21728. * @param array defines the target array
  21729. * @param offset defines the offset in the target array where to start storing values
  21730. * @returns the current matrix
  21731. */
  21732. copyToArray(array: Float32Array, offset?: number): Matrix;
  21733. /**
  21734. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  21735. * @param other defines the second operand
  21736. * @param result defines the matrix where to store the multiplication
  21737. * @returns the current matrix
  21738. */
  21739. multiplyToRef(other: Matrix, result: Matrix): Matrix;
  21740. /**
  21741. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  21742. * @param other defines the second operand
  21743. * @param result defines the array where to store the multiplication
  21744. * @param offset defines the offset in the target array where to start storing values
  21745. * @returns the current matrix
  21746. */
  21747. multiplyToArray(other: Matrix, result: Float32Array, offset: number): Matrix;
  21748. /**
  21749. * Check equality between this matrix and a second one
  21750. * @param value defines the second matrix to compare
  21751. * @returns true is the current matrix and the given one values are strictly equal
  21752. */
  21753. equals(value: Matrix): boolean;
  21754. /**
  21755. * Clone the current matrix
  21756. * @returns a new matrix from the current matrix
  21757. */
  21758. clone(): Matrix;
  21759. /**
  21760. * Returns the name of the current matrix class
  21761. * @returns the string "Matrix"
  21762. */
  21763. getClassName(): string;
  21764. /**
  21765. * Gets the hash code of the current matrix
  21766. * @returns the hash code
  21767. */
  21768. getHashCode(): number;
  21769. /**
  21770. * Decomposes the current Matrix into a translation, rotation and scaling components
  21771. * @param scale defines the scale vector3 given as a reference to update
  21772. * @param rotation defines the rotation quaternion given as a reference to update
  21773. * @param translation defines the translation vector3 given as a reference to update
  21774. * @returns true if operation was successful
  21775. */
  21776. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  21777. /**
  21778. * Gets specific row of the matrix
  21779. * @param index defines the number of the row to get
  21780. * @returns the index-th row of the current matrix as a new Vector4
  21781. */
  21782. getRow(index: number): Nullable<Vector4>;
  21783. /**
  21784. * Sets the index-th row of the current matrix to the vector4 values
  21785. * @param index defines the number of the row to set
  21786. * @param row defines the target vector4
  21787. * @returns the updated current matrix
  21788. */
  21789. setRow(index: number, row: Vector4): Matrix;
  21790. /**
  21791. * Compute the transpose of the matrix
  21792. * @returns the new transposed matrix
  21793. */
  21794. transpose(): Matrix;
  21795. /**
  21796. * Compute the transpose of the matrix and store it in a given matrix
  21797. * @param result defines the target matrix
  21798. * @returns the current matrix
  21799. */
  21800. transposeToRef(result: Matrix): Matrix;
  21801. /**
  21802. * Sets the index-th row of the current matrix with the given 4 x float values
  21803. * @param index defines the row index
  21804. * @param x defines the x component to set
  21805. * @param y defines the y component to set
  21806. * @param z defines the z component to set
  21807. * @param w defines the w component to set
  21808. * @returns the updated current matrix
  21809. */
  21810. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  21811. /**
  21812. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  21813. * @param scale defines the scale factor
  21814. * @returns a new matrix
  21815. */
  21816. scale(scale: number): Matrix;
  21817. /**
  21818. * Scale the current matrix values by a factor to a given result matrix
  21819. * @param scale defines the scale factor
  21820. * @param result defines the matrix to store the result
  21821. * @returns the current matrix
  21822. */
  21823. scaleToRef(scale: number, result: Matrix): Matrix;
  21824. /**
  21825. * Scale the current matrix values by a factor and add the result to a given matrix
  21826. * @param scale defines the scale factor
  21827. * @param result defines the Matrix to store the result
  21828. * @returns the current matrix
  21829. */
  21830. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  21831. /**
  21832. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  21833. * @param ref matrix to store the result
  21834. */
  21835. toNormalMatrix(ref: Matrix): void;
  21836. /**
  21837. * Gets only rotation part of the current matrix
  21838. * @returns a new matrix sets to the extracted rotation matrix from the current one
  21839. */
  21840. getRotationMatrix(): Matrix;
  21841. /**
  21842. * Extracts the rotation matrix from the current one and sets it as the given "result"
  21843. * @param result defines the target matrix to store data to
  21844. * @returns the current matrix
  21845. */
  21846. getRotationMatrixToRef(result: Matrix): Matrix;
  21847. /**
  21848. * Creates a matrix from an array
  21849. * @param array defines the source array
  21850. * @param offset defines an offset in the source array
  21851. * @returns a new Matrix set from the starting index of the given array
  21852. */
  21853. static FromArray(array: ArrayLike<number>, offset?: number): Matrix;
  21854. /**
  21855. * Copy the content of an array into a given matrix
  21856. * @param array defines the source array
  21857. * @param offset defines an offset in the source array
  21858. * @param result defines the target matrix
  21859. */
  21860. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Matrix): void;
  21861. /**
  21862. * Stores an array into a matrix after having multiplied each component by a given factor
  21863. * @param array defines the source array
  21864. * @param offset defines the offset in the source array
  21865. * @param scale defines the scaling factor
  21866. * @param result defines the target matrix
  21867. */
  21868. static FromFloat32ArrayToRefScaled(array: Float32Array, offset: number, scale: number, result: Matrix): void;
  21869. /**
  21870. * Stores a list of values (16) inside a given matrix
  21871. * @param initialM11 defines 1st value of 1st row
  21872. * @param initialM12 defines 2nd value of 1st row
  21873. * @param initialM13 defines 3rd value of 1st row
  21874. * @param initialM14 defines 4th value of 1st row
  21875. * @param initialM21 defines 1st value of 2nd row
  21876. * @param initialM22 defines 2nd value of 2nd row
  21877. * @param initialM23 defines 3rd value of 2nd row
  21878. * @param initialM24 defines 4th value of 2nd row
  21879. * @param initialM31 defines 1st value of 3rd row
  21880. * @param initialM32 defines 2nd value of 3rd row
  21881. * @param initialM33 defines 3rd value of 3rd row
  21882. * @param initialM34 defines 4th value of 3rd row
  21883. * @param initialM41 defines 1st value of 4th row
  21884. * @param initialM42 defines 2nd value of 4th row
  21885. * @param initialM43 defines 3rd value of 4th row
  21886. * @param initialM44 defines 4th value of 4th row
  21887. * @param result defines the target matrix
  21888. */
  21889. 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;
  21890. /**
  21891. * Gets an identity matrix that must not be updated
  21892. */
  21893. static readonly IdentityReadOnly: Matrix;
  21894. /**
  21895. * Creates new matrix from a list of values (16)
  21896. * @param initialM11 defines 1st value of 1st row
  21897. * @param initialM12 defines 2nd value of 1st row
  21898. * @param initialM13 defines 3rd value of 1st row
  21899. * @param initialM14 defines 4th value of 1st row
  21900. * @param initialM21 defines 1st value of 2nd row
  21901. * @param initialM22 defines 2nd value of 2nd row
  21902. * @param initialM23 defines 3rd value of 2nd row
  21903. * @param initialM24 defines 4th value of 2nd row
  21904. * @param initialM31 defines 1st value of 3rd row
  21905. * @param initialM32 defines 2nd value of 3rd row
  21906. * @param initialM33 defines 3rd value of 3rd row
  21907. * @param initialM34 defines 4th value of 3rd row
  21908. * @param initialM41 defines 1st value of 4th row
  21909. * @param initialM42 defines 2nd value of 4th row
  21910. * @param initialM43 defines 3rd value of 4th row
  21911. * @param initialM44 defines 4th value of 4th row
  21912. * @returns the new matrix
  21913. */
  21914. 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;
  21915. /**
  21916. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  21917. * @param scale defines the scale vector3
  21918. * @param rotation defines the rotation quaternion
  21919. * @param translation defines the translation vector3
  21920. * @returns a new matrix
  21921. */
  21922. static Compose(scale: Vector3, rotation: Quaternion, translation: Vector3): Matrix;
  21923. /**
  21924. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  21925. * @param scale defines the scale vector3
  21926. * @param rotation defines the rotation quaternion
  21927. * @param translation defines the translation vector3
  21928. * @param result defines the target matrix
  21929. */
  21930. static ComposeToRef(scale: Vector3, rotation: Quaternion, translation: Vector3, result: Matrix): void;
  21931. /**
  21932. * Creates a new identity matrix
  21933. * @returns a new identity matrix
  21934. */
  21935. static Identity(): Matrix;
  21936. /**
  21937. * Creates a new identity matrix and stores the result in a given matrix
  21938. * @param result defines the target matrix
  21939. */
  21940. static IdentityToRef(result: Matrix): void;
  21941. /**
  21942. * Creates a new zero matrix
  21943. * @returns a new zero matrix
  21944. */
  21945. static Zero(): Matrix;
  21946. /**
  21947. * Creates a new rotation matrix for "angle" radians around the X axis
  21948. * @param angle defines the angle (in radians) to use
  21949. * @return the new matrix
  21950. */
  21951. static RotationX(angle: number): Matrix;
  21952. /**
  21953. * Creates a new matrix as the invert of a given matrix
  21954. * @param source defines the source matrix
  21955. * @returns the new matrix
  21956. */
  21957. static Invert(source: Matrix): Matrix;
  21958. /**
  21959. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  21960. * @param angle defines the angle (in radians) to use
  21961. * @param result defines the target matrix
  21962. */
  21963. static RotationXToRef(angle: number, result: Matrix): void;
  21964. /**
  21965. * Creates a new rotation matrix for "angle" radians around the Y axis
  21966. * @param angle defines the angle (in radians) to use
  21967. * @return the new matrix
  21968. */
  21969. static RotationY(angle: number): Matrix;
  21970. /**
  21971. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  21972. * @param angle defines the angle (in radians) to use
  21973. * @param result defines the target matrix
  21974. */
  21975. static RotationYToRef(angle: number, result: Matrix): void;
  21976. /**
  21977. * Creates a new rotation matrix for "angle" radians around the Z axis
  21978. * @param angle defines the angle (in radians) to use
  21979. * @return the new matrix
  21980. */
  21981. static RotationZ(angle: number): Matrix;
  21982. /**
  21983. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  21984. * @param angle defines the angle (in radians) to use
  21985. * @param result defines the target matrix
  21986. */
  21987. static RotationZToRef(angle: number, result: Matrix): void;
  21988. /**
  21989. * Creates a new rotation matrix for "angle" radians around the given axis
  21990. * @param axis defines the axis to use
  21991. * @param angle defines the angle (in radians) to use
  21992. * @return the new matrix
  21993. */
  21994. static RotationAxis(axis: Vector3, angle: number): Matrix;
  21995. /**
  21996. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  21997. * @param axis defines the axis to use
  21998. * @param angle defines the angle (in radians) to use
  21999. * @param result defines the target matrix
  22000. */
  22001. static RotationAxisToRef(axis: Vector3, angle: number, result: Matrix): void;
  22002. /**
  22003. * Creates a rotation matrix
  22004. * @param yaw defines the yaw angle in radians (Y axis)
  22005. * @param pitch defines the pitch angle in radians (X axis)
  22006. * @param roll defines the roll angle in radians (X axis)
  22007. * @returns the new rotation matrix
  22008. */
  22009. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  22010. /**
  22011. * Creates a rotation matrix and stores it in a given matrix
  22012. * @param yaw defines the yaw angle in radians (Y axis)
  22013. * @param pitch defines the pitch angle in radians (X axis)
  22014. * @param roll defines the roll angle in radians (X axis)
  22015. * @param result defines the target matrix
  22016. */
  22017. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  22018. /**
  22019. * Creates a scaling matrix
  22020. * @param x defines the scale factor on X axis
  22021. * @param y defines the scale factor on Y axis
  22022. * @param z defines the scale factor on Z axis
  22023. * @returns the new matrix
  22024. */
  22025. static Scaling(x: number, y: number, z: number): Matrix;
  22026. /**
  22027. * Creates a scaling matrix and stores it in a given matrix
  22028. * @param x defines the scale factor on X axis
  22029. * @param y defines the scale factor on Y axis
  22030. * @param z defines the scale factor on Z axis
  22031. * @param result defines the target matrix
  22032. */
  22033. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  22034. /**
  22035. * Creates a translation matrix
  22036. * @param x defines the translation on X axis
  22037. * @param y defines the translation on Y axis
  22038. * @param z defines the translationon Z axis
  22039. * @returns the new matrix
  22040. */
  22041. static Translation(x: number, y: number, z: number): Matrix;
  22042. /**
  22043. * Creates a translation matrix and stores it in a given matrix
  22044. * @param x defines the translation on X axis
  22045. * @param y defines the translation on Y axis
  22046. * @param z defines the translationon Z axis
  22047. * @param result defines the target matrix
  22048. */
  22049. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  22050. /**
  22051. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  22052. * @param startValue defines the start value
  22053. * @param endValue defines the end value
  22054. * @param gradient defines the gradient factor
  22055. * @returns the new matrix
  22056. */
  22057. static Lerp(startValue: Matrix, endValue: Matrix, gradient: number): Matrix;
  22058. /**
  22059. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  22060. * @param startValue defines the start value
  22061. * @param endValue defines the end value
  22062. * @param gradient defines the gradient factor
  22063. * @param result defines the Matrix object where to store data
  22064. */
  22065. static LerpToRef(startValue: Matrix, endValue: Matrix, gradient: number, result: Matrix): void;
  22066. /**
  22067. * Builds a new matrix whose values are computed by:
  22068. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  22069. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  22070. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  22071. * @param startValue defines the first matrix
  22072. * @param endValue defines the second matrix
  22073. * @param gradient defines the gradient between the two matrices
  22074. * @returns the new matrix
  22075. */
  22076. static DecomposeLerp(startValue: Matrix, endValue: Matrix, gradient: number): Matrix;
  22077. /**
  22078. * Update a matrix to values which are computed by:
  22079. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  22080. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  22081. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  22082. * @param startValue defines the first matrix
  22083. * @param endValue defines the second matrix
  22084. * @param gradient defines the gradient between the two matrices
  22085. * @param result defines the target matrix
  22086. */
  22087. static DecomposeLerpToRef(startValue: Matrix, endValue: Matrix, gradient: number, result: Matrix): void;
  22088. /**
  22089. * 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"
  22090. * This function works in left handed mode
  22091. * @param eye defines the final position of the entity
  22092. * @param target defines where the entity should look at
  22093. * @param up defines the up vector for the entity
  22094. * @returns the new matrix
  22095. */
  22096. static LookAtLH(eye: Vector3, target: Vector3, up: Vector3): Matrix;
  22097. /**
  22098. * 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".
  22099. * This function works in left handed mode
  22100. * @param eye defines the final position of the entity
  22101. * @param target defines where the entity should look at
  22102. * @param up defines the up vector for the entity
  22103. * @param result defines the target matrix
  22104. */
  22105. static LookAtLHToRef(eye: Vector3, target: Vector3, up: Vector3, result: Matrix): void;
  22106. /**
  22107. * 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"
  22108. * This function works in right handed mode
  22109. * @param eye defines the final position of the entity
  22110. * @param target defines where the entity should look at
  22111. * @param up defines the up vector for the entity
  22112. * @returns the new matrix
  22113. */
  22114. static LookAtRH(eye: Vector3, target: Vector3, up: Vector3): Matrix;
  22115. /**
  22116. * 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".
  22117. * This function works in right handed mode
  22118. * @param eye defines the final position of the entity
  22119. * @param target defines where the entity should look at
  22120. * @param up defines the up vector for the entity
  22121. * @param result defines the target matrix
  22122. */
  22123. static LookAtRHToRef(eye: Vector3, target: Vector3, up: Vector3, result: Matrix): void;
  22124. /**
  22125. * Create a left-handed orthographic projection matrix
  22126. * @param width defines the viewport width
  22127. * @param height defines the viewport height
  22128. * @param znear defines the near clip plane
  22129. * @param zfar defines the far clip plane
  22130. * @returns a new matrix as a left-handed orthographic projection matrix
  22131. */
  22132. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  22133. /**
  22134. * Store a left-handed orthographic projection to a given matrix
  22135. * @param width defines the viewport width
  22136. * @param height defines the viewport height
  22137. * @param znear defines the near clip plane
  22138. * @param zfar defines the far clip plane
  22139. * @param result defines the target matrix
  22140. */
  22141. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  22142. /**
  22143. * Create a left-handed orthographic projection matrix
  22144. * @param left defines the viewport left coordinate
  22145. * @param right defines the viewport right coordinate
  22146. * @param bottom defines the viewport bottom coordinate
  22147. * @param top defines the viewport top coordinate
  22148. * @param znear defines the near clip plane
  22149. * @param zfar defines the far clip plane
  22150. * @returns a new matrix as a left-handed orthographic projection matrix
  22151. */
  22152. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  22153. /**
  22154. * Stores a left-handed orthographic projection into a given matrix
  22155. * @param left defines the viewport left coordinate
  22156. * @param right defines the viewport right coordinate
  22157. * @param bottom defines the viewport bottom coordinate
  22158. * @param top defines the viewport top coordinate
  22159. * @param znear defines the near clip plane
  22160. * @param zfar defines the far clip plane
  22161. * @param result defines the target matrix
  22162. */
  22163. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  22164. /**
  22165. * Creates a right-handed orthographic projection matrix
  22166. * @param left defines the viewport left coordinate
  22167. * @param right defines the viewport right coordinate
  22168. * @param bottom defines the viewport bottom coordinate
  22169. * @param top defines the viewport top coordinate
  22170. * @param znear defines the near clip plane
  22171. * @param zfar defines the far clip plane
  22172. * @returns a new matrix as a right-handed orthographic projection matrix
  22173. */
  22174. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  22175. /**
  22176. * Stores a right-handed orthographic projection into a given matrix
  22177. * @param left defines the viewport left coordinate
  22178. * @param right defines the viewport right coordinate
  22179. * @param bottom defines the viewport bottom coordinate
  22180. * @param top defines the viewport top coordinate
  22181. * @param znear defines the near clip plane
  22182. * @param zfar defines the far clip plane
  22183. * @param result defines the target matrix
  22184. */
  22185. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  22186. /**
  22187. * Creates a left-handed perspective projection matrix
  22188. * @param width defines the viewport width
  22189. * @param height defines the viewport height
  22190. * @param znear defines the near clip plane
  22191. * @param zfar defines the far clip plane
  22192. * @returns a new matrix as a left-handed perspective projection matrix
  22193. */
  22194. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  22195. /**
  22196. * Creates a left-handed perspective projection matrix
  22197. * @param fov defines the horizontal field of view
  22198. * @param aspect defines the aspect ratio
  22199. * @param znear defines the near clip plane
  22200. * @param zfar defines the far clip plane
  22201. * @returns a new matrix as a left-handed perspective projection matrix
  22202. */
  22203. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  22204. /**
  22205. * Stores a left-handed perspective projection into a given matrix
  22206. * @param fov defines the horizontal field of view
  22207. * @param aspect defines the aspect ratio
  22208. * @param znear defines the near clip plane
  22209. * @param zfar defines the far clip plane
  22210. * @param result defines the target matrix
  22211. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  22212. */
  22213. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  22214. /**
  22215. * Creates a right-handed perspective projection matrix
  22216. * @param fov defines the horizontal field of view
  22217. * @param aspect defines the aspect ratio
  22218. * @param znear defines the near clip plane
  22219. * @param zfar defines the far clip plane
  22220. * @returns a new matrix as a right-handed perspective projection matrix
  22221. */
  22222. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  22223. /**
  22224. * Stores a right-handed perspective projection into a given matrix
  22225. * @param fov defines the horizontal field of view
  22226. * @param aspect defines the aspect ratio
  22227. * @param znear defines the near clip plane
  22228. * @param zfar defines the far clip plane
  22229. * @param result defines the target matrix
  22230. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  22231. */
  22232. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  22233. /**
  22234. * Stores a perspective projection for WebVR info a given matrix
  22235. * @param fov defines the field of view
  22236. * @param znear defines the near clip plane
  22237. * @param zfar defines the far clip plane
  22238. * @param result defines the target matrix
  22239. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  22240. */
  22241. static PerspectiveFovWebVRToRef(fov: {
  22242. upDegrees: number;
  22243. downDegrees: number;
  22244. leftDegrees: number;
  22245. rightDegrees: number;
  22246. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  22247. /**
  22248. * Computes a complete transformation matrix
  22249. * @param viewport defines the viewport to use
  22250. * @param world defines the world matrix
  22251. * @param view defines the view matrix
  22252. * @param projection defines the projection matrix
  22253. * @param zmin defines the near clip plane
  22254. * @param zmax defines the far clip plane
  22255. * @returns the transformation matrix
  22256. */
  22257. static GetFinalMatrix(viewport: Viewport, world: Matrix, view: Matrix, projection: Matrix, zmin: number, zmax: number): Matrix;
  22258. /**
  22259. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  22260. * @param matrix defines the matrix to use
  22261. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  22262. */
  22263. static GetAsMatrix2x2(matrix: Matrix): Float32Array;
  22264. /**
  22265. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  22266. * @param matrix defines the matrix to use
  22267. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  22268. */
  22269. static GetAsMatrix3x3(matrix: Matrix): Float32Array;
  22270. /**
  22271. * Compute the transpose of a given matrix
  22272. * @param matrix defines the matrix to transpose
  22273. * @returns the new matrix
  22274. */
  22275. static Transpose(matrix: Matrix): Matrix;
  22276. /**
  22277. * Compute the transpose of a matrix and store it in a target matrix
  22278. * @param matrix defines the matrix to transpose
  22279. * @param result defines the target matrix
  22280. */
  22281. static TransposeToRef(matrix: Matrix, result: Matrix): void;
  22282. /**
  22283. * Computes a reflection matrix from a plane
  22284. * @param plane defines the reflection plane
  22285. * @returns a new matrix
  22286. */
  22287. static Reflection(plane: Plane): Matrix;
  22288. /**
  22289. * Computes a reflection matrix from a plane
  22290. * @param plane defines the reflection plane
  22291. * @param result defines the target matrix
  22292. */
  22293. static ReflectionToRef(plane: Plane, result: Matrix): void;
  22294. /**
  22295. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  22296. * @param xaxis defines the value of the 1st axis
  22297. * @param yaxis defines the value of the 2nd axis
  22298. * @param zaxis defines the value of the 3rd axis
  22299. * @param result defines the target matrix
  22300. */
  22301. static FromXYZAxesToRef(xaxis: Vector3, yaxis: Vector3, zaxis: Vector3, result: Matrix): void;
  22302. /**
  22303. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  22304. * @param quat defines the quaternion to use
  22305. * @param result defines the target matrix
  22306. */
  22307. static FromQuaternionToRef(quat: Quaternion, result: Matrix): void;
  22308. }
  22309. /**
  22310. * Represens a plane by the equation ax + by + cz + d = 0
  22311. */
  22312. class Plane {
  22313. /**
  22314. * Normal of the plane (a,b,c)
  22315. */
  22316. normal: Vector3;
  22317. /**
  22318. * d component of the plane
  22319. */
  22320. d: number;
  22321. /**
  22322. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  22323. * @param a a component of the plane
  22324. * @param b b component of the plane
  22325. * @param c c component of the plane
  22326. * @param d d component of the plane
  22327. */
  22328. constructor(a: number, b: number, c: number, d: number);
  22329. /**
  22330. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  22331. */
  22332. asArray(): number[];
  22333. /**
  22334. * @returns a new plane copied from the current Plane.
  22335. */
  22336. clone(): Plane;
  22337. /**
  22338. * @returns the string "Plane".
  22339. */
  22340. getClassName(): string;
  22341. /**
  22342. * @returns the Plane hash code.
  22343. */
  22344. getHashCode(): number;
  22345. /**
  22346. * Normalize the current Plane in place.
  22347. * @returns the updated Plane.
  22348. */
  22349. normalize(): Plane;
  22350. /**
  22351. * Applies a transformation the plane and returns the result
  22352. * @param transformation the transformation matrix to be applied to the plane
  22353. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  22354. */
  22355. transform(transformation: Matrix): Plane;
  22356. /**
  22357. * Calcualtte the dot product between the point and the plane normal
  22358. * @param point point to calculate the dot product with
  22359. * @returns the dot product (float) of the point coordinates and the plane normal.
  22360. */
  22361. dotCoordinate(point: Vector3): number;
  22362. /**
  22363. * Updates the current Plane from the plane defined by the three given points.
  22364. * @param point1 one of the points used to contruct the plane
  22365. * @param point2 one of the points used to contruct the plane
  22366. * @param point3 one of the points used to contruct the plane
  22367. * @returns the updated Plane.
  22368. */
  22369. copyFromPoints(point1: Vector3, point2: Vector3, point3: Vector3): Plane;
  22370. /**
  22371. * Checks if the plane is facing a given direction
  22372. * @param direction the direction to check if the plane is facing
  22373. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  22374. * @returns True is the vector "direction" is the same side than the plane normal.
  22375. */
  22376. isFrontFacingTo(direction: Vector3, epsilon: number): boolean;
  22377. /**
  22378. * Calculates the distance to a point
  22379. * @param point point to calculate distance to
  22380. * @returns the signed distance (float) from the given point to the Plane.
  22381. */
  22382. signedDistanceTo(point: Vector3): number;
  22383. /**
  22384. * Creates a plane from an array
  22385. * @param array the array to create a plane from
  22386. * @returns a new Plane from the given array.
  22387. */
  22388. static FromArray(array: ArrayLike<number>): Plane;
  22389. /**
  22390. * Creates a plane from three points
  22391. * @param point1 point used to create the plane
  22392. * @param point2 point used to create the plane
  22393. * @param point3 point used to create the plane
  22394. * @returns a new Plane defined by the three given points.
  22395. */
  22396. static FromPoints(point1: Vector3, point2: Vector3, point3: Vector3): Plane;
  22397. /**
  22398. * Creates a plane from an origin point and a normal
  22399. * @param origin origin of the plane to be constructed
  22400. * @param normal normal of the plane to be constructed
  22401. * @returns a new Plane the normal vector to this plane at the given origin point.
  22402. * Note : the vector "normal" is updated because normalized.
  22403. */
  22404. static FromPositionAndNormal(origin: Vector3, normal: Vector3): Plane;
  22405. /**
  22406. * Calculates the distance from a plane and a point
  22407. * @param origin origin of the plane to be constructed
  22408. * @param normal normal of the plane to be constructed
  22409. * @param point point to calculate distance to
  22410. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  22411. */
  22412. static SignedDistanceToPlaneFromPositionAndNormal(origin: Vector3, normal: Vector3, point: Vector3): number;
  22413. }
  22414. /**
  22415. * Class used to represent a viewport on screen
  22416. */
  22417. class Viewport {
  22418. /** viewport left coordinate */
  22419. x: number;
  22420. /** viewport top coordinate */
  22421. y: number;
  22422. /**viewport width */
  22423. width: number;
  22424. /** viewport height */
  22425. height: number;
  22426. /**
  22427. * Creates a Viewport object located at (x, y) and sized (width, height)
  22428. * @param x defines viewport left coordinate
  22429. * @param y defines viewport top coordinate
  22430. * @param width defines the viewport width
  22431. * @param height defines the viewport height
  22432. */
  22433. constructor(
  22434. /** viewport left coordinate */
  22435. x: number,
  22436. /** viewport top coordinate */
  22437. y: number,
  22438. /**viewport width */
  22439. width: number,
  22440. /** viewport height */
  22441. height: number);
  22442. /**
  22443. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  22444. * @param renderWidthOrEngine defines either an engine or the rendering width
  22445. * @param renderHeight defines the rendering height
  22446. * @returns a new Viewport
  22447. */
  22448. toGlobal(renderWidthOrEngine: number | Engine, renderHeight: number): Viewport;
  22449. /**
  22450. * Returns a new Viewport copied from the current one
  22451. * @returns a new Viewport
  22452. */
  22453. clone(): Viewport;
  22454. }
  22455. /**
  22456. * Reprasents a camera frustum
  22457. */
  22458. class Frustum {
  22459. /**
  22460. * Gets the planes representing the frustum
  22461. * @param transform matrix to be applied to the returned planes
  22462. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  22463. */
  22464. static GetPlanes(transform: Matrix): Plane[];
  22465. /**
  22466. * Gets the near frustum plane transformed by the transform matrix
  22467. * @param transform transformation matrix to be applied to the resulting frustum plane
  22468. * @param frustumPlane the resuling frustum plane
  22469. */
  22470. static GetNearPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  22471. /**
  22472. * Gets the far frustum plane transformed by the transform matrix
  22473. * @param transform transformation matrix to be applied to the resulting frustum plane
  22474. * @param frustumPlane the resuling frustum plane
  22475. */
  22476. static GetFarPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  22477. /**
  22478. * Gets the left frustum plane transformed by the transform matrix
  22479. * @param transform transformation matrix to be applied to the resulting frustum plane
  22480. * @param frustumPlane the resuling frustum plane
  22481. */
  22482. static GetLeftPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  22483. /**
  22484. * Gets the right frustum plane transformed by the transform matrix
  22485. * @param transform transformation matrix to be applied to the resulting frustum plane
  22486. * @param frustumPlane the resuling frustum plane
  22487. */
  22488. static GetRightPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  22489. /**
  22490. * Gets the top frustum plane transformed by the transform matrix
  22491. * @param transform transformation matrix to be applied to the resulting frustum plane
  22492. * @param frustumPlane the resuling frustum plane
  22493. */
  22494. static GetTopPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  22495. /**
  22496. * Gets the bottom frustum plane transformed by the transform matrix
  22497. * @param transform transformation matrix to be applied to the resulting frustum plane
  22498. * @param frustumPlane the resuling frustum plane
  22499. */
  22500. static GetBottomPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  22501. /**
  22502. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  22503. * @param transform transformation matrix to be applied to the resulting frustum planes
  22504. * @param frustumPlanes the resuling frustum planes
  22505. */
  22506. static GetPlanesToRef(transform: Matrix, frustumPlanes: Plane[]): void;
  22507. }
  22508. /** Defines supported spaces */
  22509. enum Space {
  22510. /** Local (object) space */
  22511. LOCAL = 0,
  22512. /** World space */
  22513. WORLD = 1,
  22514. /** Bone space */
  22515. BONE = 2
  22516. }
  22517. /** Defines the 3 main axes */
  22518. class Axis {
  22519. /** X axis */
  22520. static X: Vector3;
  22521. /** Y axis */
  22522. static Y: Vector3;
  22523. /** Z axis */
  22524. static Z: Vector3;
  22525. }
  22526. /** Class used to represent a Bezier curve */
  22527. class BezierCurve {
  22528. /**
  22529. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  22530. * @param t defines the time
  22531. * @param x1 defines the left coordinate on X axis
  22532. * @param y1 defines the left coordinate on Y axis
  22533. * @param x2 defines the right coordinate on X axis
  22534. * @param y2 defines the right coordinate on Y axis
  22535. * @returns the interpolated value
  22536. */
  22537. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  22538. }
  22539. /**
  22540. * Defines potential orientation for back face culling
  22541. */
  22542. enum Orientation {
  22543. /**
  22544. * Clockwise
  22545. */
  22546. CW = 0,
  22547. /** Counter clockwise */
  22548. CCW = 1
  22549. }
  22550. /**
  22551. * Defines angle representation
  22552. */
  22553. class Angle {
  22554. private _radians;
  22555. /**
  22556. * Creates an Angle object of "radians" radians (float).
  22557. */
  22558. constructor(radians: number);
  22559. /**
  22560. * Get value in degrees
  22561. * @returns the Angle value in degrees (float)
  22562. */
  22563. degrees(): number;
  22564. /**
  22565. * Get value in radians
  22566. * @returns the Angle value in radians (float)
  22567. */
  22568. radians(): number;
  22569. /**
  22570. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  22571. * @param a defines first vector
  22572. * @param b defines second vector
  22573. * @returns a new Angle
  22574. */
  22575. static BetweenTwoPoints(a: Vector2, b: Vector2): Angle;
  22576. /**
  22577. * Gets a new Angle object from the given float in radians
  22578. * @param radians defines the angle value in radians
  22579. * @returns a new Angle
  22580. */
  22581. static FromRadians(radians: number): Angle;
  22582. /**
  22583. * Gets a new Angle object from the given float in degrees
  22584. * @param degrees defines the angle value in degrees
  22585. * @returns a new Angle
  22586. */
  22587. static FromDegrees(degrees: number): Angle;
  22588. }
  22589. /**
  22590. * This represents an arc in a 2d space.
  22591. */
  22592. class Arc2 {
  22593. /** Defines the start point of the arc */
  22594. startPoint: Vector2;
  22595. /** Defines the mid point of the arc */
  22596. midPoint: Vector2;
  22597. /** Defines the end point of the arc */
  22598. endPoint: Vector2;
  22599. /**
  22600. * Defines the center point of the arc.
  22601. */
  22602. centerPoint: Vector2;
  22603. /**
  22604. * Defines the radius of the arc.
  22605. */
  22606. radius: number;
  22607. /**
  22608. * Defines the angle of the arc (from mid point to end point).
  22609. */
  22610. angle: Angle;
  22611. /**
  22612. * Defines the start angle of the arc (from start point to middle point).
  22613. */
  22614. startAngle: Angle;
  22615. /**
  22616. * Defines the orientation of the arc (clock wise/counter clock wise).
  22617. */
  22618. orientation: Orientation;
  22619. /**
  22620. * Creates an Arc object from the three given points : start, middle and end.
  22621. * @param startPoint Defines the start point of the arc
  22622. * @param midPoint Defines the midlle point of the arc
  22623. * @param endPoint Defines the end point of the arc
  22624. */
  22625. constructor(
  22626. /** Defines the start point of the arc */
  22627. startPoint: Vector2,
  22628. /** Defines the mid point of the arc */
  22629. midPoint: Vector2,
  22630. /** Defines the end point of the arc */
  22631. endPoint: Vector2);
  22632. }
  22633. /**
  22634. * Represents a 2D path made up of multiple 2D points
  22635. */
  22636. class Path2 {
  22637. private _points;
  22638. private _length;
  22639. /**
  22640. * If the path start and end point are the same
  22641. */
  22642. closed: boolean;
  22643. /**
  22644. * Creates a Path2 object from the starting 2D coordinates x and y.
  22645. * @param x the starting points x value
  22646. * @param y the starting points y value
  22647. */
  22648. constructor(x: number, y: number);
  22649. /**
  22650. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  22651. * @param x the added points x value
  22652. * @param y the added points y value
  22653. * @returns the updated Path2.
  22654. */
  22655. addLineTo(x: number, y: number): Path2;
  22656. /**
  22657. * 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.
  22658. * @param midX middle point x value
  22659. * @param midY middle point y value
  22660. * @param endX end point x value
  22661. * @param endY end point y value
  22662. * @param numberOfSegments (default: 36)
  22663. * @returns the updated Path2.
  22664. */
  22665. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  22666. /**
  22667. * Closes the Path2.
  22668. * @returns the Path2.
  22669. */
  22670. close(): Path2;
  22671. /**
  22672. * Gets the sum of the distance between each sequential point in the path
  22673. * @returns the Path2 total length (float).
  22674. */
  22675. length(): number;
  22676. /**
  22677. * Gets the points which construct the path
  22678. * @returns the Path2 internal array of points.
  22679. */
  22680. getPoints(): Vector2[];
  22681. /**
  22682. * Retreives the point at the distance aways from the starting point
  22683. * @param normalizedLengthPosition the length along the path to retreive the point from
  22684. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  22685. */
  22686. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  22687. /**
  22688. * Creates a new path starting from an x and y position
  22689. * @param x starting x value
  22690. * @param y starting y value
  22691. * @returns a new Path2 starting at the coordinates (x, y).
  22692. */
  22693. static StartingAt(x: number, y: number): Path2;
  22694. }
  22695. /**
  22696. * Represents a 3D path made up of multiple 3D points
  22697. */
  22698. class Path3D {
  22699. /**
  22700. * an array of Vector3, the curve axis of the Path3D
  22701. */
  22702. path: Vector3[];
  22703. private _curve;
  22704. private _distances;
  22705. private _tangents;
  22706. private _normals;
  22707. private _binormals;
  22708. private _raw;
  22709. /**
  22710. * new Path3D(path, normal, raw)
  22711. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  22712. * please read the description in the tutorial : http://doc.babylonjs.com/tutorials/How_to_use_Path3D
  22713. * @param path an array of Vector3, the curve axis of the Path3D
  22714. * @param normal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  22715. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  22716. */
  22717. constructor(
  22718. /**
  22719. * an array of Vector3, the curve axis of the Path3D
  22720. */
  22721. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  22722. /**
  22723. * Returns the Path3D array of successive Vector3 designing its curve.
  22724. * @returns the Path3D array of successive Vector3 designing its curve.
  22725. */
  22726. getCurve(): Vector3[];
  22727. /**
  22728. * Returns an array populated with tangent vectors on each Path3D curve point.
  22729. * @returns an array populated with tangent vectors on each Path3D curve point.
  22730. */
  22731. getTangents(): Vector3[];
  22732. /**
  22733. * Returns an array populated with normal vectors on each Path3D curve point.
  22734. * @returns an array populated with normal vectors on each Path3D curve point.
  22735. */
  22736. getNormals(): Vector3[];
  22737. /**
  22738. * Returns an array populated with binormal vectors on each Path3D curve point.
  22739. * @returns an array populated with binormal vectors on each Path3D curve point.
  22740. */
  22741. getBinormals(): Vector3[];
  22742. /**
  22743. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  22744. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  22745. */
  22746. getDistances(): number[];
  22747. /**
  22748. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  22749. * @param path path which all values are copied into the curves points
  22750. * @param firstNormal which should be projected onto the curve
  22751. * @returns the same object updated.
  22752. */
  22753. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  22754. private _compute;
  22755. private _getFirstNonNullVector;
  22756. private _getLastNonNullVector;
  22757. private _normalVector;
  22758. }
  22759. /**
  22760. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  22761. * A Curve3 is designed from a series of successive Vector3.
  22762. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  22763. */
  22764. class Curve3 {
  22765. private _points;
  22766. private _length;
  22767. /**
  22768. * Returns a Curve3 object along a Quadratic Bezier curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#quadratic-bezier-curve
  22769. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  22770. * @param v1 (Vector3) the control point
  22771. * @param v2 (Vector3) the end point of the Quadratic Bezier
  22772. * @param nbPoints (integer) the wanted number of points in the curve
  22773. * @returns the created Curve3
  22774. */
  22775. static CreateQuadraticBezier(v0: Vector3, v1: Vector3, v2: Vector3, nbPoints: number): Curve3;
  22776. /**
  22777. * Returns a Curve3 object along a Cubic Bezier curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#cubic-bezier-curve
  22778. * @param v0 (Vector3) the origin point of the Cubic Bezier
  22779. * @param v1 (Vector3) the first control point
  22780. * @param v2 (Vector3) the second control point
  22781. * @param v3 (Vector3) the end point of the Cubic Bezier
  22782. * @param nbPoints (integer) the wanted number of points in the curve
  22783. * @returns the created Curve3
  22784. */
  22785. static CreateCubicBezier(v0: Vector3, v1: Vector3, v2: Vector3, v3: Vector3, nbPoints: number): Curve3;
  22786. /**
  22787. * Returns a Curve3 object along a Hermite Spline curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#hermite-spline
  22788. * @param p1 (Vector3) the origin point of the Hermite Spline
  22789. * @param t1 (Vector3) the tangent vector at the origin point
  22790. * @param p2 (Vector3) the end point of the Hermite Spline
  22791. * @param t2 (Vector3) the tangent vector at the end point
  22792. * @param nbPoints (integer) the wanted number of points in the curve
  22793. * @returns the created Curve3
  22794. */
  22795. static CreateHermiteSpline(p1: Vector3, t1: Vector3, p2: Vector3, t2: Vector3, nbPoints: number): Curve3;
  22796. /**
  22797. * Returns a Curve3 object along a CatmullRom Spline curve :
  22798. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  22799. * @param nbPoints (integer) the wanted number of points between each curve control points
  22800. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  22801. * @returns the created Curve3
  22802. */
  22803. static CreateCatmullRomSpline(points: Vector3[], nbPoints: number, closed?: boolean): Curve3;
  22804. /**
  22805. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  22806. * A Curve3 is designed from a series of successive Vector3.
  22807. * Tuto : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#curve3-object
  22808. * @param points points which make up the curve
  22809. */
  22810. constructor(points: Vector3[]);
  22811. /**
  22812. * @returns the Curve3 stored array of successive Vector3
  22813. */
  22814. getPoints(): Vector3[];
  22815. /**
  22816. * @returns the computed length (float) of the curve.
  22817. */
  22818. length(): number;
  22819. /**
  22820. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  22821. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  22822. * curveA and curveB keep unchanged.
  22823. * @param curve the curve to continue from this curve
  22824. * @returns the newly constructed curve
  22825. */
  22826. continue(curve: Curve3): Curve3;
  22827. private _computeLength;
  22828. }
  22829. /**
  22830. * Contains position and normal vectors for a vertex
  22831. */
  22832. class PositionNormalVertex {
  22833. /** the position of the vertex (defaut: 0,0,0) */
  22834. position: Vector3;
  22835. /** the normal of the vertex (defaut: 0,1,0) */
  22836. normal: Vector3;
  22837. /**
  22838. * Creates a PositionNormalVertex
  22839. * @param position the position of the vertex (defaut: 0,0,0)
  22840. * @param normal the normal of the vertex (defaut: 0,1,0)
  22841. */
  22842. constructor(
  22843. /** the position of the vertex (defaut: 0,0,0) */
  22844. position?: Vector3,
  22845. /** the normal of the vertex (defaut: 0,1,0) */
  22846. normal?: Vector3);
  22847. /**
  22848. * Clones the PositionNormalVertex
  22849. * @returns the cloned PositionNormalVertex
  22850. */
  22851. clone(): PositionNormalVertex;
  22852. }
  22853. /**
  22854. * Contains position, normal and uv vectors for a vertex
  22855. */
  22856. class PositionNormalTextureVertex {
  22857. /** the position of the vertex (defaut: 0,0,0) */
  22858. position: Vector3;
  22859. /** the normal of the vertex (defaut: 0,1,0) */
  22860. normal: Vector3;
  22861. /** the uv of the vertex (default: 0,0) */
  22862. uv: Vector2;
  22863. /**
  22864. * Creates a PositionNormalTextureVertex
  22865. * @param position the position of the vertex (defaut: 0,0,0)
  22866. * @param normal the normal of the vertex (defaut: 0,1,0)
  22867. * @param uv the uv of the vertex (default: 0,0)
  22868. */
  22869. constructor(
  22870. /** the position of the vertex (defaut: 0,0,0) */
  22871. position?: Vector3,
  22872. /** the normal of the vertex (defaut: 0,1,0) */
  22873. normal?: Vector3,
  22874. /** the uv of the vertex (default: 0,0) */
  22875. uv?: Vector2);
  22876. /**
  22877. * Clones the PositionNormalTextureVertex
  22878. * @returns the cloned PositionNormalTextureVertex
  22879. */
  22880. clone(): PositionNormalTextureVertex;
  22881. }
  22882. /**
  22883. * @hidden
  22884. */
  22885. class Tmp {
  22886. static Color3: Color3[];
  22887. static Color4: Color4[];
  22888. static Vector2: Vector2[];
  22889. static Vector3: Vector3[];
  22890. static Vector4: Vector4[];
  22891. static Quaternion: Quaternion[];
  22892. static Matrix: Matrix[];
  22893. }
  22894. }
  22895. declare module BABYLON {
  22896. /**
  22897. * Class representing spherical polynomial coefficients to the 3rd degree
  22898. */
  22899. class SphericalPolynomial {
  22900. /**
  22901. * The x coefficients of the spherical polynomial
  22902. */
  22903. x: Vector3;
  22904. /**
  22905. * The y coefficients of the spherical polynomial
  22906. */
  22907. y: Vector3;
  22908. /**
  22909. * The z coefficients of the spherical polynomial
  22910. */
  22911. z: Vector3;
  22912. /**
  22913. * The xx coefficients of the spherical polynomial
  22914. */
  22915. xx: Vector3;
  22916. /**
  22917. * The yy coefficients of the spherical polynomial
  22918. */
  22919. yy: Vector3;
  22920. /**
  22921. * The zz coefficients of the spherical polynomial
  22922. */
  22923. zz: Vector3;
  22924. /**
  22925. * The xy coefficients of the spherical polynomial
  22926. */
  22927. xy: Vector3;
  22928. /**
  22929. * The yz coefficients of the spherical polynomial
  22930. */
  22931. yz: Vector3;
  22932. /**
  22933. * The zx coefficients of the spherical polynomial
  22934. */
  22935. zx: Vector3;
  22936. /**
  22937. * Adds an ambient color to the spherical polynomial
  22938. * @param color the color to add
  22939. */
  22940. addAmbient(color: Color3): void;
  22941. /**
  22942. * Scales the spherical polynomial by the given amount
  22943. * @param scale the amount to scale
  22944. */
  22945. scale(scale: number): void;
  22946. /**
  22947. * Gets the spherical polynomial from harmonics
  22948. * @param harmonics the spherical harmonics
  22949. * @returns the spherical polynomial
  22950. */
  22951. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  22952. /**
  22953. * Constructs a spherical polynomial from an array.
  22954. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  22955. * @returns the spherical polynomial
  22956. */
  22957. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  22958. }
  22959. /**
  22960. * Class representing spherical harmonics coefficients to the 3rd degree
  22961. */
  22962. class SphericalHarmonics {
  22963. /**
  22964. * The l0,0 coefficients of the spherical harmonics
  22965. */
  22966. l00: Vector3;
  22967. /**
  22968. * The l1,-1 coefficients of the spherical harmonics
  22969. */
  22970. l1_1: Vector3;
  22971. /**
  22972. * The l1,0 coefficients of the spherical harmonics
  22973. */
  22974. l10: Vector3;
  22975. /**
  22976. * The l1,1 coefficients of the spherical harmonics
  22977. */
  22978. l11: Vector3;
  22979. /**
  22980. * The l2,-2 coefficients of the spherical harmonics
  22981. */
  22982. l2_2: Vector3;
  22983. /**
  22984. * The l2,-1 coefficients of the spherical harmonics
  22985. */
  22986. l2_1: Vector3;
  22987. /**
  22988. * The l2,0 coefficients of the spherical harmonics
  22989. */
  22990. l20: Vector3;
  22991. /**
  22992. * The l2,1 coefficients of the spherical harmonics
  22993. */
  22994. l21: Vector3;
  22995. /**
  22996. * The l2,2 coefficients of the spherical harmonics
  22997. */
  22998. lL22: Vector3;
  22999. /**
  23000. * Adds a light to the spherical harmonics
  23001. * @param direction the direction of the light
  23002. * @param color the color of the light
  23003. * @param deltaSolidAngle the delta solid angle of the light
  23004. */
  23005. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  23006. /**
  23007. * Scales the spherical harmonics by the given amount
  23008. * @param scale the amount to scale
  23009. */
  23010. scale(scale: number): void;
  23011. /**
  23012. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  23013. *
  23014. * ```
  23015. * E_lm = A_l * L_lm
  23016. * ```
  23017. *
  23018. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  23019. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  23020. * the scaling factors are given in equation 9.
  23021. */
  23022. convertIncidentRadianceToIrradiance(): void;
  23023. /**
  23024. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  23025. *
  23026. * ```
  23027. * L = (1/pi) * E * rho
  23028. * ```
  23029. *
  23030. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  23031. */
  23032. convertIrradianceToLambertianRadiance(): void;
  23033. /**
  23034. * Gets the spherical harmonics from polynomial
  23035. * @param polynomial the spherical polynomial
  23036. * @returns the spherical harmonics
  23037. */
  23038. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  23039. /**
  23040. * Constructs a spherical harmonics from an array.
  23041. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  23042. * @returns the spherical harmonics
  23043. */
  23044. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  23045. }
  23046. }
  23047. declare module BABYLON {
  23048. /**
  23049. * This represents one of the lens effect in a `BABYLON.lensFlareSystem`.
  23050. * It controls one of the indiviual texture used in the effect.
  23051. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  23052. */
  23053. class LensFlare {
  23054. /**
  23055. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  23056. */
  23057. size: number;
  23058. /**
  23059. * 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.
  23060. */
  23061. position: number;
  23062. /**
  23063. * Define the lens color.
  23064. */
  23065. color: Color3;
  23066. /**
  23067. * Define the lens texture.
  23068. */
  23069. texture: Nullable<Texture>;
  23070. /**
  23071. * Define the alpha mode to render this particular lens.
  23072. */
  23073. alphaMode: number;
  23074. private _system;
  23075. /**
  23076. * Creates a new Lens Flare.
  23077. * This represents one of the lens effect in a `BABYLON.lensFlareSystem`.
  23078. * It controls one of the indiviual texture used in the effect.
  23079. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  23080. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  23081. * @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.
  23082. * @param color Define the lens color
  23083. * @param imgUrl Define the lens texture url
  23084. * @param system Define the `lensFlareSystem` this flare is part of
  23085. * @returns The newly created Lens Flare
  23086. */
  23087. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  23088. /**
  23089. * Instantiates a new Lens Flare.
  23090. * This represents one of the lens effect in a `BABYLON.lensFlareSystem`.
  23091. * It controls one of the indiviual texture used in the effect.
  23092. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  23093. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  23094. * @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.
  23095. * @param color Define the lens color
  23096. * @param imgUrl Define the lens texture url
  23097. * @param system Define the `lensFlareSystem` this flare is part of
  23098. */
  23099. constructor(
  23100. /**
  23101. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  23102. */
  23103. size: number,
  23104. /**
  23105. * 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.
  23106. */
  23107. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  23108. /**
  23109. * Dispose and release the lens flare with its associated resources.
  23110. */
  23111. dispose(): void;
  23112. }
  23113. }
  23114. declare module BABYLON {
  23115. /**
  23116. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  23117. * It is usually composed of several `BABYLON.lensFlare`.
  23118. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  23119. */
  23120. class LensFlareSystem {
  23121. /**
  23122. * Define the name of the lens flare system
  23123. */
  23124. name: string;
  23125. /**
  23126. * List of lens flares used in this system.
  23127. */
  23128. lensFlares: LensFlare[];
  23129. /**
  23130. * Define a limit from the border the lens flare can be visible.
  23131. */
  23132. borderLimit: number;
  23133. /**
  23134. * Define a viewport border we do not want to see the lens flare in.
  23135. */
  23136. viewportBorder: number;
  23137. /**
  23138. * Define a predicate which could limit the list of meshes able to occlude the effect.
  23139. */
  23140. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  23141. /**
  23142. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  23143. */
  23144. layerMask: number;
  23145. /**
  23146. * Define the id of the lens flare system in the scene.
  23147. * (equal to name by default)
  23148. */
  23149. id: string;
  23150. private _scene;
  23151. private _emitter;
  23152. private _vertexBuffers;
  23153. private _indexBuffer;
  23154. private _effect;
  23155. private _positionX;
  23156. private _positionY;
  23157. private _isEnabled;
  23158. /**
  23159. * Instantiates a lens flare system.
  23160. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  23161. * It is usually composed of several `BABYLON.lensFlare`.
  23162. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  23163. * @param name Define the name of the lens flare system in the scene
  23164. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  23165. * @param scene Define the scene the lens flare system belongs to
  23166. */
  23167. constructor(
  23168. /**
  23169. * Define the name of the lens flare system
  23170. */
  23171. name: string, emitter: any, scene: Scene);
  23172. /**
  23173. * Define if the lens flare system is enabled.
  23174. */
  23175. isEnabled: boolean;
  23176. /**
  23177. * Get the scene the effects belongs to.
  23178. * @returns the scene holding the lens flare system
  23179. */
  23180. getScene(): Scene;
  23181. /**
  23182. * Get the emitter of the lens flare system.
  23183. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  23184. * @returns the emitter of the lens flare system
  23185. */
  23186. getEmitter(): any;
  23187. /**
  23188. * Set the emitter of the lens flare system.
  23189. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  23190. * @param newEmitter Define the new emitter of the system
  23191. */
  23192. setEmitter(newEmitter: any): void;
  23193. /**
  23194. * Get the lens flare system emitter position.
  23195. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  23196. * @returns the position
  23197. */
  23198. getEmitterPosition(): Vector3;
  23199. /**
  23200. * @hidden
  23201. */
  23202. computeEffectivePosition(globalViewport: Viewport): boolean;
  23203. /** @hidden */
  23204. /**
  23205. * @hidden
  23206. */
  23207. render(): boolean;
  23208. /**
  23209. * Dispose and release the lens flare with its associated resources.
  23210. */
  23211. dispose(): void;
  23212. /**
  23213. * Parse a lens flare system from a JSON repressentation
  23214. * @param parsedLensFlareSystem Define the JSON to parse
  23215. * @param scene Define the scene the parsed system should be instantiated in
  23216. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  23217. * @returns the parsed system
  23218. */
  23219. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  23220. /**
  23221. * Serialize the current Lens Flare System into a JSON representation.
  23222. * @returns the serialized JSON
  23223. */
  23224. serialize(): any;
  23225. }
  23226. }
  23227. declare module BABYLON {
  23228. interface AbstractScene {
  23229. /**
  23230. * The list of lens flare system added to the scene
  23231. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  23232. */
  23233. lensFlareSystems: Array<LensFlareSystem>;
  23234. /**
  23235. * Removes the given lens flare system from this scene.
  23236. * @param toRemove The lens flare system to remove
  23237. * @returns The index of the removed lens flare system
  23238. */
  23239. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  23240. /**
  23241. * Adds the given lens flare system to this scene
  23242. * @param newLensFlareSystem The lens flare system to add
  23243. */
  23244. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  23245. /**
  23246. * Gets a lens flare system using its name
  23247. * @param name defines the name to look for
  23248. * @returns the lens flare system or null if not found
  23249. */
  23250. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  23251. /**
  23252. * Gets a lens flare system using its id
  23253. * @param id defines the id to look for
  23254. * @returns the lens flare system or null if not found
  23255. */
  23256. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  23257. }
  23258. /**
  23259. * Defines the lens flare scene component responsible to manage any lens flares
  23260. * in a given scene.
  23261. */
  23262. class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  23263. /**
  23264. * The component name helpfull to identify the component in the list of scene components.
  23265. */
  23266. readonly name: string;
  23267. /**
  23268. * The scene the component belongs to.
  23269. */
  23270. scene: Scene;
  23271. /**
  23272. * Creates a new instance of the component for the given scene
  23273. * @param scene Defines the scene to register the component in
  23274. */
  23275. constructor(scene: Scene);
  23276. /**
  23277. * Registers the component in a given scene
  23278. */
  23279. register(): void;
  23280. /**
  23281. * Rebuilds the elements related to this component in case of
  23282. * context lost for instance.
  23283. */
  23284. rebuild(): void;
  23285. /**
  23286. * Adds all the element from the container to the scene
  23287. * @param container the container holding the elements
  23288. */
  23289. addFromContainer(container: AbstractScene): void;
  23290. /**
  23291. * Removes all the elements in the container from the scene
  23292. * @param container contains the elements to remove
  23293. */
  23294. removeFromContainer(container: AbstractScene): void;
  23295. /**
  23296. * Serializes the component data to the specified json object
  23297. * @param serializationObject The object to serialize to
  23298. */
  23299. serialize(serializationObject: any): void;
  23300. /**
  23301. * Disposes the component and the associated ressources.
  23302. */
  23303. dispose(): void;
  23304. private _draw;
  23305. }
  23306. }
  23307. declare module BABYLON {
  23308. /**
  23309. * Defines a target to use with MorphTargetManager
  23310. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23311. */
  23312. class MorphTarget implements IAnimatable {
  23313. /** defines the name of the target */
  23314. name: string;
  23315. /**
  23316. * Gets or sets the list of animations
  23317. */
  23318. animations: Animation[];
  23319. private _scene;
  23320. private _positions;
  23321. private _normals;
  23322. private _tangents;
  23323. private _influence;
  23324. /**
  23325. * Observable raised when the influence changes
  23326. */
  23327. onInfluenceChanged: Observable<boolean>;
  23328. /** @hidden */
  23329. /**
  23330. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  23331. */
  23332. influence: number;
  23333. private _animationPropertiesOverride;
  23334. /**
  23335. * Gets or sets the animation properties override
  23336. */
  23337. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  23338. /**
  23339. * Creates a new MorphTarget
  23340. * @param name defines the name of the target
  23341. * @param influence defines the influence to use
  23342. */
  23343. constructor(
  23344. /** defines the name of the target */
  23345. name: string, influence?: number, scene?: Nullable<Scene>);
  23346. /**
  23347. * Gets a boolean defining if the target contains position data
  23348. */
  23349. readonly hasPositions: boolean;
  23350. /**
  23351. * Gets a boolean defining if the target contains normal data
  23352. */
  23353. readonly hasNormals: boolean;
  23354. /**
  23355. * Gets a boolean defining if the target contains tangent data
  23356. */
  23357. readonly hasTangents: boolean;
  23358. /**
  23359. * Affects position data to this target
  23360. * @param data defines the position data to use
  23361. */
  23362. setPositions(data: Nullable<FloatArray>): void;
  23363. /**
  23364. * Gets the position data stored in this target
  23365. * @returns a FloatArray containing the position data (or null if not present)
  23366. */
  23367. getPositions(): Nullable<FloatArray>;
  23368. /**
  23369. * Affects normal data to this target
  23370. * @param data defines the normal data to use
  23371. */
  23372. setNormals(data: Nullable<FloatArray>): void;
  23373. /**
  23374. * Gets the normal data stored in this target
  23375. * @returns a FloatArray containing the normal data (or null if not present)
  23376. */
  23377. getNormals(): Nullable<FloatArray>;
  23378. /**
  23379. * Affects tangent data to this target
  23380. * @param data defines the tangent data to use
  23381. */
  23382. setTangents(data: Nullable<FloatArray>): void;
  23383. /**
  23384. * Gets the tangent data stored in this target
  23385. * @returns a FloatArray containing the tangent data (or null if not present)
  23386. */
  23387. getTangents(): Nullable<FloatArray>;
  23388. /**
  23389. * Serializes the current target into a Serialization object
  23390. * @returns the serialized object
  23391. */
  23392. serialize(): any;
  23393. /**
  23394. * Creates a new target from serialized data
  23395. * @param serializationObject defines the serialized data to use
  23396. * @returns a new MorphTarget
  23397. */
  23398. static Parse(serializationObject: any): MorphTarget;
  23399. /**
  23400. * Creates a MorphTarget from mesh data
  23401. * @param mesh defines the source mesh
  23402. * @param name defines the name to use for the new target
  23403. * @param influence defines the influence to attach to the target
  23404. * @returns a new MorphTarget
  23405. */
  23406. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  23407. }
  23408. }
  23409. declare module BABYLON {
  23410. /**
  23411. * This class is used to deform meshes using morphing between different targets
  23412. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23413. */
  23414. class MorphTargetManager {
  23415. private _targets;
  23416. private _targetInfluenceChangedObservers;
  23417. private _targetDataLayoutChangedObservers;
  23418. private _activeTargets;
  23419. private _scene;
  23420. private _influences;
  23421. private _supportsNormals;
  23422. private _supportsTangents;
  23423. private _vertexCount;
  23424. private _uniqueId;
  23425. private _tempInfluences;
  23426. /**
  23427. * Creates a new MorphTargetManager
  23428. * @param scene defines the current scene
  23429. */
  23430. constructor(scene?: Nullable<Scene>);
  23431. /**
  23432. * Gets the unique ID of this manager
  23433. */
  23434. readonly uniqueId: number;
  23435. /**
  23436. * Gets the number of vertices handled by this manager
  23437. */
  23438. readonly vertexCount: number;
  23439. /**
  23440. * Gets a boolean indicating if this manager supports morphing of normals
  23441. */
  23442. readonly supportsNormals: boolean;
  23443. /**
  23444. * Gets a boolean indicating if this manager supports morphing of tangents
  23445. */
  23446. readonly supportsTangents: boolean;
  23447. /**
  23448. * Gets the number of targets stored in this manager
  23449. */
  23450. readonly numTargets: number;
  23451. /**
  23452. * Gets the number of influencers (ie. the number of targets with influences > 0)
  23453. */
  23454. readonly numInfluencers: number;
  23455. /**
  23456. * Gets the list of influences (one per target)
  23457. */
  23458. readonly influences: Float32Array;
  23459. /**
  23460. * Gets the active target at specified index. An active target is a target with an influence > 0
  23461. * @param index defines the index to check
  23462. * @returns the requested target
  23463. */
  23464. getActiveTarget(index: number): MorphTarget;
  23465. /**
  23466. * Gets the target at specified index
  23467. * @param index defines the index to check
  23468. * @returns the requested target
  23469. */
  23470. getTarget(index: number): MorphTarget;
  23471. /**
  23472. * Add a new target to this manager
  23473. * @param target defines the target to add
  23474. */
  23475. addTarget(target: MorphTarget): void;
  23476. /**
  23477. * Removes a target from the manager
  23478. * @param target defines the target to remove
  23479. */
  23480. removeTarget(target: MorphTarget): void;
  23481. /**
  23482. * Serializes the current manager into a Serialization object
  23483. * @returns the serialized object
  23484. */
  23485. serialize(): any;
  23486. private _syncActiveTargets;
  23487. /**
  23488. * Syncrhonize the targets with all the meshes using this morph target manager
  23489. */
  23490. synchronize(): void;
  23491. /**
  23492. * Creates a new MorphTargetManager from serialized data
  23493. * @param serializationObject defines the serialized data
  23494. * @param scene defines the hosting scene
  23495. * @returns the new MorphTargetManager
  23496. */
  23497. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  23498. }
  23499. }
  23500. declare module BABYLON {
  23501. /**
  23502. * Class used to store all common mesh properties
  23503. */
  23504. class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  23505. /** No occlusion */
  23506. static OCCLUSION_TYPE_NONE: number;
  23507. /** Occlusion set to optimisitic */
  23508. static OCCLUSION_TYPE_OPTIMISTIC: number;
  23509. /** Occlusion set to strict */
  23510. static OCCLUSION_TYPE_STRICT: number;
  23511. /** Use an accurante occlusion algorithm */
  23512. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  23513. /** Use a conservative occlusion algorithm */
  23514. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  23515. /** Default culling strategy with bounding box and bounding sphere and then frustum culling */
  23516. static readonly CULLINGSTRATEGY_STANDARD: number;
  23517. /** Culling strategy with bounding sphere only and then frustum culling */
  23518. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  23519. /**
  23520. * No billboard
  23521. */
  23522. static readonly BILLBOARDMODE_NONE: number;
  23523. /** Billboard on X axis */
  23524. static readonly BILLBOARDMODE_X: number;
  23525. /** Billboard on Y axis */
  23526. static readonly BILLBOARDMODE_Y: number;
  23527. /** Billboard on Z axis */
  23528. static readonly BILLBOARDMODE_Z: number;
  23529. /** Billboard on all axes */
  23530. static readonly BILLBOARDMODE_ALL: number;
  23531. private _facetData;
  23532. /** Gets ot sets the culling strategy to use to find visible meshes */
  23533. cullingStrategy: number;
  23534. /**
  23535. * Gets the number of facets in the mesh
  23536. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  23537. */
  23538. readonly facetNb: number;
  23539. /**
  23540. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  23541. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  23542. */
  23543. partitioningSubdivisions: number;
  23544. /**
  23545. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  23546. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  23547. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  23548. */
  23549. partitioningBBoxRatio: number;
  23550. /**
  23551. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  23552. * Works only for updatable meshes.
  23553. * Doesn't work with multi-materials
  23554. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  23555. */
  23556. mustDepthSortFacets: boolean;
  23557. /**
  23558. * The location (Vector3) where the facet depth sort must be computed from.
  23559. * By default, the active camera position.
  23560. * Used only when facet depth sort is enabled
  23561. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  23562. */
  23563. facetDepthSortFrom: Vector3;
  23564. /**
  23565. * gets a boolean indicating if facetData is enabled
  23566. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  23567. */
  23568. readonly isFacetDataEnabled: boolean;
  23569. /** @hidden */
  23570. /**
  23571. * An event triggered when this mesh collides with another one
  23572. */
  23573. onCollideObservable: Observable<AbstractMesh>;
  23574. private _onCollideObserver;
  23575. /** Set a function to call when this mesh collides with another one */
  23576. onCollide: () => void;
  23577. /**
  23578. * An event triggered when the collision's position changes
  23579. */
  23580. onCollisionPositionChangeObservable: Observable<Vector3>;
  23581. private _onCollisionPositionChangeObserver;
  23582. /** Set a function to call when the collision's position changes */
  23583. onCollisionPositionChange: () => void;
  23584. /**
  23585. * An event triggered when material is changed
  23586. */
  23587. onMaterialChangedObservable: Observable<AbstractMesh>;
  23588. /**
  23589. * Gets or sets the orientation for POV movement & rotation
  23590. */
  23591. definedFacingForward: boolean;
  23592. /** @hidden */
  23593. private _visibility;
  23594. /**
  23595. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  23596. */
  23597. /**
  23598. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  23599. */
  23600. visibility: number;
  23601. /** Gets or sets the alpha index used to sort transparent meshes
  23602. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  23603. */
  23604. alphaIndex: number;
  23605. /**
  23606. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  23607. */
  23608. isVisible: boolean;
  23609. /**
  23610. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  23611. */
  23612. isPickable: boolean;
  23613. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  23614. showSubMeshesBoundingBox: boolean;
  23615. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  23616. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  23617. */
  23618. isBlocker: boolean;
  23619. /**
  23620. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  23621. */
  23622. enablePointerMoveEvents: boolean;
  23623. /**
  23624. * Specifies the rendering group id for this mesh (0 by default)
  23625. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  23626. */
  23627. renderingGroupId: number;
  23628. private _material;
  23629. /** Gets or sets current material */
  23630. material: Nullable<Material>;
  23631. private _receiveShadows;
  23632. /**
  23633. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  23634. * @see http://doc.babylonjs.com/babylon101/shadows
  23635. */
  23636. receiveShadows: boolean;
  23637. /** Defines color to use when rendering outline */
  23638. outlineColor: Color3;
  23639. /** Define width to use when rendering outline */
  23640. outlineWidth: number;
  23641. /** Defines color to use when rendering overlay */
  23642. overlayColor: Color3;
  23643. /** Defines alpha to use when rendering overlay */
  23644. overlayAlpha: number;
  23645. private _hasVertexAlpha;
  23646. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  23647. hasVertexAlpha: boolean;
  23648. private _useVertexColors;
  23649. /** 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) */
  23650. useVertexColors: boolean;
  23651. private _computeBonesUsingShaders;
  23652. /**
  23653. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  23654. */
  23655. computeBonesUsingShaders: boolean;
  23656. private _numBoneInfluencers;
  23657. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  23658. numBoneInfluencers: number;
  23659. private _applyFog;
  23660. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  23661. applyFog: boolean;
  23662. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  23663. useOctreeForRenderingSelection: boolean;
  23664. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  23665. useOctreeForPicking: boolean;
  23666. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  23667. useOctreeForCollisions: boolean;
  23668. private _layerMask;
  23669. /**
  23670. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  23671. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  23672. */
  23673. layerMask: number;
  23674. /**
  23675. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  23676. */
  23677. alwaysSelectAsActiveMesh: boolean;
  23678. /**
  23679. * Gets or sets the current action manager
  23680. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  23681. */
  23682. actionManager: Nullable<ActionManager>;
  23683. private _checkCollisions;
  23684. private _collisionMask;
  23685. private _collisionGroup;
  23686. /**
  23687. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  23688. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  23689. */
  23690. ellipsoid: Vector3;
  23691. /**
  23692. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  23693. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  23694. */
  23695. ellipsoidOffset: Vector3;
  23696. private _collider;
  23697. private _oldPositionForCollisions;
  23698. private _diffPositionForCollisions;
  23699. /**
  23700. * Gets or sets a collision mask used to mask collisions (default is -1).
  23701. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  23702. */
  23703. collisionMask: number;
  23704. /**
  23705. * Gets or sets the current collision group mask (-1 by default).
  23706. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  23707. */
  23708. collisionGroup: number;
  23709. /**
  23710. * Defines edge width used when edgesRenderer is enabled
  23711. * @see https://www.babylonjs-playground.com/#10OJSG#13
  23712. */
  23713. edgesWidth: number;
  23714. /**
  23715. * Defines edge color used when edgesRenderer is enabled
  23716. * @see https://www.babylonjs-playground.com/#10OJSG#13
  23717. */
  23718. edgesColor: Color4;
  23719. /** @hidden */
  23720. /** @hidden */
  23721. /** @hidden */
  23722. /** @hidden */
  23723. /**
  23724. * Gets or sets the list of subMeshes
  23725. * @see http://doc.babylonjs.com/how_to/multi_materials
  23726. */
  23727. subMeshes: SubMesh[];
  23728. /** @hidden */
  23729. /** @hidden */
  23730. /** @hidden */
  23731. /** @hidden */
  23732. protected readonly _positions: Nullable<Vector3[]>;
  23733. /** @hidden */
  23734. /** @hidden */
  23735. private _skeleton;
  23736. /** @hidden */
  23737. /**
  23738. * Gets or sets a skeleton to apply skining transformations
  23739. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  23740. */
  23741. skeleton: Nullable<Skeleton>;
  23742. /**
  23743. * An event triggered when the mesh is rebuilt.
  23744. */
  23745. onRebuildObservable: Observable<AbstractMesh>;
  23746. /**
  23747. * Creates a new AbstractMesh
  23748. * @param name defines the name of the mesh
  23749. * @param scene defines the hosting scene
  23750. */
  23751. constructor(name: string, scene?: Nullable<Scene>);
  23752. /**
  23753. * Returns the string "AbstractMesh"
  23754. * @returns "AbstractMesh"
  23755. */
  23756. getClassName(): string;
  23757. /**
  23758. * Gets a string representation of the current mesh
  23759. * @param fullDetails defines a boolean indicating if full details must be included
  23760. * @returns a string representation of the current mesh
  23761. */
  23762. toString(fullDetails?: boolean): string;
  23763. /** @hidden */
  23764. /** @hidden */
  23765. /** @hidden */
  23766. /** @hidden */
  23767. /** @hidden */
  23768. private _markSubMeshesAsDirty;
  23769. /** @hidden */
  23770. /** @hidden */
  23771. /** @hidden */
  23772. /**
  23773. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  23774. */
  23775. scaling: Vector3;
  23776. /**
  23777. * Returns true if the mesh is blocked. Implemented by child classes
  23778. */
  23779. readonly isBlocked: boolean;
  23780. /**
  23781. * Returns the mesh itself by default. Implemented by child classes
  23782. * @param camera defines the camera to use to pick the right LOD level
  23783. * @returns the currentAbstractMesh
  23784. */
  23785. getLOD(camera: Camera): Nullable<AbstractMesh>;
  23786. /**
  23787. * Returns 0 by default. Implemented by child classes
  23788. * @returns an integer
  23789. */
  23790. getTotalVertices(): number;
  23791. /**
  23792. * Returns null by default. Implemented by child classes
  23793. * @returns null
  23794. */
  23795. getIndices(): Nullable<IndicesArray>;
  23796. /**
  23797. * Returns the array of the requested vertex data kind. Implemented by child classes
  23798. * @param kind defines the vertex data kind to use
  23799. * @returns null
  23800. */
  23801. getVerticesData(kind: string): 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. * Note that a new underlying VertexBuffer object is created each call.
  23806. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  23807. * @param kind defines vertex data kind:
  23808. * * BABYLON.VertexBuffer.PositionKind
  23809. * * BABYLON.VertexBuffer.UVKind
  23810. * * BABYLON.VertexBuffer.UV2Kind
  23811. * * BABYLON.VertexBuffer.UV3Kind
  23812. * * BABYLON.VertexBuffer.UV4Kind
  23813. * * BABYLON.VertexBuffer.UV5Kind
  23814. * * BABYLON.VertexBuffer.UV6Kind
  23815. * * BABYLON.VertexBuffer.ColorKind
  23816. * * BABYLON.VertexBuffer.MatricesIndicesKind
  23817. * * BABYLON.VertexBuffer.MatricesIndicesExtraKind
  23818. * * BABYLON.VertexBuffer.MatricesWeightsKind
  23819. * * BABYLON.VertexBuffer.MatricesWeightsExtraKind
  23820. * @param data defines the data source
  23821. * @param updatable defines if the data must be flagged as updatable (or static)
  23822. * @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
  23823. * @returns the current mesh
  23824. */
  23825. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  23826. /**
  23827. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  23828. * If the mesh has no geometry, it is simply returned as it is.
  23829. * @param kind defines vertex data kind:
  23830. * * BABYLON.VertexBuffer.PositionKind
  23831. * * BABYLON.VertexBuffer.UVKind
  23832. * * BABYLON.VertexBuffer.UV2Kind
  23833. * * BABYLON.VertexBuffer.UV3Kind
  23834. * * BABYLON.VertexBuffer.UV4Kind
  23835. * * BABYLON.VertexBuffer.UV5Kind
  23836. * * BABYLON.VertexBuffer.UV6Kind
  23837. * * BABYLON.VertexBuffer.ColorKind
  23838. * * BABYLON.VertexBuffer.MatricesIndicesKind
  23839. * * BABYLON.VertexBuffer.MatricesIndicesExtraKind
  23840. * * BABYLON.VertexBuffer.MatricesWeightsKind
  23841. * * BABYLON.VertexBuffer.MatricesWeightsExtraKind
  23842. * @param data defines the data source
  23843. * @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
  23844. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  23845. * @returns the current mesh
  23846. */
  23847. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  23848. /**
  23849. * Sets the mesh indices,
  23850. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  23851. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  23852. * @param totalVertices Defines the total number of vertices
  23853. * @returns the current mesh
  23854. */
  23855. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  23856. /**
  23857. * Gets a boolean indicating if specific vertex data is present
  23858. * @param kind defines the vertex data kind to use
  23859. * @returns true is data kind is present
  23860. */
  23861. isVerticesDataPresent(kind: string): boolean;
  23862. /**
  23863. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  23864. * @returns a BoundingInfo
  23865. */
  23866. getBoundingInfo(): BoundingInfo;
  23867. /**
  23868. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  23869. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box
  23870. * @returns the current mesh
  23871. */
  23872. normalizeToUnitCube(includeDescendants?: boolean): AbstractMesh;
  23873. /**
  23874. * Overwrite the current bounding info
  23875. * @param boundingInfo defines the new bounding info
  23876. * @returns the current mesh
  23877. */
  23878. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  23879. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  23880. readonly useBones: boolean;
  23881. /** @hidden */
  23882. /** @hidden */
  23883. /** @hidden */
  23884. /**
  23885. * Gets the current world matrix
  23886. * @returns a Matrix
  23887. */
  23888. getWorldMatrix(): Matrix;
  23889. /** @hidden */
  23890. /**
  23891. * Perform relative position change from the point of view of behind the front of the mesh.
  23892. * This is performed taking into account the meshes current rotation, so you do not have to care.
  23893. * Supports definition of mesh facing forward or backward
  23894. * @param amountRight defines the distance on the right axis
  23895. * @param amountUp defines the distance on the up axis
  23896. * @param amountForward defines the distance on the forward axis
  23897. * @returns the current mesh
  23898. */
  23899. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  23900. /**
  23901. * Calculate relative position change from the point of view of behind the front of the mesh.
  23902. * This is performed taking into account the meshes current rotation, so you do not have to care.
  23903. * Supports definition of mesh facing forward or backward
  23904. * @param amountRight defines the distance on the right axis
  23905. * @param amountUp defines the distance on the up axis
  23906. * @param amountForward defines the distance on the forward axis
  23907. * @returns the new displacement vector
  23908. */
  23909. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  23910. /**
  23911. * Perform relative rotation change from the point of view of behind the front of the mesh.
  23912. * Supports definition of mesh facing forward or backward
  23913. * @param flipBack defines the flip
  23914. * @param twirlClockwise defines the twirl
  23915. * @param tiltRight defines the tilt
  23916. * @returns the current mesh
  23917. */
  23918. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  23919. /**
  23920. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  23921. * Supports definition of mesh facing forward or backward.
  23922. * @param flipBack defines the flip
  23923. * @param twirlClockwise defines the twirl
  23924. * @param tiltRight defines the tilt
  23925. * @returns the new rotation vector
  23926. */
  23927. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  23928. /**
  23929. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  23930. * @param includeDescendants Include bounding info from descendants as well (true by default)
  23931. * @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
  23932. * @returns the new bounding vectors
  23933. */
  23934. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  23935. min: Vector3;
  23936. max: Vector3;
  23937. };
  23938. /** @hidden */
  23939. /** @hidden */
  23940. /** @hidden */
  23941. protected _afterComputeWorldMatrix(): void;
  23942. /**
  23943. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  23944. * A mesh is in the frustum if its bounding box intersects the frustum
  23945. * @param frustumPlanes defines the frustum to test
  23946. * @returns true if the mesh is in the frustum planes
  23947. */
  23948. isInFrustum(frustumPlanes: Plane[]): boolean;
  23949. /**
  23950. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  23951. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  23952. * @param frustumPlanes defines the frustum to test
  23953. * @returns true if the mesh is completely in the frustum planes
  23954. */
  23955. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  23956. /**
  23957. * True if the mesh intersects another mesh or a SolidParticle object
  23958. * @param mesh defines a target mesh or SolidParticle to test
  23959. * @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)
  23960. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  23961. * @returns true if there is an intersection
  23962. */
  23963. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  23964. /**
  23965. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  23966. * @param point defines the point to test
  23967. * @returns true if there is an intersection
  23968. */
  23969. intersectsPoint(point: Vector3): boolean;
  23970. /**
  23971. * Gets the position of the current mesh in camera space
  23972. * @param camera defines the camera to use
  23973. * @returns a position
  23974. */
  23975. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  23976. /**
  23977. * Returns the distance from the mesh to the active camera
  23978. * @param camera defines the camera to use
  23979. * @returns the distance
  23980. */
  23981. getDistanceToCamera(camera?: Nullable<Camera>): number;
  23982. /**
  23983. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  23984. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  23985. */
  23986. checkCollisions: boolean;
  23987. /**
  23988. * Gets Collider object used to compute collisions (not physics)
  23989. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  23990. */
  23991. readonly collider: Collider;
  23992. /**
  23993. * Move the mesh using collision engine
  23994. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  23995. * @param displacement defines the requested displacement vector
  23996. * @returns the current mesh
  23997. */
  23998. moveWithCollisions(displacement: Vector3): AbstractMesh;
  23999. private _onCollisionPositionChange;
  24000. /** @hidden */
  24001. /** @hidden */
  24002. /** @hidden */
  24003. /** @hidden */
  24004. /**
  24005. * Checks if the passed Ray intersects with the mesh
  24006. * @param ray defines the ray to use
  24007. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  24008. * @returns the picking info
  24009. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  24010. */
  24011. intersects(ray: Ray, fastCheck?: boolean): PickingInfo;
  24012. /**
  24013. * Clones the current mesh
  24014. * @param name defines the mesh name
  24015. * @param newParent defines the new mesh parent
  24016. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  24017. * @returns the new mesh
  24018. */
  24019. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  24020. /**
  24021. * Disposes all the submeshes of the current meshnp
  24022. * @returns the current mesh
  24023. */
  24024. releaseSubMeshes(): AbstractMesh;
  24025. /**
  24026. * Releases resources associated with this abstract mesh.
  24027. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24028. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24029. */
  24030. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24031. /**
  24032. * Adds the passed mesh as a child to the current mesh
  24033. * @param mesh defines the child mesh
  24034. * @returns the current mesh
  24035. */
  24036. addChild(mesh: AbstractMesh): AbstractMesh;
  24037. /**
  24038. * Removes the passed mesh from the current mesh children list
  24039. * @param mesh defines the child mesh
  24040. * @returns the current mesh
  24041. */
  24042. removeChild(mesh: AbstractMesh): AbstractMesh;
  24043. /** @hidden */
  24044. private _initFacetData;
  24045. /**
  24046. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  24047. * This method can be called within the render loop.
  24048. * 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
  24049. * @returns the current mesh
  24050. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24051. */
  24052. updateFacetData(): AbstractMesh;
  24053. /**
  24054. * Returns the facetLocalNormals array.
  24055. * The normals are expressed in the mesh local spac
  24056. * @returns an array of Vector3
  24057. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24058. */
  24059. getFacetLocalNormals(): Vector3[];
  24060. /**
  24061. * Returns the facetLocalPositions array.
  24062. * The facet positions are expressed in the mesh local space
  24063. * @returns an array of Vector3
  24064. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24065. */
  24066. getFacetLocalPositions(): Vector3[];
  24067. /**
  24068. * Returns the facetLocalPartioning array
  24069. * @returns an array of array of numbers
  24070. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24071. */
  24072. getFacetLocalPartitioning(): number[][];
  24073. /**
  24074. * Returns the i-th facet position in the world system.
  24075. * This method allocates a new Vector3 per call
  24076. * @param i defines the facet index
  24077. * @returns a new Vector3
  24078. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24079. */
  24080. getFacetPosition(i: number): Vector3;
  24081. /**
  24082. * Sets the reference Vector3 with the i-th facet position in the world system
  24083. * @param i defines the facet index
  24084. * @param ref defines the target vector
  24085. * @returns the current mesh
  24086. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24087. */
  24088. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  24089. /**
  24090. * Returns the i-th facet normal in the world system.
  24091. * This method allocates a new Vector3 per call
  24092. * @param i defines the facet index
  24093. * @returns a new Vector3
  24094. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24095. */
  24096. getFacetNormal(i: number): Vector3;
  24097. /**
  24098. * Sets the reference Vector3 with the i-th facet normal in the world system
  24099. * @param i defines the facet index
  24100. * @param ref defines the target vector
  24101. * @returns the current mesh
  24102. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24103. */
  24104. getFacetNormalToRef(i: number, ref: Vector3): this;
  24105. /**
  24106. * 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)
  24107. * @param x defines x coordinate
  24108. * @param y defines y coordinate
  24109. * @param z defines z coordinate
  24110. * @returns the array of facet indexes
  24111. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24112. */
  24113. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  24114. /**
  24115. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  24116. * @param projected sets as the (x,y,z) world projection on the facet
  24117. * @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
  24118. * @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
  24119. * @param x defines x coordinate
  24120. * @param y defines y coordinate
  24121. * @param z defines z coordinate
  24122. * @returns the face index if found (or null instead)
  24123. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24124. */
  24125. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  24126. /**
  24127. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  24128. * @param projected sets as the (x,y,z) local projection on the facet
  24129. * @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
  24130. * @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
  24131. * @param x defines x coordinate
  24132. * @param y defines y coordinate
  24133. * @param z defines z coordinate
  24134. * @returns the face index if found (or null instead)
  24135. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24136. */
  24137. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  24138. /**
  24139. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  24140. * @returns the parameters
  24141. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24142. */
  24143. getFacetDataParameters(): any;
  24144. /**
  24145. * Disables the feature FacetData and frees the related memory
  24146. * @returns the current mesh
  24147. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24148. */
  24149. disableFacetData(): AbstractMesh;
  24150. /**
  24151. * Updates the AbstractMesh indices array
  24152. * @param indices defines the data source
  24153. * @returns the current mesh
  24154. */
  24155. updateIndices(indices: IndicesArray): AbstractMesh;
  24156. /**
  24157. * Creates new normals data for the mesh
  24158. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  24159. * @returns the current mesh
  24160. */
  24161. createNormals(updatable: boolean): AbstractMesh;
  24162. /**
  24163. * Align the mesh with a normal
  24164. * @param normal defines the normal to use
  24165. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  24166. * @returns the current mesh
  24167. */
  24168. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  24169. /** @hidden */
  24170. }
  24171. }
  24172. declare module BABYLON {
  24173. /**
  24174. * Class used to store data that will be store in GPU memory
  24175. */
  24176. class Buffer {
  24177. private _engine;
  24178. private _buffer;
  24179. /** @hidden */
  24180. private _updatable;
  24181. private _instanced;
  24182. /**
  24183. * Gets the byte stride.
  24184. */
  24185. readonly byteStride: number;
  24186. /**
  24187. * Constructor
  24188. * @param engine the engine
  24189. * @param data the data to use for this buffer
  24190. * @param updatable whether the data is updatable
  24191. * @param stride the stride (optional)
  24192. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  24193. * @param instanced whether the buffer is instanced (optional)
  24194. * @param useBytes set to true if the stride in in bytes (optional)
  24195. */
  24196. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  24197. /**
  24198. * Create a new VertexBuffer based on the current buffer
  24199. * @param kind defines the vertex buffer kind (position, normal, etc.)
  24200. * @param offset defines offset in the buffer (0 by default)
  24201. * @param size defines the size in floats of attributes (position is 3 for instance)
  24202. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  24203. * @param instanced defines if the vertex buffer contains indexed data
  24204. * @param useBytes defines if the offset and stride are in bytes
  24205. * @returns the new vertex buffer
  24206. */
  24207. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  24208. /**
  24209. * Gets a boolean indicating if the Buffer is updatable?
  24210. * @returns true if the buffer is updatable
  24211. */
  24212. isUpdatable(): boolean;
  24213. /**
  24214. * Gets current buffer's data
  24215. * @returns a DataArray or null
  24216. */
  24217. getData(): Nullable<DataArray>;
  24218. /**
  24219. * Gets underlying native buffer
  24220. * @returns underlying native buffer
  24221. */
  24222. getBuffer(): Nullable<WebGLBuffer>;
  24223. /**
  24224. * Gets the stride in float32 units (i.e. byte stride / 4).
  24225. * May not be an integer if the byte stride is not divisible by 4.
  24226. * DEPRECATED. Use byteStride instead.
  24227. * @returns the stride in float32 units
  24228. */
  24229. getStrideSize(): number;
  24230. /**
  24231. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  24232. * @param data defines the data to store
  24233. */
  24234. create(data?: Nullable<DataArray>): void;
  24235. /** @hidden */
  24236. /**
  24237. * Update current buffer data
  24238. * @param data defines the data to store
  24239. */
  24240. update(data: DataArray): void;
  24241. /**
  24242. * Updates the data directly.
  24243. * @param data the new data
  24244. * @param offset the new offset
  24245. * @param vertexCount the vertex count (optional)
  24246. * @param useBytes set to true if the offset is in bytes
  24247. */
  24248. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  24249. /**
  24250. * Release all resources
  24251. */
  24252. dispose(): void;
  24253. }
  24254. }
  24255. declare module BABYLON {
  24256. /**
  24257. * Class for building Constructive Solid Geometry
  24258. */
  24259. class CSG {
  24260. private polygons;
  24261. /**
  24262. * The world matrix
  24263. */
  24264. matrix: Matrix;
  24265. /**
  24266. * Stores the position
  24267. */
  24268. position: Vector3;
  24269. /**
  24270. * Stores the rotation
  24271. */
  24272. rotation: Vector3;
  24273. /**
  24274. * Stores the rotation quaternion
  24275. */
  24276. rotationQuaternion: Nullable<Quaternion>;
  24277. /**
  24278. * Stores the scaling vector
  24279. */
  24280. scaling: Vector3;
  24281. /**
  24282. * Convert the BABYLON.Mesh to BABYLON.CSG
  24283. * @param mesh The BABYLON.Mesh to convert to BABYLON.CSG
  24284. * @returns A new BABYLON.CSG from the BABYLON.Mesh
  24285. */
  24286. static FromMesh(mesh: Mesh): CSG;
  24287. /**
  24288. * Construct a BABYLON.CSG solid from a list of `BABYLON.CSG.Polygon` instances.
  24289. * @param polygons Polygons used to construct a BABYLON.CSG solid
  24290. */
  24291. private static FromPolygons;
  24292. /**
  24293. * Clones, or makes a deep copy, of the BABYLON.CSG
  24294. * @returns A new BABYLON.CSG
  24295. */
  24296. clone(): CSG;
  24297. /**
  24298. * Unions this CSG with another CSG
  24299. * @param csg The CSG to union against this CSG
  24300. * @returns The unioned CSG
  24301. */
  24302. union(csg: CSG): CSG;
  24303. /**
  24304. * Unions this CSG with another CSG in place
  24305. * @param csg The CSG to union against this CSG
  24306. */
  24307. unionInPlace(csg: CSG): void;
  24308. /**
  24309. * Subtracts this CSG with another CSG
  24310. * @param csg The CSG to subtract against this CSG
  24311. * @returns A new BABYLON.CSG
  24312. */
  24313. subtract(csg: CSG): CSG;
  24314. /**
  24315. * Subtracts this CSG with another CSG in place
  24316. * @param csg The CSG to subtact against this CSG
  24317. */
  24318. subtractInPlace(csg: CSG): void;
  24319. /**
  24320. * Intersect this CSG with another CSG
  24321. * @param csg The CSG to intersect against this CSG
  24322. * @returns A new BABYLON.CSG
  24323. */
  24324. intersect(csg: CSG): CSG;
  24325. /**
  24326. * Intersects this CSG with another CSG in place
  24327. * @param csg The CSG to intersect against this CSG
  24328. */
  24329. intersectInPlace(csg: CSG): void;
  24330. /**
  24331. * Return a new BABYLON.CSG solid with solid and empty space switched. This solid is
  24332. * not modified.
  24333. * @returns A new BABYLON.CSG solid with solid and empty space switched
  24334. */
  24335. inverse(): CSG;
  24336. /**
  24337. * Inverses the BABYLON.CSG in place
  24338. */
  24339. inverseInPlace(): void;
  24340. /**
  24341. * This is used to keep meshes transformations so they can be restored
  24342. * when we build back a Babylon Mesh
  24343. * NB : All CSG operations are performed in world coordinates
  24344. * @param csg The BABYLON.CSG to copy the transform attributes from
  24345. * @returns This BABYLON.CSG
  24346. */
  24347. copyTransformAttributes(csg: CSG): CSG;
  24348. /**
  24349. * Build Raw mesh from CSG
  24350. * Coordinates here are in world space
  24351. * @param name The name of the mesh geometry
  24352. * @param scene The BABYLON.Scene
  24353. * @param keepSubMeshes Specifies if the submeshes should be kept
  24354. * @returns A new BABYLON.Mesh
  24355. */
  24356. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  24357. /**
  24358. * Build Mesh from CSG taking material and transforms into account
  24359. * @param name The name of the BABYLON.Mesh
  24360. * @param material The material of the BABYLON.Mesh
  24361. * @param scene The BABYLON.Scene
  24362. * @param keepSubMeshes Specifies if submeshes should be kept
  24363. * @returns The new BABYLON.Mesh
  24364. */
  24365. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  24366. }
  24367. }
  24368. declare module BABYLON {
  24369. /**
  24370. * Class used to store geometry data (vertex buffers + index buffer)
  24371. */
  24372. class Geometry implements IGetSetVerticesData {
  24373. /**
  24374. * Gets or sets the unique ID of the geometry
  24375. */
  24376. id: string;
  24377. /**
  24378. * Gets the delay loading state of the geometry (none by default which means not delayed)
  24379. */
  24380. delayLoadState: number;
  24381. /**
  24382. * Gets the file containing the data to load when running in delay load state
  24383. */
  24384. delayLoadingFile: Nullable<string>;
  24385. /**
  24386. * Callback called when the geometry is updated
  24387. */
  24388. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  24389. private _scene;
  24390. private _engine;
  24391. private _meshes;
  24392. private _totalVertices;
  24393. /** @hidden */
  24394. /** @hidden */
  24395. ;
  24396. private _isDisposed;
  24397. private _extend;
  24398. private _boundingBias;
  24399. /** @hidden */
  24400. private _indexBuffer;
  24401. private _indexBufferIsUpdatable;
  24402. /** @hidden */
  24403. /** @hidden */
  24404. /** @hidden */
  24405. private _vertexArrayObjects;
  24406. private _updatable;
  24407. /** @hidden */
  24408. /**
  24409. * 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
  24410. */
  24411. /**
  24412. * 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
  24413. */
  24414. boundingBias: Vector2;
  24415. /**
  24416. * Static function used to attach a new empty geometry to a mesh
  24417. * @param mesh defines the mesh to attach the geometry to
  24418. * @returns the new Geometry
  24419. */
  24420. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  24421. /**
  24422. * Creates a new geometry
  24423. * @param id defines the unique ID
  24424. * @param scene defines the hosting scene
  24425. * @param vertexData defines the VertexData used to get geometry data
  24426. * @param updatable defines if geometry must be updatable (false by default)
  24427. * @param mesh defines the mesh that will be associated with the geometry
  24428. */
  24429. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  24430. /**
  24431. * Gets the current extend of the geometry
  24432. */
  24433. readonly extend: {
  24434. minimum: Vector3;
  24435. maximum: Vector3;
  24436. };
  24437. /**
  24438. * Gets the hosting scene
  24439. * @returns the hosting Scene
  24440. */
  24441. getScene(): Scene;
  24442. /**
  24443. * Gets the hosting engine
  24444. * @returns the hosting Engine
  24445. */
  24446. getEngine(): Engine;
  24447. /**
  24448. * Defines if the geometry is ready to use
  24449. * @returns true if the geometry is ready to be used
  24450. */
  24451. isReady(): boolean;
  24452. /**
  24453. * Gets a value indicating that the geometry should not be serialized
  24454. */
  24455. readonly doNotSerialize: boolean;
  24456. /** @hidden */
  24457. /**
  24458. * Affects all geometry data in one call
  24459. * @param vertexData defines the geometry data
  24460. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  24461. */
  24462. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  24463. /**
  24464. * Set specific vertex data
  24465. * @param kind defines the data kind (Position, normal, etc...)
  24466. * @param data defines the vertex data to use
  24467. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  24468. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  24469. */
  24470. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  24471. /**
  24472. * Removes a specific vertex data
  24473. * @param kind defines the data kind (Position, normal, etc...)
  24474. */
  24475. removeVerticesData(kind: string): void;
  24476. /**
  24477. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  24478. * @param buffer defines the vertex buffer to use
  24479. * @param totalVertices defines the total number of vertices for position kind (could be null)
  24480. */
  24481. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  24482. /**
  24483. * Update a specific vertex buffer
  24484. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  24485. * It will do nothing if the buffer is not updatable
  24486. * @param kind defines the data kind (Position, normal, etc...)
  24487. * @param data defines the data to use
  24488. * @param offset defines the offset in the target buffer where to store the data
  24489. * @param useBytes set to true if the offset is in bytes
  24490. */
  24491. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  24492. /**
  24493. * Update a specific vertex buffer
  24494. * This function will create a new buffer if the current one is not updatable
  24495. * @param kind defines the data kind (Position, normal, etc...)
  24496. * @param data defines the data to use
  24497. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  24498. */
  24499. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  24500. private _updateBoundingInfo;
  24501. /** @hidden */
  24502. /**
  24503. * Gets total number of vertices
  24504. * @returns the total number of vertices
  24505. */
  24506. getTotalVertices(): number;
  24507. /**
  24508. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  24509. * @param kind defines the data kind (Position, normal, etc...)
  24510. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  24511. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24512. * @returns a float array containing vertex data
  24513. */
  24514. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24515. /**
  24516. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  24517. * @param kind defines the data kind (Position, normal, etc...)
  24518. * @returns true if the vertex buffer with the specified kind is updatable
  24519. */
  24520. isVertexBufferUpdatable(kind: string): boolean;
  24521. /**
  24522. * Gets a specific vertex buffer
  24523. * @param kind defines the data kind (Position, normal, etc...)
  24524. * @returns a VertexBuffer
  24525. */
  24526. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  24527. /**
  24528. * Returns all vertex buffers
  24529. * @return an object holding all vertex buffers indexed by kind
  24530. */
  24531. getVertexBuffers(): Nullable<{
  24532. [key: string]: VertexBuffer;
  24533. }>;
  24534. /**
  24535. * Gets a boolean indicating if specific vertex buffer is present
  24536. * @param kind defines the data kind (Position, normal, etc...)
  24537. * @returns true if data is present
  24538. */
  24539. isVerticesDataPresent(kind: string): boolean;
  24540. /**
  24541. * Gets a list of all attached data kinds (Position, normal, etc...)
  24542. * @returns a list of string containing all kinds
  24543. */
  24544. getVerticesDataKinds(): string[];
  24545. /**
  24546. * Update index buffer
  24547. * @param indices defines the indices to store in the index buffer
  24548. * @param offset defines the offset in the target buffer where to store the data
  24549. */
  24550. updateIndices(indices: IndicesArray, offset?: number): void;
  24551. /**
  24552. * Creates a new index buffer
  24553. * @param indices defines the indices to store in the index buffer
  24554. * @param totalVertices defines the total number of vertices (could be null)
  24555. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  24556. */
  24557. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  24558. /**
  24559. * Return the total number of indices
  24560. * @returns the total number of indices
  24561. */
  24562. getTotalIndices(): number;
  24563. /**
  24564. * Gets the index buffer array
  24565. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  24566. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24567. * @returns the index buffer array
  24568. */
  24569. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  24570. /**
  24571. * Gets the index buffer
  24572. * @return the index buffer
  24573. */
  24574. getIndexBuffer(): Nullable<WebGLBuffer>;
  24575. /** @hidden */
  24576. /**
  24577. * Release the associated resources for a specific mesh
  24578. * @param mesh defines the source mesh
  24579. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  24580. */
  24581. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  24582. /**
  24583. * Apply current geometry to a given mesh
  24584. * @param mesh defines the mesh to apply geometry to
  24585. */
  24586. applyToMesh(mesh: Mesh): void;
  24587. private _updateExtend;
  24588. private _applyToMesh;
  24589. private notifyUpdate;
  24590. /**
  24591. * Load the geometry if it was flagged as delay loaded
  24592. * @param scene defines the hosting scene
  24593. * @param onLoaded defines a callback called when the geometry is loaded
  24594. */
  24595. load(scene: Scene, onLoaded?: () => void): void;
  24596. private _queueLoad;
  24597. /**
  24598. * Invert the geometry to move from a right handed system to a left handed one.
  24599. */
  24600. toLeftHanded(): void;
  24601. /** @hidden */
  24602. /** @hidden */
  24603. /**
  24604. * Gets a value indicating if the geometry is disposed
  24605. * @returns true if the geometry was disposed
  24606. */
  24607. isDisposed(): boolean;
  24608. private _disposeVertexArrayObjects;
  24609. /**
  24610. * Free all associated resources
  24611. */
  24612. dispose(): void;
  24613. /**
  24614. * Clone the current geometry into a new geometry
  24615. * @param id defines the unique ID of the new geometry
  24616. * @returns a new geometry object
  24617. */
  24618. copy(id: string): Geometry;
  24619. /**
  24620. * Serialize the current geometry info (and not the vertices data) into a JSON object
  24621. * @return a JSON representation of the current geometry data (without the vertices data)
  24622. */
  24623. serialize(): any;
  24624. private toNumberArray;
  24625. /**
  24626. * Serialize all vertices data into a JSON oject
  24627. * @returns a JSON representation of the current geometry data
  24628. */
  24629. serializeVerticeData(): any;
  24630. /**
  24631. * Extracts a clone of a mesh geometry
  24632. * @param mesh defines the source mesh
  24633. * @param id defines the unique ID of the new geometry object
  24634. * @returns the new geometry object
  24635. */
  24636. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  24637. /**
  24638. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  24639. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  24640. * Be aware Math.random() could cause collisions, but:
  24641. * "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"
  24642. * @returns a string containing a new GUID
  24643. */
  24644. static RandomId(): string;
  24645. /** @hidden */
  24646. private static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  24647. private static _CleanMatricesWeights;
  24648. /**
  24649. * Create a new geometry from persisted data (Using .babylon file format)
  24650. * @param parsedVertexData defines the persisted data
  24651. * @param scene defines the hosting scene
  24652. * @param rootUrl defines the root url to use to load assets (like delayed data)
  24653. * @returns the new geometry object
  24654. */
  24655. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  24656. }
  24657. /**
  24658. * Abstract class used to provide common services for all typed geometries
  24659. * @hidden
  24660. */
  24661. class _PrimitiveGeometry extends Geometry {
  24662. private _canBeRegenerated;
  24663. private _beingRegenerated;
  24664. /**
  24665. * Creates a new typed geometry
  24666. * @param id defines the unique ID of the geometry
  24667. * @param scene defines the hosting scene
  24668. * @param _canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  24669. * @param mesh defines the hosting mesh (can be null)
  24670. */
  24671. constructor(id: string, scene: Scene, _canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  24672. /**
  24673. * Gets a value indicating if the geometry supports being regenerated with new parameters (false by default)
  24674. * @returns true if the geometry can be regenerated
  24675. */
  24676. canBeRegenerated(): boolean;
  24677. /**
  24678. * If the geometry supports regeneration, the function will recreates the geometry with updated parameter values
  24679. */
  24680. regenerate(): void;
  24681. /**
  24682. * Clone the geometry
  24683. * @param id defines the unique ID of the new geometry
  24684. * @returns the new geometry
  24685. */
  24686. asNewGeometry(id: string): Geometry;
  24687. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  24688. setVerticesData(kind: string, data: FloatArray, updatable?: boolean): void;
  24689. /** @hidden */
  24690. copy(id: string): Geometry;
  24691. serialize(): any;
  24692. }
  24693. /**
  24694. * Creates a ribbon geometry
  24695. * @description See http://doc.babylonjs.com/how_to/ribbon_tutorial, http://doc.babylonjs.com/resources/maths_make_ribbons
  24696. */
  24697. class RibbonGeometry extends _PrimitiveGeometry {
  24698. /**
  24699. * Defines the array of paths to use
  24700. */
  24701. pathArray: Vector3[][];
  24702. /**
  24703. * Defines if the last and first points of each path in your pathArray must be joined
  24704. */
  24705. closeArray: boolean;
  24706. /**
  24707. * Defines if the last and first points of each path in your pathArray must be joined
  24708. */
  24709. closePath: boolean;
  24710. /**
  24711. * Defines the offset between points
  24712. */
  24713. offset: number;
  24714. /**
  24715. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  24716. */
  24717. side: number;
  24718. /**
  24719. * Creates a ribbon geometry
  24720. * @param id defines the unique ID of the geometry
  24721. * @param scene defines the hosting scene
  24722. * @param pathArray defines the array of paths to use
  24723. * @param closeArray defines if the last path and the first path must be joined
  24724. * @param closePath defines if the last and first points of each path in your pathArray must be joined
  24725. * @param offset defines the offset between points
  24726. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  24727. * @param mesh defines the hosting mesh (can be null)
  24728. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  24729. */
  24730. constructor(id: string, scene: Scene,
  24731. /**
  24732. * Defines the array of paths to use
  24733. */
  24734. pathArray: Vector3[][],
  24735. /**
  24736. * Defines if the last and first points of each path in your pathArray must be joined
  24737. */
  24738. closeArray: boolean,
  24739. /**
  24740. * Defines if the last and first points of each path in your pathArray must be joined
  24741. */
  24742. closePath: boolean,
  24743. /**
  24744. * Defines the offset between points
  24745. */
  24746. offset: number, canBeRegenerated?: boolean, mesh?: Mesh,
  24747. /**
  24748. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  24749. */
  24750. side?: number);
  24751. /** @hidden */
  24752. copy(id: string): Geometry;
  24753. }
  24754. /**
  24755. * Creates a box geometry
  24756. * @description see http://doc.babylonjs.com/how_to/set_shapes#box
  24757. */
  24758. class BoxGeometry extends _PrimitiveGeometry {
  24759. /**
  24760. * Defines the zise of the box (width, height and depth are the same)
  24761. */
  24762. size: number;
  24763. /**
  24764. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  24765. */
  24766. side: number;
  24767. /**
  24768. * Creates a box geometry
  24769. * @param id defines the unique ID of the geometry
  24770. * @param scene defines the hosting scene
  24771. * @param size defines the zise of the box (width, height and depth are the same)
  24772. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  24773. * @param mesh defines the hosting mesh (can be null)
  24774. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  24775. */
  24776. constructor(id: string, scene: Scene,
  24777. /**
  24778. * Defines the zise of the box (width, height and depth are the same)
  24779. */
  24780. size: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  24781. /**
  24782. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  24783. */
  24784. side?: number);
  24785. /** @hidden */
  24786. copy(id: string): Geometry;
  24787. serialize(): any;
  24788. static Parse(parsedBox: any, scene: Scene): Nullable<BoxGeometry>;
  24789. }
  24790. /**
  24791. * Creates a sphere geometry
  24792. * @description see http://doc.babylonjs.com/how_to/set_shapes#sphere
  24793. */
  24794. class SphereGeometry extends _PrimitiveGeometry {
  24795. /**
  24796. * Defines the number of segments to use to create the sphere
  24797. */
  24798. segments: number;
  24799. /**
  24800. * Defines the diameter of the sphere
  24801. */
  24802. diameter: number;
  24803. /**
  24804. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  24805. */
  24806. side: number;
  24807. /**
  24808. * Create a new sphere geometry
  24809. * @param id defines the unique ID of the geometry
  24810. * @param scene defines the hosting scene
  24811. * @param segments defines the number of segments to use to create the sphere
  24812. * @param diameter defines the diameter of the sphere
  24813. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  24814. * @param mesh defines the hosting mesh (can be null)
  24815. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  24816. */
  24817. constructor(id: string, scene: Scene,
  24818. /**
  24819. * Defines the number of segments to use to create the sphere
  24820. */
  24821. segments: number,
  24822. /**
  24823. * Defines the diameter of the sphere
  24824. */
  24825. diameter: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  24826. /**
  24827. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  24828. */
  24829. side?: number);
  24830. /** @hidden */
  24831. copy(id: string): Geometry;
  24832. serialize(): any;
  24833. static Parse(parsedSphere: any, scene: Scene): Nullable<SphereGeometry>;
  24834. }
  24835. /**
  24836. * Creates a disc geometry
  24837. * @description see http://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  24838. */
  24839. class DiscGeometry extends _PrimitiveGeometry {
  24840. /**
  24841. * Defines the radius of the disc
  24842. */
  24843. radius: number;
  24844. /**
  24845. * Defines the tesselation factor to apply to the disc
  24846. */
  24847. tessellation: number;
  24848. /**
  24849. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  24850. */
  24851. side: number;
  24852. /**
  24853. * Creates a new disc geometry
  24854. * @param id defines the unique ID of the geometry
  24855. * @param scene defines the hosting scene
  24856. * @param radius defines the radius of the disc
  24857. * @param tessellation defines the tesselation factor to apply to the disc
  24858. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  24859. * @param mesh defines the hosting mesh (can be null)
  24860. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  24861. */
  24862. constructor(id: string, scene: Scene,
  24863. /**
  24864. * Defines the radius of the disc
  24865. */
  24866. radius: number,
  24867. /**
  24868. * Defines the tesselation factor to apply to the disc
  24869. */
  24870. tessellation: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  24871. /**
  24872. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  24873. */
  24874. side?: number);
  24875. /** @hidden */
  24876. copy(id: string): Geometry;
  24877. }
  24878. /**
  24879. * Creates a new cylinder geometry
  24880. * @description see http://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  24881. */
  24882. class CylinderGeometry extends _PrimitiveGeometry {
  24883. /**
  24884. * Defines the height of the cylinder
  24885. */
  24886. height: number;
  24887. /**
  24888. * Defines the diameter of the cylinder's top cap
  24889. */
  24890. diameterTop: number;
  24891. /**
  24892. * Defines the diameter of the cylinder's bottom cap
  24893. */
  24894. diameterBottom: number;
  24895. /**
  24896. * Defines the tessellation factor to apply to the cylinder
  24897. */
  24898. tessellation: number;
  24899. /**
  24900. * Defines the number of subdivisions to apply to the cylinder (1 by default)
  24901. */
  24902. subdivisions: number;
  24903. /**
  24904. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  24905. */
  24906. side: number;
  24907. /**
  24908. * Creates a new cylinder geometry
  24909. * @param id defines the unique ID of the geometry
  24910. * @param scene defines the hosting scene
  24911. * @param height defines the height of the cylinder
  24912. * @param diameterTop defines the diameter of the cylinder's top cap
  24913. * @param diameterBottom defines the diameter of the cylinder's bottom cap
  24914. * @param tessellation defines the tessellation factor to apply to the cylinder (number of radial sides)
  24915. * @param subdivisions defines the number of subdivisions to apply to the cylinder (number of rings) (1 by default)
  24916. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  24917. * @param mesh defines the hosting mesh (can be null)
  24918. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  24919. */
  24920. constructor(id: string, scene: Scene,
  24921. /**
  24922. * Defines the height of the cylinder
  24923. */
  24924. height: number,
  24925. /**
  24926. * Defines the diameter of the cylinder's top cap
  24927. */
  24928. diameterTop: number,
  24929. /**
  24930. * Defines the diameter of the cylinder's bottom cap
  24931. */
  24932. diameterBottom: number,
  24933. /**
  24934. * Defines the tessellation factor to apply to the cylinder
  24935. */
  24936. tessellation: number,
  24937. /**
  24938. * Defines the number of subdivisions to apply to the cylinder (1 by default)
  24939. */
  24940. subdivisions?: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  24941. /**
  24942. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  24943. */
  24944. side?: number);
  24945. /** @hidden */
  24946. copy(id: string): Geometry;
  24947. serialize(): any;
  24948. static Parse(parsedCylinder: any, scene: Scene): Nullable<CylinderGeometry>;
  24949. }
  24950. /**
  24951. * Creates a new torus geometry
  24952. * @description see http://doc.babylonjs.com/how_to/set_shapes#torus
  24953. */
  24954. class TorusGeometry extends _PrimitiveGeometry {
  24955. /**
  24956. * Defines the diameter of the torus
  24957. */
  24958. diameter: number;
  24959. /**
  24960. * Defines the thickness of the torus (ie. internal diameter)
  24961. */
  24962. thickness: number;
  24963. /**
  24964. * Defines the tesselation factor to apply to the torus
  24965. */
  24966. tessellation: number;
  24967. /**
  24968. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  24969. */
  24970. side: number;
  24971. /**
  24972. * Creates a new torus geometry
  24973. * @param id defines the unique ID of the geometry
  24974. * @param scene defines the hosting scene
  24975. * @param diameter defines the diameter of the torus
  24976. * @param thickness defines the thickness of the torus (ie. internal diameter)
  24977. * @param tessellation defines the tesselation factor to apply to the torus (number of segments along the circle)
  24978. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  24979. * @param mesh defines the hosting mesh (can be null)
  24980. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  24981. */
  24982. constructor(id: string, scene: Scene,
  24983. /**
  24984. * Defines the diameter of the torus
  24985. */
  24986. diameter: number,
  24987. /**
  24988. * Defines the thickness of the torus (ie. internal diameter)
  24989. */
  24990. thickness: number,
  24991. /**
  24992. * Defines the tesselation factor to apply to the torus
  24993. */
  24994. tessellation: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  24995. /**
  24996. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  24997. */
  24998. side?: number);
  24999. /** @hidden */
  25000. copy(id: string): Geometry;
  25001. serialize(): any;
  25002. static Parse(parsedTorus: any, scene: Scene): Nullable<TorusGeometry>;
  25003. }
  25004. /**
  25005. * Creates a new ground geometry
  25006. * @description see http://doc.babylonjs.com/how_to/set_shapes#ground
  25007. */
  25008. class GroundGeometry extends _PrimitiveGeometry {
  25009. /**
  25010. * Defines the width of the ground
  25011. */
  25012. width: number;
  25013. /**
  25014. * Defines the height of the ground
  25015. */
  25016. height: number;
  25017. /**
  25018. * Defines the subdivisions to apply to the ground
  25019. */
  25020. subdivisions: number;
  25021. /**
  25022. * Creates a new ground geometry
  25023. * @param id defines the unique ID of the geometry
  25024. * @param scene defines the hosting scene
  25025. * @param width defines the width of the ground
  25026. * @param height defines the height of the ground
  25027. * @param subdivisions defines the subdivisions to apply to the ground
  25028. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25029. * @param mesh defines the hosting mesh (can be null)
  25030. */
  25031. constructor(id: string, scene: Scene,
  25032. /**
  25033. * Defines the width of the ground
  25034. */
  25035. width: number,
  25036. /**
  25037. * Defines the height of the ground
  25038. */
  25039. height: number,
  25040. /**
  25041. * Defines the subdivisions to apply to the ground
  25042. */
  25043. subdivisions: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  25044. /** @hidden */
  25045. copy(id: string): Geometry;
  25046. serialize(): any;
  25047. static Parse(parsedGround: any, scene: Scene): Nullable<GroundGeometry>;
  25048. }
  25049. /**
  25050. * Creates a tiled ground geometry
  25051. * @description see http://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  25052. */
  25053. class TiledGroundGeometry extends _PrimitiveGeometry {
  25054. /**
  25055. * Defines the minimum value on X axis
  25056. */
  25057. xmin: number;
  25058. /**
  25059. * Defines the minimum value on Z axis
  25060. */
  25061. zmin: number;
  25062. /**
  25063. * Defines the maximum value on X axis
  25064. */
  25065. xmax: number;
  25066. /**
  25067. * Defines the maximum value on Z axis
  25068. */
  25069. zmax: number;
  25070. /**
  25071. * Defines the subdivisions to apply to the ground
  25072. */
  25073. subdivisions: {
  25074. w: number;
  25075. h: number;
  25076. };
  25077. /**
  25078. * Defines the precision to use when computing the tiles
  25079. */
  25080. precision: {
  25081. w: number;
  25082. h: number;
  25083. };
  25084. /**
  25085. * Creates a tiled ground geometry
  25086. * @param id defines the unique ID of the geometry
  25087. * @param scene defines the hosting scene
  25088. * @param xmin defines the minimum value on X axis
  25089. * @param zmin defines the minimum value on Z axis
  25090. * @param xmax defines the maximum value on X axis
  25091. * @param zmax defines the maximum value on Z axis
  25092. * @param subdivisions defines the subdivisions to apply to the ground (number of subdivisions (tiles) on the height and the width of the map)
  25093. * @param precision defines the precision to use when computing the tiles
  25094. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25095. * @param mesh defines the hosting mesh (can be null)
  25096. */
  25097. constructor(id: string, scene: Scene,
  25098. /**
  25099. * Defines the minimum value on X axis
  25100. */
  25101. xmin: number,
  25102. /**
  25103. * Defines the minimum value on Z axis
  25104. */
  25105. zmin: number,
  25106. /**
  25107. * Defines the maximum value on X axis
  25108. */
  25109. xmax: number,
  25110. /**
  25111. * Defines the maximum value on Z axis
  25112. */
  25113. zmax: number,
  25114. /**
  25115. * Defines the subdivisions to apply to the ground
  25116. */
  25117. subdivisions: {
  25118. w: number;
  25119. h: number;
  25120. },
  25121. /**
  25122. * Defines the precision to use when computing the tiles
  25123. */
  25124. precision: {
  25125. w: number;
  25126. h: number;
  25127. }, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  25128. /** @hidden */
  25129. copy(id: string): Geometry;
  25130. }
  25131. /**
  25132. * Creates a plane geometry
  25133. * @description see http://doc.babylonjs.com/how_to/set_shapes#plane
  25134. */
  25135. class PlaneGeometry extends _PrimitiveGeometry {
  25136. /**
  25137. * Defines the size of the plane (width === height)
  25138. */
  25139. size: number;
  25140. /**
  25141. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25142. */
  25143. side: number;
  25144. /**
  25145. * Creates a plane geometry
  25146. * @param id defines the unique ID of the geometry
  25147. * @param scene defines the hosting scene
  25148. * @param size defines the size of the plane (width === height)
  25149. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25150. * @param mesh defines the hosting mesh (can be null)
  25151. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25152. */
  25153. constructor(id: string, scene: Scene,
  25154. /**
  25155. * Defines the size of the plane (width === height)
  25156. */
  25157. size: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  25158. /**
  25159. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25160. */
  25161. side?: number);
  25162. /** @hidden */
  25163. copy(id: string): Geometry;
  25164. serialize(): any;
  25165. static Parse(parsedPlane: any, scene: Scene): Nullable<PlaneGeometry>;
  25166. }
  25167. /**
  25168. * Creates a torus knot geometry
  25169. * @description see http://doc.babylonjs.com/how_to/set_shapes#torus-knot
  25170. */
  25171. class TorusKnotGeometry extends _PrimitiveGeometry {
  25172. /**
  25173. * Defines the radius of the torus knot
  25174. */
  25175. radius: number;
  25176. /**
  25177. * Defines the thickness of the torus knot tube
  25178. */
  25179. tube: number;
  25180. /**
  25181. * Defines the number of radial segments
  25182. */
  25183. radialSegments: number;
  25184. /**
  25185. * Defines the number of tubular segments
  25186. */
  25187. tubularSegments: number;
  25188. /**
  25189. * Defines the first number of windings
  25190. */
  25191. p: number;
  25192. /**
  25193. * Defines the second number of windings
  25194. */
  25195. q: number;
  25196. /**
  25197. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25198. */
  25199. side: number;
  25200. /**
  25201. * Creates a torus knot geometry
  25202. * @param id defines the unique ID of the geometry
  25203. * @param scene defines the hosting scene
  25204. * @param radius defines the radius of the torus knot
  25205. * @param tube defines the thickness of the torus knot tube
  25206. * @param radialSegments defines the number of radial segments
  25207. * @param tubularSegments defines the number of tubular segments
  25208. * @param p defines the first number of windings
  25209. * @param q defines the second number of windings
  25210. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25211. * @param mesh defines the hosting mesh (can be null)
  25212. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25213. */
  25214. constructor(id: string, scene: Scene,
  25215. /**
  25216. * Defines the radius of the torus knot
  25217. */
  25218. radius: number,
  25219. /**
  25220. * Defines the thickness of the torus knot tube
  25221. */
  25222. tube: number,
  25223. /**
  25224. * Defines the number of radial segments
  25225. */
  25226. radialSegments: number,
  25227. /**
  25228. * Defines the number of tubular segments
  25229. */
  25230. tubularSegments: number,
  25231. /**
  25232. * Defines the first number of windings
  25233. */
  25234. p: number,
  25235. /**
  25236. * Defines the second number of windings
  25237. */
  25238. q: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  25239. /**
  25240. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25241. */
  25242. side?: number);
  25243. /** @hidden */
  25244. copy(id: string): Geometry;
  25245. serialize(): any;
  25246. static Parse(parsedTorusKnot: any, scene: Scene): Nullable<TorusKnotGeometry>;
  25247. }
  25248. }
  25249. declare module BABYLON {
  25250. /**
  25251. * Mesh representing the gorund
  25252. */
  25253. class GroundMesh extends Mesh {
  25254. /** If octree should be generated */
  25255. generateOctree: boolean;
  25256. private _heightQuads;
  25257. /** @hidden */
  25258. /** @hidden */
  25259. /** @hidden */
  25260. /** @hidden */
  25261. /** @hidden */
  25262. /** @hidden */
  25263. /** @hidden */
  25264. /** @hidden */
  25265. constructor(name: string, scene: Scene);
  25266. /**
  25267. * "GroundMesh"
  25268. * @returns "GroundMesh"
  25269. */
  25270. getClassName(): string;
  25271. /**
  25272. * The minimum of x and y subdivisions
  25273. */
  25274. readonly subdivisions: number;
  25275. /**
  25276. * X subdivisions
  25277. */
  25278. readonly subdivisionsX: number;
  25279. /**
  25280. * Y subdivisions
  25281. */
  25282. readonly subdivisionsY: number;
  25283. /**
  25284. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  25285. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  25286. * @param chunksCount the number of subdivisions for x and y
  25287. * @param octreeBlocksSize (Default: 32)
  25288. */
  25289. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  25290. /**
  25291. * Returns a height (y) value in the Worl system :
  25292. * the ground altitude at the coordinates (x, z) expressed in the World system.
  25293. * @param x x coordinate
  25294. * @param z z coordinate
  25295. * @returns the ground y position if (x, z) are outside the ground surface.
  25296. */
  25297. getHeightAtCoordinates(x: number, z: number): number;
  25298. /**
  25299. * Returns a normalized vector (Vector3) orthogonal to the ground
  25300. * at the ground coordinates (x, z) expressed in the World system.
  25301. * @param x x coordinate
  25302. * @param z z coordinate
  25303. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  25304. */
  25305. getNormalAtCoordinates(x: number, z: number): Vector3;
  25306. /**
  25307. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  25308. * at the ground coordinates (x, z) expressed in the World system.
  25309. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  25310. * @param x x coordinate
  25311. * @param z z coordinate
  25312. * @param ref vector to store the result
  25313. * @returns the GroundMesh.
  25314. */
  25315. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  25316. /**
  25317. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  25318. * if the ground has been updated.
  25319. * This can be used in the render loop.
  25320. * @returns the GroundMesh.
  25321. */
  25322. updateCoordinateHeights(): GroundMesh;
  25323. private _getFacetAt;
  25324. private _initHeightQuads;
  25325. private _computeHeightQuads;
  25326. /**
  25327. * Serializes this ground mesh
  25328. * @param serializationObject object to write serialization to
  25329. */
  25330. serialize(serializationObject: any): void;
  25331. /**
  25332. * Parses a serialized ground mesh
  25333. * @param parsedMesh the serialized mesh
  25334. * @param scene the scene to create the ground mesh in
  25335. * @returns the created ground mesh
  25336. */
  25337. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  25338. }
  25339. }
  25340. declare module BABYLON {
  25341. /**
  25342. * Creates an instance based on a source mesh.
  25343. */
  25344. class InstancedMesh extends AbstractMesh {
  25345. private _sourceMesh;
  25346. private _currentLOD;
  25347. constructor(name: string, source: Mesh);
  25348. /**
  25349. * Returns the string "InstancedMesh".
  25350. */
  25351. getClassName(): string;
  25352. /**
  25353. * If the source mesh receives shadows
  25354. */
  25355. readonly receiveShadows: boolean;
  25356. /**
  25357. * The material of the source mesh
  25358. */
  25359. readonly material: Nullable<Material>;
  25360. /**
  25361. * Visibility of the source mesh
  25362. */
  25363. readonly visibility: number;
  25364. /**
  25365. * Skeleton of the source mesh
  25366. */
  25367. readonly skeleton: Nullable<Skeleton>;
  25368. /**
  25369. * Rendering ground id of the source mesh
  25370. */
  25371. renderingGroupId: number;
  25372. /**
  25373. * Returns the total number of vertices (integer).
  25374. */
  25375. getTotalVertices(): number;
  25376. /**
  25377. * The source mesh of the instance
  25378. */
  25379. readonly sourceMesh: Mesh;
  25380. /**
  25381. * Is this node ready to be used/rendered
  25382. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  25383. * @return {boolean} is it ready
  25384. */
  25385. isReady(completeCheck?: boolean): boolean;
  25386. /**
  25387. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  25388. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  25389. * @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.
  25390. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  25391. */
  25392. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  25393. /**
  25394. * Sets the vertex data of the mesh geometry for the requested `kind`.
  25395. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  25396. * The `data` are either a numeric array either a Float32Array.
  25397. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  25398. * 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).
  25399. * Note that a new underlying VertexBuffer object is created each call.
  25400. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  25401. *
  25402. * Possible `kind` values :
  25403. * - BABYLON.VertexBuffer.PositionKind
  25404. * - BABYLON.VertexBuffer.UVKind
  25405. * - BABYLON.VertexBuffer.UV2Kind
  25406. * - BABYLON.VertexBuffer.UV3Kind
  25407. * - BABYLON.VertexBuffer.UV4Kind
  25408. * - BABYLON.VertexBuffer.UV5Kind
  25409. * - BABYLON.VertexBuffer.UV6Kind
  25410. * - BABYLON.VertexBuffer.ColorKind
  25411. * - BABYLON.VertexBuffer.MatricesIndicesKind
  25412. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  25413. * - BABYLON.VertexBuffer.MatricesWeightsKind
  25414. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  25415. *
  25416. * Returns the Mesh.
  25417. */
  25418. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  25419. /**
  25420. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  25421. * If the mesh has no geometry, it is simply returned as it is.
  25422. * The `data` are either a numeric array either a Float32Array.
  25423. * No new underlying VertexBuffer object is created.
  25424. * 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.
  25425. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  25426. *
  25427. * Possible `kind` values :
  25428. * - BABYLON.VertexBuffer.PositionKind
  25429. * - BABYLON.VertexBuffer.UVKind
  25430. * - BABYLON.VertexBuffer.UV2Kind
  25431. * - BABYLON.VertexBuffer.UV3Kind
  25432. * - BABYLON.VertexBuffer.UV4Kind
  25433. * - BABYLON.VertexBuffer.UV5Kind
  25434. * - BABYLON.VertexBuffer.UV6Kind
  25435. * - BABYLON.VertexBuffer.ColorKind
  25436. * - BABYLON.VertexBuffer.MatricesIndicesKind
  25437. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  25438. * - BABYLON.VertexBuffer.MatricesWeightsKind
  25439. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  25440. *
  25441. * Returns the Mesh.
  25442. */
  25443. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  25444. /**
  25445. * Sets the mesh indices.
  25446. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  25447. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  25448. * This method creates a new index buffer each call.
  25449. * Returns the Mesh.
  25450. */
  25451. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  25452. /**
  25453. * Boolean : True if the mesh owns the requested kind of data.
  25454. */
  25455. isVerticesDataPresent(kind: string): boolean;
  25456. /**
  25457. * Returns an array of indices (IndicesArray).
  25458. */
  25459. getIndices(): Nullable<IndicesArray>;
  25460. protected readonly _positions: Nullable<Vector3[]>;
  25461. /**
  25462. * Sets a new updated BoundingInfo to the mesh.
  25463. * @returns the mesh.
  25464. */
  25465. refreshBoundingInfo(): InstancedMesh;
  25466. /** @hidden */
  25467. /** @hidden */
  25468. /**
  25469. * Returns the current associated LOD AbstractMesh.
  25470. */
  25471. getLOD(camera: Camera): AbstractMesh;
  25472. /** @hidden */
  25473. /** @hidden */
  25474. /**
  25475. * Creates a new InstancedMesh from the current mesh.
  25476. * - name (string) : the cloned mesh name
  25477. * - newParent (optional Node) : the optional Node to parent the clone to.
  25478. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  25479. *
  25480. * Returns the clone.
  25481. */
  25482. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  25483. /**
  25484. * Disposes the InstancedMesh.
  25485. * Returns nothing.
  25486. */
  25487. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25488. }
  25489. }
  25490. declare module BABYLON {
  25491. /**
  25492. * Line mesh
  25493. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  25494. */
  25495. class LinesMesh extends Mesh {
  25496. /**
  25497. * If vertex color should be applied to the mesh
  25498. */
  25499. useVertexColor?: boolean | undefined;
  25500. /**
  25501. * If vertex alpha should be applied to the mesh
  25502. */
  25503. useVertexAlpha?: boolean | undefined;
  25504. /**
  25505. * Color of the line (Default: White)
  25506. */
  25507. color: Color3;
  25508. /**
  25509. * Alpha of the line (Default: 1)
  25510. */
  25511. alpha: number;
  25512. /**
  25513. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  25514. * This margin is expressed in world space coordinates, so its value may vary.
  25515. * Default value is 0.1
  25516. * @returns the intersection Threshold value.
  25517. */
  25518. /**
  25519. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  25520. * This margin is expressed in world space coordinates, so its value may vary.
  25521. */
  25522. intersectionThreshold: number;
  25523. private _intersectionThreshold;
  25524. private _colorShader;
  25525. /**
  25526. * Creates a new LinesMesh
  25527. * @param name defines the name
  25528. * @param scene defines the hosting scene
  25529. * @param parent defines the parent mesh if any
  25530. * @param source defines the optional source LinesMesh used to clone data from
  25531. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  25532. * When false, achieved by calling a clone(), also passing False.
  25533. * This will make creation of children, recursive.
  25534. * @param useVertexColor defines if this LinesMesh supports vertex color
  25535. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  25536. */
  25537. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  25538. /**
  25539. * If vertex color should be applied to the mesh
  25540. */
  25541. useVertexColor?: boolean | undefined,
  25542. /**
  25543. * If vertex alpha should be applied to the mesh
  25544. */
  25545. useVertexAlpha?: boolean | undefined);
  25546. /**
  25547. * Returns the string "LineMesh"
  25548. */
  25549. getClassName(): string;
  25550. /**
  25551. * @hidden
  25552. */
  25553. /**
  25554. * @hidden
  25555. */
  25556. material: Material;
  25557. /**
  25558. * @hidden
  25559. */
  25560. readonly checkCollisions: boolean;
  25561. /** @hidden */
  25562. /** @hidden */
  25563. /**
  25564. * Disposes of the line mesh
  25565. * @param doNotRecurse If children should be disposed
  25566. */
  25567. dispose(doNotRecurse?: boolean): void;
  25568. /**
  25569. * Returns a new LineMesh object cloned from the current one.
  25570. */
  25571. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  25572. }
  25573. }
  25574. declare module BABYLON {
  25575. /**
  25576. * @hidden
  25577. **/
  25578. class _CreationDataStorage {
  25579. closePath?: boolean;
  25580. closeArray?: boolean;
  25581. idx: number[];
  25582. dashSize: number;
  25583. gapSize: number;
  25584. path3D: Path3D;
  25585. pathArray: Vector3[][];
  25586. arc: number;
  25587. radius: number;
  25588. cap: number;
  25589. tessellation: number;
  25590. }
  25591. /**
  25592. * @hidden
  25593. **/
  25594. class _InstanceDataStorage {
  25595. visibleInstances: any;
  25596. renderIdForInstances: number[];
  25597. batchCache: _InstancesBatch;
  25598. instancesBufferSize: number;
  25599. instancesBuffer: Nullable<Buffer>;
  25600. instancesData: Float32Array;
  25601. overridenInstanceCount: number;
  25602. }
  25603. /**
  25604. * @hidden
  25605. **/
  25606. class _InstancesBatch {
  25607. mustReturn: boolean;
  25608. visibleInstances: Nullable<InstancedMesh[]>[];
  25609. renderSelf: boolean[];
  25610. }
  25611. /**
  25612. * Class used to represent renderable models
  25613. */
  25614. class Mesh extends AbstractMesh implements IGetSetVerticesData {
  25615. /**
  25616. * Mesh side orientation : usually the external or front surface
  25617. */
  25618. static readonly FRONTSIDE: number;
  25619. /**
  25620. * Mesh side orientation : usually the internal or back surface
  25621. */
  25622. static readonly BACKSIDE: number;
  25623. /**
  25624. * Mesh side orientation : both internal and external or front and back surfaces
  25625. */
  25626. static readonly DOUBLESIDE: number;
  25627. /**
  25628. * Mesh side orientation : by default, `FRONTSIDE`
  25629. */
  25630. static readonly DEFAULTSIDE: number;
  25631. /**
  25632. * Mesh cap setting : no cap
  25633. */
  25634. static readonly NO_CAP: number;
  25635. /**
  25636. * Mesh cap setting : one cap at the beginning of the mesh
  25637. */
  25638. static readonly CAP_START: number;
  25639. /**
  25640. * Mesh cap setting : one cap at the end of the mesh
  25641. */
  25642. static readonly CAP_END: number;
  25643. /**
  25644. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  25645. */
  25646. static readonly CAP_ALL: number;
  25647. private _onBeforeRenderObservable;
  25648. private _onAfterRenderObservable;
  25649. private _onBeforeDrawObservable;
  25650. /**
  25651. * An event triggered before rendering the mesh
  25652. */
  25653. readonly onBeforeRenderObservable: Observable<Mesh>;
  25654. /**
  25655. * An event triggered after rendering the mesh
  25656. */
  25657. readonly onAfterRenderObservable: Observable<Mesh>;
  25658. /**
  25659. * An event triggered before drawing the mesh
  25660. */
  25661. readonly onBeforeDrawObservable: Observable<Mesh>;
  25662. private _onBeforeDrawObserver;
  25663. /**
  25664. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  25665. */
  25666. onBeforeDraw: () => void;
  25667. /**
  25668. * Gets the delay loading state of the mesh (when delay loading is turned on)
  25669. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  25670. */
  25671. delayLoadState: number;
  25672. /**
  25673. * Gets the list of instances created from this mesh
  25674. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  25675. */
  25676. instances: InstancedMesh[];
  25677. /**
  25678. * Gets the file containing delay loading data for this mesh
  25679. */
  25680. delayLoadingFile: string;
  25681. /** @hidden */
  25682. private _LODLevels;
  25683. /**
  25684. * User defined function used to change how LOD level selection is done
  25685. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  25686. */
  25687. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  25688. private _morphTargetManager;
  25689. /**
  25690. * Gets or sets the morph target manager
  25691. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  25692. */
  25693. morphTargetManager: Nullable<MorphTargetManager>;
  25694. /** @hidden */
  25695. /** @hidden */
  25696. /** @hidden */
  25697. /** @hidden */
  25698. /** @hidden */
  25699. private _effectiveMaterial;
  25700. /** @hidden */
  25701. private _preActivateId;
  25702. /** @hidden */
  25703. /**
  25704. * Use this property to change the original side orientation defined at construction time
  25705. */
  25706. overrideMaterialSideOrientation: Nullable<number>;
  25707. private _areNormalsFrozen;
  25708. private _sourcePositions;
  25709. private _sourceNormals;
  25710. private _source;
  25711. /**
  25712. * Gets the source mesh (the one used to clone this one from)
  25713. */
  25714. readonly source: Nullable<Mesh>;
  25715. /**
  25716. * Gets or sets a boolean indicating that this mesh does not use index buffer
  25717. */
  25718. isUnIndexed: boolean;
  25719. /**
  25720. * @constructor
  25721. * @param name The value used by scene.getMeshByName() to do a lookup.
  25722. * @param scene The scene to add this mesh to.
  25723. * @param parent The parent of this mesh, if it has one
  25724. * @param source An optional Mesh from which geometry is shared, cloned.
  25725. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  25726. * When false, achieved by calling a clone(), also passing False.
  25727. * This will make creation of children, recursive.
  25728. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  25729. */
  25730. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  25731. /**
  25732. * Gets the class name
  25733. * @returns the string "Mesh".
  25734. */
  25735. getClassName(): string;
  25736. /**
  25737. * Returns a description of this mesh
  25738. * @param fullDetails define if full details about this mesh must be used
  25739. * @returns a descriptive string representing this mesh
  25740. */
  25741. toString(fullDetails?: boolean): string;
  25742. /** @hidden */
  25743. /**
  25744. * Gets a boolean indicating if this mesh has LOD
  25745. */
  25746. readonly hasLODLevels: boolean;
  25747. /**
  25748. * Gets the list of MeshLODLevel associated with the current mesh
  25749. * @returns an array of MeshLODLevel
  25750. */
  25751. getLODLevels(): MeshLODLevel[];
  25752. private _sortLODLevels;
  25753. /**
  25754. * Add a mesh as LOD level triggered at the given distance.
  25755. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  25756. * @param distance The distance from the center of the object to show this level
  25757. * @param mesh The mesh to be added as LOD level (can be null)
  25758. * @return This mesh (for chaining)
  25759. */
  25760. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  25761. /**
  25762. * Returns the LOD level mesh at the passed distance or null if not found.
  25763. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  25764. * @param distance The distance from the center of the object to show this level
  25765. * @returns a Mesh or `null`
  25766. */
  25767. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  25768. /**
  25769. * Remove a mesh from the LOD array
  25770. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  25771. * @param mesh defines the mesh to be removed
  25772. * @return This mesh (for chaining)
  25773. */
  25774. removeLODLevel(mesh: Mesh): Mesh;
  25775. /**
  25776. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  25777. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  25778. * @param camera defines the camera to use to compute distance
  25779. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  25780. * @return This mesh (for chaining)
  25781. */
  25782. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  25783. /**
  25784. * Gets the mesh internal Geometry object
  25785. */
  25786. readonly geometry: Nullable<Geometry>;
  25787. /**
  25788. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  25789. * @returns the total number of vertices
  25790. */
  25791. getTotalVertices(): number;
  25792. /**
  25793. * Returns the content of an associated vertex buffer
  25794. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  25795. * - BABYLON.VertexBuffer.PositionKind
  25796. * - BABYLON.VertexBuffer.UVKind
  25797. * - BABYLON.VertexBuffer.UV2Kind
  25798. * - BABYLON.VertexBuffer.UV3Kind
  25799. * - BABYLON.VertexBuffer.UV4Kind
  25800. * - BABYLON.VertexBuffer.UV5Kind
  25801. * - BABYLON.VertexBuffer.UV6Kind
  25802. * - BABYLON.VertexBuffer.ColorKind
  25803. * - BABYLON.VertexBuffer.MatricesIndicesKind
  25804. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  25805. * - BABYLON.VertexBuffer.MatricesWeightsKind
  25806. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  25807. * @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
  25808. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  25809. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  25810. */
  25811. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  25812. /**
  25813. * Returns the mesh VertexBuffer object from the requested `kind`
  25814. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  25815. * - BABYLON.VertexBuffer.PositionKind
  25816. * - BABYLON.VertexBuffer.UVKind
  25817. * - BABYLON.VertexBuffer.UV2Kind
  25818. * - BABYLON.VertexBuffer.UV3Kind
  25819. * - BABYLON.VertexBuffer.UV4Kind
  25820. * - BABYLON.VertexBuffer.UV5Kind
  25821. * - BABYLON.VertexBuffer.UV6Kind
  25822. * - BABYLON.VertexBuffer.ColorKind
  25823. * - BABYLON.VertexBuffer.MatricesIndicesKind
  25824. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  25825. * - BABYLON.VertexBuffer.MatricesWeightsKind
  25826. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  25827. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  25828. */
  25829. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  25830. /**
  25831. * Tests if a specific vertex buffer is associated with this mesh
  25832. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  25833. * - BABYLON.VertexBuffer.PositionKind
  25834. * - BABYLON.VertexBuffer.UVKind
  25835. * - BABYLON.VertexBuffer.UV2Kind
  25836. * - BABYLON.VertexBuffer.UV3Kind
  25837. * - BABYLON.VertexBuffer.UV4Kind
  25838. * - BABYLON.VertexBuffer.UV5Kind
  25839. * - BABYLON.VertexBuffer.UV6Kind
  25840. * - BABYLON.VertexBuffer.ColorKind
  25841. * - BABYLON.VertexBuffer.MatricesIndicesKind
  25842. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  25843. * - BABYLON.VertexBuffer.MatricesWeightsKind
  25844. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  25845. * @returns a boolean
  25846. */
  25847. isVerticesDataPresent(kind: string): boolean;
  25848. /**
  25849. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  25850. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  25851. * - BABYLON.VertexBuffer.PositionKind
  25852. * - BABYLON.VertexBuffer.UVKind
  25853. * - BABYLON.VertexBuffer.UV2Kind
  25854. * - BABYLON.VertexBuffer.UV3Kind
  25855. * - BABYLON.VertexBuffer.UV4Kind
  25856. * - BABYLON.VertexBuffer.UV5Kind
  25857. * - BABYLON.VertexBuffer.UV6Kind
  25858. * - BABYLON.VertexBuffer.ColorKind
  25859. * - BABYLON.VertexBuffer.MatricesIndicesKind
  25860. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  25861. * - BABYLON.VertexBuffer.MatricesWeightsKind
  25862. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  25863. * @returns a boolean
  25864. */
  25865. isVertexBufferUpdatable(kind: string): boolean;
  25866. /**
  25867. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  25868. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  25869. * - BABYLON.VertexBuffer.PositionKind
  25870. * - BABYLON.VertexBuffer.UVKind
  25871. * - BABYLON.VertexBuffer.UV2Kind
  25872. * - BABYLON.VertexBuffer.UV3Kind
  25873. * - BABYLON.VertexBuffer.UV4Kind
  25874. * - BABYLON.VertexBuffer.UV5Kind
  25875. * - BABYLON.VertexBuffer.UV6Kind
  25876. * - BABYLON.VertexBuffer.ColorKind
  25877. * - BABYLON.VertexBuffer.MatricesIndicesKind
  25878. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  25879. * - BABYLON.VertexBuffer.MatricesWeightsKind
  25880. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  25881. * @returns an array of strings
  25882. */
  25883. getVerticesDataKinds(): string[];
  25884. /**
  25885. * Returns a positive integer : the total number of indices in this mesh geometry.
  25886. * @returns the numner of indices or zero if the mesh has no geometry.
  25887. */
  25888. getTotalIndices(): number;
  25889. /**
  25890. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  25891. * @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.
  25892. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25893. * @returns the indices array or an empty array if the mesh has no geometry
  25894. */
  25895. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  25896. readonly isBlocked: boolean;
  25897. /**
  25898. * Determine if the current mesh is ready to be rendered
  25899. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  25900. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  25901. * @returns true if all associated assets are ready (material, textures, shaders)
  25902. */
  25903. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  25904. /**
  25905. * 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.
  25906. */
  25907. readonly areNormalsFrozen: boolean;
  25908. /**
  25909. * 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.
  25910. * @returns the current mesh
  25911. */
  25912. freezeNormals(): Mesh;
  25913. /**
  25914. * 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
  25915. * @returns the current mesh
  25916. */
  25917. unfreezeNormals(): Mesh;
  25918. /**
  25919. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  25920. */
  25921. overridenInstanceCount: number;
  25922. /** @hidden */
  25923. /** @hidden */
  25924. /** @hidden */
  25925. /**
  25926. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  25927. * This means the mesh underlying bounding box and sphere are recomputed.
  25928. * @returns the current mesh
  25929. */
  25930. refreshBoundingInfo(): Mesh;
  25931. /** @hidden */
  25932. private _getPositionData;
  25933. /** @hidden */
  25934. /**
  25935. * This function will subdivide the mesh into multiple submeshes
  25936. * @param count defines the expected number of submeshes
  25937. */
  25938. subdivide(count: number): void;
  25939. /**
  25940. * Copy a FloatArray into a specific associated vertex buffer
  25941. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  25942. * - BABYLON.VertexBuffer.PositionKind
  25943. * - BABYLON.VertexBuffer.UVKind
  25944. * - BABYLON.VertexBuffer.UV2Kind
  25945. * - BABYLON.VertexBuffer.UV3Kind
  25946. * - BABYLON.VertexBuffer.UV4Kind
  25947. * - BABYLON.VertexBuffer.UV5Kind
  25948. * - BABYLON.VertexBuffer.UV6Kind
  25949. * - BABYLON.VertexBuffer.ColorKind
  25950. * - BABYLON.VertexBuffer.MatricesIndicesKind
  25951. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  25952. * - BABYLON.VertexBuffer.MatricesWeightsKind
  25953. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  25954. * @param data defines the data source
  25955. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  25956. * @param stride defines the data stride size (can be null)
  25957. * @returns the current mesh
  25958. */
  25959. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  25960. /**
  25961. * Flags an associated vertex buffer as updatable
  25962. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  25963. * - BABYLON.VertexBuffer.PositionKind
  25964. * - BABYLON.VertexBuffer.UVKind
  25965. * - BABYLON.VertexBuffer.UV2Kind
  25966. * - BABYLON.VertexBuffer.UV3Kind
  25967. * - BABYLON.VertexBuffer.UV4Kind
  25968. * - BABYLON.VertexBuffer.UV5Kind
  25969. * - BABYLON.VertexBuffer.UV6Kind
  25970. * - BABYLON.VertexBuffer.ColorKind
  25971. * - BABYLON.VertexBuffer.MatricesIndicesKind
  25972. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  25973. * - BABYLON.VertexBuffer.MatricesWeightsKind
  25974. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  25975. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  25976. */
  25977. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  25978. /**
  25979. * Sets the mesh global Vertex Buffer
  25980. * @param buffer defines the buffer to use
  25981. * @returns the current mesh
  25982. */
  25983. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  25984. /**
  25985. * Update a specific associated vertex buffer
  25986. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  25987. * - BABYLON.VertexBuffer.PositionKind
  25988. * - BABYLON.VertexBuffer.UVKind
  25989. * - BABYLON.VertexBuffer.UV2Kind
  25990. * - BABYLON.VertexBuffer.UV3Kind
  25991. * - BABYLON.VertexBuffer.UV4Kind
  25992. * - BABYLON.VertexBuffer.UV5Kind
  25993. * - BABYLON.VertexBuffer.UV6Kind
  25994. * - BABYLON.VertexBuffer.ColorKind
  25995. * - BABYLON.VertexBuffer.MatricesIndicesKind
  25996. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  25997. * - BABYLON.VertexBuffer.MatricesWeightsKind
  25998. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  25999. * @param data defines the data source
  26000. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  26001. * @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)
  26002. * @returns the current mesh
  26003. */
  26004. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  26005. /**
  26006. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  26007. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  26008. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  26009. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  26010. * @returns the current mesh
  26011. */
  26012. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  26013. /**
  26014. * Creates a un-shared specific occurence of the geometry for the mesh.
  26015. * @returns the current mesh
  26016. */
  26017. makeGeometryUnique(): Mesh;
  26018. /**
  26019. * Set the index buffer of this mesh
  26020. * @param indices defines the source data
  26021. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  26022. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  26023. * @returns the current mesh
  26024. */
  26025. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  26026. /**
  26027. * Update the current index buffer
  26028. * @param indices defines the source data
  26029. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  26030. * @returns the current mesh
  26031. */
  26032. updateIndices(indices: IndicesArray, offset?: number): Mesh;
  26033. /**
  26034. * Invert the geometry to move from a right handed system to a left handed one.
  26035. * @returns the current mesh
  26036. */
  26037. toLeftHanded(): Mesh;
  26038. /** @hidden */
  26039. /** @hidden */
  26040. /**
  26041. * Registers for this mesh a javascript function called just before the rendering process
  26042. * @param func defines the function to call before rendering this mesh
  26043. * @returns the current mesh
  26044. */
  26045. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  26046. /**
  26047. * Disposes a previously registered javascript function called before the rendering
  26048. * @param func defines the function to remove
  26049. * @returns the current mesh
  26050. */
  26051. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  26052. /**
  26053. * Registers for this mesh a javascript function called just after the rendering is complete
  26054. * @param func defines the function to call after rendering this mesh
  26055. * @returns the current mesh
  26056. */
  26057. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  26058. /**
  26059. * Disposes a previously registered javascript function called after the rendering.
  26060. * @param func defines the function to remove
  26061. * @returns the current mesh
  26062. */
  26063. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  26064. /** @hidden */
  26065. /** @hidden */
  26066. /** @hidden */
  26067. /**
  26068. * 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
  26069. * @param subMesh defines the subMesh to render
  26070. * @param enableAlphaMode defines if alpha mode can be changed
  26071. * @returns the current mesh
  26072. */
  26073. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  26074. private _onBeforeDraw;
  26075. /**
  26076. * Renormalize the mesh and patch it up if there are no weights
  26077. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  26078. * However in the case of zero weights then we set just a single influence to 1.
  26079. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  26080. */
  26081. cleanMatrixWeights(): void;
  26082. private normalizeSkinFourWeights;
  26083. private normalizeSkinWeightsAndExtra;
  26084. /**
  26085. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  26086. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  26087. * the user know there was an issue with importing the mesh
  26088. * @returns a validation object with skinned, valid and report string
  26089. */
  26090. validateSkinning(): {
  26091. skinned: boolean;
  26092. valid: boolean;
  26093. report: string;
  26094. };
  26095. /** @hidden */
  26096. private _queueLoad;
  26097. /**
  26098. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  26099. * A mesh is in the frustum if its bounding box intersects the frustum
  26100. * @param frustumPlanes defines the frustum to test
  26101. * @returns true if the mesh is in the frustum planes
  26102. */
  26103. isInFrustum(frustumPlanes: Plane[]): boolean;
  26104. /**
  26105. * Sets the mesh material by the material or multiMaterial `id` property
  26106. * @param id is a string identifying the material or the multiMaterial
  26107. * @returns the current mesh
  26108. */
  26109. setMaterialByID(id: string): Mesh;
  26110. /**
  26111. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  26112. * @returns an array of IAnimatable
  26113. */
  26114. getAnimatables(): IAnimatable[];
  26115. /**
  26116. * Modifies the mesh geometry according to the passed transformation matrix.
  26117. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  26118. * The mesh normals are modified using the same transformation.
  26119. * Note that, under the hood, this method sets a new VertexBuffer each call.
  26120. * @param transform defines the transform matrix to use
  26121. * @see http://doc.babylonjs.com/resources/baking_transformations
  26122. * @returns the current mesh
  26123. */
  26124. bakeTransformIntoVertices(transform: Matrix): Mesh;
  26125. /**
  26126. * Modifies the mesh geometry according to its own current World Matrix.
  26127. * The mesh World Matrix is then reset.
  26128. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  26129. * Note that, under the hood, this method sets a new VertexBuffer each call.
  26130. * @see http://doc.babylonjs.com/resources/baking_transformations
  26131. * @returns the current mesh
  26132. */
  26133. bakeCurrentTransformIntoVertices(): Mesh;
  26134. /** @hidden */
  26135. protected readonly _positions: Nullable<Vector3[]>;
  26136. /** @hidden */
  26137. /** @hidden */
  26138. /**
  26139. * Returns a new Mesh object generated from the current mesh properties.
  26140. * This method must not get confused with createInstance()
  26141. * @param name is a string, the name given to the new mesh
  26142. * @param newParent can be any Node object (default `null`)
  26143. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  26144. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  26145. * @returns a new mesh
  26146. */
  26147. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  26148. /**
  26149. * Releases resources associated with this mesh.
  26150. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26151. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26152. */
  26153. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26154. /**
  26155. * Modifies the mesh geometry according to a displacement map.
  26156. * 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.
  26157. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  26158. * @param url is a string, the URL from the image file is to be downloaded.
  26159. * @param minHeight is the lower limit of the displacement.
  26160. * @param maxHeight is the upper limit of the displacement.
  26161. * @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.
  26162. * @param uvOffset is an optional vector2 used to offset UV.
  26163. * @param uvScale is an optional vector2 used to scale UV.
  26164. * @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.
  26165. * @returns the Mesh.
  26166. */
  26167. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  26168. /**
  26169. * Modifies the mesh geometry according to a displacementMap buffer.
  26170. * 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.
  26171. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  26172. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  26173. * @param heightMapWidth is the width of the buffer image.
  26174. * @param heightMapHeight is the height of the buffer image.
  26175. * @param minHeight is the lower limit of the displacement.
  26176. * @param maxHeight is the upper limit of the displacement.
  26177. * @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.
  26178. * @param uvOffset is an optional vector2 used to offset UV.
  26179. * @param uvScale is an optional vector2 used to scale UV.
  26180. * @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.
  26181. * @returns the Mesh.
  26182. */
  26183. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  26184. /**
  26185. * Modify the mesh to get a flat shading rendering.
  26186. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  26187. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  26188. * @returns current mesh
  26189. */
  26190. convertToFlatShadedMesh(): Mesh;
  26191. /**
  26192. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  26193. * In other words, more vertices, no more indices and a single bigger VBO.
  26194. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  26195. * @returns current mesh
  26196. */
  26197. convertToUnIndexedMesh(): Mesh;
  26198. /**
  26199. * Inverses facet orientations.
  26200. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  26201. * @param flipNormals will also inverts the normals
  26202. * @returns current mesh
  26203. */
  26204. flipFaces(flipNormals?: boolean): Mesh;
  26205. /**
  26206. * Creates a new InstancedMesh object from the mesh model.
  26207. * Warning : this method is not supported for Line mesh and LineSystem
  26208. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  26209. * @param name defines the name of the new instance
  26210. * @returns a new InstancedMesh
  26211. */
  26212. createInstance(name: string): InstancedMesh;
  26213. /**
  26214. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  26215. * After this call, all the mesh instances have the same submeshes than the current mesh.
  26216. * @returns the current mesh
  26217. */
  26218. synchronizeInstances(): Mesh;
  26219. /**
  26220. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  26221. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  26222. * This should be used together with the simplification to avoid disappearing triangles.
  26223. * @param successCallback an optional success callback to be called after the optimization finished.
  26224. * @returns the current mesh
  26225. */
  26226. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  26227. /**
  26228. * Serialize current mesh
  26229. * @param serializationObject defines the object which will receive the serialization data
  26230. */
  26231. serialize(serializationObject: any): void;
  26232. /** @hidden */
  26233. /**
  26234. * Returns a new Mesh object parsed from the source provided.
  26235. * @param parsedMesh is the source
  26236. * @param scene defines the hosting scene
  26237. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  26238. * @returns a new Mesh
  26239. */
  26240. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  26241. /**
  26242. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  26243. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  26244. * @param name defines the name of the mesh to create
  26245. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  26246. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  26247. * @param closePath creates a seam between the first and the last points of each path of the path array
  26248. * @param offset is taken in account only if the `pathArray` is containing a single path
  26249. * @param scene defines the hosting scene
  26250. * @param updatable defines if the mesh must be flagged as updatable
  26251. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26252. * @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)
  26253. * @returns a new Mesh
  26254. */
  26255. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean | undefined, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  26256. /**
  26257. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  26258. * @param name defines the name of the mesh to create
  26259. * @param radius sets the radius size (float) of the polygon (default 0.5)
  26260. * @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
  26261. * @param scene defines the hosting scene
  26262. * @param updatable defines if the mesh must be flagged as updatable
  26263. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26264. * @returns a new Mesh
  26265. */
  26266. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  26267. /**
  26268. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  26269. * @param name defines the name of the mesh to create
  26270. * @param size sets the size (float) of each box side (default 1)
  26271. * @param scene defines the hosting scene
  26272. * @param updatable defines if the mesh must be flagged as updatable
  26273. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26274. * @returns a new Mesh
  26275. */
  26276. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  26277. /**
  26278. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  26279. * @param name defines the name of the mesh to create
  26280. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  26281. * @param diameter sets the diameter size (float) of the sphere (default 1)
  26282. * @param scene defines the hosting scene
  26283. * @param updatable defines if the mesh must be flagged as updatable
  26284. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26285. * @returns a new Mesh
  26286. */
  26287. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  26288. /**
  26289. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  26290. * @param name defines the name of the mesh to create
  26291. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  26292. * @param diameterTop set the top cap diameter (floats, default 1)
  26293. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  26294. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  26295. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  26296. * @param scene defines the hosting scene
  26297. * @param updatable defines if the mesh must be flagged as updatable
  26298. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26299. * @returns a new Mesh
  26300. */
  26301. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  26302. /**
  26303. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  26304. * @param name defines the name of the mesh to create
  26305. * @param diameter sets the diameter size (float) of the torus (default 1)
  26306. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  26307. * @param tessellation sets the number of torus sides (postive integer, default 16)
  26308. * @param scene defines the hosting scene
  26309. * @param updatable defines if the mesh must be flagged as updatable
  26310. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26311. * @returns a new Mesh
  26312. */
  26313. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  26314. /**
  26315. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  26316. * @param name defines the name of the mesh to create
  26317. * @param radius sets the global radius size (float) of the torus knot (default 2)
  26318. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  26319. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  26320. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  26321. * @param p the number of windings on X axis (positive integers, default 2)
  26322. * @param q the number of windings on Y axis (positive integers, default 3)
  26323. * @param scene defines the hosting scene
  26324. * @param updatable defines if the mesh must be flagged as updatable
  26325. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26326. * @returns a new Mesh
  26327. */
  26328. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  26329. /**
  26330. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  26331. * @param name defines the name of the mesh to create
  26332. * @param points is an array successive Vector3
  26333. * @param scene defines the hosting scene
  26334. * @param updatable defines if the mesh must be flagged as updatable
  26335. * @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).
  26336. * @returns a new Mesh
  26337. */
  26338. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  26339. /**
  26340. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  26341. * @param name defines the name of the mesh to create
  26342. * @param points is an array successive Vector3
  26343. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  26344. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  26345. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  26346. * @param scene defines the hosting scene
  26347. * @param updatable defines if the mesh must be flagged as updatable
  26348. * @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)
  26349. * @returns a new Mesh
  26350. */
  26351. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  26352. /**
  26353. * Creates a polygon mesh.
  26354. * Please consider using the same method from the MeshBuilder class instead.
  26355. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  26356. * 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.
  26357. * You can set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  26358. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  26359. * Remember you can only change the shape positions, not their number when updating a polygon.
  26360. */
  26361. /**
  26362. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  26363. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  26364. * @param name defines the name of the mesh to create
  26365. * @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
  26366. * @param scene defines the hosting scene
  26367. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  26368. * @param updatable defines if the mesh must be flagged as updatable
  26369. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26370. * @returns a new Mesh
  26371. */
  26372. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number): Mesh;
  26373. /**
  26374. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  26375. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  26376. * @param name defines the name of the mesh to create
  26377. * @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
  26378. * @param depth defines the height of extrusion
  26379. * @param scene defines the hosting scene
  26380. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  26381. * @param updatable defines if the mesh must be flagged as updatable
  26382. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26383. * @returns a new Mesh
  26384. */
  26385. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number): Mesh;
  26386. /**
  26387. * Creates an extruded shape mesh.
  26388. * 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
  26389. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  26390. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  26391. * @param name defines the name of the mesh to create
  26392. * @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
  26393. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  26394. * @param scale is the value to scale the shape
  26395. * @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
  26396. * @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
  26397. * @param scene defines the hosting scene
  26398. * @param updatable defines if the mesh must be flagged as updatable
  26399. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26400. * @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)
  26401. * @returns a new Mesh
  26402. */
  26403. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  26404. /**
  26405. * Creates an custom extruded shape mesh.
  26406. * The custom extrusion is a parametric shape.
  26407. * It has no predefined shape. Its final shape will depend on the input parameters.
  26408. * Please consider using the same method from the MeshBuilder class instead
  26409. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  26410. * @param name defines the name of the mesh to create
  26411. * @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
  26412. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  26413. * @param scaleFunction is a custom Javascript function called on each path point
  26414. * @param rotationFunction is a custom Javascript function called on each path point
  26415. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  26416. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  26417. * @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
  26418. * @param scene defines the hosting scene
  26419. * @param updatable defines if the mesh must be flagged as updatable
  26420. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26421. * @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)
  26422. * @returns a new Mesh
  26423. */
  26424. 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;
  26425. /**
  26426. * Creates lathe mesh.
  26427. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  26428. * Please consider using the same method from the MeshBuilder class instead
  26429. * @param name defines the name of the mesh to create
  26430. * @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
  26431. * @param radius is the radius value of the lathe
  26432. * @param tessellation is the side number of the lathe.
  26433. * @param scene defines the hosting scene
  26434. * @param updatable defines if the mesh must be flagged as updatable
  26435. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26436. * @returns a new Mesh
  26437. */
  26438. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  26439. /**
  26440. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  26441. * @param name defines the name of the mesh to create
  26442. * @param size sets the size (float) of both sides of the plane at once (default 1)
  26443. * @param scene defines the hosting scene
  26444. * @param updatable defines if the mesh must be flagged as updatable
  26445. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26446. * @returns a new Mesh
  26447. */
  26448. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  26449. /**
  26450. * Creates a ground mesh.
  26451. * Please consider using the same method from the MeshBuilder class instead
  26452. * @param name defines the name of the mesh to create
  26453. * @param width set the width of the ground
  26454. * @param height set the height of the ground
  26455. * @param subdivisions sets the number of subdivisions per side
  26456. * @param scene defines the hosting scene
  26457. * @param updatable defines if the mesh must be flagged as updatable
  26458. * @returns a new Mesh
  26459. */
  26460. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  26461. /**
  26462. * Creates a tiled ground mesh.
  26463. * Please consider using the same method from the MeshBuilder class instead
  26464. * @param name defines the name of the mesh to create
  26465. * @param xmin set the ground minimum X coordinate
  26466. * @param zmin set the ground minimum Y coordinate
  26467. * @param xmax set the ground maximum X coordinate
  26468. * @param zmax set the ground maximum Z coordinate
  26469. * @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
  26470. * @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
  26471. * @param scene defines the hosting scene
  26472. * @param updatable defines if the mesh must be flagged as updatable
  26473. * @returns a new Mesh
  26474. */
  26475. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  26476. w: number;
  26477. h: number;
  26478. }, precision: {
  26479. w: number;
  26480. h: number;
  26481. }, scene: Scene, updatable?: boolean): Mesh;
  26482. /**
  26483. * Creates a ground mesh from a height map.
  26484. * Please consider using the same method from the MeshBuilder class instead
  26485. * @see http://doc.babylonjs.com/babylon101/height_map
  26486. * @param name defines the name of the mesh to create
  26487. * @param url sets the URL of the height map image resource
  26488. * @param width set the ground width size
  26489. * @param height set the ground height size
  26490. * @param subdivisions sets the number of subdivision per side
  26491. * @param minHeight is the minimum altitude on the ground
  26492. * @param maxHeight is the maximum altitude on the ground
  26493. * @param scene defines the hosting scene
  26494. * @param updatable defines if the mesh must be flagged as updatable
  26495. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  26496. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  26497. * @returns a new Mesh
  26498. */
  26499. 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;
  26500. /**
  26501. * Creates a tube mesh.
  26502. * The tube is a parametric shape.
  26503. * It has no predefined shape. Its final shape will depend on the input parameters.
  26504. * Please consider using the same method from the MeshBuilder class instead
  26505. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  26506. * @param name defines the name of the mesh to create
  26507. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  26508. * @param radius sets the tube radius size
  26509. * @param tessellation is the number of sides on the tubular surface
  26510. * @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
  26511. * @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
  26512. * @param scene defines the hosting scene
  26513. * @param updatable defines if the mesh must be flagged as updatable
  26514. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26515. * @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)
  26516. * @returns a new Mesh
  26517. */
  26518. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  26519. (i: number, distance: number): number;
  26520. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  26521. /**
  26522. * Creates a polyhedron mesh.
  26523. * Please consider using the same method from the MeshBuilder class instead.
  26524. * * 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
  26525. * * The parameter `size` (positive float, default 1) sets the polygon size
  26526. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  26527. * * 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`
  26528. * * 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
  26529. * * 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)`)
  26530. * * 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
  26531. * * 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
  26532. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  26533. * * 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
  26534. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  26535. * @param name defines the name of the mesh to create
  26536. * @param options defines the options used to create the mesh
  26537. * @param scene defines the hosting scene
  26538. * @returns a new Mesh
  26539. */
  26540. static CreatePolyhedron(name: string, options: {
  26541. type?: number;
  26542. size?: number;
  26543. sizeX?: number;
  26544. sizeY?: number;
  26545. sizeZ?: number;
  26546. custom?: any;
  26547. faceUV?: Vector4[];
  26548. faceColors?: Color4[];
  26549. updatable?: boolean;
  26550. sideOrientation?: number;
  26551. }, scene: Scene): Mesh;
  26552. /**
  26553. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  26554. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  26555. * * 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`)
  26556. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  26557. * * 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
  26558. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  26559. * * 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
  26560. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  26561. * @param name defines the name of the mesh
  26562. * @param options defines the options used to create the mesh
  26563. * @param scene defines the hosting scene
  26564. * @returns a new Mesh
  26565. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  26566. */
  26567. static CreateIcoSphere(name: string, options: {
  26568. radius?: number;
  26569. flat?: boolean;
  26570. subdivisions?: number;
  26571. sideOrientation?: number;
  26572. updatable?: boolean;
  26573. }, scene: Scene): Mesh;
  26574. /**
  26575. * Creates a decal mesh.
  26576. * Please consider using the same method from the MeshBuilder class instead.
  26577. * A decal is a mesh usually applied as a model onto the surface of another mesh
  26578. * @param name defines the name of the mesh
  26579. * @param sourceMesh defines the mesh receiving the decal
  26580. * @param position sets the position of the decal in world coordinates
  26581. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  26582. * @param size sets the decal scaling
  26583. * @param angle sets the angle to rotate the decal
  26584. * @returns a new Mesh
  26585. */
  26586. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  26587. /**
  26588. * Prepare internal position array for software CPU skinning
  26589. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  26590. */
  26591. setPositionsForCPUSkinning(): Float32Array;
  26592. /**
  26593. * Prepare internal normal array for software CPU skinning
  26594. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  26595. */
  26596. setNormalsForCPUSkinning(): Float32Array;
  26597. /**
  26598. * Updates the vertex buffer by applying transformation from the bones
  26599. * @param skeleton defines the skeleton to apply to current mesh
  26600. * @returns the current mesh
  26601. */
  26602. applySkeleton(skeleton: Skeleton): Mesh;
  26603. /**
  26604. * 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
  26605. * @param meshes defines the list of meshes to scan
  26606. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  26607. */
  26608. static MinMax(meshes: AbstractMesh[]): {
  26609. min: Vector3;
  26610. max: Vector3;
  26611. };
  26612. /**
  26613. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  26614. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  26615. * @returns a vector3
  26616. */
  26617. static Center(meshesOrMinMaxVector: {
  26618. min: Vector3;
  26619. max: Vector3;
  26620. } | AbstractMesh[]): Vector3;
  26621. /**
  26622. * Merge the array of meshes into a single mesh for performance reasons.
  26623. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  26624. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  26625. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  26626. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  26627. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  26628. * @returns a new mesh
  26629. */
  26630. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean): Nullable<Mesh>;
  26631. }
  26632. }
  26633. declare module BABYLON {
  26634. /**
  26635. * Define an interface for all classes that will get and set the data on vertices
  26636. */
  26637. interface IGetSetVerticesData {
  26638. /**
  26639. * Gets a boolean indicating if specific vertex data is present
  26640. * @param kind defines the vertex data kind to use
  26641. * @returns true is data kind is present
  26642. */
  26643. isVerticesDataPresent(kind: string): boolean;
  26644. /**
  26645. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  26646. * @param kind defines the data kind (Position, normal, etc...)
  26647. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  26648. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  26649. * @returns a float array containing vertex data
  26650. */
  26651. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  26652. /**
  26653. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  26654. * @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.
  26655. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  26656. * @returns the indices array or an empty array if the mesh has no geometry
  26657. */
  26658. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  26659. /**
  26660. * Set specific vertex data
  26661. * @param kind defines the data kind (Position, normal, etc...)
  26662. * @param data defines the vertex data to use
  26663. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  26664. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  26665. */
  26666. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  26667. /**
  26668. * Update a specific associated vertex buffer
  26669. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  26670. * - BABYLON.VertexBuffer.PositionKind
  26671. * - BABYLON.VertexBuffer.UVKind
  26672. * - BABYLON.VertexBuffer.UV2Kind
  26673. * - BABYLON.VertexBuffer.UV3Kind
  26674. * - BABYLON.VertexBuffer.UV4Kind
  26675. * - BABYLON.VertexBuffer.UV5Kind
  26676. * - BABYLON.VertexBuffer.UV6Kind
  26677. * - BABYLON.VertexBuffer.ColorKind
  26678. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26679. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26680. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26681. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26682. * @param data defines the data source
  26683. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  26684. * @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)
  26685. */
  26686. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  26687. /**
  26688. * Creates a new index buffer
  26689. * @param indices defines the indices to store in the index buffer
  26690. * @param totalVertices defines the total number of vertices (could be null)
  26691. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  26692. */
  26693. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  26694. }
  26695. /**
  26696. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  26697. */
  26698. class VertexData {
  26699. /**
  26700. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  26701. */
  26702. positions: Nullable<FloatArray>;
  26703. /**
  26704. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  26705. */
  26706. normals: Nullable<FloatArray>;
  26707. /**
  26708. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  26709. */
  26710. tangents: Nullable<FloatArray>;
  26711. /**
  26712. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26713. */
  26714. uvs: Nullable<FloatArray>;
  26715. /**
  26716. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26717. */
  26718. uvs2: Nullable<FloatArray>;
  26719. /**
  26720. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26721. */
  26722. uvs3: Nullable<FloatArray>;
  26723. /**
  26724. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26725. */
  26726. uvs4: Nullable<FloatArray>;
  26727. /**
  26728. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26729. */
  26730. uvs5: Nullable<FloatArray>;
  26731. /**
  26732. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26733. */
  26734. uvs6: Nullable<FloatArray>;
  26735. /**
  26736. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  26737. */
  26738. colors: Nullable<FloatArray>;
  26739. /**
  26740. * 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).
  26741. */
  26742. matricesIndices: Nullable<FloatArray>;
  26743. /**
  26744. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  26745. */
  26746. matricesWeights: Nullable<FloatArray>;
  26747. /**
  26748. * An array extending the number of possible indices
  26749. */
  26750. matricesIndicesExtra: Nullable<FloatArray>;
  26751. /**
  26752. * An array extending the number of possible weights when the number of indices is extended
  26753. */
  26754. matricesWeightsExtra: Nullable<FloatArray>;
  26755. /**
  26756. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  26757. */
  26758. indices: Nullable<IndicesArray>;
  26759. /**
  26760. * Uses the passed data array to set the set the values for the specified kind of data
  26761. * @param data a linear array of floating numbers
  26762. * @param kind the type of data that is being set, eg positions, colors etc
  26763. */
  26764. set(data: FloatArray, kind: string): void;
  26765. /**
  26766. * Associates the vertexData to the passed Mesh.
  26767. * Sets it as updatable or not (default `false`)
  26768. * @param mesh the mesh the vertexData is applied to
  26769. * @param updatable when used and having the value true allows new data to update the vertexData
  26770. * @returns the VertexData
  26771. */
  26772. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  26773. /**
  26774. * Associates the vertexData to the passed Geometry.
  26775. * Sets it as updatable or not (default `false`)
  26776. * @param geometry the geometry the vertexData is applied to
  26777. * @param updatable when used and having the value true allows new data to update the vertexData
  26778. * @returns VertexData
  26779. */
  26780. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  26781. /**
  26782. * Updates the associated mesh
  26783. * @param mesh the mesh to be updated
  26784. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  26785. * @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
  26786. * @returns VertexData
  26787. */
  26788. updateMesh(mesh: Mesh, updateExtends?: boolean, makeItUnique?: boolean): VertexData;
  26789. /**
  26790. * Updates the associated geometry
  26791. * @param geometry the geometry to be updated
  26792. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  26793. * @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
  26794. * @returns VertexData.
  26795. */
  26796. updateGeometry(geometry: Geometry, updateExtends?: boolean, makeItUnique?: boolean): VertexData;
  26797. private _applyTo;
  26798. private _update;
  26799. /**
  26800. * Transforms each position and each normal of the vertexData according to the passed Matrix
  26801. * @param matrix the transforming matrix
  26802. * @returns the VertexData
  26803. */
  26804. transform(matrix: Matrix): VertexData;
  26805. /**
  26806. * Merges the passed VertexData into the current one
  26807. * @param other the VertexData to be merged into the current one
  26808. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  26809. * @returns the modified VertexData
  26810. */
  26811. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  26812. private _mergeElement;
  26813. private _validate;
  26814. /**
  26815. * Serializes the VertexData
  26816. * @returns a serialized object
  26817. */
  26818. serialize(): any;
  26819. /**
  26820. * Extracts the vertexData from a mesh
  26821. * @param mesh the mesh from which to extract the VertexData
  26822. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  26823. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  26824. * @returns the object VertexData associated to the passed mesh
  26825. */
  26826. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  26827. /**
  26828. * Extracts the vertexData from the geometry
  26829. * @param geometry the geometry from which to extract the VertexData
  26830. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  26831. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  26832. * @returns the object VertexData associated to the passed mesh
  26833. */
  26834. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  26835. private static _ExtractFrom;
  26836. /**
  26837. * Creates the VertexData for a Ribbon
  26838. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  26839. * * pathArray array of paths, each of which an array of successive Vector3
  26840. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  26841. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  26842. * * 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
  26843. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  26844. * * 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)
  26845. * * 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)
  26846. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  26847. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  26848. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  26849. * @returns the VertexData of the ribbon
  26850. */
  26851. static CreateRibbon(options: {
  26852. pathArray: Vector3[][];
  26853. closeArray?: boolean;
  26854. closePath?: boolean;
  26855. offset?: number;
  26856. sideOrientation?: number;
  26857. frontUVs?: Vector4;
  26858. backUVs?: Vector4;
  26859. invertUV?: boolean;
  26860. uvs?: Vector2[];
  26861. colors?: Color4[];
  26862. }): VertexData;
  26863. /**
  26864. * Creates the VertexData for a box
  26865. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26866. * * size sets the width, height and depth of the box to the value of size, optional default 1
  26867. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  26868. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  26869. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  26870. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  26871. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  26872. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  26873. * * 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)
  26874. * * 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)
  26875. * @returns the VertexData of the box
  26876. */
  26877. static CreateBox(options: {
  26878. size?: number;
  26879. width?: number;
  26880. height?: number;
  26881. depth?: number;
  26882. faceUV?: Vector4[];
  26883. faceColors?: Color4[];
  26884. sideOrientation?: number;
  26885. frontUVs?: Vector4;
  26886. backUVs?: Vector4;
  26887. }): VertexData;
  26888. /**
  26889. * Creates the VertexData for an ellipsoid, defaults to a sphere
  26890. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26891. * * segments sets the number of horizontal strips optional, default 32
  26892. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  26893. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  26894. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  26895. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  26896. * * 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
  26897. * * 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
  26898. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  26899. * * 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)
  26900. * * 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)
  26901. * @returns the VertexData of the ellipsoid
  26902. */
  26903. static CreateSphere(options: {
  26904. segments?: number;
  26905. diameter?: number;
  26906. diameterX?: number;
  26907. diameterY?: number;
  26908. diameterZ?: number;
  26909. arc?: number;
  26910. slice?: number;
  26911. sideOrientation?: number;
  26912. frontUVs?: Vector4;
  26913. backUVs?: Vector4;
  26914. }): VertexData;
  26915. /**
  26916. * Creates the VertexData for a cylinder, cone or prism
  26917. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26918. * * height sets the height (y direction) of the cylinder, optional, default 2
  26919. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  26920. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  26921. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  26922. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  26923. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  26924. * * 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
  26925. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  26926. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  26927. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  26928. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  26929. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  26930. * * 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)
  26931. * * 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)
  26932. * @returns the VertexData of the cylinder, cone or prism
  26933. */
  26934. static CreateCylinder(options: {
  26935. height?: number;
  26936. diameterTop?: number;
  26937. diameterBottom?: number;
  26938. diameter?: number;
  26939. tessellation?: number;
  26940. subdivisions?: number;
  26941. arc?: number;
  26942. faceColors?: Color4[];
  26943. faceUV?: Vector4[];
  26944. hasRings?: boolean;
  26945. enclose?: boolean;
  26946. sideOrientation?: number;
  26947. frontUVs?: Vector4;
  26948. backUVs?: Vector4;
  26949. }): VertexData;
  26950. /**
  26951. * Creates the VertexData for a torus
  26952. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26953. * * diameter the diameter of the torus, optional default 1
  26954. * * thickness the diameter of the tube forming the torus, optional default 0.5
  26955. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  26956. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  26957. * * 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)
  26958. * * 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)
  26959. * @returns the VertexData of the torus
  26960. */
  26961. static CreateTorus(options: {
  26962. diameter?: number;
  26963. thickness?: number;
  26964. tessellation?: number;
  26965. sideOrientation?: number;
  26966. frontUVs?: Vector4;
  26967. backUVs?: Vector4;
  26968. }): VertexData;
  26969. /**
  26970. * Creates the VertexData of the LineSystem
  26971. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  26972. * - lines an array of lines, each line being an array of successive Vector3
  26973. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  26974. * @returns the VertexData of the LineSystem
  26975. */
  26976. static CreateLineSystem(options: {
  26977. lines: Vector3[][];
  26978. colors?: Nullable<Color4[][]>;
  26979. }): VertexData;
  26980. /**
  26981. * Create the VertexData for a DashedLines
  26982. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  26983. * - points an array successive Vector3
  26984. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  26985. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  26986. * - dashNb the intended total number of dashes, optional, default 200
  26987. * @returns the VertexData for the DashedLines
  26988. */
  26989. static CreateDashedLines(options: {
  26990. points: Vector3[];
  26991. dashSize?: number;
  26992. gapSize?: number;
  26993. dashNb?: number;
  26994. }): VertexData;
  26995. /**
  26996. * Creates the VertexData for a Ground
  26997. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  26998. * - width the width (x direction) of the ground, optional, default 1
  26999. * - height the height (z direction) of the ground, optional, default 1
  27000. * - subdivisions the number of subdivisions per side, optional, default 1
  27001. * @returns the VertexData of the Ground
  27002. */
  27003. static CreateGround(options: {
  27004. width?: number;
  27005. height?: number;
  27006. subdivisions?: number;
  27007. subdivisionsX?: number;
  27008. subdivisionsY?: number;
  27009. }): VertexData;
  27010. /**
  27011. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  27012. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  27013. * * xmin the ground minimum X coordinate, optional, default -1
  27014. * * zmin the ground minimum Z coordinate, optional, default -1
  27015. * * xmax the ground maximum X coordinate, optional, default 1
  27016. * * zmax the ground maximum Z coordinate, optional, default 1
  27017. * * 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}
  27018. * * 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}
  27019. * @returns the VertexData of the TiledGround
  27020. */
  27021. static CreateTiledGround(options: {
  27022. xmin: number;
  27023. zmin: number;
  27024. xmax: number;
  27025. zmax: number;
  27026. subdivisions?: {
  27027. w: number;
  27028. h: number;
  27029. };
  27030. precision?: {
  27031. w: number;
  27032. h: number;
  27033. };
  27034. }): VertexData;
  27035. /**
  27036. * Creates the VertexData of the Ground designed from a heightmap
  27037. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  27038. * * width the width (x direction) of the ground
  27039. * * height the height (z direction) of the ground
  27040. * * subdivisions the number of subdivisions per side
  27041. * * minHeight the minimum altitude on the ground, optional, default 0
  27042. * * maxHeight the maximum altitude on the ground, optional default 1
  27043. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  27044. * * buffer the array holding the image color data
  27045. * * bufferWidth the width of image
  27046. * * bufferHeight the height of image
  27047. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  27048. * @returns the VertexData of the Ground designed from a heightmap
  27049. */
  27050. static CreateGroundFromHeightMap(options: {
  27051. width: number;
  27052. height: number;
  27053. subdivisions: number;
  27054. minHeight: number;
  27055. maxHeight: number;
  27056. colorFilter: Color3;
  27057. buffer: Uint8Array;
  27058. bufferWidth: number;
  27059. bufferHeight: number;
  27060. alphaFilter: number;
  27061. }): VertexData;
  27062. /**
  27063. * Creates the VertexData for a Plane
  27064. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  27065. * * size sets the width and height of the plane to the value of size, optional default 1
  27066. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  27067. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  27068. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27069. * * 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)
  27070. * * 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)
  27071. * @returns the VertexData of the box
  27072. */
  27073. static CreatePlane(options: {
  27074. size?: number;
  27075. width?: number;
  27076. height?: number;
  27077. sideOrientation?: number;
  27078. frontUVs?: Vector4;
  27079. backUVs?: Vector4;
  27080. }): VertexData;
  27081. /**
  27082. * Creates the VertexData of the Disc or regular Polygon
  27083. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  27084. * * radius the radius of the disc, optional default 0.5
  27085. * * tessellation the number of polygon sides, optional, default 64
  27086. * * 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
  27087. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27088. * * 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)
  27089. * * 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)
  27090. * @returns the VertexData of the box
  27091. */
  27092. static CreateDisc(options: {
  27093. radius?: number;
  27094. tessellation?: number;
  27095. arc?: number;
  27096. sideOrientation?: number;
  27097. frontUVs?: Vector4;
  27098. backUVs?: Vector4;
  27099. }): VertexData;
  27100. /**
  27101. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  27102. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  27103. * @param polygon a mesh built from polygonTriangulation.build()
  27104. * @param sideOrientation takes the values BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27105. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  27106. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  27107. * @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)
  27108. * @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)
  27109. * @returns the VertexData of the Polygon
  27110. */
  27111. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  27112. /**
  27113. * Creates the VertexData of the IcoSphere
  27114. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  27115. * * radius the radius of the IcoSphere, optional default 1
  27116. * * radiusX allows stretching in the x direction, optional, default radius
  27117. * * radiusY allows stretching in the y direction, optional, default radius
  27118. * * radiusZ allows stretching in the z direction, optional, default radius
  27119. * * flat when true creates a flat shaded mesh, optional, default true
  27120. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  27121. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27122. * * 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)
  27123. * * 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)
  27124. * @returns the VertexData of the IcoSphere
  27125. */
  27126. static CreateIcoSphere(options: {
  27127. radius?: number;
  27128. radiusX?: number;
  27129. radiusY?: number;
  27130. radiusZ?: number;
  27131. flat?: boolean;
  27132. subdivisions?: number;
  27133. sideOrientation?: number;
  27134. frontUVs?: Vector4;
  27135. backUVs?: Vector4;
  27136. }): VertexData;
  27137. /**
  27138. * Creates the VertexData for a Polyhedron
  27139. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  27140. * * type provided types are:
  27141. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  27142. * * 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)
  27143. * * size the size of the IcoSphere, optional default 1
  27144. * * sizeX allows stretching in the x direction, optional, default size
  27145. * * sizeY allows stretching in the y direction, optional, default size
  27146. * * sizeZ allows stretching in the z direction, optional, default size
  27147. * * 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
  27148. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  27149. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  27150. * * flat when true creates a flat shaded mesh, optional, default true
  27151. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  27152. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27153. * * 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)
  27154. * * 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)
  27155. * @returns the VertexData of the Polyhedron
  27156. */
  27157. static CreatePolyhedron(options: {
  27158. type?: number;
  27159. size?: number;
  27160. sizeX?: number;
  27161. sizeY?: number;
  27162. sizeZ?: number;
  27163. custom?: any;
  27164. faceUV?: Vector4[];
  27165. faceColors?: Color4[];
  27166. flat?: boolean;
  27167. sideOrientation?: number;
  27168. frontUVs?: Vector4;
  27169. backUVs?: Vector4;
  27170. }): VertexData;
  27171. /**
  27172. * Creates the VertexData for a TorusKnot
  27173. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  27174. * * radius the radius of the torus knot, optional, default 2
  27175. * * tube the thickness of the tube, optional, default 0.5
  27176. * * radialSegments the number of sides on each tube segments, optional, default 32
  27177. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  27178. * * p the number of windings around the z axis, optional, default 2
  27179. * * q the number of windings around the x axis, optional, default 3
  27180. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27181. * * 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)
  27182. * * 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)
  27183. * @returns the VertexData of the Torus Knot
  27184. */
  27185. static CreateTorusKnot(options: {
  27186. radius?: number;
  27187. tube?: number;
  27188. radialSegments?: number;
  27189. tubularSegments?: number;
  27190. p?: number;
  27191. q?: number;
  27192. sideOrientation?: number;
  27193. frontUVs?: Vector4;
  27194. backUVs?: Vector4;
  27195. }): VertexData;
  27196. /**
  27197. * Compute normals for given positions and indices
  27198. * @param positions an array of vertex positions, [...., x, y, z, ......]
  27199. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  27200. * @param normals an array of vertex normals, [...., x, y, z, ......]
  27201. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  27202. * * facetNormals : optional array of facet normals (vector3)
  27203. * * facetPositions : optional array of facet positions (vector3)
  27204. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  27205. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  27206. * * bInfo : optional bounding info, required for facetPartitioning computation
  27207. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  27208. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  27209. * * useRightHandedSystem: optional boolean to for right handed system computation
  27210. * * depthSort : optional boolean to enable the facet depth sort computation
  27211. * * distanceTo : optional Vector3 to compute the facet depth from this location
  27212. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  27213. */
  27214. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  27215. facetNormals?: any;
  27216. facetPositions?: any;
  27217. facetPartitioning?: any;
  27218. ratio?: number;
  27219. bInfo?: any;
  27220. bbSize?: Vector3;
  27221. subDiv?: any;
  27222. useRightHandedSystem?: boolean;
  27223. depthSort?: boolean;
  27224. distanceTo?: Vector3;
  27225. depthSortedFacets?: any;
  27226. }): void;
  27227. private static _ComputeSides;
  27228. /**
  27229. * Applies VertexData created from the imported parameters to the geometry
  27230. * @param parsedVertexData the parsed data from an imported file
  27231. * @param geometry the geometry to apply the VertexData to
  27232. */
  27233. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  27234. }
  27235. }
  27236. declare module BABYLON {
  27237. /**
  27238. * Class containing static functions to help procedurally build meshes
  27239. */
  27240. class MeshBuilder {
  27241. private static updateSideOrientation;
  27242. /**
  27243. * Creates a box mesh
  27244. * * The parameter `size` sets the size (float) of each box side (default 1)
  27245. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  27246. * * 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)
  27247. * * Please read this tutorial : http://doc.babylonjs.com/tutorials/CreateBox_Per_Face_Textures_And_Colors
  27248. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27249. * * 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
  27250. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  27251. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#box
  27252. * @param name defines the name of the mesh
  27253. * @param options defines the options used to create the mesh
  27254. * @param scene defines the hosting scene
  27255. * @returns the box mesh
  27256. */
  27257. static CreateBox(name: string, options: {
  27258. size?: number;
  27259. width?: number;
  27260. height?: number;
  27261. depth?: number;
  27262. faceUV?: Vector4[];
  27263. faceColors?: Color4[];
  27264. sideOrientation?: number;
  27265. frontUVs?: Vector4;
  27266. backUVs?: Vector4;
  27267. updatable?: boolean;
  27268. }, scene?: Nullable<Scene>): Mesh;
  27269. /**
  27270. * Creates a sphere mesh
  27271. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  27272. * * 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`)
  27273. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  27274. * * 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
  27275. * * 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)
  27276. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27277. * * 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
  27278. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  27279. * @param name defines the name of the mesh
  27280. * @param options defines the options used to create the mesh
  27281. * @param scene defines the hosting scene
  27282. * @returns the sphere mesh
  27283. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#sphere
  27284. */
  27285. static CreateSphere(name: string, options: {
  27286. segments?: number;
  27287. diameter?: number;
  27288. diameterX?: number;
  27289. diameterY?: number;
  27290. diameterZ?: number;
  27291. arc?: number;
  27292. slice?: number;
  27293. sideOrientation?: number;
  27294. frontUVs?: Vector4;
  27295. backUVs?: Vector4;
  27296. updatable?: boolean;
  27297. }, scene: any): Mesh;
  27298. /**
  27299. * Creates a plane polygonal mesh. By default, this is a disc
  27300. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  27301. * * 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
  27302. * * 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
  27303. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27304. * * 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
  27305. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  27306. * @param name defines the name of the mesh
  27307. * @param options defines the options used to create the mesh
  27308. * @param scene defines the hosting scene
  27309. * @returns the plane polygonal mesh
  27310. * @see http://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  27311. */
  27312. static CreateDisc(name: string, options: {
  27313. radius?: number;
  27314. tessellation?: number;
  27315. arc?: number;
  27316. updatable?: boolean;
  27317. sideOrientation?: number;
  27318. frontUVs?: Vector4;
  27319. backUVs?: Vector4;
  27320. }, scene?: Nullable<Scene>): Mesh;
  27321. /**
  27322. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  27323. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  27324. * * 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`)
  27325. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  27326. * * 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
  27327. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27328. * * 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
  27329. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  27330. * @param name defines the name of the mesh
  27331. * @param options defines the options used to create the mesh
  27332. * @param scene defines the hosting scene
  27333. * @returns the icosahedron mesh
  27334. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  27335. */
  27336. static CreateIcoSphere(name: string, options: {
  27337. radius?: number;
  27338. radiusX?: number;
  27339. radiusY?: number;
  27340. radiusZ?: number;
  27341. flat?: boolean;
  27342. subdivisions?: number;
  27343. sideOrientation?: number;
  27344. frontUVs?: Vector4;
  27345. backUVs?: Vector4;
  27346. updatable?: boolean;
  27347. }, scene: Scene): Mesh;
  27348. /**
  27349. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  27350. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  27351. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  27352. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  27353. * * 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
  27354. * * 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
  27355. * * 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
  27356. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27357. * * 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
  27358. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  27359. * * 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
  27360. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  27361. * * 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
  27362. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  27363. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  27364. * @param name defines the name of the mesh
  27365. * @param options defines the options used to create the mesh
  27366. * @param scene defines the hosting scene
  27367. * @returns the ribbon mesh
  27368. * @see http://doc.babylonjs.com/tutorials/Ribbon_Tutorial
  27369. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  27370. */
  27371. static CreateRibbon(name: string, options: {
  27372. pathArray: Vector3[][];
  27373. closeArray?: boolean;
  27374. closePath?: boolean;
  27375. offset?: number;
  27376. updatable?: boolean;
  27377. sideOrientation?: number;
  27378. frontUVs?: Vector4;
  27379. backUVs?: Vector4;
  27380. instance?: Mesh;
  27381. invertUV?: boolean;
  27382. uvs?: Vector2[];
  27383. colors?: Color4[];
  27384. }, scene?: Nullable<Scene>): Mesh;
  27385. /**
  27386. * Creates a cylinder or a cone mesh
  27387. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  27388. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  27389. * * 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.
  27390. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  27391. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  27392. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  27393. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  27394. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  27395. * * 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).
  27396. * * 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
  27397. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  27398. * * 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
  27399. * * 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.
  27400. * * If `enclose` is false, a ring surface is one element.
  27401. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  27402. * * 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
  27403. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27404. * * 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
  27405. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  27406. * @param name defines the name of the mesh
  27407. * @param options defines the options used to create the mesh
  27408. * @param scene defines the hosting scene
  27409. * @returns the cylinder mesh
  27410. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#cylinder-or-cone
  27411. */
  27412. static CreateCylinder(name: string, options: {
  27413. height?: number;
  27414. diameterTop?: number;
  27415. diameterBottom?: number;
  27416. diameter?: number;
  27417. tessellation?: number;
  27418. subdivisions?: number;
  27419. arc?: number;
  27420. faceColors?: Color4[];
  27421. faceUV?: Vector4[];
  27422. updatable?: boolean;
  27423. hasRings?: boolean;
  27424. enclose?: boolean;
  27425. sideOrientation?: number;
  27426. frontUVs?: Vector4;
  27427. backUVs?: Vector4;
  27428. }, scene: any): Mesh;
  27429. /**
  27430. * Creates a torus mesh
  27431. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  27432. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  27433. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  27434. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27435. * * 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
  27436. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  27437. * @param name defines the name of the mesh
  27438. * @param options defines the options used to create the mesh
  27439. * @param scene defines the hosting scene
  27440. * @returns the torus mesh
  27441. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#torus
  27442. */
  27443. static CreateTorus(name: string, options: {
  27444. diameter?: number;
  27445. thickness?: number;
  27446. tessellation?: number;
  27447. updatable?: boolean;
  27448. sideOrientation?: number;
  27449. frontUVs?: Vector4;
  27450. backUVs?: Vector4;
  27451. }, scene: any): Mesh;
  27452. /**
  27453. * Creates a torus knot mesh
  27454. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  27455. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  27456. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  27457. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  27458. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27459. * * 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
  27460. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  27461. * @param name defines the name of the mesh
  27462. * @param options defines the options used to create the mesh
  27463. * @param scene defines the hosting scene
  27464. * @returns the torus knot mesh
  27465. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#torus-knot
  27466. */
  27467. static CreateTorusKnot(name: string, options: {
  27468. radius?: number;
  27469. tube?: number;
  27470. radialSegments?: number;
  27471. tubularSegments?: number;
  27472. p?: number;
  27473. q?: number;
  27474. updatable?: boolean;
  27475. sideOrientation?: number;
  27476. frontUVs?: Vector4;
  27477. backUVs?: Vector4;
  27478. }, scene: any): Mesh;
  27479. /**
  27480. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  27481. * * 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
  27482. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  27483. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  27484. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  27485. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  27486. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  27487. * * 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
  27488. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  27489. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  27490. * @see http://doc.babylonjs.com/how_to/parametric_shapes#line-system
  27491. * @param name defines the name of the new line system
  27492. * @param options defines the options used to create the line system
  27493. * @param scene defines the hosting scene
  27494. * @returns a new line system mesh
  27495. */
  27496. static CreateLineSystem(name: string, options: {
  27497. lines: Vector3[][];
  27498. updatable?: boolean;
  27499. instance?: Nullable<LinesMesh>;
  27500. colors?: Nullable<Color4[][]>;
  27501. useVertexAlpha?: boolean;
  27502. }, scene: Nullable<Scene>): LinesMesh;
  27503. /**
  27504. * Creates a line mesh
  27505. * 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
  27506. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  27507. * * The parameter `points` is an array successive Vector3
  27508. * * 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
  27509. * * The optional parameter `colors` is an array of successive Color4, one per line point
  27510. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  27511. * * When updating an instance, remember that only point positions can change, not the number of points
  27512. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  27513. * @see http://doc.babylonjs.com/how_to/parametric_shapes#lines
  27514. * @param name defines the name of the new line system
  27515. * @param options defines the options used to create the line system
  27516. * @param scene defines the hosting scene
  27517. * @returns a new line mesh
  27518. */
  27519. static CreateLines(name: string, options: {
  27520. points: Vector3[];
  27521. updatable?: boolean;
  27522. instance?: Nullable<LinesMesh>;
  27523. colors?: Color4[];
  27524. useVertexAlpha?: boolean;
  27525. }, scene?: Nullable<Scene>): LinesMesh;
  27526. /**
  27527. * Creates a dashed line mesh
  27528. * * 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
  27529. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  27530. * * The parameter `points` is an array successive Vector3
  27531. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  27532. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  27533. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  27534. * * 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
  27535. * * When updating an instance, remember that only point positions can change, not the number of points
  27536. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  27537. * @param name defines the name of the mesh
  27538. * @param options defines the options used to create the mesh
  27539. * @param scene defines the hosting scene
  27540. * @returns the dashed line mesh
  27541. * @see http://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  27542. */
  27543. static CreateDashedLines(name: string, options: {
  27544. points: Vector3[];
  27545. dashSize?: number;
  27546. gapSize?: number;
  27547. dashNb?: number;
  27548. updatable?: boolean;
  27549. instance?: LinesMesh;
  27550. }, scene?: Nullable<Scene>): LinesMesh;
  27551. /**
  27552. * 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.
  27553. * * 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.
  27554. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  27555. * * 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.
  27556. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  27557. * * 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
  27558. * * 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
  27559. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  27560. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27561. * * 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
  27562. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  27563. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  27564. * @param name defines the name of the mesh
  27565. * @param options defines the options used to create the mesh
  27566. * @param scene defines the hosting scene
  27567. * @returns the extruded shape mesh
  27568. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  27569. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  27570. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  27571. */
  27572. static ExtrudeShape(name: string, options: {
  27573. shape: Vector3[];
  27574. path: Vector3[];
  27575. scale?: number;
  27576. rotation?: number;
  27577. cap?: number;
  27578. updatable?: boolean;
  27579. sideOrientation?: number;
  27580. frontUVs?: Vector4;
  27581. backUVs?: Vector4;
  27582. instance?: Mesh;
  27583. invertUV?: boolean;
  27584. }, scene?: Nullable<Scene>): Mesh;
  27585. /**
  27586. * Creates an custom extruded shape mesh.
  27587. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  27588. * * 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.
  27589. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  27590. * * 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
  27591. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  27592. * * 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
  27593. * * It must returns a float value that will be the scale value applied to the shape on each path point
  27594. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  27595. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  27596. * * 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
  27597. * * 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
  27598. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  27599. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27600. * * 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
  27601. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  27602. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  27603. * @param name defines the name of the mesh
  27604. * @param options defines the options used to create the mesh
  27605. * @param scene defines the hosting scene
  27606. * @returns the custom extruded shape mesh
  27607. * @see http://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  27608. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  27609. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  27610. */
  27611. static ExtrudeShapeCustom(name: string, options: {
  27612. shape: Vector3[];
  27613. path: Vector3[];
  27614. scaleFunction?: any;
  27615. rotationFunction?: any;
  27616. ribbonCloseArray?: boolean;
  27617. ribbonClosePath?: boolean;
  27618. cap?: number;
  27619. updatable?: boolean;
  27620. sideOrientation?: number;
  27621. frontUVs?: Vector4;
  27622. backUVs?: Vector4;
  27623. instance?: Mesh;
  27624. invertUV?: boolean;
  27625. }, scene: Scene): Mesh;
  27626. /**
  27627. * Creates lathe mesh.
  27628. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  27629. * * 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
  27630. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  27631. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  27632. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  27633. * * 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
  27634. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  27635. * * 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
  27636. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27637. * * 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
  27638. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  27639. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  27640. * @param name defines the name of the mesh
  27641. * @param options defines the options used to create the mesh
  27642. * @param scene defines the hosting scene
  27643. * @returns the lathe mesh
  27644. * @see http://doc.babylonjs.com/how_to/parametric_shapes#lathe
  27645. */
  27646. static CreateLathe(name: string, options: {
  27647. shape: Vector3[];
  27648. radius?: number;
  27649. tessellation?: number;
  27650. clip?: number;
  27651. arc?: number;
  27652. closed?: boolean;
  27653. updatable?: boolean;
  27654. sideOrientation?: number;
  27655. frontUVs?: Vector4;
  27656. backUVs?: Vector4;
  27657. cap?: number;
  27658. invertUV?: boolean;
  27659. }, scene: Scene): Mesh;
  27660. /**
  27661. * Creates a plane mesh
  27662. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  27663. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  27664. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  27665. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27666. * * 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
  27667. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  27668. * @param name defines the name of the mesh
  27669. * @param options defines the options used to create the mesh
  27670. * @param scene defines the hosting scene
  27671. * @returns the plane mesh
  27672. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#plane
  27673. */
  27674. static CreatePlane(name: string, options: {
  27675. size?: number;
  27676. width?: number;
  27677. height?: number;
  27678. sideOrientation?: number;
  27679. frontUVs?: Vector4;
  27680. backUVs?: Vector4;
  27681. updatable?: boolean;
  27682. sourcePlane?: Plane;
  27683. }, scene: Scene): Mesh;
  27684. /**
  27685. * Creates a ground mesh
  27686. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  27687. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  27688. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  27689. * @param name defines the name of the mesh
  27690. * @param options defines the options used to create the mesh
  27691. * @param scene defines the hosting scene
  27692. * @returns the ground mesh
  27693. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#plane
  27694. */
  27695. static CreateGround(name: string, options: {
  27696. width?: number;
  27697. height?: number;
  27698. subdivisions?: number;
  27699. subdivisionsX?: number;
  27700. subdivisionsY?: number;
  27701. updatable?: boolean;
  27702. }, scene: any): Mesh;
  27703. /**
  27704. * Creates a tiled ground mesh
  27705. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  27706. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  27707. * * 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
  27708. * * 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
  27709. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  27710. * @param name defines the name of the mesh
  27711. * @param options defines the options used to create the mesh
  27712. * @param scene defines the hosting scene
  27713. * @returns the tiled ground mesh
  27714. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#tiled-ground
  27715. */
  27716. static CreateTiledGround(name: string, options: {
  27717. xmin: number;
  27718. zmin: number;
  27719. xmax: number;
  27720. zmax: number;
  27721. subdivisions?: {
  27722. w: number;
  27723. h: number;
  27724. };
  27725. precision?: {
  27726. w: number;
  27727. h: number;
  27728. };
  27729. updatable?: boolean;
  27730. }, scene: Scene): Mesh;
  27731. /**
  27732. * Creates a ground mesh from a height map
  27733. * * The parameter `url` sets the URL of the height map image resource.
  27734. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  27735. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  27736. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  27737. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  27738. * * 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.
  27739. * * 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).
  27740. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  27741. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  27742. * @param name defines the name of the mesh
  27743. * @param url defines the url to the height map
  27744. * @param options defines the options used to create the mesh
  27745. * @param scene defines the hosting scene
  27746. * @returns the ground mesh
  27747. * @see http://doc.babylonjs.com/babylon101/height_map
  27748. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#ground-from-a-height-map
  27749. */
  27750. static CreateGroundFromHeightMap(name: string, url: string, options: {
  27751. width?: number;
  27752. height?: number;
  27753. subdivisions?: number;
  27754. minHeight?: number;
  27755. maxHeight?: number;
  27756. colorFilter?: Color3;
  27757. alphaFilter?: number;
  27758. updatable?: boolean;
  27759. onReady?: (mesh: GroundMesh) => void;
  27760. }, scene: Scene): GroundMesh;
  27761. /**
  27762. * Creates a polygon mesh
  27763. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  27764. * * 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
  27765. * * You can set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27766. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  27767. * * 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)
  27768. * * Remember you can only change the shape positions, not their number when updating a polygon
  27769. * @param name defines the name of the mesh
  27770. * @param options defines the options used to create the mesh
  27771. * @param scene defines the hosting scene
  27772. * @returns the polygon mesh
  27773. */
  27774. static CreatePolygon(name: string, options: {
  27775. shape: Vector3[];
  27776. holes?: Vector3[][];
  27777. depth?: number;
  27778. faceUV?: Vector4[];
  27779. faceColors?: Color4[];
  27780. updatable?: boolean;
  27781. sideOrientation?: number;
  27782. frontUVs?: Vector4;
  27783. backUVs?: Vector4;
  27784. }, scene: Scene): Mesh;
  27785. /**
  27786. * Creates an extruded polygon mesh, with depth in the Y direction.
  27787. * * 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)
  27788. * @see http://doc.babylonjs.com/tutorials/CreateBox_Per_Face_Textures_And_Colors
  27789. * @param name defines the name of the mesh
  27790. * @param options defines the options used to create the mesh
  27791. * @param scene defines the hosting scene
  27792. * @returns the polygon mesh
  27793. */
  27794. static ExtrudePolygon(name: string, options: {
  27795. shape: Vector3[];
  27796. holes?: Vector3[][];
  27797. depth?: number;
  27798. faceUV?: Vector4[];
  27799. faceColors?: Color4[];
  27800. updatable?: boolean;
  27801. sideOrientation?: number;
  27802. frontUVs?: Vector4;
  27803. backUVs?: Vector4;
  27804. }, scene: Scene): Mesh;
  27805. /**
  27806. * Creates a tube mesh.
  27807. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  27808. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  27809. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  27810. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  27811. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  27812. * * 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)
  27813. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  27814. * * 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
  27815. * * 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
  27816. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27817. * * 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
  27818. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  27819. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  27820. * @param name defines the name of the mesh
  27821. * @param options defines the options used to create the mesh
  27822. * @param scene defines the hosting scene
  27823. * @returns the tube mesh
  27824. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  27825. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#tube
  27826. */
  27827. static CreateTube(name: string, options: {
  27828. path: Vector3[];
  27829. radius?: number;
  27830. tessellation?: number;
  27831. radiusFunction?: {
  27832. (i: number, distance: number): number;
  27833. };
  27834. cap?: number;
  27835. arc?: number;
  27836. updatable?: boolean;
  27837. sideOrientation?: number;
  27838. frontUVs?: Vector4;
  27839. backUVs?: Vector4;
  27840. instance?: Mesh;
  27841. invertUV?: boolean;
  27842. }, scene: Scene): Mesh;
  27843. /**
  27844. * Creates a polyhedron mesh
  27845. * * 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
  27846. * * The parameter `size` (positive float, default 1) sets the polygon size
  27847. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  27848. * * 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`
  27849. * * 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
  27850. * * 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)`)
  27851. * * 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
  27852. * * 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
  27853. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27854. * * 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
  27855. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  27856. * @param name defines the name of the mesh
  27857. * @param options defines the options used to create the mesh
  27858. * @param scene defines the hosting scene
  27859. * @returns the polyhedron mesh
  27860. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes
  27861. */
  27862. static CreatePolyhedron(name: string, options: {
  27863. type?: number;
  27864. size?: number;
  27865. sizeX?: number;
  27866. sizeY?: number;
  27867. sizeZ?: number;
  27868. custom?: any;
  27869. faceUV?: Vector4[];
  27870. faceColors?: Color4[];
  27871. flat?: boolean;
  27872. updatable?: boolean;
  27873. sideOrientation?: number;
  27874. frontUVs?: Vector4;
  27875. backUVs?: Vector4;
  27876. }, scene: Scene): Mesh;
  27877. /**
  27878. * Creates a decal mesh.
  27879. * 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
  27880. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  27881. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  27882. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  27883. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  27884. * @param name defines the name of the mesh
  27885. * @param sourceMesh defines the mesh where the decal must be applied
  27886. * @param options defines the options used to create the mesh
  27887. * @param scene defines the hosting scene
  27888. * @returns the decal mesh
  27889. * @see http://doc.babylonjs.com/how_to/decals
  27890. */
  27891. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  27892. position?: Vector3;
  27893. normal?: Vector3;
  27894. size?: Vector3;
  27895. angle?: number;
  27896. }): Mesh;
  27897. private static _ExtrudeShapeGeneric;
  27898. }
  27899. }
  27900. declare module BABYLON {
  27901. /**
  27902. * Class used to represent a specific level of detail of a mesh
  27903. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  27904. */
  27905. class MeshLODLevel {
  27906. /** Defines the distance where this level should star being displayed */
  27907. distance: number;
  27908. /** Defines the mesh to use to render this level */
  27909. mesh: Nullable<Mesh>;
  27910. /**
  27911. * Creates a new LOD level
  27912. * @param distance defines the distance where this level should star being displayed
  27913. * @param mesh defines the mesh to use to render this level
  27914. */
  27915. constructor(
  27916. /** Defines the distance where this level should star being displayed */
  27917. distance: number,
  27918. /** Defines the mesh to use to render this level */
  27919. mesh: Nullable<Mesh>);
  27920. }
  27921. }
  27922. declare module BABYLON {
  27923. /**
  27924. * A simplifier interface for future simplification implementations
  27925. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  27926. */
  27927. interface ISimplifier {
  27928. /**
  27929. * Simplification of a given mesh according to the given settings.
  27930. * Since this requires computation, it is assumed that the function runs async.
  27931. * @param settings The settings of the simplification, including quality and distance
  27932. * @param successCallback A callback that will be called after the mesh was simplified.
  27933. * @param errorCallback in case of an error, this callback will be called. optional.
  27934. */
  27935. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  27936. }
  27937. /**
  27938. * Expected simplification settings.
  27939. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  27940. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  27941. */
  27942. interface ISimplificationSettings {
  27943. /**
  27944. * Gets or sets the expected quality
  27945. */
  27946. quality: number;
  27947. /**
  27948. * Gets or sets the distance when this optimized version should be used
  27949. */
  27950. distance: number;
  27951. /**
  27952. * Gets an already optimized mesh
  27953. */
  27954. optimizeMesh?: boolean;
  27955. }
  27956. /**
  27957. * Class used to specify simplification options
  27958. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  27959. */
  27960. class SimplificationSettings implements ISimplificationSettings {
  27961. /** expected quality */
  27962. quality: number;
  27963. /** distance when this optimized version should be used */
  27964. distance: number;
  27965. /** already optimized mesh */
  27966. optimizeMesh?: boolean | undefined;
  27967. /**
  27968. * Creates a SimplificationSettings
  27969. * @param quality expected quality
  27970. * @param distance distance when this optimized version should be used
  27971. * @param optimizeMesh already optimized mesh
  27972. */
  27973. constructor(
  27974. /** expected quality */
  27975. quality: number,
  27976. /** distance when this optimized version should be used */
  27977. distance: number,
  27978. /** already optimized mesh */
  27979. optimizeMesh?: boolean | undefined);
  27980. }
  27981. /**
  27982. * Interface used to define a simplification task
  27983. */
  27984. interface ISimplificationTask {
  27985. /**
  27986. * Array of settings
  27987. */
  27988. settings: Array<ISimplificationSettings>;
  27989. /**
  27990. * Simplification type
  27991. */
  27992. simplificationType: SimplificationType;
  27993. /**
  27994. * Mesh to simplify
  27995. */
  27996. mesh: Mesh;
  27997. /**
  27998. * Callback called on success
  27999. */
  28000. successCallback?: () => void;
  28001. /**
  28002. * Defines if parallel processing can be used
  28003. */
  28004. parallelProcessing: boolean;
  28005. }
  28006. /**
  28007. * Queue used to order the simplification tasks
  28008. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  28009. */
  28010. class SimplificationQueue {
  28011. private _simplificationArray;
  28012. /**
  28013. * Gets a boolean indicating that the process is still running
  28014. */
  28015. running: boolean;
  28016. /**
  28017. * Creates a new queue
  28018. */
  28019. constructor();
  28020. /**
  28021. * Adds a new simplification task
  28022. * @param task defines a task to add
  28023. */
  28024. addTask(task: ISimplificationTask): void;
  28025. /**
  28026. * Execute next task
  28027. */
  28028. executeNext(): void;
  28029. /**
  28030. * Execute a simplification task
  28031. * @param task defines the task to run
  28032. */
  28033. runSimplification(task: ISimplificationTask): void;
  28034. private getSimplifier;
  28035. }
  28036. /**
  28037. * The implemented types of simplification
  28038. * At the moment only Quadratic Error Decimation is implemented
  28039. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  28040. */
  28041. enum SimplificationType {
  28042. /** Quadratic error decimation */
  28043. QUADRATIC = 0
  28044. }
  28045. }
  28046. declare module BABYLON {
  28047. interface Scene {
  28048. /** @hidden (Backing field) */
  28049. /**
  28050. * Gets or sets the simplification queue attached to the scene
  28051. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  28052. */
  28053. simplificationQueue: SimplificationQueue;
  28054. }
  28055. interface Mesh {
  28056. /**
  28057. * Simplify the mesh according to the given array of settings.
  28058. * Function will return immediately and will simplify async
  28059. * @param settings a collection of simplification settings
  28060. * @param parallelProcessing should all levels calculate parallel or one after the other
  28061. * @param simplificationType the type of simplification to run
  28062. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  28063. * @returns the current mesh
  28064. */
  28065. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  28066. }
  28067. /**
  28068. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  28069. * created in a scene
  28070. */
  28071. class SimplicationQueueSceneComponent implements ISceneComponent {
  28072. /**
  28073. * The component name helpfull to identify the component in the list of scene components.
  28074. */
  28075. readonly name: string;
  28076. /**
  28077. * The scene the component belongs to.
  28078. */
  28079. scene: Scene;
  28080. /**
  28081. * Creates a new instance of the component for the given scene
  28082. * @param scene Defines the scene to register the component in
  28083. */
  28084. constructor(scene: Scene);
  28085. /**
  28086. * Registers the component in a given scene
  28087. */
  28088. register(): void;
  28089. /**
  28090. * Rebuilds the elements related to this component in case of
  28091. * context lost for instance.
  28092. */
  28093. rebuild(): void;
  28094. /**
  28095. * Disposes the component and the associated ressources
  28096. */
  28097. dispose(): void;
  28098. private _beforeCameraUpdate;
  28099. }
  28100. }
  28101. declare module BABYLON {
  28102. /**
  28103. * Polygon
  28104. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  28105. */
  28106. class Polygon {
  28107. /**
  28108. * Creates a rectangle
  28109. * @param xmin bottom X coord
  28110. * @param ymin bottom Y coord
  28111. * @param xmax top X coord
  28112. * @param ymax top Y coord
  28113. * @returns points that make the resulting rectation
  28114. */
  28115. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  28116. /**
  28117. * Creates a circle
  28118. * @param radius radius of circle
  28119. * @param cx scale in x
  28120. * @param cy scale in y
  28121. * @param numberOfSides number of sides that make up the circle
  28122. * @returns points that make the resulting circle
  28123. */
  28124. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  28125. /**
  28126. * Creates a polygon from input string
  28127. * @param input Input polygon data
  28128. * @returns the parsed points
  28129. */
  28130. static Parse(input: string): Vector2[];
  28131. /**
  28132. * Starts building a polygon from x and y coordinates
  28133. * @param x x coordinate
  28134. * @param y y coordinate
  28135. * @returns the started path2
  28136. */
  28137. static StartingAt(x: number, y: number): Path2;
  28138. }
  28139. /**
  28140. * Builds a polygon
  28141. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  28142. */
  28143. class PolygonMeshBuilder {
  28144. private _points;
  28145. private _outlinepoints;
  28146. private _holes;
  28147. private _name;
  28148. private _scene;
  28149. private _epoints;
  28150. private _eholes;
  28151. private _addToepoint;
  28152. /**
  28153. * Creates a PolygonMeshBuilder
  28154. * @param name name of the builder
  28155. * @param contours Path of the polygon
  28156. * @param scene scene to add to
  28157. */
  28158. constructor(name: string, contours: Path2 | Vector2[] | any, scene: Scene);
  28159. /**
  28160. * Adds a whole within the polygon
  28161. * @param hole Array of points defining the hole
  28162. * @returns this
  28163. */
  28164. addHole(hole: Vector2[]): PolygonMeshBuilder;
  28165. /**
  28166. * Creates the polygon
  28167. * @param updatable If the mesh should be updatable
  28168. * @param depth The depth of the mesh created
  28169. * @returns the created mesh
  28170. */
  28171. build(updatable?: boolean, depth?: number): Mesh;
  28172. /**
  28173. * Adds a side to the polygon
  28174. * @param positions points that make the polygon
  28175. * @param normals normals of the polygon
  28176. * @param uvs uvs of the polygon
  28177. * @param indices indices of the polygon
  28178. * @param bounds bounds of the polygon
  28179. * @param points points of the polygon
  28180. * @param depth depth of the polygon
  28181. * @param flip flip of the polygon
  28182. */
  28183. private addSide;
  28184. }
  28185. }
  28186. declare module BABYLON {
  28187. /**
  28188. * Base class for submeshes
  28189. */
  28190. class BaseSubMesh {
  28191. /** @hidden */
  28192. /** @hidden */
  28193. /**
  28194. * Gets associated effect
  28195. */
  28196. readonly effect: Nullable<Effect>;
  28197. /**
  28198. * Sets associated effect (effect used to render this submesh)
  28199. * @param effect defines the effect to associate with
  28200. * @param defines defines the set of defines used to compile this effect
  28201. */
  28202. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  28203. }
  28204. /**
  28205. * Defines a subdivision inside a mesh
  28206. */
  28207. class SubMesh extends BaseSubMesh implements ICullable {
  28208. /** the material index to use */
  28209. materialIndex: number;
  28210. /** vertex index start */
  28211. verticesStart: number;
  28212. /** vertices count */
  28213. verticesCount: number;
  28214. /** index start */
  28215. indexStart: number;
  28216. /** indices count */
  28217. indexCount: number;
  28218. /** @hidden */
  28219. private _mesh;
  28220. private _renderingMesh;
  28221. private _boundingInfo;
  28222. private _linesIndexBuffer;
  28223. /** @hidden */
  28224. /** @hidden */
  28225. /** @hidden */
  28226. /** @hidden */
  28227. /** @hidden */
  28228. /** @hidden */
  28229. /** @hidden */
  28230. private _currentMaterial;
  28231. /**
  28232. * Add a new submesh to a mesh
  28233. * @param materialIndex defines the material index to use
  28234. * @param verticesStart defines vertex index start
  28235. * @param verticesCount defines vertices count
  28236. * @param indexStart defines index start
  28237. * @param indexCount defines indices count
  28238. * @param mesh defines the parent mesh
  28239. * @param renderingMesh defines an optional rendering mesh
  28240. * @param createBoundingBox defines if bounding box should be created for this submesh
  28241. * @returns the new submesh
  28242. */
  28243. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  28244. /**
  28245. * Creates a new submesh
  28246. * @param materialIndex defines the material index to use
  28247. * @param verticesStart defines vertex index start
  28248. * @param verticesCount defines vertices count
  28249. * @param indexStart defines index start
  28250. * @param indexCount defines indices count
  28251. * @param mesh defines the parent mesh
  28252. * @param renderingMesh defines an optional rendering mesh
  28253. * @param createBoundingBox defines if bounding box should be created for this submesh
  28254. */
  28255. constructor(
  28256. /** the material index to use */
  28257. materialIndex: number,
  28258. /** vertex index start */
  28259. verticesStart: number,
  28260. /** vertices count */
  28261. verticesCount: number,
  28262. /** index start */
  28263. indexStart: number,
  28264. /** indices count */
  28265. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  28266. /**
  28267. * Returns true if this submesh covers the entire parent mesh
  28268. * @ignorenaming
  28269. */
  28270. readonly IsGlobal: boolean;
  28271. /**
  28272. * Returns the submesh BoudingInfo object
  28273. * @returns current bounding info (or mesh's one if the submesh is global)
  28274. */
  28275. getBoundingInfo(): BoundingInfo;
  28276. /**
  28277. * Sets the submesh BoundingInfo
  28278. * @param boundingInfo defines the new bounding info to use
  28279. * @returns the SubMesh
  28280. */
  28281. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  28282. /**
  28283. * Returns the mesh of the current submesh
  28284. * @return the parent mesh
  28285. */
  28286. getMesh(): AbstractMesh;
  28287. /**
  28288. * Returns the rendering mesh of the submesh
  28289. * @returns the rendering mesh (could be different from parent mesh)
  28290. */
  28291. getRenderingMesh(): Mesh;
  28292. /**
  28293. * Returns the submesh material
  28294. * @returns null or the current material
  28295. */
  28296. getMaterial(): Nullable<Material>;
  28297. /**
  28298. * Sets a new updated BoundingInfo object to the submesh
  28299. * @returns the SubMesh
  28300. */
  28301. refreshBoundingInfo(): SubMesh;
  28302. /** @hidden */
  28303. /**
  28304. * Updates the submesh BoundingInfo
  28305. * @param world defines the world matrix to use to update the bounding info
  28306. * @returns the submesh
  28307. */
  28308. updateBoundingInfo(world: Matrix): SubMesh;
  28309. /**
  28310. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  28311. * @param frustumPlanes defines the frustum planes
  28312. * @returns true if the submesh is intersecting with the frustum
  28313. */
  28314. isInFrustum(frustumPlanes: Plane[]): boolean;
  28315. /**
  28316. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  28317. * @param frustumPlanes defines the frustum planes
  28318. * @returns true if the submesh is inside the frustum
  28319. */
  28320. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  28321. /**
  28322. * Renders the submesh
  28323. * @param enableAlphaMode defines if alpha needs to be used
  28324. * @returns the submesh
  28325. */
  28326. render(enableAlphaMode: boolean): SubMesh;
  28327. /**
  28328. * @hidden
  28329. */
  28330. /**
  28331. * Checks if the submesh intersects with a ray
  28332. * @param ray defines the ray to test
  28333. * @returns true is the passed ray intersects the submesh bounding box
  28334. */
  28335. canIntersects(ray: Ray): boolean;
  28336. /**
  28337. * Intersects current submesh with a ray
  28338. * @param ray defines the ray to test
  28339. * @param positions defines mesh's positions array
  28340. * @param indices defines mesh's indices array
  28341. * @param fastCheck defines if only bounding info should be used
  28342. * @returns intersection info or null if no intersection
  28343. */
  28344. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean): Nullable<IntersectionInfo>;
  28345. /** @hidden */
  28346. private _intersectLines;
  28347. /** @hidden */
  28348. private _intersectTriangles;
  28349. /** @hidden */
  28350. /**
  28351. * Creates a new submesh from the passed mesh
  28352. * @param newMesh defines the new hosting mesh
  28353. * @param newRenderingMesh defines an optional rendering mesh
  28354. * @returns the new submesh
  28355. */
  28356. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  28357. /**
  28358. * Release associated resources
  28359. */
  28360. dispose(): void;
  28361. /**
  28362. * Creates a new submesh from indices data
  28363. * @param materialIndex the index of the main mesh material
  28364. * @param startIndex the index where to start the copy in the mesh indices array
  28365. * @param indexCount the number of indices to copy then from the startIndex
  28366. * @param mesh the main mesh to create the submesh from
  28367. * @param renderingMesh the optional rendering mesh
  28368. * @returns a new submesh
  28369. */
  28370. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  28371. }
  28372. }
  28373. declare module BABYLON {
  28374. /**
  28375. * A TransformNode is an object that is not rendered but can be used as a center of transformation. This can decrease memory usage and increase rendering speed compared to using an empty mesh as a parent and is less complicated than using a pivot matrix.
  28376. * @see https://doc.babylonjs.com/how_to/transformnode
  28377. */
  28378. class TransformNode extends Node {
  28379. /**
  28380. * Object will not rotate to face the camera
  28381. */
  28382. static BILLBOARDMODE_NONE: number;
  28383. /**
  28384. * Object will rotate to face the camera but only on the x axis
  28385. */
  28386. static BILLBOARDMODE_X: number;
  28387. /**
  28388. * Object will rotate to face the camera but only on the y axis
  28389. */
  28390. static BILLBOARDMODE_Y: number;
  28391. /**
  28392. * Object will rotate to face the camera but only on the z axis
  28393. */
  28394. static BILLBOARDMODE_Z: number;
  28395. /**
  28396. * Object will rotate to face the camera
  28397. */
  28398. static BILLBOARDMODE_ALL: number;
  28399. private _forward;
  28400. private _forwardInverted;
  28401. private _up;
  28402. private _right;
  28403. private _rightInverted;
  28404. private _position;
  28405. private _rotation;
  28406. private _rotationQuaternion;
  28407. protected _scaling: Vector3;
  28408. protected _isDirty: boolean;
  28409. private _transformToBoneReferal;
  28410. /**
  28411. * Set the billboard mode. Default is 0.
  28412. *
  28413. * | Value | Type | Description |
  28414. * | --- | --- | --- |
  28415. * | 0 | BILLBOARDMODE_NONE | |
  28416. * | 1 | BILLBOARDMODE_X | |
  28417. * | 2 | BILLBOARDMODE_Y | |
  28418. * | 4 | BILLBOARDMODE_Z | |
  28419. * | 7 | BILLBOARDMODE_ALL | |
  28420. *
  28421. */
  28422. billboardMode: number;
  28423. /**
  28424. * Multiplication factor on scale x/y/z when computing the world matrix. Eg. for a 1x1x1 cube setting this to 2 will make it a 2x2x2 cube
  28425. */
  28426. scalingDeterminant: number;
  28427. /**
  28428. * Sets the distance of the object to max, often used by skybox
  28429. */
  28430. infiniteDistance: boolean;
  28431. /**
  28432. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  28433. * By default the system will update normals to compensate
  28434. */
  28435. ignoreNonUniformScaling: boolean;
  28436. /** @hidden */
  28437. private _localWorld;
  28438. private _absolutePosition;
  28439. private _pivotMatrix;
  28440. private _pivotMatrixInverse;
  28441. private _postMultiplyPivotMatrix;
  28442. protected _isWorldMatrixFrozen: boolean;
  28443. /**
  28444. * An event triggered after the world matrix is updated
  28445. */
  28446. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  28447. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  28448. /**
  28449. * Gets a string identifying the name of the class
  28450. * @returns "TransformNode" string
  28451. */
  28452. getClassName(): string;
  28453. /**
  28454. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  28455. */
  28456. position: Vector3;
  28457. /**
  28458. * 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)).
  28459. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  28460. */
  28461. rotation: Vector3;
  28462. /**
  28463. * 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)).
  28464. */
  28465. scaling: Vector3;
  28466. /**
  28467. * Gets or sets the rotation Quaternion property : this a Quaternion object defining the node rotation by using a unit quaternion (null by default).
  28468. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  28469. */
  28470. rotationQuaternion: Nullable<Quaternion>;
  28471. /**
  28472. * The forward direction of that transform in world space.
  28473. */
  28474. readonly forward: Vector3;
  28475. /**
  28476. * The up direction of that transform in world space.
  28477. */
  28478. readonly up: Vector3;
  28479. /**
  28480. * The right direction of that transform in world space.
  28481. */
  28482. readonly right: Vector3;
  28483. /**
  28484. * Copies the parameter passed Matrix into the mesh Pose matrix.
  28485. * @param matrix the matrix to copy the pose from
  28486. * @returns this TransformNode.
  28487. */
  28488. updatePoseMatrix(matrix: Matrix): TransformNode;
  28489. /**
  28490. * Returns the mesh Pose matrix.
  28491. * @returns the pose matrix
  28492. */
  28493. getPoseMatrix(): Matrix;
  28494. /** @hidden */
  28495. /** @hidden */
  28496. /**
  28497. * Flag the transform node as dirty (Forcing it to update everything)
  28498. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  28499. * @returns this transform node
  28500. */
  28501. markAsDirty(property: string): TransformNode;
  28502. /**
  28503. * Returns the current mesh absolute position.
  28504. * Returns a Vector3.
  28505. */
  28506. readonly absolutePosition: Vector3;
  28507. /**
  28508. * Sets a new matrix to apply before all other transformation
  28509. * @param matrix defines the transform matrix
  28510. * @returns the current TransformNode
  28511. */
  28512. setPreTransformMatrix(matrix: Matrix): TransformNode;
  28513. /**
  28514. * Sets a new pivot matrix to the current node
  28515. * @param matrix defines the new pivot matrix to use
  28516. * @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
  28517. * @returns the current TransformNode
  28518. */
  28519. setPivotMatrix(matrix: Matrix, postMultiplyPivotMatrix?: boolean): TransformNode;
  28520. /**
  28521. * Returns the mesh pivot matrix.
  28522. * Default : Identity.
  28523. * @returns the matrix
  28524. */
  28525. getPivotMatrix(): Matrix;
  28526. /**
  28527. * Prevents the World matrix to be computed any longer.
  28528. * @returns the TransformNode.
  28529. */
  28530. freezeWorldMatrix(): TransformNode;
  28531. /**
  28532. * Allows back the World matrix computation.
  28533. * @returns the TransformNode.
  28534. */
  28535. unfreezeWorldMatrix(): this;
  28536. /**
  28537. * True if the World matrix has been frozen.
  28538. */
  28539. readonly isWorldMatrixFrozen: boolean;
  28540. /**
  28541. * Retuns the mesh absolute position in the World.
  28542. * @returns a Vector3.
  28543. */
  28544. getAbsolutePosition(): Vector3;
  28545. /**
  28546. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  28547. * @param absolutePosition the absolute position to set
  28548. * @returns the TransformNode.
  28549. */
  28550. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  28551. /**
  28552. * Sets the mesh position in its local space.
  28553. * @param vector3 the position to set in localspace
  28554. * @returns the TransformNode.
  28555. */
  28556. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  28557. /**
  28558. * Returns the mesh position in the local space from the current World matrix values.
  28559. * @returns a new Vector3.
  28560. */
  28561. getPositionExpressedInLocalSpace(): Vector3;
  28562. /**
  28563. * Translates the mesh along the passed Vector3 in its local space.
  28564. * @param vector3 the distance to translate in localspace
  28565. * @returns the TransformNode.
  28566. */
  28567. locallyTranslate(vector3: Vector3): TransformNode;
  28568. private static _lookAtVectorCache;
  28569. /**
  28570. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  28571. * @param targetPoint the position (must be in same space as current mesh) to look at
  28572. * @param yawCor optional yaw (y-axis) correction in radians
  28573. * @param pitchCor optional pitch (x-axis) correction in radians
  28574. * @param rollCor optional roll (z-axis) correction in radians
  28575. * @param space the choosen space of the target
  28576. * @returns the TransformNode.
  28577. */
  28578. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  28579. /**
  28580. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  28581. * This Vector3 is expressed in the World space.
  28582. * @param localAxis axis to rotate
  28583. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  28584. */
  28585. getDirection(localAxis: Vector3): Vector3;
  28586. /**
  28587. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  28588. * localAxis is expressed in the mesh local space.
  28589. * result is computed in the Wordl space from the mesh World matrix.
  28590. * @param localAxis axis to rotate
  28591. * @param result the resulting transformnode
  28592. * @returns this TransformNode.
  28593. */
  28594. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  28595. /**
  28596. * Sets a new pivot point to the current node
  28597. * @param point defines the new pivot point to use
  28598. * @param space defines if the point is in world or local space (local by default)
  28599. * @returns the current TransformNode
  28600. */
  28601. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  28602. /**
  28603. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  28604. * @returns the pivot point
  28605. */
  28606. getPivotPoint(): Vector3;
  28607. /**
  28608. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  28609. * @param result the vector3 to store the result
  28610. * @returns this TransformNode.
  28611. */
  28612. getPivotPointToRef(result: Vector3): TransformNode;
  28613. /**
  28614. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  28615. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  28616. */
  28617. getAbsolutePivotPoint(): Vector3;
  28618. /**
  28619. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  28620. * @param result vector3 to store the result
  28621. * @returns this TransformNode.
  28622. */
  28623. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  28624. /**
  28625. * Defines the passed node as the parent of the current node.
  28626. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  28627. * @param node the node ot set as the parent
  28628. * @returns this TransformNode.
  28629. */
  28630. setParent(node: Nullable<Node>): TransformNode;
  28631. private _nonUniformScaling;
  28632. /**
  28633. * True if the scaling property of this object is non uniform eg. (1,2,1)
  28634. */
  28635. readonly nonUniformScaling: boolean;
  28636. /** @hidden */
  28637. /**
  28638. * Attach the current TransformNode to another TransformNode associated with a bone
  28639. * @param bone Bone affecting the TransformNode
  28640. * @param affectedTransformNode TransformNode associated with the bone
  28641. * @returns this object
  28642. */
  28643. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  28644. /**
  28645. * Detach the transform node if its associated with a bone
  28646. * @returns this object
  28647. */
  28648. detachFromBone(): TransformNode;
  28649. private static _rotationAxisCache;
  28650. /**
  28651. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  28652. * space (default LOCAL) can be either BABYLON.Space.LOCAL, either BABYLON.Space.WORLD.
  28653. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  28654. * The passed axis is also normalized.
  28655. * @param axis the axis to rotate around
  28656. * @param amount the amount to rotate in radians
  28657. * @param space Space to rotate in (Default: local)
  28658. * @returns the TransformNode.
  28659. */
  28660. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  28661. /**
  28662. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  28663. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  28664. * The passed axis is also normalized. .
  28665. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  28666. * @param point the point to rotate around
  28667. * @param axis the axis to rotate around
  28668. * @param amount the amount to rotate in radians
  28669. * @returns the TransformNode
  28670. */
  28671. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  28672. /**
  28673. * Translates the mesh along the axis vector for the passed distance in the given space.
  28674. * space (default LOCAL) can be either BABYLON.Space.LOCAL, either BABYLON.Space.WORLD.
  28675. * @param axis the axis to translate in
  28676. * @param distance the distance to translate
  28677. * @param space Space to rotate in (Default: local)
  28678. * @returns the TransformNode.
  28679. */
  28680. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  28681. /**
  28682. * Adds a rotation step to the mesh current rotation.
  28683. * x, y, z are Euler angles expressed in radians.
  28684. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  28685. * This means this rotation is made in the mesh local space only.
  28686. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  28687. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  28688. * ```javascript
  28689. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  28690. * ```
  28691. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  28692. * 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.
  28693. * @param x Rotation to add
  28694. * @param y Rotation to add
  28695. * @param z Rotation to add
  28696. * @returns the TransformNode.
  28697. */
  28698. addRotation(x: number, y: number, z: number): TransformNode;
  28699. /**
  28700. * Computes the world matrix of the node
  28701. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  28702. * @returns the world matrix
  28703. */
  28704. computeWorldMatrix(force?: boolean): Matrix;
  28705. protected _afterComputeWorldMatrix(): void;
  28706. /**
  28707. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  28708. * @param func callback function to add
  28709. *
  28710. * @returns the TransformNode.
  28711. */
  28712. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  28713. /**
  28714. * Removes a registered callback function.
  28715. * @param func callback function to remove
  28716. * @returns the TransformNode.
  28717. */
  28718. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  28719. /**
  28720. * Clone the current transform node
  28721. * @param name Name of the new clone
  28722. * @param newParent New parent for the clone
  28723. * @param doNotCloneChildren Do not clone children hierarchy
  28724. * @returns the new transform node
  28725. */
  28726. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  28727. /**
  28728. * Serializes the objects information.
  28729. * @param currentSerializationObject defines the object to serialize in
  28730. * @returns the serialized object
  28731. */
  28732. serialize(currentSerializationObject?: any): any;
  28733. /**
  28734. * Returns a new TransformNode object parsed from the source provided.
  28735. * @param parsedTransformNode is the source.
  28736. * @param scene the scne the object belongs to
  28737. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  28738. * @returns a new TransformNode object parsed from the source provided.
  28739. */
  28740. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  28741. /**
  28742. * Releases resources associated with this transform node.
  28743. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  28744. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  28745. */
  28746. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28747. }
  28748. }
  28749. declare module BABYLON {
  28750. /**
  28751. * Specialized buffer used to store vertex data
  28752. */
  28753. class VertexBuffer {
  28754. /** @hidden */
  28755. private _kind;
  28756. private _size;
  28757. private _ownsBuffer;
  28758. private _instanced;
  28759. private _instanceDivisor;
  28760. /**
  28761. * The byte type.
  28762. */
  28763. static readonly BYTE: number;
  28764. /**
  28765. * The unsigned byte type.
  28766. */
  28767. static readonly UNSIGNED_BYTE: number;
  28768. /**
  28769. * The short type.
  28770. */
  28771. static readonly SHORT: number;
  28772. /**
  28773. * The unsigned short type.
  28774. */
  28775. static readonly UNSIGNED_SHORT: number;
  28776. /**
  28777. * The integer type.
  28778. */
  28779. static readonly INT: number;
  28780. /**
  28781. * The unsigned integer type.
  28782. */
  28783. static readonly UNSIGNED_INT: number;
  28784. /**
  28785. * The float type.
  28786. */
  28787. static readonly FLOAT: number;
  28788. /**
  28789. * Gets or sets the instance divisor when in instanced mode
  28790. */
  28791. instanceDivisor: number;
  28792. /**
  28793. * Gets the byte stride.
  28794. */
  28795. readonly byteStride: number;
  28796. /**
  28797. * Gets the byte offset.
  28798. */
  28799. readonly byteOffset: number;
  28800. /**
  28801. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  28802. */
  28803. readonly normalized: boolean;
  28804. /**
  28805. * Gets the data type of each component in the array.
  28806. */
  28807. readonly type: number;
  28808. /**
  28809. * Constructor
  28810. * @param engine the engine
  28811. * @param data the data to use for this vertex buffer
  28812. * @param kind the vertex buffer kind
  28813. * @param updatable whether the data is updatable
  28814. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  28815. * @param stride the stride (optional)
  28816. * @param instanced whether the buffer is instanced (optional)
  28817. * @param offset the offset of the data (optional)
  28818. * @param size the number of components (optional)
  28819. * @param type the type of the component (optional)
  28820. * @param normalized whether the data contains normalized data (optional)
  28821. * @param useBytes set to true if stride and offset are in bytes (optional)
  28822. */
  28823. 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);
  28824. /** @hidden */
  28825. /**
  28826. * Returns the kind of the VertexBuffer (string)
  28827. * @returns a string
  28828. */
  28829. getKind(): string;
  28830. /**
  28831. * Gets a boolean indicating if the VertexBuffer is updatable?
  28832. * @returns true if the buffer is updatable
  28833. */
  28834. isUpdatable(): boolean;
  28835. /**
  28836. * Gets current buffer's data
  28837. * @returns a DataArray or null
  28838. */
  28839. getData(): Nullable<DataArray>;
  28840. /**
  28841. * Gets underlying native buffer
  28842. * @returns underlying native buffer
  28843. */
  28844. getBuffer(): Nullable<WebGLBuffer>;
  28845. /**
  28846. * Gets the stride in float32 units (i.e. byte stride / 4).
  28847. * May not be an integer if the byte stride is not divisible by 4.
  28848. * DEPRECATED. Use byteStride instead.
  28849. * @returns the stride in float32 units
  28850. */
  28851. getStrideSize(): number;
  28852. /**
  28853. * Returns the offset as a multiple of the type byte length.
  28854. * DEPRECATED. Use byteOffset instead.
  28855. * @returns the offset in bytes
  28856. */
  28857. getOffset(): number;
  28858. /**
  28859. * Returns the number of components per vertex attribute (integer)
  28860. * @returns the size in float
  28861. */
  28862. getSize(): number;
  28863. /**
  28864. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  28865. * @returns true if this buffer is instanced
  28866. */
  28867. getIsInstanced(): boolean;
  28868. /**
  28869. * Returns the instancing divisor, zero for non-instanced (integer).
  28870. * @returns a number
  28871. */
  28872. getInstanceDivisor(): number;
  28873. /**
  28874. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  28875. * @param data defines the data to store
  28876. */
  28877. create(data?: DataArray): void;
  28878. /**
  28879. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  28880. * This function will create a new buffer if the current one is not updatable
  28881. * @param data defines the data to store
  28882. */
  28883. update(data: DataArray): void;
  28884. /**
  28885. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  28886. * Returns the directly updated WebGLBuffer.
  28887. * @param data the new data
  28888. * @param offset the new offset
  28889. * @param useBytes set to true if the offset is in bytes
  28890. */
  28891. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  28892. /**
  28893. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  28894. */
  28895. dispose(): void;
  28896. /**
  28897. * Enumerates each value of this vertex buffer as numbers.
  28898. * @param count the number of values to enumerate
  28899. * @param callback the callback function called for each value
  28900. */
  28901. forEach(count: number, callback: (value: number, index: number) => void): void;
  28902. /**
  28903. * Positions
  28904. */
  28905. static readonly PositionKind: string;
  28906. /**
  28907. * Normals
  28908. */
  28909. static readonly NormalKind: string;
  28910. /**
  28911. * Tangents
  28912. */
  28913. static readonly TangentKind: string;
  28914. /**
  28915. * Texture coordinates
  28916. */
  28917. static readonly UVKind: string;
  28918. /**
  28919. * Texture coordinates 2
  28920. */
  28921. static readonly UV2Kind: string;
  28922. /**
  28923. * Texture coordinates 3
  28924. */
  28925. static readonly UV3Kind: string;
  28926. /**
  28927. * Texture coordinates 4
  28928. */
  28929. static readonly UV4Kind: string;
  28930. /**
  28931. * Texture coordinates 5
  28932. */
  28933. static readonly UV5Kind: string;
  28934. /**
  28935. * Texture coordinates 6
  28936. */
  28937. static readonly UV6Kind: string;
  28938. /**
  28939. * Colors
  28940. */
  28941. static readonly ColorKind: string;
  28942. /**
  28943. * Matrix indices (for bones)
  28944. */
  28945. static readonly MatricesIndicesKind: string;
  28946. /**
  28947. * Matrix weights (for bones)
  28948. */
  28949. static readonly MatricesWeightsKind: string;
  28950. /**
  28951. * Additional matrix indices (for bones)
  28952. */
  28953. static readonly MatricesIndicesExtraKind: string;
  28954. /**
  28955. * Additional matrix weights (for bones)
  28956. */
  28957. static readonly MatricesWeightsExtraKind: string;
  28958. /**
  28959. * Deduces the stride given a kind.
  28960. * @param kind The kind string to deduce
  28961. * @returns The deduced stride
  28962. */
  28963. static DeduceStride(kind: string): number;
  28964. /**
  28965. * Gets the byte length of the given type.
  28966. * @param type the type
  28967. * @returns the number of bytes
  28968. */
  28969. static GetTypeByteLength(type: number): number;
  28970. /**
  28971. * Enumerates each value of the given parameters as numbers.
  28972. * @param data the data to enumerate
  28973. * @param byteOffset the byte offset of the data
  28974. * @param byteStride the byte stride of the data
  28975. * @param componentCount the number of components per element
  28976. * @param componentType the type of the component
  28977. * @param count the total number of components
  28978. * @param normalized whether the data is normalized
  28979. * @param callback the callback function called for each value
  28980. */
  28981. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  28982. private static _GetFloatValue;
  28983. }
  28984. }
  28985. declare module BABYLON {
  28986. /**
  28987. * This represents the base class for particle system in Babylon.
  28988. * 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.
  28989. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  28990. * @example https://doc.babylonjs.com/babylon101/particles
  28991. */
  28992. class BaseParticleSystem {
  28993. /**
  28994. * Source color is added to the destination color without alpha affecting the result
  28995. */
  28996. static BLENDMODE_ONEONE: number;
  28997. /**
  28998. * Blend current color and particle color using particle’s alpha
  28999. */
  29000. static BLENDMODE_STANDARD: number;
  29001. /**
  29002. * Add current color and particle color multiplied by particle’s alpha
  29003. */
  29004. static BLENDMODE_ADD: number;
  29005. /**
  29006. * Multiply current color with particle color
  29007. */
  29008. static BLENDMODE_MULTIPLY: number;
  29009. /**
  29010. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  29011. */
  29012. static BLENDMODE_MULTIPLYADD: number;
  29013. /**
  29014. * List of animations used by the particle system.
  29015. */
  29016. animations: Animation[];
  29017. /**
  29018. * The id of the Particle system.
  29019. */
  29020. id: string;
  29021. /**
  29022. * The friendly name of the Particle system.
  29023. */
  29024. name: string;
  29025. /**
  29026. * The rendering group used by the Particle system to chose when to render.
  29027. */
  29028. renderingGroupId: number;
  29029. /**
  29030. * The emitter represents the Mesh or position we are attaching the particle system to.
  29031. */
  29032. emitter: Nullable<AbstractMesh | Vector3>;
  29033. /**
  29034. * The maximum number of particles to emit per frame
  29035. */
  29036. emitRate: number;
  29037. /**
  29038. * If you want to launch only a few particles at once, that can be done, as well.
  29039. */
  29040. manualEmitCount: number;
  29041. /**
  29042. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  29043. */
  29044. updateSpeed: number;
  29045. /**
  29046. * The amount of time the particle system is running (depends of the overall update speed).
  29047. */
  29048. targetStopDuration: number;
  29049. /**
  29050. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  29051. */
  29052. disposeOnStop: boolean;
  29053. /**
  29054. * Minimum power of emitting particles.
  29055. */
  29056. minEmitPower: number;
  29057. /**
  29058. * Maximum power of emitting particles.
  29059. */
  29060. maxEmitPower: number;
  29061. /**
  29062. * Minimum life time of emitting particles.
  29063. */
  29064. minLifeTime: number;
  29065. /**
  29066. * Maximum life time of emitting particles.
  29067. */
  29068. maxLifeTime: number;
  29069. /**
  29070. * Minimum Size of emitting particles.
  29071. */
  29072. minSize: number;
  29073. /**
  29074. * Maximum Size of emitting particles.
  29075. */
  29076. maxSize: number;
  29077. /**
  29078. * Minimum scale of emitting particles on X axis.
  29079. */
  29080. minScaleX: number;
  29081. /**
  29082. * Maximum scale of emitting particles on X axis.
  29083. */
  29084. maxScaleX: number;
  29085. /**
  29086. * Minimum scale of emitting particles on Y axis.
  29087. */
  29088. minScaleY: number;
  29089. /**
  29090. * Maximum scale of emitting particles on Y axis.
  29091. */
  29092. maxScaleY: number;
  29093. /**
  29094. * Gets or sets the minimal initial rotation in radians.
  29095. */
  29096. minInitialRotation: number;
  29097. /**
  29098. * Gets or sets the maximal initial rotation in radians.
  29099. */
  29100. maxInitialRotation: number;
  29101. /**
  29102. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  29103. */
  29104. minAngularSpeed: number;
  29105. /**
  29106. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  29107. */
  29108. maxAngularSpeed: number;
  29109. /**
  29110. * The texture used to render each particle. (this can be a spritesheet)
  29111. */
  29112. particleTexture: Nullable<Texture>;
  29113. /**
  29114. * The layer mask we are rendering the particles through.
  29115. */
  29116. layerMask: number;
  29117. /**
  29118. * This can help using your own shader to render the particle system.
  29119. * The according effect will be created
  29120. */
  29121. customShader: any;
  29122. /**
  29123. * By default particle system starts as soon as they are created. This prevents the
  29124. * automatic start to happen and let you decide when to start emitting particles.
  29125. */
  29126. preventAutoStart: boolean;
  29127. /**
  29128. * Gets or sets a texture used to add random noise to particle positions
  29129. */
  29130. noiseTexture: Nullable<ProceduralTexture>;
  29131. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  29132. noiseStrength: Vector3;
  29133. /**
  29134. * Callback triggered when the particle animation is ending.
  29135. */
  29136. onAnimationEnd: Nullable<() => void>;
  29137. /**
  29138. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  29139. */
  29140. blendMode: number;
  29141. /**
  29142. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  29143. * to override the particles.
  29144. */
  29145. forceDepthWrite: boolean;
  29146. /** 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 */
  29147. preWarmCycles: number;
  29148. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  29149. preWarmStepOffset: number;
  29150. /**
  29151. * 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)
  29152. */
  29153. spriteCellChangeSpeed: number;
  29154. /**
  29155. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  29156. */
  29157. startSpriteCellID: number;
  29158. /**
  29159. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  29160. */
  29161. endSpriteCellID: number;
  29162. /**
  29163. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  29164. */
  29165. spriteCellWidth: number;
  29166. /**
  29167. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  29168. */
  29169. spriteCellHeight: number;
  29170. /**
  29171. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  29172. */
  29173. spriteRandomStartCell: boolean;
  29174. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  29175. translationPivot: Vector2;
  29176. /** @hidden */
  29177. protected _isAnimationSheetEnabled: boolean;
  29178. /**
  29179. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  29180. */
  29181. beginAnimationOnStart: boolean;
  29182. /**
  29183. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  29184. */
  29185. beginAnimationFrom: number;
  29186. /**
  29187. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  29188. */
  29189. beginAnimationTo: number;
  29190. /**
  29191. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  29192. */
  29193. beginAnimationLoop: boolean;
  29194. /**
  29195. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  29196. */
  29197. isAnimationSheetEnabled: boolean;
  29198. /**
  29199. * Get hosting scene
  29200. * @returns the scene
  29201. */
  29202. getScene(): Scene;
  29203. /**
  29204. * You can use gravity if you want to give an orientation to your particles.
  29205. */
  29206. gravity: Vector3;
  29207. protected _colorGradients: Nullable<Array<ColorGradient>>;
  29208. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  29209. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  29210. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  29211. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  29212. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  29213. protected _dragGradients: Nullable<Array<FactorGradient>>;
  29214. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  29215. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  29216. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  29217. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  29218. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  29219. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  29220. /**
  29221. * Defines the delay in milliseconds before starting the system (0 by default)
  29222. */
  29223. startDelay: number;
  29224. /**
  29225. * Gets the current list of drag gradients.
  29226. * You must use addDragGradient and removeDragGradient to udpate this list
  29227. * @returns the list of drag gradients
  29228. */
  29229. getDragGradients(): Nullable<Array<FactorGradient>>;
  29230. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  29231. limitVelocityDamping: number;
  29232. /**
  29233. * Gets the current list of limit velocity gradients.
  29234. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  29235. * @returns the list of limit velocity gradients
  29236. */
  29237. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  29238. /**
  29239. * Gets the current list of color gradients.
  29240. * You must use addColorGradient and removeColorGradient to udpate this list
  29241. * @returns the list of color gradients
  29242. */
  29243. getColorGradients(): Nullable<Array<ColorGradient>>;
  29244. /**
  29245. * Gets the current list of size gradients.
  29246. * You must use addSizeGradient and removeSizeGradient to udpate this list
  29247. * @returns the list of size gradients
  29248. */
  29249. getSizeGradients(): Nullable<Array<FactorGradient>>;
  29250. /**
  29251. * Gets the current list of color remap gradients.
  29252. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  29253. * @returns the list of color remap gradients
  29254. */
  29255. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  29256. /**
  29257. * Gets the current list of alpha remap gradients.
  29258. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  29259. * @returns the list of alpha remap gradients
  29260. */
  29261. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  29262. /**
  29263. * Gets the current list of life time gradients.
  29264. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  29265. * @returns the list of life time gradients
  29266. */
  29267. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  29268. /**
  29269. * Gets the current list of angular speed gradients.
  29270. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  29271. * @returns the list of angular speed gradients
  29272. */
  29273. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  29274. /**
  29275. * Gets the current list of velocity gradients.
  29276. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  29277. * @returns the list of velocity gradients
  29278. */
  29279. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  29280. /**
  29281. * Gets the current list of start size gradients.
  29282. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  29283. * @returns the list of start size gradients
  29284. */
  29285. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  29286. /**
  29287. * Gets the current list of emit rate gradients.
  29288. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  29289. * @returns the list of emit rate gradients
  29290. */
  29291. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  29292. /**
  29293. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  29294. * This only works when particleEmitterTyps is a BoxParticleEmitter
  29295. */
  29296. direction1: Vector3;
  29297. /**
  29298. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  29299. * This only works when particleEmitterTyps is a BoxParticleEmitter
  29300. */
  29301. direction2: Vector3;
  29302. /**
  29303. * 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.
  29304. * This only works when particleEmitterTyps is a BoxParticleEmitter
  29305. */
  29306. minEmitBox: Vector3;
  29307. /**
  29308. * 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.
  29309. * This only works when particleEmitterTyps is a BoxParticleEmitter
  29310. */
  29311. maxEmitBox: Vector3;
  29312. /**
  29313. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  29314. */
  29315. color1: Color4;
  29316. /**
  29317. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  29318. */
  29319. color2: Color4;
  29320. /**
  29321. * Color the particle will have at the end of its lifetime
  29322. */
  29323. colorDead: Color4;
  29324. /**
  29325. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  29326. */
  29327. textureMask: Color4;
  29328. /**
  29329. * The particle emitter type defines the emitter used by the particle system.
  29330. * It can be for example box, sphere, or cone...
  29331. */
  29332. particleEmitterType: IParticleEmitterType;
  29333. /** @hidden */
  29334. /**
  29335. * Gets or sets the billboard mode to use when isBillboardBased = true.
  29336. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  29337. */
  29338. billboardMode: number;
  29339. protected _isBillboardBased: boolean;
  29340. /**
  29341. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  29342. */
  29343. isBillboardBased: boolean;
  29344. /**
  29345. * The scene the particle system belongs to.
  29346. */
  29347. protected _scene: Scene;
  29348. /**
  29349. * Local cache of defines for image processing.
  29350. */
  29351. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  29352. /**
  29353. * Default configuration related to image processing available in the standard Material.
  29354. */
  29355. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  29356. /**
  29357. * Gets the image processing configuration used either in this material.
  29358. */
  29359. /**
  29360. * Sets the Default image processing configuration used either in the this material.
  29361. *
  29362. * If sets to null, the scene one is in use.
  29363. */
  29364. imageProcessingConfiguration: ImageProcessingConfiguration;
  29365. /**
  29366. * Attaches a new image processing configuration to the Standard Material.
  29367. * @param configuration
  29368. */
  29369. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  29370. /** @hidden */
  29371. protected _reset(): void;
  29372. /** @hidden */
  29373. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  29374. /**
  29375. * Instantiates a particle system.
  29376. * 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.
  29377. * @param name The name of the particle system
  29378. */
  29379. constructor(name: string);
  29380. /**
  29381. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  29382. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  29383. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  29384. * @returns the emitter
  29385. */
  29386. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  29387. /**
  29388. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  29389. * @param radius The radius of the hemisphere to emit from
  29390. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  29391. * @returns the emitter
  29392. */
  29393. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  29394. /**
  29395. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  29396. * @param radius The radius of the sphere to emit from
  29397. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  29398. * @returns the emitter
  29399. */
  29400. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  29401. /**
  29402. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  29403. * @param radius The radius of the sphere to emit from
  29404. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  29405. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  29406. * @returns the emitter
  29407. */
  29408. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  29409. /**
  29410. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  29411. * @param radius The radius of the emission cylinder
  29412. * @param height The height of the emission cylinder
  29413. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  29414. * @param directionRandomizer How much to randomize the particle direction [0-1]
  29415. * @returns the emitter
  29416. */
  29417. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  29418. /**
  29419. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  29420. * @param radius The radius of the cylinder to emit from
  29421. * @param height The height of the emission cylinder
  29422. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  29423. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  29424. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  29425. * @returns the emitter
  29426. */
  29427. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  29428. /**
  29429. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  29430. * @param radius The radius of the cone to emit from
  29431. * @param angle The base angle of the cone
  29432. * @returns the emitter
  29433. */
  29434. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  29435. /**
  29436. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  29437. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  29438. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  29439. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  29440. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  29441. * @returns the emitter
  29442. */
  29443. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  29444. }
  29445. }
  29446. declare module BABYLON {
  29447. /**
  29448. * This represents a GPU particle system in Babylon
  29449. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  29450. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  29451. */
  29452. class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  29453. /**
  29454. * The layer mask we are rendering the particles through.
  29455. */
  29456. layerMask: number;
  29457. private _capacity;
  29458. private _activeCount;
  29459. private _currentActiveCount;
  29460. private _accumulatedCount;
  29461. private _renderEffect;
  29462. private _updateEffect;
  29463. private _buffer0;
  29464. private _buffer1;
  29465. private _spriteBuffer;
  29466. private _updateVAO;
  29467. private _renderVAO;
  29468. private _targetIndex;
  29469. private _sourceBuffer;
  29470. private _targetBuffer;
  29471. private _engine;
  29472. private _currentRenderId;
  29473. private _started;
  29474. private _stopped;
  29475. private _timeDelta;
  29476. private _randomTexture;
  29477. private _randomTexture2;
  29478. private _attributesStrideSize;
  29479. private _updateEffectOptions;
  29480. private _randomTextureSize;
  29481. private _actualFrame;
  29482. private readonly _rawTextureWidth;
  29483. /**
  29484. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  29485. */
  29486. static readonly IsSupported: boolean;
  29487. /**
  29488. * An event triggered when the system is disposed.
  29489. */
  29490. onDisposeObservable: Observable<GPUParticleSystem>;
  29491. /**
  29492. * Gets the maximum number of particles active at the same time.
  29493. * @returns The max number of active particles.
  29494. */
  29495. getCapacity(): number;
  29496. /**
  29497. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  29498. * to override the particles.
  29499. */
  29500. forceDepthWrite: boolean;
  29501. /**
  29502. * Gets or set the number of active particles
  29503. */
  29504. activeParticleCount: number;
  29505. private _preWarmDone;
  29506. /**
  29507. * Is this system ready to be used/rendered
  29508. * @return true if the system is ready
  29509. */
  29510. isReady(): boolean;
  29511. /**
  29512. * Gets if the system has been started. (Note: this will still be true after stop is called)
  29513. * @returns True if it has been started, otherwise false.
  29514. */
  29515. isStarted(): boolean;
  29516. /**
  29517. * Starts the particle system and begins to emit
  29518. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  29519. */
  29520. start(delay?: number): void;
  29521. /**
  29522. * Stops the particle system.
  29523. */
  29524. stop(): void;
  29525. /**
  29526. * Remove all active particles
  29527. */
  29528. reset(): void;
  29529. /**
  29530. * Returns the string "GPUParticleSystem"
  29531. * @returns a string containing the class name
  29532. */
  29533. getClassName(): string;
  29534. private _colorGradientsTexture;
  29535. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  29536. /**
  29537. * Adds a new color gradient
  29538. * @param gradient defines the gradient to use (between 0 and 1)
  29539. * @param color1 defines the color to affect to the specified gradient
  29540. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  29541. * @returns the current particle system
  29542. */
  29543. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  29544. /**
  29545. * Remove a specific color gradient
  29546. * @param gradient defines the gradient to remove
  29547. * @returns the current particle system
  29548. */
  29549. removeColorGradient(gradient: number): GPUParticleSystem;
  29550. private _angularSpeedGradientsTexture;
  29551. private _sizeGradientsTexture;
  29552. private _velocityGradientsTexture;
  29553. private _limitVelocityGradientsTexture;
  29554. private _dragGradientsTexture;
  29555. private _addFactorGradient;
  29556. /**
  29557. * Adds a new size gradient
  29558. * @param gradient defines the gradient to use (between 0 and 1)
  29559. * @param factor defines the size factor to affect to the specified gradient
  29560. * @returns the current particle system
  29561. */
  29562. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  29563. /**
  29564. * Remove a specific size gradient
  29565. * @param gradient defines the gradient to remove
  29566. * @returns the current particle system
  29567. */
  29568. removeSizeGradient(gradient: number): GPUParticleSystem;
  29569. /**
  29570. * Adds a new angular speed gradient
  29571. * @param gradient defines the gradient to use (between 0 and 1)
  29572. * @param factor defines the angular speed to affect to the specified gradient
  29573. * @returns the current particle system
  29574. */
  29575. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  29576. /**
  29577. * Remove a specific angular speed gradient
  29578. * @param gradient defines the gradient to remove
  29579. * @returns the current particle system
  29580. */
  29581. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  29582. /**
  29583. * Adds a new velocity gradient
  29584. * @param gradient defines the gradient to use (between 0 and 1)
  29585. * @param factor defines the velocity to affect to the specified gradient
  29586. * @returns the current particle system
  29587. */
  29588. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  29589. /**
  29590. * Remove a specific velocity gradient
  29591. * @param gradient defines the gradient to remove
  29592. * @returns the current particle system
  29593. */
  29594. removeVelocityGradient(gradient: number): GPUParticleSystem;
  29595. /**
  29596. * Adds a new limit velocity gradient
  29597. * @param gradient defines the gradient to use (between 0 and 1)
  29598. * @param factor defines the limit velocity value to affect to the specified gradient
  29599. * @returns the current particle system
  29600. */
  29601. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  29602. /**
  29603. * Remove a specific limit velocity gradient
  29604. * @param gradient defines the gradient to remove
  29605. * @returns the current particle system
  29606. */
  29607. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  29608. /**
  29609. * Adds a new drag gradient
  29610. * @param gradient defines the gradient to use (between 0 and 1)
  29611. * @param factor defines the drag value to affect to the specified gradient
  29612. * @returns the current particle system
  29613. */
  29614. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  29615. /**
  29616. * Remove a specific drag gradient
  29617. * @param gradient defines the gradient to remove
  29618. * @returns the current particle system
  29619. */
  29620. removeDragGradient(gradient: number): GPUParticleSystem;
  29621. /**
  29622. * Not supported by GPUParticleSystem
  29623. * @param gradient defines the gradient to use (between 0 and 1)
  29624. * @param factor defines the emit rate value to affect to the specified gradient
  29625. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  29626. * @returns the current particle system
  29627. */
  29628. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  29629. /**
  29630. * Not supported by GPUParticleSystem
  29631. * @param gradient defines the gradient to remove
  29632. * @returns the current particle system
  29633. */
  29634. removeEmitRateGradient(gradient: number): IParticleSystem;
  29635. /**
  29636. * Not supported by GPUParticleSystem
  29637. * @param gradient defines the gradient to use (between 0 and 1)
  29638. * @param factor defines the start size value to affect to the specified gradient
  29639. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  29640. * @returns the current particle system
  29641. */
  29642. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  29643. /**
  29644. * Not supported by GPUParticleSystem
  29645. * @param gradient defines the gradient to remove
  29646. * @returns the current particle system
  29647. */
  29648. removeStartSizeGradient(gradient: number): IParticleSystem;
  29649. /**
  29650. * Not supported by GPUParticleSystem
  29651. * @param gradient defines the gradient to use (between 0 and 1)
  29652. * @param min defines the color remap minimal range
  29653. * @param max defines the color remap maximal range
  29654. * @returns the current particle system
  29655. */
  29656. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  29657. /**
  29658. * Not supported by GPUParticleSystem
  29659. * @param gradient defines the gradient to remove
  29660. * @returns the current particle system
  29661. */
  29662. removeColorRemapGradient(gradient: number): IParticleSystem;
  29663. /**
  29664. * Not supported by GPUParticleSystem
  29665. * @param gradient defines the gradient to use (between 0 and 1)
  29666. * @param min defines the alpha remap minimal range
  29667. * @param max defines the alpha remap maximal range
  29668. * @returns the current particle system
  29669. */
  29670. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  29671. /**
  29672. * Not supported by GPUParticleSystem
  29673. * @param gradient defines the gradient to remove
  29674. * @returns the current particle system
  29675. */
  29676. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  29677. /**
  29678. * Not supported by GPUParticleSystem
  29679. * @param gradient defines the gradient to use (between 0 and 1)
  29680. * @param color defines the color to affect to the specified gradient
  29681. * @returns the current particle system
  29682. */
  29683. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  29684. /**
  29685. * Not supported by GPUParticleSystem
  29686. * @param gradient defines the gradient to remove
  29687. * @returns the current particle system
  29688. */
  29689. removeRampGradient(gradient: number): IParticleSystem;
  29690. /**
  29691. * Not supported by GPUParticleSystem
  29692. * @returns the list of ramp gradients
  29693. */
  29694. getRampGradients(): Nullable<Array<Color3Gradient>>;
  29695. /**
  29696. * Not supported by GPUParticleSystem
  29697. * Gets or sets a boolean indicating that ramp gradients must be used
  29698. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  29699. */
  29700. useRampGradients: boolean;
  29701. /**
  29702. * Not supported by GPUParticleSystem
  29703. * @param gradient defines the gradient to use (between 0 and 1)
  29704. * @param factor defines the life time factor to affect to the specified gradient
  29705. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  29706. * @returns the current particle system
  29707. */
  29708. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  29709. /**
  29710. * Not supported by GPUParticleSystem
  29711. * @param gradient defines the gradient to remove
  29712. * @returns the current particle system
  29713. */
  29714. removeLifeTimeGradient(gradient: number): IParticleSystem;
  29715. /**
  29716. * Instantiates a GPU particle system.
  29717. * 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.
  29718. * @param name The name of the particle system
  29719. * @param options The options used to create the system
  29720. * @param scene The scene the particle system belongs to
  29721. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  29722. */
  29723. constructor(name: string, options: Partial<{
  29724. capacity: number;
  29725. randomTextureSize: number;
  29726. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  29727. protected _reset(): void;
  29728. private _createUpdateVAO;
  29729. private _createRenderVAO;
  29730. private _initialize;
  29731. /** @hidden */
  29732. /** @hidden */
  29733. /**
  29734. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  29735. * @param preWarm defines if we are in the pre-warmimg phase
  29736. */
  29737. animate(preWarm?: boolean): void;
  29738. private _createFactorGradientTexture;
  29739. private _createSizeGradientTexture;
  29740. private _createAngularSpeedGradientTexture;
  29741. private _createVelocityGradientTexture;
  29742. private _createLimitVelocityGradientTexture;
  29743. private _createDragGradientTexture;
  29744. private _createColorGradientTexture;
  29745. /**
  29746. * Renders the particle system in its current state
  29747. * @param preWarm defines if the system should only update the particles but not render them
  29748. * @returns the current number of particles
  29749. */
  29750. render(preWarm?: boolean): number;
  29751. /**
  29752. * Rebuilds the particle system
  29753. */
  29754. rebuild(): void;
  29755. private _releaseBuffers;
  29756. private _releaseVAOs;
  29757. /**
  29758. * Disposes the particle system and free the associated resources
  29759. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  29760. */
  29761. dispose(disposeTexture?: boolean): void;
  29762. /**
  29763. * Clones the particle system.
  29764. * @param name The name of the cloned object
  29765. * @param newEmitter The new emitter to use
  29766. * @returns the cloned particle system
  29767. */
  29768. clone(name: string, newEmitter: any): GPUParticleSystem;
  29769. /**
  29770. * Serializes the particle system to a JSON object.
  29771. * @returns the JSON object
  29772. */
  29773. serialize(): any;
  29774. /**
  29775. * Parses a JSON object to create a GPU particle system.
  29776. * @param parsedParticleSystem The JSON object to parse
  29777. * @param scene The scene to create the particle system in
  29778. * @param rootUrl The root url to use to load external dependencies like texture
  29779. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  29780. * @returns the parsed GPU particle system
  29781. */
  29782. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  29783. }
  29784. }
  29785. declare module BABYLON {
  29786. /**
  29787. * Interface representing a particle system in Babylon.js.
  29788. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  29789. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  29790. */
  29791. interface IParticleSystem {
  29792. /**
  29793. * List of animations used by the particle system.
  29794. */
  29795. animations: Animation[];
  29796. /**
  29797. * The id of the Particle system.
  29798. */
  29799. id: string;
  29800. /**
  29801. * The name of the Particle system.
  29802. */
  29803. name: string;
  29804. /**
  29805. * The emitter represents the Mesh or position we are attaching the particle system to.
  29806. */
  29807. emitter: Nullable<AbstractMesh | Vector3>;
  29808. /**
  29809. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  29810. */
  29811. isBillboardBased: boolean;
  29812. /**
  29813. * The rendering group used by the Particle system to chose when to render.
  29814. */
  29815. renderingGroupId: number;
  29816. /**
  29817. * The layer mask we are rendering the particles through.
  29818. */
  29819. layerMask: number;
  29820. /**
  29821. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  29822. */
  29823. updateSpeed: number;
  29824. /**
  29825. * The amount of time the particle system is running (depends of the overall update speed).
  29826. */
  29827. targetStopDuration: number;
  29828. /**
  29829. * The texture used to render each particle. (this can be a spritesheet)
  29830. */
  29831. particleTexture: Nullable<Texture>;
  29832. /**
  29833. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  29834. */
  29835. blendMode: number;
  29836. /**
  29837. * Minimum life time of emitting particles.
  29838. */
  29839. minLifeTime: number;
  29840. /**
  29841. * Maximum life time of emitting particles.
  29842. */
  29843. maxLifeTime: number;
  29844. /**
  29845. * Minimum Size of emitting particles.
  29846. */
  29847. minSize: number;
  29848. /**
  29849. * Maximum Size of emitting particles.
  29850. */
  29851. maxSize: number;
  29852. /**
  29853. * Minimum scale of emitting particles on X axis.
  29854. */
  29855. minScaleX: number;
  29856. /**
  29857. * Maximum scale of emitting particles on X axis.
  29858. */
  29859. maxScaleX: number;
  29860. /**
  29861. * Minimum scale of emitting particles on Y axis.
  29862. */
  29863. minScaleY: number;
  29864. /**
  29865. * Maximum scale of emitting particles on Y axis.
  29866. */
  29867. maxScaleY: number;
  29868. /**
  29869. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  29870. */
  29871. color1: Color4;
  29872. /**
  29873. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  29874. */
  29875. color2: Color4;
  29876. /**
  29877. * Color the particle will have at the end of its lifetime.
  29878. */
  29879. colorDead: Color4;
  29880. /**
  29881. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  29882. */
  29883. emitRate: number;
  29884. /**
  29885. * You can use gravity if you want to give an orientation to your particles.
  29886. */
  29887. gravity: Vector3;
  29888. /**
  29889. * Minimum power of emitting particles.
  29890. */
  29891. minEmitPower: number;
  29892. /**
  29893. * Maximum power of emitting particles.
  29894. */
  29895. maxEmitPower: number;
  29896. /**
  29897. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  29898. */
  29899. minAngularSpeed: number;
  29900. /**
  29901. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  29902. */
  29903. maxAngularSpeed: number;
  29904. /**
  29905. * Gets or sets the minimal initial rotation in radians.
  29906. */
  29907. minInitialRotation: number;
  29908. /**
  29909. * Gets or sets the maximal initial rotation in radians.
  29910. */
  29911. maxInitialRotation: number;
  29912. /**
  29913. * The particle emitter type defines the emitter used by the particle system.
  29914. * It can be for example box, sphere, or cone...
  29915. */
  29916. particleEmitterType: Nullable<IParticleEmitterType>;
  29917. /**
  29918. * Defines the delay in milliseconds before starting the system (0 by default)
  29919. */
  29920. startDelay: number;
  29921. /**
  29922. * 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
  29923. */
  29924. preWarmCycles: number;
  29925. /**
  29926. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  29927. */
  29928. preWarmStepOffset: number;
  29929. /**
  29930. * 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)
  29931. */
  29932. spriteCellChangeSpeed: number;
  29933. /**
  29934. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  29935. */
  29936. startSpriteCellID: number;
  29937. /**
  29938. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  29939. */
  29940. endSpriteCellID: number;
  29941. /**
  29942. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  29943. */
  29944. spriteCellWidth: number;
  29945. /**
  29946. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  29947. */
  29948. spriteCellHeight: number;
  29949. /**
  29950. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  29951. */
  29952. spriteRandomStartCell: boolean;
  29953. /**
  29954. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  29955. */
  29956. isAnimationSheetEnabled: boolean;
  29957. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  29958. translationPivot: Vector2;
  29959. /**
  29960. * Gets or sets a texture used to add random noise to particle positions
  29961. */
  29962. noiseTexture: Nullable<BaseTexture>;
  29963. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  29964. noiseStrength: Vector3;
  29965. /**
  29966. * Gets or sets the billboard mode to use when isBillboardBased = true.
  29967. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  29968. */
  29969. billboardMode: number;
  29970. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  29971. limitVelocityDamping: number;
  29972. /**
  29973. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  29974. */
  29975. beginAnimationOnStart: boolean;
  29976. /**
  29977. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  29978. */
  29979. beginAnimationFrom: number;
  29980. /**
  29981. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  29982. */
  29983. beginAnimationTo: number;
  29984. /**
  29985. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  29986. */
  29987. beginAnimationLoop: boolean;
  29988. /**
  29989. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  29990. */
  29991. disposeOnStop: boolean;
  29992. /**
  29993. * Gets the maximum number of particles active at the same time.
  29994. * @returns The max number of active particles.
  29995. */
  29996. getCapacity(): number;
  29997. /**
  29998. * Gets if the system has been started. (Note: this will still be true after stop is called)
  29999. * @returns True if it has been started, otherwise false.
  30000. */
  30001. isStarted(): boolean;
  30002. /**
  30003. * Animates the particle system for this frame.
  30004. */
  30005. animate(): void;
  30006. /**
  30007. * Renders the particle system in its current state.
  30008. * @returns the current number of particles
  30009. */
  30010. render(): number;
  30011. /**
  30012. * Dispose the particle system and frees its associated resources.
  30013. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  30014. */
  30015. dispose(disposeTexture?: boolean): void;
  30016. /**
  30017. * Clones the particle system.
  30018. * @param name The name of the cloned object
  30019. * @param newEmitter The new emitter to use
  30020. * @returns the cloned particle system
  30021. */
  30022. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  30023. /**
  30024. * Serializes the particle system to a JSON object.
  30025. * @returns the JSON object
  30026. */
  30027. serialize(): any;
  30028. /**
  30029. * Rebuild the particle system
  30030. */
  30031. rebuild(): void;
  30032. /**
  30033. * Starts the particle system and begins to emit
  30034. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  30035. */
  30036. start(delay?: number): void;
  30037. /**
  30038. * Stops the particle system.
  30039. */
  30040. stop(): void;
  30041. /**
  30042. * Remove all active particles
  30043. */
  30044. reset(): void;
  30045. /**
  30046. * Is this system ready to be used/rendered
  30047. * @return true if the system is ready
  30048. */
  30049. isReady(): boolean;
  30050. /**
  30051. * Adds a new color gradient
  30052. * @param gradient defines the gradient to use (between 0 and 1)
  30053. * @param color1 defines the color to affect to the specified gradient
  30054. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  30055. * @returns the current particle system
  30056. */
  30057. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  30058. /**
  30059. * Remove a specific color gradient
  30060. * @param gradient defines the gradient to remove
  30061. * @returns the current particle system
  30062. */
  30063. removeColorGradient(gradient: number): IParticleSystem;
  30064. /**
  30065. * Adds a new size gradient
  30066. * @param gradient defines the gradient to use (between 0 and 1)
  30067. * @param factor defines the size factor to affect to the specified gradient
  30068. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  30069. * @returns the current particle system
  30070. */
  30071. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  30072. /**
  30073. * Remove a specific size gradient
  30074. * @param gradient defines the gradient to remove
  30075. * @returns the current particle system
  30076. */
  30077. removeSizeGradient(gradient: number): IParticleSystem;
  30078. /**
  30079. * Gets the current list of color gradients.
  30080. * You must use addColorGradient and removeColorGradient to udpate this list
  30081. * @returns the list of color gradients
  30082. */
  30083. getColorGradients(): Nullable<Array<ColorGradient>>;
  30084. /**
  30085. * Gets the current list of size gradients.
  30086. * You must use addSizeGradient and removeSizeGradient to udpate this list
  30087. * @returns the list of size gradients
  30088. */
  30089. getSizeGradients(): Nullable<Array<FactorGradient>>;
  30090. /**
  30091. * Gets the current list of angular speed gradients.
  30092. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  30093. * @returns the list of angular speed gradients
  30094. */
  30095. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  30096. /**
  30097. * Adds a new angular speed gradient
  30098. * @param gradient defines the gradient to use (between 0 and 1)
  30099. * @param factor defines the angular speed to affect to the specified gradient
  30100. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  30101. * @returns the current particle system
  30102. */
  30103. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  30104. /**
  30105. * Remove a specific angular speed gradient
  30106. * @param gradient defines the gradient to remove
  30107. * @returns the current particle system
  30108. */
  30109. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  30110. /**
  30111. * Gets the current list of velocity gradients.
  30112. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  30113. * @returns the list of velocity gradients
  30114. */
  30115. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  30116. /**
  30117. * Adds a new velocity gradient
  30118. * @param gradient defines the gradient to use (between 0 and 1)
  30119. * @param factor defines the velocity to affect to the specified gradient
  30120. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  30121. * @returns the current particle system
  30122. */
  30123. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  30124. /**
  30125. * Remove a specific velocity gradient
  30126. * @param gradient defines the gradient to remove
  30127. * @returns the current particle system
  30128. */
  30129. removeVelocityGradient(gradient: number): IParticleSystem;
  30130. /**
  30131. * Gets the current list of limit velocity gradients.
  30132. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  30133. * @returns the list of limit velocity gradients
  30134. */
  30135. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  30136. /**
  30137. * Adds a new limit velocity gradient
  30138. * @param gradient defines the gradient to use (between 0 and 1)
  30139. * @param factor defines the limit velocity to affect to the specified gradient
  30140. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  30141. * @returns the current particle system
  30142. */
  30143. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  30144. /**
  30145. * Remove a specific limit velocity gradient
  30146. * @param gradient defines the gradient to remove
  30147. * @returns the current particle system
  30148. */
  30149. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  30150. /**
  30151. * Adds a new drag gradient
  30152. * @param gradient defines the gradient to use (between 0 and 1)
  30153. * @param factor defines the drag to affect to the specified gradient
  30154. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  30155. * @returns the current particle system
  30156. */
  30157. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  30158. /**
  30159. * Remove a specific drag gradient
  30160. * @param gradient defines the gradient to remove
  30161. * @returns the current particle system
  30162. */
  30163. removeDragGradient(gradient: number): IParticleSystem;
  30164. /**
  30165. * Gets the current list of drag gradients.
  30166. * You must use addDragGradient and removeDragGradient to udpate this list
  30167. * @returns the list of drag gradients
  30168. */
  30169. getDragGradients(): Nullable<Array<FactorGradient>>;
  30170. /**
  30171. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  30172. * @param gradient defines the gradient to use (between 0 and 1)
  30173. * @param factor defines the emit rate to affect to the specified gradient
  30174. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  30175. * @returns the current particle system
  30176. */
  30177. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  30178. /**
  30179. * Remove a specific emit rate gradient
  30180. * @param gradient defines the gradient to remove
  30181. * @returns the current particle system
  30182. */
  30183. removeEmitRateGradient(gradient: number): IParticleSystem;
  30184. /**
  30185. * Gets the current list of emit rate gradients.
  30186. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  30187. * @returns the list of emit rate gradients
  30188. */
  30189. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  30190. /**
  30191. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  30192. * @param gradient defines the gradient to use (between 0 and 1)
  30193. * @param factor defines the start size to affect to the specified gradient
  30194. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  30195. * @returns the current particle system
  30196. */
  30197. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  30198. /**
  30199. * Remove a specific start size gradient
  30200. * @param gradient defines the gradient to remove
  30201. * @returns the current particle system
  30202. */
  30203. removeStartSizeGradient(gradient: number): IParticleSystem;
  30204. /**
  30205. * Gets the current list of start size gradients.
  30206. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  30207. * @returns the list of start size gradients
  30208. */
  30209. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  30210. /**
  30211. * Adds a new life time gradient
  30212. * @param gradient defines the gradient to use (between 0 and 1)
  30213. * @param factor defines the life time factor to affect to the specified gradient
  30214. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  30215. * @returns the current particle system
  30216. */
  30217. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  30218. /**
  30219. * Remove a specific life time gradient
  30220. * @param gradient defines the gradient to remove
  30221. * @returns the current particle system
  30222. */
  30223. removeLifeTimeGradient(gradient: number): IParticleSystem;
  30224. /**
  30225. * Gets the current list of life time gradients.
  30226. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  30227. * @returns the list of life time gradients
  30228. */
  30229. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  30230. /**
  30231. * Gets the current list of color gradients.
  30232. * You must use addColorGradient and removeColorGradient to udpate this list
  30233. * @returns the list of color gradients
  30234. */
  30235. getColorGradients(): Nullable<Array<ColorGradient>>;
  30236. /**
  30237. * Adds a new ramp gradient used to remap particle colors
  30238. * @param gradient defines the gradient to use (between 0 and 1)
  30239. * @param color defines the color to affect to the specified gradient
  30240. * @returns the current particle system
  30241. */
  30242. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  30243. /**
  30244. * Gets the current list of ramp gradients.
  30245. * You must use addRampGradient and removeRampGradient to udpate this list
  30246. * @returns the list of ramp gradients
  30247. */
  30248. getRampGradients(): Nullable<Array<Color3Gradient>>;
  30249. /** Gets or sets a boolean indicating that ramp gradients must be used
  30250. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  30251. */
  30252. useRampGradients: boolean;
  30253. /**
  30254. * Adds a new color remap gradient
  30255. * @param gradient defines the gradient to use (between 0 and 1)
  30256. * @param min defines the color remap minimal range
  30257. * @param max defines the color remap maximal range
  30258. * @returns the current particle system
  30259. */
  30260. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  30261. /**
  30262. * Gets the current list of color remap gradients.
  30263. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  30264. * @returns the list of color remap gradients
  30265. */
  30266. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  30267. /**
  30268. * Adds a new alpha remap gradient
  30269. * @param gradient defines the gradient to use (between 0 and 1)
  30270. * @param min defines the alpha remap minimal range
  30271. * @param max defines the alpha remap maximal range
  30272. * @returns the current particle system
  30273. */
  30274. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  30275. /**
  30276. * Gets the current list of alpha remap gradients.
  30277. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  30278. * @returns the list of alpha remap gradients
  30279. */
  30280. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  30281. /**
  30282. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  30283. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  30284. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  30285. * @returns the emitter
  30286. */
  30287. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  30288. /**
  30289. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  30290. * @param radius The radius of the hemisphere to emit from
  30291. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  30292. * @returns the emitter
  30293. */
  30294. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  30295. /**
  30296. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  30297. * @param radius The radius of the sphere to emit from
  30298. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  30299. * @returns the emitter
  30300. */
  30301. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  30302. /**
  30303. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  30304. * @param radius The radius of the sphere to emit from
  30305. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  30306. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  30307. * @returns the emitter
  30308. */
  30309. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  30310. /**
  30311. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  30312. * @param radius The radius of the emission cylinder
  30313. * @param height The height of the emission cylinder
  30314. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  30315. * @param directionRandomizer How much to randomize the particle direction [0-1]
  30316. * @returns the emitter
  30317. */
  30318. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  30319. /**
  30320. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  30321. * @param radius The radius of the cylinder to emit from
  30322. * @param height The height of the emission cylinder
  30323. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  30324. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  30325. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  30326. * @returns the emitter
  30327. */
  30328. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  30329. /**
  30330. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  30331. * @param radius The radius of the cone to emit from
  30332. * @param angle The base angle of the cone
  30333. * @returns the emitter
  30334. */
  30335. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  30336. /**
  30337. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  30338. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  30339. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  30340. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  30341. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  30342. * @returns the emitter
  30343. */
  30344. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  30345. /**
  30346. * Get hosting scene
  30347. * @returns the scene
  30348. */
  30349. getScene(): Scene;
  30350. }
  30351. }
  30352. declare module BABYLON {
  30353. /**
  30354. * A particle represents one of the element emitted by a particle system.
  30355. * This is mainly define by its coordinates, direction, velocity and age.
  30356. */
  30357. class Particle {
  30358. /**
  30359. * The particle system the particle belongs to.
  30360. */
  30361. particleSystem: ParticleSystem;
  30362. private static _Count;
  30363. /**
  30364. * Unique ID of the particle
  30365. */
  30366. id: number;
  30367. /**
  30368. * The world position of the particle in the scene.
  30369. */
  30370. position: Vector3;
  30371. /**
  30372. * The world direction of the particle in the scene.
  30373. */
  30374. direction: Vector3;
  30375. /**
  30376. * The color of the particle.
  30377. */
  30378. color: Color4;
  30379. /**
  30380. * The color change of the particle per step.
  30381. */
  30382. colorStep: Color4;
  30383. /**
  30384. * Defines how long will the life of the particle be.
  30385. */
  30386. lifeTime: number;
  30387. /**
  30388. * The current age of the particle.
  30389. */
  30390. age: number;
  30391. /**
  30392. * The current size of the particle.
  30393. */
  30394. size: number;
  30395. /**
  30396. * The current scale of the particle.
  30397. */
  30398. scale: Vector2;
  30399. /**
  30400. * The current angle of the particle.
  30401. */
  30402. angle: number;
  30403. /**
  30404. * Defines how fast is the angle changing.
  30405. */
  30406. angularSpeed: number;
  30407. /**
  30408. * Defines the cell index used by the particle to be rendered from a sprite.
  30409. */
  30410. cellIndex: number;
  30411. /**
  30412. * The information required to support color remapping
  30413. */
  30414. remapData: Vector4;
  30415. /** @hidden */
  30416. /** @hidden */
  30417. /** @hidden */
  30418. /** @hidden */
  30419. /** @hidden */
  30420. /** @hidden */
  30421. /** @hidden */
  30422. /** @hidden */
  30423. /** @hidden */
  30424. /** @hidden */
  30425. /** @hidden */
  30426. /** @hidden */
  30427. /** @hidden */
  30428. /** @hidden */
  30429. /** @hidden */
  30430. /** @hidden */
  30431. /** @hidden */
  30432. /** @hidden */
  30433. /** @hidden */
  30434. /** @hidden */
  30435. /** @hidden */
  30436. /** @hidden */
  30437. /** @hidden */
  30438. /** @hidden */
  30439. /** @hidden */
  30440. /**
  30441. * Creates a new instance Particle
  30442. * @param particleSystem the particle system the particle belongs to
  30443. */
  30444. constructor(
  30445. /**
  30446. * The particle system the particle belongs to.
  30447. */
  30448. particleSystem: ParticleSystem);
  30449. private updateCellInfoFromSystem;
  30450. /**
  30451. * Defines how the sprite cell index is updated for the particle
  30452. */
  30453. updateCellIndex(): void;
  30454. /** @hidden */
  30455. /** @hidden */
  30456. /** @hidden */
  30457. /**
  30458. * Copy the properties of particle to another one.
  30459. * @param other the particle to copy the information to.
  30460. */
  30461. copyTo(other: Particle): void;
  30462. }
  30463. }
  30464. declare module BABYLON {
  30465. /**
  30466. * This class is made for on one-liner static method to help creating particle system set.
  30467. */
  30468. class ParticleHelper {
  30469. /**
  30470. * Gets or sets base Assets URL
  30471. */
  30472. static BaseAssetsUrl: string;
  30473. /**
  30474. * Create a default particle system that you can tweak
  30475. * @param emitter defines the emitter to use
  30476. * @param capacity defines the system capacity (default is 500 particles)
  30477. * @param scene defines the hosting scene
  30478. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  30479. * @returns the new Particle system
  30480. */
  30481. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  30482. /**
  30483. * This is the main static method (one-liner) of this helper to create different particle systems
  30484. * @param type This string represents the type to the particle system to create
  30485. * @param scene The scene where the particle system should live
  30486. * @param gpu If the system will use gpu
  30487. * @returns the ParticleSystemSet created
  30488. */
  30489. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  30490. /**
  30491. * Static function used to export a particle system to a ParticleSystemSet variable.
  30492. * Please note that the emitter shape is not exported
  30493. * @param systems defines the particle systems to export
  30494. * @returns the created particle system set
  30495. */
  30496. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  30497. }
  30498. }
  30499. declare module BABYLON {
  30500. /**
  30501. * This represents a particle system in Babylon.
  30502. * 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.
  30503. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  30504. * @example https://doc.babylonjs.com/babylon101/particles
  30505. */
  30506. class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  30507. /**
  30508. * Billboard mode will only apply to Y axis
  30509. */
  30510. static readonly BILLBOARDMODE_Y: number;
  30511. /**
  30512. * Billboard mode will apply to all axes
  30513. */
  30514. static readonly BILLBOARDMODE_ALL: number;
  30515. /**
  30516. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  30517. */
  30518. static readonly BILLBOARDMODE_STRETCHED: number;
  30519. /**
  30520. * This function can be defined to provide custom update for active particles.
  30521. * This function will be called instead of regular update (age, position, color, etc.).
  30522. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  30523. */
  30524. updateFunction: (particles: Particle[]) => void;
  30525. private _emitterWorldMatrix;
  30526. /**
  30527. * This function can be defined to specify initial direction for every new particle.
  30528. * It by default use the emitterType defined function
  30529. */
  30530. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  30531. /**
  30532. * This function can be defined to specify initial position for every new particle.
  30533. * It by default use the emitterType defined function
  30534. */
  30535. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  30536. /**
  30537. * @hidden
  30538. */
  30539. /**
  30540. * An event triggered when the system is disposed
  30541. */
  30542. onDisposeObservable: Observable<ParticleSystem>;
  30543. private _onDisposeObserver;
  30544. /**
  30545. * Sets a callback that will be triggered when the system is disposed
  30546. */
  30547. onDispose: () => void;
  30548. private _particles;
  30549. private _epsilon;
  30550. private _capacity;
  30551. private _stockParticles;
  30552. private _newPartsExcess;
  30553. private _vertexData;
  30554. private _vertexBuffer;
  30555. private _vertexBuffers;
  30556. private _spriteBuffer;
  30557. private _indexBuffer;
  30558. private _effect;
  30559. private _customEffect;
  30560. private _cachedDefines;
  30561. private _scaledColorStep;
  30562. private _colorDiff;
  30563. private _scaledDirection;
  30564. private _scaledGravity;
  30565. private _currentRenderId;
  30566. private _alive;
  30567. private _useInstancing;
  30568. private _started;
  30569. private _stopped;
  30570. private _actualFrame;
  30571. private _scaledUpdateSpeed;
  30572. private _vertexBufferSize;
  30573. /** @hidden */
  30574. /** @hidden */
  30575. /** @hidden */
  30576. /** @hidden */
  30577. /** @hidden */
  30578. /** @hidden */
  30579. private readonly _rawTextureWidth;
  30580. private _rampGradientsTexture;
  30581. private _useRampGradients;
  30582. /** Gets or sets a boolean indicating that ramp gradients must be used
  30583. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  30584. */
  30585. useRampGradients: boolean;
  30586. /**
  30587. * 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.
  30588. * 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: [])
  30589. */
  30590. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  30591. private _subEmitters;
  30592. /**
  30593. * @hidden
  30594. * If the particle systems emitter should be disposed when the particle system is disposed
  30595. */
  30596. /**
  30597. * The current active Sub-systems, this property is used by the root particle system only.
  30598. */
  30599. activeSubSystems: Array<ParticleSystem>;
  30600. private _rootParticleSystem;
  30601. /**
  30602. * Gets the current list of active particles
  30603. */
  30604. readonly particles: Particle[];
  30605. /**
  30606. * Returns the string "ParticleSystem"
  30607. * @returns a string containing the class name
  30608. */
  30609. getClassName(): string;
  30610. /**
  30611. * Instantiates a particle system.
  30612. * 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.
  30613. * @param name The name of the particle system
  30614. * @param capacity The max number of particles alive at the same time
  30615. * @param scene The scene the particle system belongs to
  30616. * @param customEffect a custom effect used to change the way particles are rendered by default
  30617. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  30618. * @param epsilon Offset used to render the particles
  30619. */
  30620. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  30621. private _addFactorGradient;
  30622. private _removeFactorGradient;
  30623. /**
  30624. * Adds a new life time gradient
  30625. * @param gradient defines the gradient to use (between 0 and 1)
  30626. * @param factor defines the life time factor to affect to the specified gradient
  30627. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  30628. * @returns the current particle system
  30629. */
  30630. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  30631. /**
  30632. * Remove a specific life time gradient
  30633. * @param gradient defines the gradient to remove
  30634. * @returns the current particle system
  30635. */
  30636. removeLifeTimeGradient(gradient: number): IParticleSystem;
  30637. /**
  30638. * Adds a new size gradient
  30639. * @param gradient defines the gradient to use (between 0 and 1)
  30640. * @param factor defines the size factor to affect to the specified gradient
  30641. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  30642. * @returns the current particle system
  30643. */
  30644. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  30645. /**
  30646. * Remove a specific size gradient
  30647. * @param gradient defines the gradient to remove
  30648. * @returns the current particle system
  30649. */
  30650. removeSizeGradient(gradient: number): IParticleSystem;
  30651. /**
  30652. * Adds a new color remap gradient
  30653. * @param gradient defines the gradient to use (between 0 and 1)
  30654. * @param min defines the color remap minimal range
  30655. * @param max defines the color remap maximal range
  30656. * @returns the current particle system
  30657. */
  30658. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  30659. /**
  30660. * Remove a specific color remap gradient
  30661. * @param gradient defines the gradient to remove
  30662. * @returns the current particle system
  30663. */
  30664. removeColorRemapGradient(gradient: number): IParticleSystem;
  30665. /**
  30666. * Adds a new alpha remap gradient
  30667. * @param gradient defines the gradient to use (between 0 and 1)
  30668. * @param min defines the alpha remap minimal range
  30669. * @param max defines the alpha remap maximal range
  30670. * @returns the current particle system
  30671. */
  30672. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  30673. /**
  30674. * Remove a specific alpha remap gradient
  30675. * @param gradient defines the gradient to remove
  30676. * @returns the current particle system
  30677. */
  30678. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  30679. /**
  30680. * Adds a new angular speed gradient
  30681. * @param gradient defines the gradient to use (between 0 and 1)
  30682. * @param factor defines the angular speed to affect to the specified gradient
  30683. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  30684. * @returns the current particle system
  30685. */
  30686. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  30687. /**
  30688. * Remove a specific angular speed gradient
  30689. * @param gradient defines the gradient to remove
  30690. * @returns the current particle system
  30691. */
  30692. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  30693. /**
  30694. * Adds a new velocity gradient
  30695. * @param gradient defines the gradient to use (between 0 and 1)
  30696. * @param factor defines the velocity to affect to the specified gradient
  30697. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  30698. * @returns the current particle system
  30699. */
  30700. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  30701. /**
  30702. * Remove a specific velocity gradient
  30703. * @param gradient defines the gradient to remove
  30704. * @returns the current particle system
  30705. */
  30706. removeVelocityGradient(gradient: number): IParticleSystem;
  30707. /**
  30708. * Adds a new limit velocity gradient
  30709. * @param gradient defines the gradient to use (between 0 and 1)
  30710. * @param factor defines the limit velocity value to affect to the specified gradient
  30711. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  30712. * @returns the current particle system
  30713. */
  30714. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  30715. /**
  30716. * Remove a specific limit velocity gradient
  30717. * @param gradient defines the gradient to remove
  30718. * @returns the current particle system
  30719. */
  30720. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  30721. /**
  30722. * Adds a new drag gradient
  30723. * @param gradient defines the gradient to use (between 0 and 1)
  30724. * @param factor defines the drag value to affect to the specified gradient
  30725. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  30726. * @returns the current particle system
  30727. */
  30728. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  30729. /**
  30730. * Remove a specific drag gradient
  30731. * @param gradient defines the gradient to remove
  30732. * @returns the current particle system
  30733. */
  30734. removeDragGradient(gradient: number): IParticleSystem;
  30735. /**
  30736. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  30737. * @param gradient defines the gradient to use (between 0 and 1)
  30738. * @param factor defines the emit rate value to affect to the specified gradient
  30739. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  30740. * @returns the current particle system
  30741. */
  30742. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  30743. /**
  30744. * Remove a specific emit rate gradient
  30745. * @param gradient defines the gradient to remove
  30746. * @returns the current particle system
  30747. */
  30748. removeEmitRateGradient(gradient: number): IParticleSystem;
  30749. /**
  30750. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  30751. * @param gradient defines the gradient to use (between 0 and 1)
  30752. * @param factor defines the start size value to affect to the specified gradient
  30753. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  30754. * @returns the current particle system
  30755. */
  30756. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  30757. /**
  30758. * Remove a specific start size gradient
  30759. * @param gradient defines the gradient to remove
  30760. * @returns the current particle system
  30761. */
  30762. removeStartSizeGradient(gradient: number): IParticleSystem;
  30763. private _createRampGradientTexture;
  30764. /**
  30765. * Gets the current list of ramp gradients.
  30766. * You must use addRampGradient and removeRampGradient to udpate this list
  30767. * @returns the list of ramp gradients
  30768. */
  30769. getRampGradients(): Nullable<Array<Color3Gradient>>;
  30770. /**
  30771. * Adds a new ramp gradient used to remap particle colors
  30772. * @param gradient defines the gradient to use (between 0 and 1)
  30773. * @param color defines the color to affect to the specified gradient
  30774. * @returns the current particle system
  30775. */
  30776. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  30777. /**
  30778. * Remove a specific ramp gradient
  30779. * @param gradient defines the gradient to remove
  30780. * @returns the current particle system
  30781. */
  30782. removeRampGradient(gradient: number): ParticleSystem;
  30783. /**
  30784. * Adds a new color gradient
  30785. * @param gradient defines the gradient to use (between 0 and 1)
  30786. * @param color1 defines the color to affect to the specified gradient
  30787. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  30788. * @returns this particle system
  30789. */
  30790. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  30791. /**
  30792. * Remove a specific color gradient
  30793. * @param gradient defines the gradient to remove
  30794. * @returns this particle system
  30795. */
  30796. removeColorGradient(gradient: number): IParticleSystem;
  30797. private _fetchR;
  30798. protected _reset(): void;
  30799. private _resetEffect;
  30800. private _createVertexBuffers;
  30801. private _createIndexBuffer;
  30802. /**
  30803. * Gets the maximum number of particles active at the same time.
  30804. * @returns The max number of active particles.
  30805. */
  30806. getCapacity(): number;
  30807. /**
  30808. * Gets whether there are still active particles in the system.
  30809. * @returns True if it is alive, otherwise false.
  30810. */
  30811. isAlive(): boolean;
  30812. /**
  30813. * Gets if the system has been started. (Note: this will still be true after stop is called)
  30814. * @returns True if it has been started, otherwise false.
  30815. */
  30816. isStarted(): boolean;
  30817. private _prepareSubEmitterInternalArray;
  30818. /**
  30819. * Starts the particle system and begins to emit
  30820. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  30821. */
  30822. start(delay?: number): void;
  30823. /**
  30824. * Stops the particle system.
  30825. * @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.
  30826. */
  30827. stop(stopSubEmitters?: boolean): void;
  30828. /**
  30829. * Remove all active particles
  30830. */
  30831. reset(): void;
  30832. /**
  30833. * @hidden (for internal use only)
  30834. */
  30835. /**
  30836. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  30837. * Its lifetime will start back at 0.
  30838. */
  30839. recycleParticle: (particle: Particle) => void;
  30840. private _stopSubEmitters;
  30841. private _createParticle;
  30842. private _removeFromRoot;
  30843. private _emitFromParticle;
  30844. private _update;
  30845. /** @hidden */
  30846. private static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  30847. /** @hidden */
  30848. private static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  30849. /** @hidden */
  30850. private _getEffect;
  30851. /**
  30852. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  30853. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  30854. */
  30855. animate(preWarmOnly?: boolean): void;
  30856. private _appendParticleVertices;
  30857. /**
  30858. * Rebuilds the particle system.
  30859. */
  30860. rebuild(): void;
  30861. /**
  30862. * Is this system ready to be used/rendered
  30863. * @return true if the system is ready
  30864. */
  30865. isReady(): boolean;
  30866. private _render;
  30867. /**
  30868. * Renders the particle system in its current state.
  30869. * @returns the current number of particles
  30870. */
  30871. render(): number;
  30872. /**
  30873. * Disposes the particle system and free the associated resources
  30874. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  30875. */
  30876. dispose(disposeTexture?: boolean): void;
  30877. /**
  30878. * Clones the particle system.
  30879. * @param name The name of the cloned object
  30880. * @param newEmitter The new emitter to use
  30881. * @returns the cloned particle system
  30882. */
  30883. clone(name: string, newEmitter: any): ParticleSystem;
  30884. /**
  30885. * Serializes the particle system to a JSON object.
  30886. * @returns the JSON object
  30887. */
  30888. serialize(): any;
  30889. /** @hidden */
  30890. private static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  30891. /** @hidden */
  30892. private static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  30893. /**
  30894. * Parses a JSON object to create a particle system.
  30895. * @param parsedParticleSystem The JSON object to parse
  30896. * @param scene The scene to create the particle system in
  30897. * @param rootUrl The root url to use to load external dependencies like texture
  30898. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  30899. * @returns the Parsed particle system
  30900. */
  30901. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  30902. }
  30903. }
  30904. declare module BABYLON {
  30905. interface Engine {
  30906. /**
  30907. * Create an effect to use with particle systems.
  30908. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  30909. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  30910. * @param uniformsNames defines a list of attribute names
  30911. * @param samplers defines an array of string used to represent textures
  30912. * @param defines defines the string containing the defines to use to compile the shaders
  30913. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  30914. * @param onCompiled defines a function to call when the effect creation is successful
  30915. * @param onError defines a function to call when the effect creation has failed
  30916. * @returns the new Effect
  30917. */
  30918. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  30919. }
  30920. interface Mesh {
  30921. /**
  30922. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  30923. * @returns an array of IParticleSystem
  30924. */
  30925. getEmittedParticleSystems(): IParticleSystem[];
  30926. /**
  30927. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  30928. * @returns an array of IParticleSystem
  30929. */
  30930. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  30931. }
  30932. }
  30933. declare module BABYLON {
  30934. /**
  30935. * Represents a set of particle systems working together to create a specific effect
  30936. */
  30937. class ParticleSystemSet implements IDisposable {
  30938. private _emitterCreationOptions;
  30939. private _emitterNode;
  30940. /**
  30941. * Gets the particle system list
  30942. */
  30943. systems: IParticleSystem[];
  30944. /**
  30945. * Gets the emitter node used with this set
  30946. */
  30947. readonly emitterNode: Nullable<TransformNode>;
  30948. /**
  30949. * Creates a new emitter mesh as a sphere
  30950. * @param options defines the options used to create the sphere
  30951. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  30952. * @param scene defines the hosting scene
  30953. */
  30954. setEmitterAsSphere(options: {
  30955. diameter: number;
  30956. segments: number;
  30957. color: Color3;
  30958. }, renderingGroupId: number, scene: Scene): void;
  30959. /**
  30960. * Starts all particle systems of the set
  30961. * @param emitter defines an optional mesh to use as emitter for the particle systems
  30962. */
  30963. start(emitter?: AbstractMesh): void;
  30964. /**
  30965. * Release all associated resources
  30966. */
  30967. dispose(): void;
  30968. /**
  30969. * Serialize the set into a JSON compatible object
  30970. * @returns a JSON compatible representation of the set
  30971. */
  30972. serialize(): any;
  30973. /**
  30974. * Parse a new ParticleSystemSet from a serialized source
  30975. * @param data defines a JSON compatible representation of the set
  30976. * @param scene defines the hosting scene
  30977. * @param gpu defines if we want GPU particles or CPU particles
  30978. * @returns a new ParticleSystemSet
  30979. */
  30980. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  30981. }
  30982. }
  30983. declare module BABYLON {
  30984. /**
  30985. * Represents one particle of a solid particle system.
  30986. */
  30987. class SolidParticle {
  30988. /**
  30989. * particle global index
  30990. */
  30991. idx: number;
  30992. /**
  30993. * The color of the particle
  30994. */
  30995. color: Nullable<Color4>;
  30996. /**
  30997. * The world space position of the particle.
  30998. */
  30999. position: Vector3;
  31000. /**
  31001. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  31002. */
  31003. rotation: Vector3;
  31004. /**
  31005. * The world space rotation quaternion of the particle.
  31006. */
  31007. rotationQuaternion: Nullable<Quaternion>;
  31008. /**
  31009. * The scaling of the particle.
  31010. */
  31011. scaling: Vector3;
  31012. /**
  31013. * The uvs of the particle.
  31014. */
  31015. uvs: Vector4;
  31016. /**
  31017. * The current speed of the particle.
  31018. */
  31019. velocity: Vector3;
  31020. /**
  31021. * The pivot point in the particle local space.
  31022. */
  31023. pivot: Vector3;
  31024. /**
  31025. * Must the particle be translated from its pivot point in its local space ?
  31026. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  31027. * Default : false
  31028. */
  31029. translateFromPivot: boolean;
  31030. /**
  31031. * Is the particle active or not ?
  31032. */
  31033. alive: boolean;
  31034. /**
  31035. * Is the particle visible or not ?
  31036. */
  31037. isVisible: boolean;
  31038. /**
  31039. * Index of this particle in the global "positions" array (Internal use)
  31040. * @hidden
  31041. */
  31042. /**
  31043. * @hidden Index of this particle in the global "indices" array (Internal use)
  31044. */
  31045. /**
  31046. * @hidden ModelShape of this particle (Internal use)
  31047. */
  31048. /**
  31049. * ModelShape id of this particle
  31050. */
  31051. shapeId: number;
  31052. /**
  31053. * Index of the particle in its shape id (Internal use)
  31054. */
  31055. idxInShape: number;
  31056. /**
  31057. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  31058. */
  31059. /**
  31060. * @hidden Particle BoundingInfo object (Internal use)
  31061. */
  31062. /**
  31063. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  31064. */
  31065. /**
  31066. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  31067. */
  31068. /**
  31069. * @hidden Last computed particle rotation matrix
  31070. */
  31071. /**
  31072. * Parent particle Id, if any.
  31073. * Default null.
  31074. */
  31075. parentId: Nullable<number>;
  31076. /**
  31077. * @hidden Internal global position in the SPS.
  31078. */
  31079. /**
  31080. * Creates a Solid Particle object.
  31081. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  31082. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  31083. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  31084. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  31085. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  31086. * @param shapeId (integer) is the model shape identifier in the SPS.
  31087. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  31088. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  31089. */
  31090. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  31091. /**
  31092. * Legacy support, changed scale to scaling
  31093. */
  31094. /**
  31095. * Legacy support, changed scale to scaling
  31096. */
  31097. scale: Vector3;
  31098. /**
  31099. * Legacy support, changed quaternion to rotationQuaternion
  31100. */
  31101. /**
  31102. * Legacy support, changed quaternion to rotationQuaternion
  31103. */
  31104. quaternion: Nullable<Quaternion>;
  31105. /**
  31106. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  31107. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  31108. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  31109. * @returns true if it intersects
  31110. */
  31111. intersectsMesh(target: Mesh | SolidParticle): boolean;
  31112. }
  31113. /**
  31114. * Represents the shape of the model used by one particle of a solid particle system.
  31115. * SPS internal tool, don't use it manually.
  31116. */
  31117. class ModelShape {
  31118. /**
  31119. * The shape id
  31120. * @hidden
  31121. */
  31122. shapeID: number;
  31123. /**
  31124. * flat array of model positions (internal use)
  31125. * @hidden
  31126. */
  31127. /**
  31128. * flat array of model UVs (internal use)
  31129. * @hidden
  31130. */
  31131. /**
  31132. * length of the shape in the model indices array (internal use)
  31133. * @hidden
  31134. */
  31135. /**
  31136. * Custom position function (internal use)
  31137. * @hidden
  31138. */
  31139. /**
  31140. * Custom vertex function (internal use)
  31141. * @hidden
  31142. */
  31143. /**
  31144. * 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.
  31145. * SPS internal tool, don't use it manually.
  31146. * @hidden
  31147. */
  31148. 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>);
  31149. }
  31150. /**
  31151. * Represents a Depth Sorted Particle in the solid particle system.
  31152. */
  31153. class DepthSortedParticle {
  31154. /**
  31155. * Index of the particle in the "indices" array
  31156. */
  31157. ind: number;
  31158. /**
  31159. * Length of the particle shape in the "indices" array
  31160. */
  31161. indicesLength: number;
  31162. /**
  31163. * Squared distance from the particle to the camera
  31164. */
  31165. sqDistance: number;
  31166. }
  31167. }
  31168. declare module BABYLON {
  31169. /**
  31170. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  31171. *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.
  31172. * The SPS is also a particle system. It provides some methods to manage the particles.
  31173. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  31174. *
  31175. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  31176. */
  31177. class SolidParticleSystem implements IDisposable {
  31178. /**
  31179. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  31180. * Example : var p = SPS.particles[i];
  31181. */
  31182. particles: SolidParticle[];
  31183. /**
  31184. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  31185. */
  31186. nbParticles: number;
  31187. /**
  31188. * If the particles must ever face the camera (default false). Useful for planar particles.
  31189. */
  31190. billboard: boolean;
  31191. /**
  31192. * Recompute normals when adding a shape
  31193. */
  31194. recomputeNormals: boolean;
  31195. /**
  31196. * This a counter ofr your own usage. It's not set by any SPS functions.
  31197. */
  31198. counter: number;
  31199. /**
  31200. * The SPS name. This name is also given to the underlying mesh.
  31201. */
  31202. name: string;
  31203. /**
  31204. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  31205. */
  31206. mesh: Mesh;
  31207. /**
  31208. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  31209. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  31210. */
  31211. vars: any;
  31212. /**
  31213. * This array is populated when the SPS is set as 'pickable'.
  31214. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  31215. * Each element of this array is an object `{idx: int, faceId: int}`.
  31216. * `idx` is the picked particle index in the `SPS.particles` array
  31217. * `faceId` is the picked face index counted within this particle.
  31218. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  31219. */
  31220. pickedParticles: {
  31221. idx: number;
  31222. faceId: number;
  31223. }[];
  31224. /**
  31225. * This array is populated when `enableDepthSort` is set to true.
  31226. * Each element of this array is an instance of the class DepthSortedParticle.
  31227. */
  31228. depthSortedParticles: DepthSortedParticle[];
  31229. /**
  31230. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  31231. * @hidden
  31232. */
  31233. /**
  31234. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  31235. * @hidden
  31236. */
  31237. private _scene;
  31238. private _positions;
  31239. private _indices;
  31240. private _normals;
  31241. private _colors;
  31242. private _uvs;
  31243. private _indices32;
  31244. private _positions32;
  31245. private _normals32;
  31246. private _fixedNormal32;
  31247. private _colors32;
  31248. private _uvs32;
  31249. private _index;
  31250. private _updatable;
  31251. private _pickable;
  31252. private _isVisibilityBoxLocked;
  31253. private _alwaysVisible;
  31254. private _depthSort;
  31255. private _shapeCounter;
  31256. private _copy;
  31257. private _shape;
  31258. private _shapeUV;
  31259. private _color;
  31260. private _computeParticleColor;
  31261. private _computeParticleTexture;
  31262. private _computeParticleRotation;
  31263. private _computeParticleVertex;
  31264. private _computeBoundingBox;
  31265. private _depthSortParticles;
  31266. private _cam_axisZ;
  31267. private _cam_axisY;
  31268. private _cam_axisX;
  31269. private _axisZ;
  31270. private _camera;
  31271. private _particle;
  31272. private _camDir;
  31273. private _camInvertedPosition;
  31274. private _rotMatrix;
  31275. private _invertMatrix;
  31276. private _rotated;
  31277. private _quaternion;
  31278. private _vertex;
  31279. private _normal;
  31280. private _yaw;
  31281. private _pitch;
  31282. private _roll;
  31283. private _halfroll;
  31284. private _halfpitch;
  31285. private _halfyaw;
  31286. private _sinRoll;
  31287. private _cosRoll;
  31288. private _sinPitch;
  31289. private _cosPitch;
  31290. private _sinYaw;
  31291. private _cosYaw;
  31292. private _mustUnrotateFixedNormals;
  31293. private _minimum;
  31294. private _maximum;
  31295. private _minBbox;
  31296. private _maxBbox;
  31297. private _particlesIntersect;
  31298. private _depthSortFunction;
  31299. private _needs32Bits;
  31300. private _pivotBackTranslation;
  31301. private _scaledPivot;
  31302. private _particleHasParent;
  31303. private _parent;
  31304. /**
  31305. * Creates a SPS (Solid Particle System) object.
  31306. * @param name (String) is the SPS name, this will be the underlying mesh name.
  31307. * @param scene (Scene) is the scene in which the SPS is added.
  31308. * @param updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  31309. * @param isPickable (optional boolean, default false) : if the solid particles must be pickable.
  31310. * @param enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  31311. * @param particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  31312. * @param boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  31313. * @param bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  31314. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  31315. */
  31316. constructor(name: string, scene: Scene, options?: {
  31317. updatable?: boolean;
  31318. isPickable?: boolean;
  31319. enableDepthSort?: boolean;
  31320. particleIntersection?: boolean;
  31321. boundingSphereOnly?: boolean;
  31322. bSphereRadiusFactor?: number;
  31323. });
  31324. /**
  31325. * Builds the SPS underlying mesh. Returns a standard Mesh.
  31326. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  31327. * @returns the created mesh
  31328. */
  31329. buildMesh(): Mesh;
  31330. /**
  31331. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  31332. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  31333. * Thus the particles generated from `digest()` have their property `position` set yet.
  31334. * @param mesh ( Mesh ) is the mesh to be digested
  31335. * @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
  31336. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  31337. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  31338. * @returns the current SPS
  31339. */
  31340. digest(mesh: Mesh, options?: {
  31341. facetNb?: number;
  31342. number?: number;
  31343. delta?: number;
  31344. }): SolidParticleSystem;
  31345. private _unrotateFixedNormals;
  31346. private _resetCopy;
  31347. private _meshBuilder;
  31348. private _posToShape;
  31349. private _uvsToShapeUV;
  31350. private _addParticle;
  31351. /**
  31352. * Adds some particles to the SPS from the model shape. Returns the shape id.
  31353. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  31354. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  31355. * @param nb (positive integer) the number of particles to be created from this model
  31356. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  31357. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  31358. * @returns the number of shapes in the system
  31359. */
  31360. addShape(mesh: Mesh, nb: number, options?: {
  31361. positionFunction?: any;
  31362. vertexFunction?: any;
  31363. }): number;
  31364. private _rebuildParticle;
  31365. /**
  31366. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  31367. * @returns the SPS.
  31368. */
  31369. rebuildMesh(): SolidParticleSystem;
  31370. /**
  31371. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  31372. * This method calls `updateParticle()` for each particle of the SPS.
  31373. * For an animated SPS, it is usually called within the render loop.
  31374. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  31375. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  31376. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  31377. * @returns the SPS.
  31378. */
  31379. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  31380. private _quaternionRotationYPR;
  31381. private _quaternionToRotationMatrix;
  31382. /**
  31383. * Disposes the SPS.
  31384. */
  31385. dispose(): void;
  31386. /**
  31387. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  31388. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  31389. * @returns the SPS.
  31390. */
  31391. refreshVisibleSize(): SolidParticleSystem;
  31392. /**
  31393. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  31394. * @param size the size (float) of the visibility box
  31395. * note : this doesn't lock the SPS mesh bounding box.
  31396. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  31397. */
  31398. setVisibilityBox(size: number): void;
  31399. /**
  31400. * Gets whether the SPS as always visible or not
  31401. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  31402. */
  31403. /**
  31404. * Sets the SPS as always visible or not
  31405. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  31406. */
  31407. isAlwaysVisible: boolean;
  31408. /**
  31409. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  31410. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  31411. */
  31412. /**
  31413. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  31414. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  31415. */
  31416. isVisibilityBoxLocked: boolean;
  31417. /**
  31418. * Tells to `setParticles()` to compute the particle rotations or not.
  31419. * Default value : true. The SPS is faster when it's set to false.
  31420. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  31421. */
  31422. /**
  31423. * Gets if `setParticles()` computes the particle rotations or not.
  31424. * Default value : true. The SPS is faster when it's set to false.
  31425. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  31426. */
  31427. computeParticleRotation: boolean;
  31428. /**
  31429. * Tells to `setParticles()` to compute the particle colors or not.
  31430. * Default value : true. The SPS is faster when it's set to false.
  31431. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  31432. */
  31433. /**
  31434. * Gets if `setParticles()` computes the particle colors or not.
  31435. * Default value : true. The SPS is faster when it's set to false.
  31436. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  31437. */
  31438. computeParticleColor: boolean;
  31439. /**
  31440. * Gets if `setParticles()` computes the particle textures or not.
  31441. * Default value : true. The SPS is faster when it's set to false.
  31442. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  31443. */
  31444. computeParticleTexture: boolean;
  31445. /**
  31446. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  31447. * Default value : false. The SPS is faster when it's set to false.
  31448. * Note : the particle custom vertex positions aren't stored values.
  31449. */
  31450. /**
  31451. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  31452. * Default value : false. The SPS is faster when it's set to false.
  31453. * Note : the particle custom vertex positions aren't stored values.
  31454. */
  31455. computeParticleVertex: boolean;
  31456. /**
  31457. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  31458. */
  31459. /**
  31460. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  31461. */
  31462. computeBoundingBox: boolean;
  31463. /**
  31464. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  31465. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  31466. * Default : `true`
  31467. */
  31468. /**
  31469. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  31470. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  31471. * Default : `true`
  31472. */
  31473. depthSortParticles: boolean;
  31474. /**
  31475. * This function does nothing. It may be overwritten to set all the particle first values.
  31476. * The SPS doesn't call this function, you may have to call it by your own.
  31477. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  31478. */
  31479. initParticles(): void;
  31480. /**
  31481. * This function does nothing. It may be overwritten to recycle a particle.
  31482. * The SPS doesn't call this function, you may have to call it by your own.
  31483. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  31484. * @param particle The particle to recycle
  31485. * @returns the recycled particle
  31486. */
  31487. recycleParticle(particle: SolidParticle): SolidParticle;
  31488. /**
  31489. * Updates a particle : this function should be overwritten by the user.
  31490. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  31491. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  31492. * @example : just set a particle position or velocity and recycle conditions
  31493. * @param particle The particle to update
  31494. * @returns the updated particle
  31495. */
  31496. updateParticle(particle: SolidParticle): SolidParticle;
  31497. /**
  31498. * Updates a vertex of a particle : it can be overwritten by the user.
  31499. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  31500. * @param particle the current particle
  31501. * @param vertex the current index of the current particle
  31502. * @param pt the index of the current vertex in the particle shape
  31503. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  31504. * @example : just set a vertex particle position
  31505. * @returns the updated vertex
  31506. */
  31507. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  31508. /**
  31509. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  31510. * This does nothing and may be overwritten by the user.
  31511. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31512. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31513. * @param update the boolean update value actually passed to setParticles()
  31514. */
  31515. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  31516. /**
  31517. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  31518. * This will be passed three parameters.
  31519. * This does nothing and may be overwritten by the user.
  31520. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31521. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31522. * @param update the boolean update value actually passed to setParticles()
  31523. */
  31524. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  31525. }
  31526. }
  31527. declare module BABYLON {
  31528. /**
  31529. * Type of sub emitter
  31530. */
  31531. enum SubEmitterType {
  31532. /**
  31533. * Attached to the particle over it's lifetime
  31534. */
  31535. ATTACHED = 0,
  31536. /**
  31537. * Created when the particle dies
  31538. */
  31539. END = 1
  31540. }
  31541. /**
  31542. * Sub emitter class used to emit particles from an existing particle
  31543. */
  31544. class SubEmitter {
  31545. /**
  31546. * the particle system to be used by the sub emitter
  31547. */
  31548. particleSystem: ParticleSystem;
  31549. /**
  31550. * Type of the submitter (Default: END)
  31551. */
  31552. type: SubEmitterType;
  31553. /**
  31554. * 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)
  31555. * Note: This only is supported when using an emitter of type Mesh
  31556. */
  31557. inheritDirection: boolean;
  31558. /**
  31559. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  31560. */
  31561. inheritedVelocityAmount: number;
  31562. /**
  31563. * Creates a sub emitter
  31564. * @param particleSystem the particle system to be used by the sub emitter
  31565. */
  31566. constructor(
  31567. /**
  31568. * the particle system to be used by the sub emitter
  31569. */
  31570. particleSystem: ParticleSystem);
  31571. /**
  31572. * Clones the sub emitter
  31573. * @returns the cloned sub emitter
  31574. */
  31575. clone(): SubEmitter;
  31576. /**
  31577. * Serialize current object to a JSON object
  31578. * @returns the serialized object
  31579. */
  31580. serialize(): any;
  31581. /**
  31582. * Creates a new SubEmitter from a serialized JSON version
  31583. * @param serializationObject defines the JSON object to read from
  31584. * @param scene defines the hosting scene
  31585. * @param rootUrl defines the rootUrl for data loading
  31586. * @returns a new SubEmitter
  31587. */
  31588. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  31589. /** Release associated resources */
  31590. dispose(): void;
  31591. }
  31592. }
  31593. declare module BABYLON {
  31594. /**
  31595. * Interface used to describe a physics joint
  31596. */
  31597. interface PhysicsImpostorJoint {
  31598. /** Defines the main impostor to which the joint is linked */
  31599. mainImpostor: PhysicsImpostor;
  31600. /** Defines the impostor that is connected to the main impostor using this joint */
  31601. connectedImpostor: PhysicsImpostor;
  31602. /** Defines the joint itself */
  31603. joint: PhysicsJoint;
  31604. }
  31605. /** @hidden */
  31606. interface IPhysicsEnginePlugin {
  31607. world: any;
  31608. name: string;
  31609. setGravity(gravity: Vector3): void;
  31610. setTimeStep(timeStep: number): void;
  31611. getTimeStep(): number;
  31612. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  31613. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  31614. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  31615. generatePhysicsBody(impostor: PhysicsImpostor): void;
  31616. removePhysicsBody(impostor: PhysicsImpostor): void;
  31617. generateJoint(joint: PhysicsImpostorJoint): void;
  31618. removeJoint(joint: PhysicsImpostorJoint): void;
  31619. isSupported(): boolean;
  31620. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  31621. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  31622. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  31623. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  31624. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  31625. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  31626. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  31627. getBodyMass(impostor: PhysicsImpostor): number;
  31628. getBodyFriction(impostor: PhysicsImpostor): number;
  31629. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  31630. getBodyRestitution(impostor: PhysicsImpostor): number;
  31631. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  31632. sleepBody(impostor: PhysicsImpostor): void;
  31633. wakeUpBody(impostor: PhysicsImpostor): void;
  31634. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  31635. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  31636. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  31637. getRadius(impostor: PhysicsImpostor): number;
  31638. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  31639. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  31640. dispose(): void;
  31641. }
  31642. /**
  31643. * Interface used to define a physics engine
  31644. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  31645. */
  31646. interface IPhysicsEngine {
  31647. /**
  31648. * Gets the gravity vector used by the simulation
  31649. */
  31650. gravity: Vector3;
  31651. /**
  31652. * Sets the gravity vector used by the simulation
  31653. * @param gravity defines the gravity vector to use
  31654. */
  31655. setGravity(gravity: Vector3): void;
  31656. /**
  31657. * Set the time step of the physics engine.
  31658. * Default is 1/60.
  31659. * To slow it down, enter 1/600 for example.
  31660. * To speed it up, 1/30
  31661. * @param newTimeStep the new timestep to apply to this world.
  31662. */
  31663. setTimeStep(newTimeStep: number): void;
  31664. /**
  31665. * Get the time step of the physics engine.
  31666. * @returns the current time step
  31667. */
  31668. getTimeStep(): number;
  31669. /**
  31670. * Release all resources
  31671. */
  31672. dispose(): void;
  31673. /**
  31674. * Gets the name of the current physics plugin
  31675. * @returns the name of the plugin
  31676. */
  31677. getPhysicsPluginName(): string;
  31678. /**
  31679. * Adding a new impostor for the impostor tracking.
  31680. * This will be done by the impostor itself.
  31681. * @param impostor the impostor to add
  31682. */
  31683. addImpostor(impostor: PhysicsImpostor): void;
  31684. /**
  31685. * Remove an impostor from the engine.
  31686. * This impostor and its mesh will not longer be updated by the physics engine.
  31687. * @param impostor the impostor to remove
  31688. */
  31689. removeImpostor(impostor: PhysicsImpostor): void;
  31690. /**
  31691. * Add a joint to the physics engine
  31692. * @param mainImpostor defines the main impostor to which the joint is added.
  31693. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  31694. * @param joint defines the joint that will connect both impostors.
  31695. */
  31696. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  31697. /**
  31698. * Removes a joint from the simulation
  31699. * @param mainImpostor defines the impostor used with the joint
  31700. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  31701. * @param joint defines the joint to remove
  31702. */
  31703. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  31704. /**
  31705. * Gets the current plugin used to run the simulation
  31706. * @returns current plugin
  31707. */
  31708. getPhysicsPlugin(): IPhysicsEnginePlugin;
  31709. /**
  31710. * Gets the list of physic impostors
  31711. * @returns an array of PhysicsImpostor
  31712. */
  31713. getImpostors(): Array<PhysicsImpostor>;
  31714. /**
  31715. * Gets the impostor for a physics enabled object
  31716. * @param object defines the object impersonated by the impostor
  31717. * @returns the PhysicsImpostor or null if not found
  31718. */
  31719. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  31720. /**
  31721. * Gets the impostor for a physics body object
  31722. * @param body defines physics body used by the impostor
  31723. * @returns the PhysicsImpostor or null if not found
  31724. */
  31725. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  31726. /**
  31727. * Called by the scene. No need to call it.
  31728. * @param delta defines the timespam between frames
  31729. */
  31730. }
  31731. }
  31732. declare module BABYLON {
  31733. /**
  31734. * Class used to control physics engine
  31735. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  31736. */
  31737. class PhysicsEngine implements IPhysicsEngine {
  31738. private _physicsPlugin;
  31739. /**
  31740. * Global value used to control the smallest number supported by the simulation
  31741. */
  31742. static Epsilon: number;
  31743. private _impostors;
  31744. private _joints;
  31745. /**
  31746. * Gets the gravity vector used by the simulation
  31747. */
  31748. gravity: Vector3;
  31749. /**
  31750. * Creates a new Physics Engine
  31751. * @param gravity defines the gravity vector used by the simulation
  31752. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  31753. */
  31754. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  31755. /**
  31756. * Sets the gravity vector used by the simulation
  31757. * @param gravity defines the gravity vector to use
  31758. */
  31759. setGravity(gravity: Vector3): void;
  31760. /**
  31761. * Set the time step of the physics engine.
  31762. * Default is 1/60.
  31763. * To slow it down, enter 1/600 for example.
  31764. * To speed it up, 1/30
  31765. * @param newTimeStep defines the new timestep to apply to this world.
  31766. */
  31767. setTimeStep(newTimeStep?: number): void;
  31768. /**
  31769. * Get the time step of the physics engine.
  31770. * @returns the current time step
  31771. */
  31772. getTimeStep(): number;
  31773. /**
  31774. * Release all resources
  31775. */
  31776. dispose(): void;
  31777. /**
  31778. * Gets the name of the current physics plugin
  31779. * @returns the name of the plugin
  31780. */
  31781. getPhysicsPluginName(): string;
  31782. /**
  31783. * Adding a new impostor for the impostor tracking.
  31784. * This will be done by the impostor itself.
  31785. * @param impostor the impostor to add
  31786. */
  31787. addImpostor(impostor: PhysicsImpostor): void;
  31788. /**
  31789. * Remove an impostor from the engine.
  31790. * This impostor and its mesh will not longer be updated by the physics engine.
  31791. * @param impostor the impostor to remove
  31792. */
  31793. removeImpostor(impostor: PhysicsImpostor): void;
  31794. /**
  31795. * Add a joint to the physics engine
  31796. * @param mainImpostor defines the main impostor to which the joint is added.
  31797. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  31798. * @param joint defines the joint that will connect both impostors.
  31799. */
  31800. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  31801. /**
  31802. * Removes a joint from the simulation
  31803. * @param mainImpostor defines the impostor used with the joint
  31804. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  31805. * @param joint defines the joint to remove
  31806. */
  31807. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  31808. /**
  31809. * Called by the scene. No need to call it.
  31810. * @param delta defines the timespam between frames
  31811. */
  31812. /**
  31813. * Gets the current plugin used to run the simulation
  31814. * @returns current plugin
  31815. */
  31816. getPhysicsPlugin(): IPhysicsEnginePlugin;
  31817. /**
  31818. * Gets the list of physic impostors
  31819. * @returns an array of PhysicsImpostor
  31820. */
  31821. getImpostors(): Array<PhysicsImpostor>;
  31822. /**
  31823. * Gets the impostor for a physics enabled object
  31824. * @param object defines the object impersonated by the impostor
  31825. * @returns the PhysicsImpostor or null if not found
  31826. */
  31827. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  31828. /**
  31829. * Gets the impostor for a physics body object
  31830. * @param body defines physics body used by the impostor
  31831. * @returns the PhysicsImpostor or null if not found
  31832. */
  31833. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  31834. }
  31835. }
  31836. declare module BABYLON {
  31837. interface Scene {
  31838. /** @hidden (Backing field) */
  31839. /**
  31840. * Gets the current physics engine
  31841. * @returns a IPhysicsEngine or null if none attached
  31842. */
  31843. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  31844. /**
  31845. * Enables physics to the current scene
  31846. * @param gravity defines the scene's gravity for the physics engine
  31847. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  31848. * @return a boolean indicating if the physics engine was initialized
  31849. */
  31850. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  31851. /**
  31852. * Disables and disposes the physics engine associated with the scene
  31853. */
  31854. disablePhysicsEngine(): void;
  31855. /**
  31856. * Gets a boolean indicating if there is an active physics engine
  31857. * @returns a boolean indicating if there is an active physics engine
  31858. */
  31859. isPhysicsEnabled(): boolean;
  31860. /**
  31861. * Deletes a physics compound impostor
  31862. * @param compound defines the compound to delete
  31863. */
  31864. deleteCompoundImpostor(compound: any): void;
  31865. /**
  31866. * An event triggered when physic simulation is about to be run
  31867. */
  31868. onBeforePhysicsObservable: Observable<Scene>;
  31869. /**
  31870. * An event triggered when physic simulation has been done
  31871. */
  31872. onAfterPhysicsObservable: Observable<Scene>;
  31873. }
  31874. interface AbstractMesh {
  31875. /** @hidden */
  31876. /**
  31877. * Gets or sets impostor used for physic simulation
  31878. * @see http://doc.babylonjs.com/features/physics_engine
  31879. */
  31880. physicsImpostor: Nullable<PhysicsImpostor>;
  31881. /**
  31882. * Gets the current physics impostor
  31883. * @see http://doc.babylonjs.com/features/physics_engine
  31884. * @returns a physics impostor or null
  31885. */
  31886. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  31887. /** Apply a physic impulse to the mesh
  31888. * @param force defines the force to apply
  31889. * @param contactPoint defines where to apply the force
  31890. * @returns the current mesh
  31891. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  31892. */
  31893. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  31894. /**
  31895. * Creates a physic joint between two meshes
  31896. * @param otherMesh defines the other mesh to use
  31897. * @param pivot1 defines the pivot to use on this mesh
  31898. * @param pivot2 defines the pivot to use on the other mesh
  31899. * @param options defines additional options (can be plugin dependent)
  31900. * @returns the current mesh
  31901. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  31902. */
  31903. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  31904. /** @hidden */
  31905. }
  31906. /**
  31907. * Defines the physics engine scene component responsible to manage a physics engine
  31908. */
  31909. class PhysicsEngineSceneComponent implements ISceneComponent {
  31910. /**
  31911. * The component name helpful to identify the component in the list of scene components.
  31912. */
  31913. readonly name: string;
  31914. /**
  31915. * The scene the component belongs to.
  31916. */
  31917. scene: Scene;
  31918. /**
  31919. * Creates a new instance of the component for the given scene
  31920. * @param scene Defines the scene to register the component in
  31921. */
  31922. constructor(scene: Scene);
  31923. /**
  31924. * Registers the component in a given scene
  31925. */
  31926. register(): void;
  31927. /**
  31928. * Rebuilds the elements related to this component in case of
  31929. * context lost for instance.
  31930. */
  31931. rebuild(): void;
  31932. /**
  31933. * Disposes the component and the associated ressources
  31934. */
  31935. dispose(): void;
  31936. }
  31937. }
  31938. declare module BABYLON {
  31939. /**
  31940. * A helper for physics simulations
  31941. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31942. */
  31943. class PhysicsHelper {
  31944. private _scene;
  31945. private _physicsEngine;
  31946. /**
  31947. * Initializes the Physics helper
  31948. * @param scene Babylon.js scene
  31949. */
  31950. constructor(scene: Scene);
  31951. /**
  31952. * Applies a radial explosion impulse
  31953. * @param origin the origin of the explosion
  31954. * @param radius the explosion radius
  31955. * @param strength the explosion strength
  31956. * @param falloff possible options: Constant & Linear. Defaults to Constant
  31957. * @returns A physics radial explosion event, or null
  31958. */
  31959. applyRadialExplosionImpulse(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  31960. /**
  31961. * Applies a radial explosion force
  31962. * @param origin the origin of the explosion
  31963. * @param radius the explosion radius
  31964. * @param strength the explosion strength
  31965. * @param falloff possible options: Constant & Linear. Defaults to Constant
  31966. * @returns A physics radial explosion event, or null
  31967. */
  31968. applyRadialExplosionForce(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  31969. /**
  31970. * Creates a gravitational field
  31971. * @param origin the origin of the explosion
  31972. * @param radius the explosion radius
  31973. * @param strength the explosion strength
  31974. * @param falloff possible options: Constant & Linear. Defaults to Constant
  31975. * @returns A physics gravitational field event, or null
  31976. */
  31977. gravitationalField(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  31978. /**
  31979. * Creates a physics updraft event
  31980. * @param origin the origin of the updraft
  31981. * @param radius the radius of the updraft
  31982. * @param strength the strength of the updraft
  31983. * @param height the height of the updraft
  31984. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  31985. * @returns A physics updraft event, or null
  31986. */
  31987. updraft(origin: Vector3, radius: number, strength: number, height: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  31988. /**
  31989. * Creates a physics vortex event
  31990. * @param origin the of the vortex
  31991. * @param radius the radius of the vortex
  31992. * @param strength the strength of the vortex
  31993. * @param height the height of the vortex
  31994. * @returns a Physics vortex event, or null
  31995. * A physics vortex event or null
  31996. */
  31997. vortex(origin: Vector3, radius: number, strength: number, height: number): Nullable<PhysicsVortexEvent>;
  31998. }
  31999. /**
  32000. * Represents a physics radial explosion event
  32001. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32002. */
  32003. class PhysicsRadialExplosionEvent {
  32004. private _scene;
  32005. private _sphere;
  32006. private _sphereOptions;
  32007. private _rays;
  32008. private _dataFetched;
  32009. /**
  32010. * Initializes a radial explosioin event
  32011. * @param scene BabylonJS scene
  32012. */
  32013. constructor(scene: Scene);
  32014. /**
  32015. * Returns the data related to the radial explosion event (sphere & rays).
  32016. * @returns The radial explosion event data
  32017. */
  32018. getData(): PhysicsRadialExplosionEventData;
  32019. /**
  32020. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  32021. * @param impostor A physics imposter
  32022. * @param origin the origin of the explosion
  32023. * @param radius the explosion radius
  32024. * @param strength the explosion strength
  32025. * @param falloff possible options: Constant & Linear
  32026. * @returns {Nullable<PhysicsForceAndContactPoint>} A physics force and contact point, or null
  32027. */
  32028. getImpostorForceAndContactPoint(impostor: PhysicsImpostor, origin: Vector3, radius: number, strength: number, falloff: PhysicsRadialImpulseFalloff): Nullable<PhysicsForceAndContactPoint>;
  32029. /**
  32030. * Disposes the sphere.
  32031. * @param force Specifies if the sphere should be disposed by force
  32032. */
  32033. dispose(force?: boolean): void;
  32034. /*** Helpers ***/
  32035. private _prepareSphere;
  32036. private _intersectsWithSphere;
  32037. }
  32038. /**
  32039. * Represents a gravitational field event
  32040. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32041. */
  32042. class PhysicsGravitationalFieldEvent {
  32043. private _physicsHelper;
  32044. private _scene;
  32045. private _origin;
  32046. private _radius;
  32047. private _strength;
  32048. private _falloff;
  32049. private _tickCallback;
  32050. private _sphere;
  32051. private _dataFetched;
  32052. /**
  32053. * Initializes the physics gravitational field event
  32054. * @param physicsHelper A physics helper
  32055. * @param scene BabylonJS scene
  32056. * @param origin The origin position of the gravitational field event
  32057. * @param radius The radius of the gravitational field event
  32058. * @param strength The strength of the gravitational field event
  32059. * @param falloff The falloff for the gravitational field event
  32060. */
  32061. constructor(physicsHelper: PhysicsHelper, scene: Scene, origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff);
  32062. /**
  32063. * Returns the data related to the gravitational field event (sphere).
  32064. * @returns A gravitational field event
  32065. */
  32066. getData(): PhysicsGravitationalFieldEventData;
  32067. /**
  32068. * Enables the gravitational field.
  32069. */
  32070. enable(): void;
  32071. /**
  32072. * Disables the gravitational field.
  32073. */
  32074. disable(): void;
  32075. /**
  32076. * Disposes the sphere.
  32077. * @param force The force to dispose from the gravitational field event
  32078. */
  32079. dispose(force?: boolean): void;
  32080. private _tick;
  32081. }
  32082. /**
  32083. * Represents a physics updraft event
  32084. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32085. */
  32086. class PhysicsUpdraftEvent {
  32087. private _scene;
  32088. private _origin;
  32089. private _radius;
  32090. private _strength;
  32091. private _height;
  32092. private _updraftMode;
  32093. private _physicsEngine;
  32094. private _originTop;
  32095. private _originDirection;
  32096. private _tickCallback;
  32097. private _cylinder;
  32098. private _cylinderPosition;
  32099. private _dataFetched;
  32100. /**
  32101. * Initializes the physics updraft event
  32102. * @param _scene BabylonJS scene
  32103. * @param _origin The origin position of the updraft
  32104. * @param _radius The radius of the updraft
  32105. * @param _strength The strength of the updraft
  32106. * @param _height The height of the updraft
  32107. * @param _updraftMode The mode of the updraft
  32108. */
  32109. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number, _updraftMode: PhysicsUpdraftMode);
  32110. /**
  32111. * Returns the data related to the updraft event (cylinder).
  32112. * @returns A physics updraft event
  32113. */
  32114. getData(): PhysicsUpdraftEventData;
  32115. /**
  32116. * Enables the updraft.
  32117. */
  32118. enable(): void;
  32119. /**
  32120. * Disables the cortex.
  32121. */
  32122. disable(): void;
  32123. /**
  32124. * Disposes the sphere.
  32125. * @param force Specifies if the updraft should be disposed by force
  32126. */
  32127. dispose(force?: boolean): void;
  32128. private getImpostorForceAndContactPoint;
  32129. private _tick;
  32130. /*** Helpers ***/
  32131. private _prepareCylinder;
  32132. private _intersectsWithCylinder;
  32133. }
  32134. /**
  32135. * Represents a physics vortex event
  32136. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32137. */
  32138. class PhysicsVortexEvent {
  32139. private _scene;
  32140. private _origin;
  32141. private _radius;
  32142. private _strength;
  32143. private _height;
  32144. private _physicsEngine;
  32145. private _originTop;
  32146. private _centripetalForceThreshold;
  32147. private _updraftMultiplier;
  32148. private _tickCallback;
  32149. private _cylinder;
  32150. private _cylinderPosition;
  32151. private _dataFetched;
  32152. /**
  32153. * Initializes the physics vortex event
  32154. * @param _scene The BabylonJS scene
  32155. * @param _origin The origin position of the vortex
  32156. * @param _radius The radius of the vortex
  32157. * @param _strength The strength of the vortex
  32158. * @param _height The height of the vortex
  32159. */
  32160. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number);
  32161. /**
  32162. * Returns the data related to the vortex event (cylinder).
  32163. * @returns The physics vortex event data
  32164. */
  32165. getData(): PhysicsVortexEventData;
  32166. /**
  32167. * Enables the vortex.
  32168. */
  32169. enable(): void;
  32170. /**
  32171. * Disables the cortex.
  32172. */
  32173. disable(): void;
  32174. /**
  32175. * Disposes the sphere.
  32176. * @param force
  32177. */
  32178. dispose(force?: boolean): void;
  32179. private getImpostorForceAndContactPoint;
  32180. private _tick;
  32181. /*** Helpers ***/
  32182. private _prepareCylinder;
  32183. private _intersectsWithCylinder;
  32184. }
  32185. /**
  32186. * The strenght of the force in correspondence to the distance of the affected object
  32187. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32188. */
  32189. enum PhysicsRadialImpulseFalloff {
  32190. /** Defines that impulse is constant in strength across it's whole radius */
  32191. Constant = 0,
  32192. /** DEfines that impulse gets weaker if it's further from the origin */
  32193. Linear = 1
  32194. }
  32195. /**
  32196. * The strength of the force in correspondence to the distance of the affected object
  32197. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32198. */
  32199. enum PhysicsUpdraftMode {
  32200. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  32201. Center = 0,
  32202. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  32203. Perpendicular = 1
  32204. }
  32205. /**
  32206. * Interface for a physics force and contact point
  32207. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32208. */
  32209. interface PhysicsForceAndContactPoint {
  32210. /**
  32211. * The force applied at the contact point
  32212. */
  32213. force: Vector3;
  32214. /**
  32215. * The contact point
  32216. */
  32217. contactPoint: Vector3;
  32218. }
  32219. /**
  32220. * Interface for radial explosion event data
  32221. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32222. */
  32223. interface PhysicsRadialExplosionEventData {
  32224. /**
  32225. * A sphere used for the radial explosion event
  32226. */
  32227. sphere: Mesh;
  32228. /**
  32229. * An array of rays for the radial explosion event
  32230. */
  32231. rays: Array<Ray>;
  32232. }
  32233. /**
  32234. * Interface for gravitational field event data
  32235. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32236. */
  32237. interface PhysicsGravitationalFieldEventData {
  32238. /**
  32239. * A sphere mesh used for the gravitational field event
  32240. */
  32241. sphere: Mesh;
  32242. }
  32243. /**
  32244. * Interface for updraft event data
  32245. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32246. */
  32247. interface PhysicsUpdraftEventData {
  32248. /**
  32249. * A cylinder used for the updraft event
  32250. */
  32251. cylinder: Mesh;
  32252. }
  32253. /**
  32254. * Interface for vortex event data
  32255. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32256. */
  32257. interface PhysicsVortexEventData {
  32258. /**
  32259. * A cylinder used for the vortex event
  32260. */
  32261. cylinder: Mesh;
  32262. }
  32263. }
  32264. declare module BABYLON {
  32265. /**
  32266. * The interface for the physics imposter parameters
  32267. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32268. */
  32269. interface PhysicsImpostorParameters {
  32270. /**
  32271. * The mass of the physics imposter
  32272. */
  32273. mass: number;
  32274. /**
  32275. * The friction of the physics imposter
  32276. */
  32277. friction?: number;
  32278. /**
  32279. * The coefficient of restitution of the physics imposter
  32280. */
  32281. restitution?: number;
  32282. /**
  32283. * The native options of the physics imposter
  32284. */
  32285. nativeOptions?: any;
  32286. /**
  32287. * Specifies if the parent should be ignored
  32288. */
  32289. ignoreParent?: boolean;
  32290. /**
  32291. * Specifies if bi-directional transformations should be disabled
  32292. */
  32293. disableBidirectionalTransformation?: boolean;
  32294. }
  32295. /**
  32296. * Interface for a physics-enabled object
  32297. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32298. */
  32299. interface IPhysicsEnabledObject {
  32300. /**
  32301. * The position of the physics-enabled object
  32302. */
  32303. position: Vector3;
  32304. /**
  32305. * The rotation of the physics-enabled object
  32306. */
  32307. rotationQuaternion: Nullable<Quaternion>;
  32308. /**
  32309. * The scale of the physics-enabled object
  32310. */
  32311. scaling: Vector3;
  32312. /**
  32313. * The rotation of the physics-enabled object
  32314. */
  32315. rotation?: Vector3;
  32316. /**
  32317. * The parent of the physics-enabled object
  32318. */
  32319. parent?: any;
  32320. /**
  32321. * The bounding info of the physics-enabled object
  32322. * @returns The bounding info of the physics-enabled object
  32323. */
  32324. getBoundingInfo(): BoundingInfo;
  32325. /**
  32326. * Computes the world matrix
  32327. * @param force Specifies if the world matrix should be computed by force
  32328. * @returns A world matrix
  32329. */
  32330. computeWorldMatrix(force: boolean): Matrix;
  32331. /**
  32332. * Gets the world matrix
  32333. * @returns A world matrix
  32334. */
  32335. getWorldMatrix?(): Matrix;
  32336. /**
  32337. * Gets the child meshes
  32338. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  32339. * @returns An array of abstract meshes
  32340. */
  32341. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  32342. /**
  32343. * Gets the vertex data
  32344. * @param kind The type of vertex data
  32345. * @returns A nullable array of numbers, or a float32 array
  32346. */
  32347. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  32348. /**
  32349. * Gets the indices from the mesh
  32350. * @returns A nullable array of index arrays
  32351. */
  32352. getIndices?(): Nullable<IndicesArray>;
  32353. /**
  32354. * Gets the scene from the mesh
  32355. * @returns the indices array or null
  32356. */
  32357. getScene?(): Scene;
  32358. /**
  32359. * Gets the absolute position from the mesh
  32360. * @returns the absolute position
  32361. */
  32362. getAbsolutePosition(): Vector3;
  32363. /**
  32364. * Gets the absolute pivot point from the mesh
  32365. * @returns the absolute pivot point
  32366. */
  32367. getAbsolutePivotPoint(): Vector3;
  32368. /**
  32369. * Rotates the mesh
  32370. * @param axis The axis of rotation
  32371. * @param amount The amount of rotation
  32372. * @param space The space of the rotation
  32373. * @returns The rotation transform node
  32374. */
  32375. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  32376. /**
  32377. * Translates the mesh
  32378. * @param axis The axis of translation
  32379. * @param distance The distance of translation
  32380. * @param space The space of the translation
  32381. * @returns The transform node
  32382. */
  32383. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  32384. /**
  32385. * Sets the absolute position of the mesh
  32386. * @param absolutePosition The absolute position of the mesh
  32387. * @returns The transform node
  32388. */
  32389. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  32390. /**
  32391. * Gets the class name of the mesh
  32392. * @returns The class name
  32393. */
  32394. getClassName(): string;
  32395. }
  32396. /**
  32397. * Represents a physics imposter
  32398. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32399. */
  32400. class PhysicsImpostor {
  32401. /**
  32402. * The physics-enabled object used as the physics imposter
  32403. */
  32404. object: IPhysicsEnabledObject;
  32405. /**
  32406. * The type of the physics imposter
  32407. */
  32408. type: number;
  32409. private _options;
  32410. private _scene?;
  32411. /**
  32412. * The default object size of the imposter
  32413. */
  32414. static DEFAULT_OBJECT_SIZE: Vector3;
  32415. /**
  32416. * The identity quaternion of the imposter
  32417. */
  32418. static IDENTITY_QUATERNION: Quaternion;
  32419. private _physicsEngine;
  32420. private _physicsBody;
  32421. private _bodyUpdateRequired;
  32422. private _onBeforePhysicsStepCallbacks;
  32423. private _onAfterPhysicsStepCallbacks;
  32424. private _onPhysicsCollideCallbacks;
  32425. private _deltaPosition;
  32426. private _deltaRotation;
  32427. private _deltaRotationConjugated;
  32428. private _parent;
  32429. private _isDisposed;
  32430. private static _tmpVecs;
  32431. private static _tmpQuat;
  32432. /**
  32433. * Specifies if the physics imposter is disposed
  32434. */
  32435. readonly isDisposed: boolean;
  32436. /**
  32437. * Gets the mass of the physics imposter
  32438. */
  32439. mass: number;
  32440. /**
  32441. * Gets the coefficient of friction
  32442. */
  32443. /**
  32444. * Sets the coefficient of friction
  32445. */
  32446. friction: number;
  32447. /**
  32448. * Gets the coefficient of restitution
  32449. */
  32450. /**
  32451. * Sets the coefficient of restitution
  32452. */
  32453. restitution: number;
  32454. /**
  32455. * The unique id of the physics imposter
  32456. * set by the physics engine when adding this impostor to the array
  32457. */
  32458. uniqueId: number;
  32459. private _joints;
  32460. /**
  32461. * Initializes the physics imposter
  32462. * @param object The physics-enabled object used as the physics imposter
  32463. * @param type The type of the physics imposter
  32464. * @param _options The options for the physics imposter
  32465. * @param _scene The Babylon scene
  32466. */
  32467. constructor(
  32468. /**
  32469. * The physics-enabled object used as the physics imposter
  32470. */
  32471. object: IPhysicsEnabledObject,
  32472. /**
  32473. * The type of the physics imposter
  32474. */
  32475. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  32476. /**
  32477. * This function will completly initialize this impostor.
  32478. * It will create a new body - but only if this mesh has no parent.
  32479. * If it has, this impostor will not be used other than to define the impostor
  32480. * of the child mesh.
  32481. * @hidden
  32482. */
  32483. private _getPhysicsParent;
  32484. /**
  32485. * Should a new body be generated.
  32486. * @returns boolean specifying if body initialization is required
  32487. */
  32488. isBodyInitRequired(): boolean;
  32489. /**
  32490. * Sets the updated scaling
  32491. * @param updated Specifies if the scaling is updated
  32492. */
  32493. setScalingUpdated(updated: boolean): void;
  32494. /**
  32495. * Force a regeneration of this or the parent's impostor's body.
  32496. * Use under cautious - This will remove all joints already implemented.
  32497. */
  32498. forceUpdate(): void;
  32499. /**
  32500. * Gets the body that holds this impostor. Either its own, or its parent.
  32501. */
  32502. /**
  32503. * Set the physics body. Used mainly by the physics engine/plugin
  32504. */
  32505. physicsBody: any;
  32506. /**
  32507. * Get the parent of the physics imposter
  32508. * @returns Physics imposter or null
  32509. */
  32510. /**
  32511. * Sets the parent of the physics imposter
  32512. */
  32513. parent: Nullable<PhysicsImpostor>;
  32514. /**
  32515. * Resets the update flags
  32516. */
  32517. resetUpdateFlags(): void;
  32518. /**
  32519. * Gets the object extend size
  32520. * @returns the object extend size
  32521. */
  32522. getObjectExtendSize(): Vector3;
  32523. /**
  32524. * Gets the object center
  32525. * @returns The object center
  32526. */
  32527. getObjectCenter(): Vector3;
  32528. /**
  32529. * Get a specific parametes from the options parameter
  32530. * @param paramName The object parameter name
  32531. * @returns The object parameter
  32532. */
  32533. getParam(paramName: string): any;
  32534. /**
  32535. * Sets a specific parameter in the options given to the physics plugin
  32536. * @param paramName The parameter name
  32537. * @param value The value of the parameter
  32538. */
  32539. setParam(paramName: string, value: number): void;
  32540. /**
  32541. * Specifically change the body's mass option. Won't recreate the physics body object
  32542. * @param mass The mass of the physics imposter
  32543. */
  32544. setMass(mass: number): void;
  32545. /**
  32546. * Gets the linear velocity
  32547. * @returns linear velocity or null
  32548. */
  32549. getLinearVelocity(): Nullable<Vector3>;
  32550. /**
  32551. * Sets the linear velocity
  32552. * @param velocity linear velocity or null
  32553. */
  32554. setLinearVelocity(velocity: Nullable<Vector3>): void;
  32555. /**
  32556. * Gets the angular velocity
  32557. * @returns angular velocity or null
  32558. */
  32559. getAngularVelocity(): Nullable<Vector3>;
  32560. /**
  32561. * Sets the angular velocity
  32562. * @param velocity The velocity or null
  32563. */
  32564. setAngularVelocity(velocity: Nullable<Vector3>): void;
  32565. /**
  32566. * Execute a function with the physics plugin native code
  32567. * Provide a function the will have two variables - the world object and the physics body object
  32568. * @param func The function to execute with the physics plugin native code
  32569. */
  32570. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  32571. /**
  32572. * Register a function that will be executed before the physics world is stepping forward
  32573. * @param func The function to execute before the physics world is stepped forward
  32574. */
  32575. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  32576. /**
  32577. * Unregister a function that will be executed before the physics world is stepping forward
  32578. * @param func The function to execute before the physics world is stepped forward
  32579. */
  32580. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  32581. /**
  32582. * Register a function that will be executed after the physics step
  32583. * @param func The function to execute after physics step
  32584. */
  32585. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  32586. /**
  32587. * Unregisters a function that will be executed after the physics step
  32588. * @param func The function to execute after physics step
  32589. */
  32590. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  32591. /**
  32592. * register a function that will be executed when this impostor collides against a different body
  32593. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  32594. * @param func Callback that is executed on collision
  32595. */
  32596. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  32597. /**
  32598. * Unregisters the physics imposter on contact
  32599. * @param collideAgainst The physics object to collide against
  32600. * @param func Callback to execute on collision
  32601. */
  32602. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  32603. private _tmpQuat;
  32604. private _tmpQuat2;
  32605. /**
  32606. * Get the parent rotation
  32607. * @returns The parent rotation
  32608. */
  32609. getParentsRotation(): Quaternion;
  32610. /**
  32611. * this function is executed by the physics engine.
  32612. */
  32613. beforeStep: () => void;
  32614. /**
  32615. * this function is executed by the physics engine
  32616. */
  32617. afterStep: () => void;
  32618. /**
  32619. * Legacy collision detection event support
  32620. */
  32621. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  32622. /**
  32623. * event and body object due to cannon's event-based architecture.
  32624. */
  32625. onCollide: (e: {
  32626. body: any;
  32627. }) => void;
  32628. /**
  32629. * Apply a force
  32630. * @param force The force to apply
  32631. * @param contactPoint The contact point for the force
  32632. * @returns The physics imposter
  32633. */
  32634. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  32635. /**
  32636. * Apply an impulse
  32637. * @param force The impulse force
  32638. * @param contactPoint The contact point for the impulse force
  32639. * @returns The physics imposter
  32640. */
  32641. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  32642. /**
  32643. * A help function to create a joint
  32644. * @param otherImpostor A physics imposter used to create a joint
  32645. * @param jointType The type of joint
  32646. * @param jointData The data for the joint
  32647. * @returns The physics imposter
  32648. */
  32649. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  32650. /**
  32651. * Add a joint to this impostor with a different impostor
  32652. * @param otherImpostor A physics imposter used to add a joint
  32653. * @param joint The joint to add
  32654. * @returns The physics imposter
  32655. */
  32656. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  32657. /**
  32658. * Will keep this body still, in a sleep mode.
  32659. * @returns the physics imposter
  32660. */
  32661. sleep(): PhysicsImpostor;
  32662. /**
  32663. * Wake the body up.
  32664. * @returns The physics imposter
  32665. */
  32666. wakeUp(): PhysicsImpostor;
  32667. /**
  32668. * Clones the physics imposter
  32669. * @param newObject The physics imposter clones to this physics-enabled object
  32670. * @returns A nullable physics imposter
  32671. */
  32672. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  32673. /**
  32674. * Disposes the physics imposter
  32675. */
  32676. dispose(): void;
  32677. /**
  32678. * Sets the delta position
  32679. * @param position The delta position amount
  32680. */
  32681. setDeltaPosition(position: Vector3): void;
  32682. /**
  32683. * Sets the delta rotation
  32684. * @param rotation The delta rotation amount
  32685. */
  32686. setDeltaRotation(rotation: Quaternion): void;
  32687. /**
  32688. * Gets the box size of the physics imposter and stores the result in the input parameter
  32689. * @param result Stores the box size
  32690. * @returns The physics imposter
  32691. */
  32692. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  32693. /**
  32694. * Gets the radius of the physics imposter
  32695. * @returns Radius of the physics imposter
  32696. */
  32697. getRadius(): number;
  32698. /**
  32699. * Sync a bone with this impostor
  32700. * @param bone The bone to sync to the impostor.
  32701. * @param boneMesh The mesh that the bone is influencing.
  32702. * @param jointPivot The pivot of the joint / bone in local space.
  32703. * @param distToJoint Optional distance from the impostor to the joint.
  32704. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  32705. */
  32706. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  32707. /**
  32708. * Sync impostor to a bone
  32709. * @param bone The bone that the impostor will be synced to.
  32710. * @param boneMesh The mesh that the bone is influencing.
  32711. * @param jointPivot The pivot of the joint / bone in local space.
  32712. * @param distToJoint Optional distance from the impostor to the joint.
  32713. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  32714. * @param boneAxis Optional vector3 axis the bone is aligned with
  32715. */
  32716. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  32717. /**
  32718. * No-Imposter type
  32719. */
  32720. static NoImpostor: number;
  32721. /**
  32722. * Sphere-Imposter type
  32723. */
  32724. static SphereImpostor: number;
  32725. /**
  32726. * Box-Imposter type
  32727. */
  32728. static BoxImpostor: number;
  32729. /**
  32730. * Plane-Imposter type
  32731. */
  32732. static PlaneImpostor: number;
  32733. /**
  32734. * Mesh-imposter type
  32735. */
  32736. static MeshImpostor: number;
  32737. /**
  32738. * Cylinder-Imposter type
  32739. */
  32740. static CylinderImpostor: number;
  32741. /**
  32742. * Particle-Imposter type
  32743. */
  32744. static ParticleImpostor: number;
  32745. /**
  32746. * Heightmap-Imposter type
  32747. */
  32748. static HeightmapImpostor: number;
  32749. }
  32750. }
  32751. declare module BABYLON {
  32752. /**
  32753. * Interface for Physics-Joint data
  32754. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32755. */
  32756. interface PhysicsJointData {
  32757. /**
  32758. * The main pivot of the joint
  32759. */
  32760. mainPivot?: Vector3;
  32761. /**
  32762. * The connected pivot of the joint
  32763. */
  32764. connectedPivot?: Vector3;
  32765. /**
  32766. * The main axis of the joint
  32767. */
  32768. mainAxis?: Vector3;
  32769. /**
  32770. * The connected axis of the joint
  32771. */
  32772. connectedAxis?: Vector3;
  32773. /**
  32774. * The collision of the joint
  32775. */
  32776. collision?: boolean;
  32777. /**
  32778. * Native Oimo/Cannon/Energy data
  32779. */
  32780. nativeParams?: any;
  32781. }
  32782. /**
  32783. * This is a holder class for the physics joint created by the physics plugin
  32784. * It holds a set of functions to control the underlying joint
  32785. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32786. */
  32787. class PhysicsJoint {
  32788. /**
  32789. * The type of the physics joint
  32790. */
  32791. type: number;
  32792. /**
  32793. * The data for the physics joint
  32794. */
  32795. jointData: PhysicsJointData;
  32796. private _physicsJoint;
  32797. protected _physicsPlugin: IPhysicsEnginePlugin;
  32798. /**
  32799. * Initializes the physics joint
  32800. * @param type The type of the physics joint
  32801. * @param jointData The data for the physics joint
  32802. */
  32803. constructor(
  32804. /**
  32805. * The type of the physics joint
  32806. */
  32807. type: number,
  32808. /**
  32809. * The data for the physics joint
  32810. */
  32811. jointData: PhysicsJointData);
  32812. /**
  32813. * Gets the physics joint
  32814. */
  32815. /**
  32816. * Sets the physics joint
  32817. */
  32818. physicsJoint: any;
  32819. /**
  32820. * Sets the physics plugin
  32821. */
  32822. physicsPlugin: IPhysicsEnginePlugin;
  32823. /**
  32824. * Execute a function that is physics-plugin specific.
  32825. * @param {Function} func the function that will be executed.
  32826. * It accepts two parameters: the physics world and the physics joint
  32827. */
  32828. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  32829. /**
  32830. * Distance-Joint type
  32831. */
  32832. static DistanceJoint: number;
  32833. /**
  32834. * Hinge-Joint type
  32835. */
  32836. static HingeJoint: number;
  32837. /**
  32838. * Ball-and-Socket joint type
  32839. */
  32840. static BallAndSocketJoint: number;
  32841. /**
  32842. * Wheel-Joint type
  32843. */
  32844. static WheelJoint: number;
  32845. /**
  32846. * Slider-Joint type
  32847. */
  32848. static SliderJoint: number;
  32849. /**
  32850. * Prismatic-Joint type
  32851. */
  32852. static PrismaticJoint: number;
  32853. /**
  32854. * Universal-Joint type
  32855. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  32856. */
  32857. static UniversalJoint: number;
  32858. /**
  32859. * Hinge-Joint 2 type
  32860. */
  32861. static Hinge2Joint: number;
  32862. /**
  32863. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  32864. */
  32865. static PointToPointJoint: number;
  32866. /**
  32867. * Spring-Joint type
  32868. */
  32869. static SpringJoint: number;
  32870. /**
  32871. * Lock-Joint type
  32872. */
  32873. static LockJoint: number;
  32874. }
  32875. /**
  32876. * A class representing a physics distance joint
  32877. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32878. */
  32879. class DistanceJoint extends PhysicsJoint {
  32880. /**
  32881. *
  32882. * @param jointData The data for the Distance-Joint
  32883. */
  32884. constructor(jointData: DistanceJointData);
  32885. /**
  32886. * Update the predefined distance.
  32887. * @param maxDistance The maximum preferred distance
  32888. * @param minDistance The minimum preferred distance
  32889. */
  32890. updateDistance(maxDistance: number, minDistance?: number): void;
  32891. }
  32892. /**
  32893. * Represents a Motor-Enabled Joint
  32894. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32895. */
  32896. class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  32897. /**
  32898. * Initializes the Motor-Enabled Joint
  32899. * @param type The type of the joint
  32900. * @param jointData The physica joint data for the joint
  32901. */
  32902. constructor(type: number, jointData: PhysicsJointData);
  32903. /**
  32904. * Set the motor values.
  32905. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32906. * @param force the force to apply
  32907. * @param maxForce max force for this motor.
  32908. */
  32909. setMotor(force?: number, maxForce?: number): void;
  32910. /**
  32911. * Set the motor's limits.
  32912. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32913. * @param upperLimit The upper limit of the motor
  32914. * @param lowerLimit The lower limit of the motor
  32915. */
  32916. setLimit(upperLimit: number, lowerLimit?: number): void;
  32917. }
  32918. /**
  32919. * This class represents a single physics Hinge-Joint
  32920. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32921. */
  32922. class HingeJoint extends MotorEnabledJoint {
  32923. /**
  32924. * Initializes the Hinge-Joint
  32925. * @param jointData The joint data for the Hinge-Joint
  32926. */
  32927. constructor(jointData: PhysicsJointData);
  32928. /**
  32929. * Set the motor values.
  32930. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32931. * @param {number} force the force to apply
  32932. * @param {number} maxForce max force for this motor.
  32933. */
  32934. setMotor(force?: number, maxForce?: number): void;
  32935. /**
  32936. * Set the motor's limits.
  32937. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32938. * @param upperLimit The upper limit of the motor
  32939. * @param lowerLimit The lower limit of the motor
  32940. */
  32941. setLimit(upperLimit: number, lowerLimit?: number): void;
  32942. }
  32943. /**
  32944. * This class represents a dual hinge physics joint (same as wheel joint)
  32945. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32946. */
  32947. class Hinge2Joint extends MotorEnabledJoint {
  32948. /**
  32949. * Initializes the Hinge2-Joint
  32950. * @param jointData The joint data for the Hinge2-Joint
  32951. */
  32952. constructor(jointData: PhysicsJointData);
  32953. /**
  32954. * Set the motor values.
  32955. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32956. * @param {number} force the force to apply
  32957. * @param {number} maxForce max force for this motor.
  32958. * @param {motorIndex} the motor's index, 0 or 1.
  32959. */
  32960. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  32961. /**
  32962. * Set the motor limits.
  32963. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32964. * @param {number} upperLimit the upper limit
  32965. * @param {number} lowerLimit lower limit
  32966. * @param {motorIndex} the motor's index, 0 or 1.
  32967. */
  32968. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  32969. }
  32970. /**
  32971. * Interface for a motor enabled joint
  32972. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32973. */
  32974. interface IMotorEnabledJoint {
  32975. /**
  32976. * Physics joint
  32977. */
  32978. physicsJoint: any;
  32979. /**
  32980. * Sets the motor of the motor-enabled joint
  32981. * @param force The force of the motor
  32982. * @param maxForce The maximum force of the motor
  32983. * @param motorIndex The index of the motor
  32984. */
  32985. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  32986. /**
  32987. * Sets the limit of the motor
  32988. * @param upperLimit The upper limit of the motor
  32989. * @param lowerLimit The lower limit of the motor
  32990. * @param motorIndex The index of the motor
  32991. */
  32992. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  32993. }
  32994. /**
  32995. * Joint data for a Distance-Joint
  32996. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32997. */
  32998. interface DistanceJointData extends PhysicsJointData {
  32999. /**
  33000. * Max distance the 2 joint objects can be apart
  33001. */
  33002. maxDistance: number;
  33003. }
  33004. /**
  33005. * Joint data from a spring joint
  33006. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33007. */
  33008. interface SpringJointData extends PhysicsJointData {
  33009. /**
  33010. * Length of the spring
  33011. */
  33012. length: number;
  33013. /**
  33014. * Stiffness of the spring
  33015. */
  33016. stiffness: number;
  33017. /**
  33018. * Damping of the spring
  33019. */
  33020. damping: number;
  33021. /** this callback will be called when applying the force to the impostors. */
  33022. forceApplicationCallback: () => void;
  33023. }
  33024. }
  33025. declare module BABYLON {
  33026. interface Scene {
  33027. /**
  33028. * The list of reflection probes added to the scene
  33029. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  33030. */
  33031. reflectionProbes: Array<ReflectionProbe>;
  33032. }
  33033. /**
  33034. * Class used to generate realtime reflection / refraction cube textures
  33035. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  33036. */
  33037. class ReflectionProbe {
  33038. /** defines the name of the probe */
  33039. name: string;
  33040. private _scene;
  33041. private _renderTargetTexture;
  33042. private _projectionMatrix;
  33043. private _viewMatrix;
  33044. private _target;
  33045. private _add;
  33046. private _attachedMesh;
  33047. private _invertYAxis;
  33048. /** Gets or sets probe position (center of the cube map) */
  33049. position: Vector3;
  33050. /**
  33051. * Creates a new reflection probe
  33052. * @param name defines the name of the probe
  33053. * @param size defines the texture resolution (for each face)
  33054. * @param scene defines the hosting scene
  33055. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  33056. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  33057. */
  33058. constructor(
  33059. /** defines the name of the probe */
  33060. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  33061. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  33062. samples: number;
  33063. /** Gets or sets the refresh rate to use (on every frame by default) */
  33064. refreshRate: number;
  33065. /**
  33066. * Gets the hosting scene
  33067. * @returns a Scene
  33068. */
  33069. getScene(): Scene;
  33070. /** Gets the internal CubeTexture used to render to */
  33071. readonly cubeTexture: RenderTargetTexture;
  33072. /** Gets the list of meshes to render */
  33073. readonly renderList: Nullable<AbstractMesh[]>;
  33074. /**
  33075. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  33076. * @param mesh defines the mesh to attach to
  33077. */
  33078. attachToMesh(mesh: AbstractMesh): void;
  33079. /**
  33080. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  33081. * @param renderingGroupId The rendering group id corresponding to its index
  33082. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  33083. */
  33084. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  33085. /**
  33086. * Clean all associated resources
  33087. */
  33088. dispose(): void;
  33089. }
  33090. }
  33091. declare module BABYLON {
  33092. /**
  33093. * Postprocess used to generate anaglyphic rendering
  33094. */
  33095. class AnaglyphPostProcess extends PostProcess {
  33096. private _passedProcess;
  33097. /**
  33098. * Creates a new AnaglyphPostProcess
  33099. * @param name defines postprocess name
  33100. * @param options defines creation options or target ratio scale
  33101. * @param rigCameras defines cameras using this postprocess
  33102. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  33103. * @param engine defines hosting engine
  33104. * @param reusable defines if the postprocess will be reused multiple times per frame
  33105. */
  33106. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  33107. }
  33108. }
  33109. declare module BABYLON {
  33110. /**
  33111. * Post process used to render in black and white
  33112. */
  33113. class BlackAndWhitePostProcess extends PostProcess {
  33114. /**
  33115. * Linear about to convert he result to black and white (default: 1)
  33116. */
  33117. degree: number;
  33118. /**
  33119. * Creates a black and white post process
  33120. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  33121. * @param name The name of the effect.
  33122. * @param options The required width/height ratio to downsize to before computing the render pass.
  33123. * @param camera The camera to apply the render pass to.
  33124. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  33125. * @param engine The engine which the post process will be applied. (default: current engine)
  33126. * @param reusable If the post process can be reused on the same frame. (default: false)
  33127. */
  33128. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  33129. }
  33130. }
  33131. declare module BABYLON {
  33132. /**
  33133. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  33134. */
  33135. class BloomEffect extends PostProcessRenderEffect {
  33136. private bloomScale;
  33137. /**
  33138. * @hidden Internal
  33139. */
  33140. /**
  33141. * @hidden Internal
  33142. */
  33143. private _blurX;
  33144. private _blurY;
  33145. private _merge;
  33146. /**
  33147. * The luminance threshold to find bright areas of the image to bloom.
  33148. */
  33149. threshold: number;
  33150. /**
  33151. * The strength of the bloom.
  33152. */
  33153. weight: number;
  33154. /**
  33155. * Specifies the size of the bloom blur kernel, relative to the final output size
  33156. */
  33157. kernel: number;
  33158. /**
  33159. * Creates a new instance of @see BloomEffect
  33160. * @param scene The scene the effect belongs to.
  33161. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  33162. * @param bloomKernel The size of the kernel to be used when applying the blur.
  33163. * @param bloomWeight The the strength of bloom.
  33164. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  33165. * @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)
  33166. */
  33167. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  33168. /**
  33169. * Disposes each of the internal effects for a given camera.
  33170. * @param camera The camera to dispose the effect on.
  33171. */
  33172. disposeEffects(camera: Camera): void;
  33173. /**
  33174. * @hidden Internal
  33175. */
  33176. /**
  33177. * Internal
  33178. * @returns if all the contained post processes are ready.
  33179. * @hidden
  33180. */
  33181. }
  33182. }
  33183. declare module BABYLON {
  33184. /**
  33185. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  33186. */
  33187. class BloomMergePostProcess extends PostProcess {
  33188. /** Weight of the bloom to be added to the original input. */
  33189. weight: number;
  33190. /**
  33191. * Creates a new instance of @see BloomMergePostProcess
  33192. * @param name The name of the effect.
  33193. * @param originalFromInput Post process which's input will be used for the merge.
  33194. * @param blurred Blurred highlights post process which's output will be used.
  33195. * @param weight Weight of the bloom to be added to the original input.
  33196. * @param options The required width/height ratio to downsize to before computing the render pass.
  33197. * @param camera The camera to apply the render pass to.
  33198. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  33199. * @param engine The engine which the post process will be applied. (default: current engine)
  33200. * @param reusable If the post process can be reused on the same frame. (default: false)
  33201. * @param textureType Type of textures used when performing the post process. (default: 0)
  33202. * @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)
  33203. */
  33204. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  33205. /** Weight of the bloom to be added to the original input. */
  33206. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  33207. }
  33208. }
  33209. declare module BABYLON {
  33210. /**
  33211. * The Blur Post Process which blurs an image based on a kernel and direction.
  33212. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  33213. */
  33214. class BlurPostProcess extends PostProcess {
  33215. /** The direction in which to blur the image. */
  33216. direction: Vector2;
  33217. private blockCompilation;
  33218. protected _kernel: number;
  33219. protected _idealKernel: number;
  33220. protected _packedFloat: boolean;
  33221. private _staticDefines;
  33222. /**
  33223. * Sets the length in pixels of the blur sample region
  33224. */
  33225. /**
  33226. * Gets the length in pixels of the blur sample region
  33227. */
  33228. kernel: number;
  33229. /**
  33230. * Sets wether or not the blur needs to unpack/repack floats
  33231. */
  33232. /**
  33233. * Gets wether or not the blur is unpacking/repacking floats
  33234. */
  33235. packedFloat: boolean;
  33236. /**
  33237. * Creates a new instance BlurPostProcess
  33238. * @param name The name of the effect.
  33239. * @param direction The direction in which to blur the image.
  33240. * @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.
  33241. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  33242. * @param camera The camera to apply the render pass to.
  33243. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  33244. * @param engine The engine which the post process will be applied. (default: current engine)
  33245. * @param reusable If the post process can be reused on the same frame. (default: false)
  33246. * @param textureType Type of textures used when performing the post process. (default: 0)
  33247. * @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)
  33248. */
  33249. constructor(name: string,
  33250. /** The direction in which to blur the image. */
  33251. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  33252. /**
  33253. * Updates the effect with the current post process compile time values and recompiles the shader.
  33254. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  33255. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  33256. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  33257. * @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
  33258. * @param onCompiled Called when the shader has been compiled.
  33259. * @param onError Called if there is an error when compiling a shader.
  33260. */
  33261. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  33262. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  33263. /**
  33264. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  33265. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  33266. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  33267. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  33268. * The gaps between physical kernels are compensated for in the weighting of the samples
  33269. * @param idealKernel Ideal blur kernel.
  33270. * @return Nearest best kernel.
  33271. */
  33272. protected _nearestBestKernel(idealKernel: number): number;
  33273. /**
  33274. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  33275. * @param x The point on the Gaussian distribution to sample.
  33276. * @return the value of the Gaussian function at x.
  33277. */
  33278. protected _gaussianWeight(x: number): number;
  33279. /**
  33280. * Generates a string that can be used as a floating point number in GLSL.
  33281. * @param x Value to print.
  33282. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  33283. * @return GLSL float string.
  33284. */
  33285. protected _glslFloat(x: number, decimalFigures?: number): string;
  33286. }
  33287. }
  33288. declare module BABYLON {
  33289. /**
  33290. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  33291. */
  33292. class ChromaticAberrationPostProcess extends PostProcess {
  33293. /**
  33294. * The amount of seperation of rgb channels (default: 30)
  33295. */
  33296. aberrationAmount: number;
  33297. /**
  33298. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  33299. */
  33300. radialIntensity: number;
  33301. /**
  33302. * 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))
  33303. */
  33304. direction: Vector2;
  33305. /**
  33306. * 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))
  33307. */
  33308. centerPosition: Vector2;
  33309. /**
  33310. * Creates a new instance ChromaticAberrationPostProcess
  33311. * @param name The name of the effect.
  33312. * @param screenWidth The width of the screen to apply the effect on.
  33313. * @param screenHeight The height of the screen to apply the effect on.
  33314. * @param options The required width/height ratio to downsize to before computing the render pass.
  33315. * @param camera The camera to apply the render pass to.
  33316. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  33317. * @param engine The engine which the post process will be applied. (default: current engine)
  33318. * @param reusable If the post process can be reused on the same frame. (default: false)
  33319. * @param textureType Type of textures used when performing the post process. (default: 0)
  33320. * @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)
  33321. */
  33322. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  33323. }
  33324. }
  33325. declare module BABYLON {
  33326. /**
  33327. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  33328. */
  33329. class CircleOfConfusionPostProcess extends PostProcess {
  33330. /**
  33331. * 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.
  33332. */
  33333. lensSize: number;
  33334. /**
  33335. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  33336. */
  33337. fStop: number;
  33338. /**
  33339. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  33340. */
  33341. focusDistance: number;
  33342. /**
  33343. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  33344. */
  33345. focalLength: number;
  33346. private _depthTexture;
  33347. /**
  33348. * Creates a new instance CircleOfConfusionPostProcess
  33349. * @param name The name of the effect.
  33350. * @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.
  33351. * @param options The required width/height ratio to downsize to before computing the render pass.
  33352. * @param camera The camera to apply the render pass to.
  33353. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  33354. * @param engine The engine which the post process will be applied. (default: current engine)
  33355. * @param reusable If the post process can be reused on the same frame. (default: false)
  33356. * @param textureType Type of textures used when performing the post process. (default: 0)
  33357. * @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)
  33358. */
  33359. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  33360. /**
  33361. * 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.
  33362. */
  33363. depthTexture: RenderTargetTexture;
  33364. }
  33365. }
  33366. declare module BABYLON {
  33367. /**
  33368. *
  33369. * This post-process allows the modification of rendered colors by using
  33370. * a 'look-up table' (LUT). This effect is also called Color Grading.
  33371. *
  33372. * The object needs to be provided an url to a texture containing the color
  33373. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  33374. * Use an image editing software to tweak the LUT to match your needs.
  33375. *
  33376. * For an example of a color LUT, see here:
  33377. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  33378. * For explanations on color grading, see here:
  33379. * @see http://udn.epicgames.com/Three/ColorGrading.html
  33380. *
  33381. */
  33382. class ColorCorrectionPostProcess extends PostProcess {
  33383. private _colorTableTexture;
  33384. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  33385. }
  33386. }
  33387. declare module BABYLON {
  33388. /**
  33389. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  33390. * input texture to perform effects such as edge detection or sharpening
  33391. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  33392. */
  33393. class ConvolutionPostProcess extends PostProcess {
  33394. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  33395. kernel: number[];
  33396. /**
  33397. * Creates a new instance ConvolutionPostProcess
  33398. * @param name The name of the effect.
  33399. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  33400. * @param options The required width/height ratio to downsize to before computing the render pass.
  33401. * @param camera The camera to apply the render pass to.
  33402. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  33403. * @param engine The engine which the post process will be applied. (default: current engine)
  33404. * @param reusable If the post process can be reused on the same frame. (default: false)
  33405. * @param textureType Type of textures used when performing the post process. (default: 0)
  33406. */
  33407. constructor(name: string,
  33408. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  33409. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  33410. /**
  33411. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  33412. */
  33413. static EdgeDetect0Kernel: number[];
  33414. /**
  33415. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  33416. */
  33417. static EdgeDetect1Kernel: number[];
  33418. /**
  33419. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  33420. */
  33421. static EdgeDetect2Kernel: number[];
  33422. /**
  33423. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  33424. */
  33425. static SharpenKernel: number[];
  33426. /**
  33427. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  33428. */
  33429. static EmbossKernel: number[];
  33430. /**
  33431. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  33432. */
  33433. static GaussianKernel: number[];
  33434. }
  33435. }
  33436. declare module BABYLON {
  33437. /**
  33438. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  33439. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  33440. * based on samples that have a large difference in distance than the center pixel.
  33441. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  33442. */
  33443. class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  33444. direction: Vector2;
  33445. /**
  33446. * Creates a new instance CircleOfConfusionPostProcess
  33447. * @param name The name of the effect.
  33448. * @param scene The scene the effect belongs to.
  33449. * @param direction The direction the blur should be applied.
  33450. * @param kernel The size of the kernel used to blur.
  33451. * @param options The required width/height ratio to downsize to before computing the render pass.
  33452. * @param camera The camera to apply the render pass to.
  33453. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  33454. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  33455. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  33456. * @param engine The engine which the post process will be applied. (default: current engine)
  33457. * @param reusable If the post process can be reused on the same frame. (default: false)
  33458. * @param textureType Type of textures used when performing the post process. (default: 0)
  33459. * @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)
  33460. */
  33461. 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);
  33462. }
  33463. }
  33464. declare module BABYLON {
  33465. /**
  33466. * Specifies the level of max blur that should be applied when using the depth of field effect
  33467. */
  33468. enum DepthOfFieldEffectBlurLevel {
  33469. /**
  33470. * Subtle blur
  33471. */
  33472. Low = 0,
  33473. /**
  33474. * Medium blur
  33475. */
  33476. Medium = 1,
  33477. /**
  33478. * Large blur
  33479. */
  33480. High = 2
  33481. }
  33482. /**
  33483. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  33484. */
  33485. class DepthOfFieldEffect extends PostProcessRenderEffect {
  33486. private _circleOfConfusion;
  33487. /**
  33488. * @hidden Internal, blurs from high to low
  33489. */
  33490. private _depthOfFieldBlurY;
  33491. private _dofMerge;
  33492. /**
  33493. * @hidden Internal post processes in depth of field effect
  33494. */
  33495. /**
  33496. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  33497. */
  33498. focalLength: number;
  33499. /**
  33500. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  33501. */
  33502. fStop: number;
  33503. /**
  33504. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  33505. */
  33506. focusDistance: number;
  33507. /**
  33508. * 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.
  33509. */
  33510. lensSize: number;
  33511. /**
  33512. * Creates a new instance DepthOfFieldEffect
  33513. * @param scene The scene the effect belongs to.
  33514. * @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.
  33515. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  33516. * @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)
  33517. */
  33518. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  33519. /**
  33520. * 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.
  33521. */
  33522. depthTexture: RenderTargetTexture;
  33523. /**
  33524. * Disposes each of the internal effects for a given camera.
  33525. * @param camera The camera to dispose the effect on.
  33526. */
  33527. disposeEffects(camera: Camera): void;
  33528. /**
  33529. * @hidden Internal
  33530. */
  33531. /**
  33532. * Internal
  33533. * @returns if all the contained post processes are ready.
  33534. * @hidden
  33535. */
  33536. }
  33537. }
  33538. declare module BABYLON {
  33539. /**
  33540. * Options to be set when merging outputs from the default pipeline.
  33541. */
  33542. class DepthOfFieldMergePostProcessOptions {
  33543. /**
  33544. * The original image to merge on top of
  33545. */
  33546. originalFromInput: PostProcess;
  33547. /**
  33548. * Parameters to perform the merge of the depth of field effect
  33549. */
  33550. depthOfField?: {
  33551. circleOfConfusion: PostProcess;
  33552. blurSteps: Array<PostProcess>;
  33553. };
  33554. /**
  33555. * Parameters to perform the merge of bloom effect
  33556. */
  33557. bloom?: {
  33558. blurred: PostProcess;
  33559. weight: number;
  33560. };
  33561. }
  33562. /**
  33563. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  33564. */
  33565. class DepthOfFieldMergePostProcess extends PostProcess {
  33566. private blurSteps;
  33567. /**
  33568. * Creates a new instance of DepthOfFieldMergePostProcess
  33569. * @param name The name of the effect.
  33570. * @param originalFromInput Post process which's input will be used for the merge.
  33571. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  33572. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  33573. * @param options The required width/height ratio to downsize to before computing the render pass.
  33574. * @param camera The camera to apply the render pass to.
  33575. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  33576. * @param engine The engine which the post process will be applied. (default: current engine)
  33577. * @param reusable If the post process can be reused on the same frame. (default: false)
  33578. * @param textureType Type of textures used when performing the post process. (default: 0)
  33579. * @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)
  33580. */
  33581. 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);
  33582. /**
  33583. * Updates the effect with the current post process compile time values and recompiles the shader.
  33584. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  33585. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  33586. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  33587. * @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
  33588. * @param onCompiled Called when the shader has been compiled.
  33589. * @param onError Called if there is an error when compiling a shader.
  33590. */
  33591. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  33592. }
  33593. }
  33594. declare module BABYLON {
  33595. /**
  33596. * DisplayPassPostProcess which produces an output the same as it's input
  33597. */
  33598. class DisplayPassPostProcess extends PostProcess {
  33599. /**
  33600. * Creates the DisplayPassPostProcess
  33601. * @param name The name of the effect.
  33602. * @param options The required width/height ratio to downsize to before computing the render pass.
  33603. * @param camera The camera to apply the render pass to.
  33604. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  33605. * @param engine The engine which the post process will be applied. (default: current engine)
  33606. * @param reusable If the post process can be reused on the same frame. (default: false)
  33607. */
  33608. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  33609. }
  33610. }
  33611. declare module BABYLON {
  33612. /**
  33613. * 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.
  33614. */
  33615. class ExtractHighlightsPostProcess extends PostProcess {
  33616. /**
  33617. * The luminance threshold, pixels below this value will be set to black.
  33618. */
  33619. threshold: number;
  33620. /** @hidden */
  33621. /**
  33622. * Post process which has the input texture to be used when performing highlight extraction
  33623. * @hidden
  33624. */
  33625. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  33626. }
  33627. }
  33628. declare module BABYLON {
  33629. /**
  33630. * Applies a kernel filter to the image
  33631. */
  33632. class FilterPostProcess extends PostProcess {
  33633. /** The matrix to be applied to the image */
  33634. kernelMatrix: Matrix;
  33635. /**
  33636. *
  33637. * @param name The name of the effect.
  33638. * @param kernelMatrix The matrix to be applied to the image
  33639. * @param options The required width/height ratio to downsize to before computing the render pass.
  33640. * @param camera The camera to apply the render pass to.
  33641. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  33642. * @param engine The engine which the post process will be applied. (default: current engine)
  33643. * @param reusable If the post process can be reused on the same frame. (default: false)
  33644. */
  33645. constructor(name: string,
  33646. /** The matrix to be applied to the image */
  33647. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  33648. }
  33649. }
  33650. declare module BABYLON {
  33651. /**
  33652. * Fxaa post process
  33653. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  33654. */
  33655. class FxaaPostProcess extends PostProcess {
  33656. /** @hidden */
  33657. texelWidth: number;
  33658. /** @hidden */
  33659. texelHeight: number;
  33660. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  33661. private _getDefines;
  33662. }
  33663. }
  33664. declare module BABYLON {
  33665. /**
  33666. * The GrainPostProcess adds noise to the image at mid luminance levels
  33667. */
  33668. class GrainPostProcess extends PostProcess {
  33669. /**
  33670. * The intensity of the grain added (default: 30)
  33671. */
  33672. intensity: number;
  33673. /**
  33674. * If the grain should be randomized on every frame
  33675. */
  33676. animated: boolean;
  33677. /**
  33678. * Creates a new instance of @see GrainPostProcess
  33679. * @param name The name of the effect.
  33680. * @param options The required width/height ratio to downsize to before computing the render pass.
  33681. * @param camera The camera to apply the render pass to.
  33682. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  33683. * @param engine The engine which the post process will be applied. (default: current engine)
  33684. * @param reusable If the post process can be reused on the same frame. (default: false)
  33685. * @param textureType Type of textures used when performing the post process. (default: 0)
  33686. * @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)
  33687. */
  33688. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  33689. }
  33690. }
  33691. declare module BABYLON {
  33692. /**
  33693. * Extracts highlights from the image
  33694. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  33695. */
  33696. class HighlightsPostProcess extends PostProcess {
  33697. /**
  33698. * Extracts highlights from the image
  33699. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  33700. * @param name The name of the effect.
  33701. * @param options The required width/height ratio to downsize to before computing the render pass.
  33702. * @param camera The camera to apply the render pass to.
  33703. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  33704. * @param engine The engine which the post process will be applied. (default: current engine)
  33705. * @param reusable If the post process can be reused on the same frame. (default: false)
  33706. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  33707. */
  33708. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  33709. }
  33710. }
  33711. declare module BABYLON {
  33712. /**
  33713. * ImageProcessingPostProcess
  33714. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  33715. */
  33716. class ImageProcessingPostProcess extends PostProcess {
  33717. /**
  33718. * Default configuration related to image processing available in the PBR Material.
  33719. */
  33720. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  33721. /**
  33722. * Gets the image processing configuration used either in this material.
  33723. */
  33724. /**
  33725. * Sets the Default image processing configuration used either in the this material.
  33726. *
  33727. * If sets to null, the scene one is in use.
  33728. */
  33729. imageProcessingConfiguration: ImageProcessingConfiguration;
  33730. /**
  33731. * Keep track of the image processing observer to allow dispose and replace.
  33732. */
  33733. private _imageProcessingObserver;
  33734. /**
  33735. * Attaches a new image processing configuration to the PBR Material.
  33736. * @param configuration
  33737. */
  33738. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  33739. /**
  33740. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  33741. */
  33742. /**
  33743. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  33744. */
  33745. colorCurves: Nullable<ColorCurves>;
  33746. /**
  33747. * Gets wether the color curves effect is enabled.
  33748. */
  33749. /**
  33750. * Sets wether the color curves effect is enabled.
  33751. */
  33752. colorCurvesEnabled: boolean;
  33753. /**
  33754. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  33755. */
  33756. /**
  33757. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  33758. */
  33759. colorGradingTexture: Nullable<BaseTexture>;
  33760. /**
  33761. * Gets wether the color grading effect is enabled.
  33762. */
  33763. /**
  33764. * Gets wether the color grading effect is enabled.
  33765. */
  33766. colorGradingEnabled: boolean;
  33767. /**
  33768. * Gets exposure used in the effect.
  33769. */
  33770. /**
  33771. * Sets exposure used in the effect.
  33772. */
  33773. exposure: number;
  33774. /**
  33775. * Gets wether tonemapping is enabled or not.
  33776. */
  33777. /**
  33778. * Sets wether tonemapping is enabled or not
  33779. */
  33780. toneMappingEnabled: boolean;
  33781. /**
  33782. * Gets contrast used in the effect.
  33783. */
  33784. /**
  33785. * Sets contrast used in the effect.
  33786. */
  33787. contrast: number;
  33788. /**
  33789. * Gets Vignette stretch size.
  33790. */
  33791. /**
  33792. * Sets Vignette stretch size.
  33793. */
  33794. vignetteStretch: number;
  33795. /**
  33796. * Gets Vignette centre X Offset.
  33797. */
  33798. /**
  33799. * Sets Vignette centre X Offset.
  33800. */
  33801. vignetteCentreX: number;
  33802. /**
  33803. * Gets Vignette centre Y Offset.
  33804. */
  33805. /**
  33806. * Sets Vignette centre Y Offset.
  33807. */
  33808. vignetteCentreY: number;
  33809. /**
  33810. * Gets Vignette weight or intensity of the vignette effect.
  33811. */
  33812. /**
  33813. * Sets Vignette weight or intensity of the vignette effect.
  33814. */
  33815. vignetteWeight: number;
  33816. /**
  33817. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  33818. * if vignetteEnabled is set to true.
  33819. */
  33820. /**
  33821. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  33822. * if vignetteEnabled is set to true.
  33823. */
  33824. vignetteColor: Color4;
  33825. /**
  33826. * Gets Camera field of view used by the Vignette effect.
  33827. */
  33828. /**
  33829. * Sets Camera field of view used by the Vignette effect.
  33830. */
  33831. vignetteCameraFov: number;
  33832. /**
  33833. * Gets the vignette blend mode allowing different kind of effect.
  33834. */
  33835. /**
  33836. * Sets the vignette blend mode allowing different kind of effect.
  33837. */
  33838. vignetteBlendMode: number;
  33839. /**
  33840. * Gets wether the vignette effect is enabled.
  33841. */
  33842. /**
  33843. * Sets wether the vignette effect is enabled.
  33844. */
  33845. vignetteEnabled: boolean;
  33846. private _fromLinearSpace;
  33847. /**
  33848. * Gets wether the input of the processing is in Gamma or Linear Space.
  33849. */
  33850. /**
  33851. * Sets wether the input of the processing is in Gamma or Linear Space.
  33852. */
  33853. fromLinearSpace: boolean;
  33854. /**
  33855. * Defines cache preventing GC.
  33856. */
  33857. private _defines;
  33858. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  33859. /**
  33860. * "ImageProcessingPostProcess"
  33861. * @returns "ImageProcessingPostProcess"
  33862. */
  33863. getClassName(): string;
  33864. protected _updateParameters(): void;
  33865. dispose(camera?: Camera): void;
  33866. }
  33867. }
  33868. declare module BABYLON {
  33869. /**
  33870. * PassPostProcess which produces an output the same as it's input
  33871. */
  33872. class PassPostProcess extends PostProcess {
  33873. /**
  33874. * Creates the PassPostProcess
  33875. * @param name The name of the effect.
  33876. * @param options The required width/height ratio to downsize to before computing the render pass.
  33877. * @param camera The camera to apply the render pass to.
  33878. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  33879. * @param engine The engine which the post process will be applied. (default: current engine)
  33880. * @param reusable If the post process can be reused on the same frame. (default: false)
  33881. * @param textureType The type of texture to be used when performing the post processing.
  33882. * @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)
  33883. */
  33884. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  33885. }
  33886. }
  33887. declare module BABYLON {
  33888. /**
  33889. * Size options for a post process
  33890. */
  33891. type PostProcessOptions = {
  33892. width: number;
  33893. height: number;
  33894. };
  33895. /**
  33896. * PostProcess can be used to apply a shader to a texture after it has been rendered
  33897. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  33898. */
  33899. class PostProcess {
  33900. /** Name of the PostProcess. */
  33901. name: string;
  33902. /**
  33903. * Width of the texture to apply the post process on
  33904. */
  33905. width: number;
  33906. /**
  33907. * Height of the texture to apply the post process on
  33908. */
  33909. height: number;
  33910. /**
  33911. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  33912. * @hidden
  33913. */
  33914. /**
  33915. * Sampling mode used by the shader
  33916. * See https://doc.babylonjs.com/classes/3.1/texture
  33917. */
  33918. renderTargetSamplingMode: number;
  33919. /**
  33920. * Clear color to use when screen clearing
  33921. */
  33922. clearColor: Color4;
  33923. /**
  33924. * If the buffer needs to be cleared before applying the post process. (default: true)
  33925. * Should be set to false if shader will overwrite all previous pixels.
  33926. */
  33927. autoClear: boolean;
  33928. /**
  33929. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  33930. */
  33931. alphaMode: number;
  33932. /**
  33933. * Sets the setAlphaBlendConstants of the babylon engine
  33934. */
  33935. alphaConstants: Color4;
  33936. /**
  33937. * Animations to be used for the post processing
  33938. */
  33939. animations: Animation[];
  33940. /**
  33941. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  33942. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  33943. */
  33944. enablePixelPerfectMode: boolean;
  33945. /**
  33946. * Force the postprocess to be applied without taking in account viewport
  33947. */
  33948. forceFullscreenViewport: boolean;
  33949. /**
  33950. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  33951. *
  33952. * | Value | Type | Description |
  33953. * | ----- | ----------------------------------- | ----------- |
  33954. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  33955. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  33956. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  33957. *
  33958. */
  33959. scaleMode: number;
  33960. /**
  33961. * Force textures to be a power of two (default: false)
  33962. */
  33963. alwaysForcePOT: boolean;
  33964. private _samples;
  33965. /**
  33966. * Number of sample textures (default: 1)
  33967. */
  33968. samples: number;
  33969. /**
  33970. * Modify the scale of the post process to be the same as the viewport (default: false)
  33971. */
  33972. adaptScaleToCurrentViewport: boolean;
  33973. private _camera;
  33974. private _scene;
  33975. private _engine;
  33976. private _options;
  33977. private _reusable;
  33978. private _textureType;
  33979. /**
  33980. * Smart array of input and output textures for the post process.
  33981. * @hidden
  33982. */
  33983. /**
  33984. * The index in _textures that corresponds to the output texture.
  33985. * @hidden
  33986. */
  33987. private _effect;
  33988. private _samplers;
  33989. private _fragmentUrl;
  33990. private _vertexUrl;
  33991. private _parameters;
  33992. private _scaleRatio;
  33993. protected _indexParameters: any;
  33994. private _shareOutputWithPostProcess;
  33995. private _texelSize;
  33996. private _forcedOutputTexture;
  33997. /**
  33998. * An event triggered when the postprocess is activated.
  33999. */
  34000. onActivateObservable: Observable<Camera>;
  34001. private _onActivateObserver;
  34002. /**
  34003. * A function that is added to the onActivateObservable
  34004. */
  34005. onActivate: Nullable<(camera: Camera) => void>;
  34006. /**
  34007. * An event triggered when the postprocess changes its size.
  34008. */
  34009. onSizeChangedObservable: Observable<PostProcess>;
  34010. private _onSizeChangedObserver;
  34011. /**
  34012. * A function that is added to the onSizeChangedObservable
  34013. */
  34014. onSizeChanged: (postProcess: PostProcess) => void;
  34015. /**
  34016. * An event triggered when the postprocess applies its effect.
  34017. */
  34018. onApplyObservable: Observable<Effect>;
  34019. private _onApplyObserver;
  34020. /**
  34021. * A function that is added to the onApplyObservable
  34022. */
  34023. onApply: (effect: Effect) => void;
  34024. /**
  34025. * An event triggered before rendering the postprocess
  34026. */
  34027. onBeforeRenderObservable: Observable<Effect>;
  34028. private _onBeforeRenderObserver;
  34029. /**
  34030. * A function that is added to the onBeforeRenderObservable
  34031. */
  34032. onBeforeRender: (effect: Effect) => void;
  34033. /**
  34034. * An event triggered after rendering the postprocess
  34035. */
  34036. onAfterRenderObservable: Observable<Effect>;
  34037. private _onAfterRenderObserver;
  34038. /**
  34039. * A function that is added to the onAfterRenderObservable
  34040. */
  34041. onAfterRender: (efect: Effect) => void;
  34042. /**
  34043. * 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
  34044. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  34045. */
  34046. inputTexture: InternalTexture;
  34047. /**
  34048. * Gets the camera which post process is applied to.
  34049. * @returns The camera the post process is applied to.
  34050. */
  34051. getCamera(): Camera;
  34052. /**
  34053. * Gets the texel size of the postprocess.
  34054. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  34055. */
  34056. readonly texelSize: Vector2;
  34057. /**
  34058. * Creates a new instance PostProcess
  34059. * @param name The name of the PostProcess.
  34060. * @param fragmentUrl The url of the fragment shader to be used.
  34061. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  34062. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  34063. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  34064. * @param camera The camera to apply the render pass to.
  34065. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34066. * @param engine The engine which the post process will be applied. (default: current engine)
  34067. * @param reusable If the post process can be reused on the same frame. (default: false)
  34068. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  34069. * @param textureType Type of textures used when performing the post process. (default: 0)
  34070. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  34071. * @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
  34072. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  34073. */
  34074. constructor(
  34075. /** Name of the PostProcess. */
  34076. 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);
  34077. /**
  34078. * Gets the engine which this post process belongs to.
  34079. * @returns The engine the post process was enabled with.
  34080. */
  34081. getEngine(): Engine;
  34082. /**
  34083. * The effect that is created when initializing the post process.
  34084. * @returns The created effect corrisponding the the postprocess.
  34085. */
  34086. getEffect(): Effect;
  34087. /**
  34088. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  34089. * @param postProcess The post process to share the output with.
  34090. * @returns This post process.
  34091. */
  34092. shareOutputWith(postProcess: PostProcess): PostProcess;
  34093. /**
  34094. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  34095. * This should be called if the post process that shares output with this post process is disabled/disposed.
  34096. */
  34097. useOwnOutput(): void;
  34098. /**
  34099. * Updates the effect with the current post process compile time values and recompiles the shader.
  34100. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  34101. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  34102. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  34103. * @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
  34104. * @param onCompiled Called when the shader has been compiled.
  34105. * @param onError Called if there is an error when compiling a shader.
  34106. */
  34107. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  34108. /**
  34109. * The post process is reusable if it can be used multiple times within one frame.
  34110. * @returns If the post process is reusable
  34111. */
  34112. isReusable(): boolean;
  34113. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  34114. markTextureDirty(): void;
  34115. /**
  34116. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  34117. * 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.
  34118. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  34119. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  34120. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  34121. * @returns The target texture that was bound to be written to.
  34122. */
  34123. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  34124. /**
  34125. * If the post process is supported.
  34126. */
  34127. readonly isSupported: boolean;
  34128. /**
  34129. * The aspect ratio of the output texture.
  34130. */
  34131. readonly aspectRatio: number;
  34132. /**
  34133. * Get a value indicating if the post-process is ready to be used
  34134. * @returns true if the post-process is ready (shader is compiled)
  34135. */
  34136. isReady(): boolean;
  34137. /**
  34138. * Binds all textures and uniforms to the shader, this will be run on every pass.
  34139. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  34140. */
  34141. apply(): Nullable<Effect>;
  34142. private _disposeTextures;
  34143. /**
  34144. * Disposes the post process.
  34145. * @param camera The camera to dispose the post process on.
  34146. */
  34147. dispose(camera?: Camera): void;
  34148. }
  34149. }
  34150. declare module BABYLON {
  34151. /**
  34152. * PostProcessManager is used to manage one or more post processes or post process pipelines
  34153. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  34154. */
  34155. class PostProcessManager {
  34156. private _scene;
  34157. private _indexBuffer;
  34158. private _vertexBuffers;
  34159. /**
  34160. * Creates a new instance PostProcess
  34161. * @param scene The scene that the post process is associated with.
  34162. */
  34163. constructor(scene: Scene);
  34164. private _prepareBuffers;
  34165. private _buildIndexBuffer;
  34166. /**
  34167. * Rebuilds the vertex buffers of the manager.
  34168. * @hidden
  34169. */
  34170. /**
  34171. * Prepares a frame to be run through a post process.
  34172. * @param sourceTexture The input texture to the post procesess. (default: null)
  34173. * @param postProcesses An array of post processes to be run. (default: null)
  34174. * @returns True if the post processes were able to be run.
  34175. * @hidden
  34176. */
  34177. /**
  34178. * Manually render a set of post processes to a texture.
  34179. * @param postProcesses An array of post processes to be run.
  34180. * @param targetTexture The target texture to render to.
  34181. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  34182. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  34183. * @param lodLevel defines which lod of the texture to render to
  34184. */
  34185. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  34186. /**
  34187. * Finalize the result of the output of the postprocesses.
  34188. * @param doNotPresent If true the result will not be displayed to the screen.
  34189. * @param targetTexture The target texture to render to.
  34190. * @param faceIndex The index of the face to bind the target texture to.
  34191. * @param postProcesses The array of post processes to render.
  34192. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  34193. * @hidden
  34194. */
  34195. /**
  34196. * Disposes of the post process manager.
  34197. */
  34198. dispose(): void;
  34199. }
  34200. }
  34201. declare module BABYLON {
  34202. /**
  34203. * Post process which applies a refractin texture
  34204. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  34205. */
  34206. class RefractionPostProcess extends PostProcess {
  34207. /** the base color of the refraction (used to taint the rendering) */
  34208. color: Color3;
  34209. /** simulated refraction depth */
  34210. depth: number;
  34211. /** the coefficient of the base color (0 to remove base color tainting) */
  34212. colorLevel: number;
  34213. private _refTexture;
  34214. private _ownRefractionTexture;
  34215. /**
  34216. * Gets or sets the refraction texture
  34217. * Please note that you are responsible for disposing the texture if you set it manually
  34218. */
  34219. refractionTexture: Texture;
  34220. /**
  34221. * Initializes the RefractionPostProcess
  34222. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  34223. * @param name The name of the effect.
  34224. * @param refractionTextureUrl Url of the refraction texture to use
  34225. * @param color the base color of the refraction (used to taint the rendering)
  34226. * @param depth simulated refraction depth
  34227. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  34228. * @param camera The camera to apply the render pass to.
  34229. * @param options The required width/height ratio to downsize to before computing the render pass.
  34230. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34231. * @param engine The engine which the post process will be applied. (default: current engine)
  34232. * @param reusable If the post process can be reused on the same frame. (default: false)
  34233. */
  34234. constructor(name: string, refractionTextureUrl: string,
  34235. /** the base color of the refraction (used to taint the rendering) */
  34236. color: Color3,
  34237. /** simulated refraction depth */
  34238. depth: number,
  34239. /** the coefficient of the base color (0 to remove base color tainting) */
  34240. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  34241. /**
  34242. * Disposes of the post process
  34243. * @param camera Camera to dispose post process on
  34244. */
  34245. dispose(camera: Camera): void;
  34246. }
  34247. }
  34248. declare module BABYLON {
  34249. /**
  34250. * The SharpenPostProcess applies a sharpen kernel to every pixel
  34251. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  34252. */
  34253. class SharpenPostProcess extends PostProcess {
  34254. /**
  34255. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  34256. */
  34257. colorAmount: number;
  34258. /**
  34259. * How much sharpness should be applied (default: 0.3)
  34260. */
  34261. edgeAmount: number;
  34262. /**
  34263. * Creates a new instance ConvolutionPostProcess
  34264. * @param name The name of the effect.
  34265. * @param options The required width/height ratio to downsize to before computing the render pass.
  34266. * @param camera The camera to apply the render pass to.
  34267. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34268. * @param engine The engine which the post process will be applied. (default: current engine)
  34269. * @param reusable If the post process can be reused on the same frame. (default: false)
  34270. * @param textureType Type of textures used when performing the post process. (default: 0)
  34271. * @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)
  34272. */
  34273. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  34274. }
  34275. }
  34276. declare module BABYLON {
  34277. /**
  34278. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  34279. */
  34280. class StereoscopicInterlacePostProcess extends PostProcess {
  34281. private _stepSize;
  34282. private _passedProcess;
  34283. /**
  34284. * Initializes a StereoscopicInterlacePostProcess
  34285. * @param name The name of the effect.
  34286. * @param rigCameras The rig cameras to be appled to the post process
  34287. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  34288. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34289. * @param engine The engine which the post process will be applied. (default: current engine)
  34290. * @param reusable If the post process can be reused on the same frame. (default: false)
  34291. */
  34292. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  34293. }
  34294. }
  34295. declare module BABYLON {
  34296. /** Defines operator used for tonemapping */
  34297. enum TonemappingOperator {
  34298. /** Hable */
  34299. Hable = 0,
  34300. /** Reinhard */
  34301. Reinhard = 1,
  34302. /** HejiDawson */
  34303. HejiDawson = 2,
  34304. /** Photographic */
  34305. Photographic = 3
  34306. }
  34307. /**
  34308. * Defines a post process to apply tone mapping
  34309. */
  34310. class TonemapPostProcess extends PostProcess {
  34311. private _operator;
  34312. /** Defines the required exposure adjustement */
  34313. exposureAdjustment: number;
  34314. /**
  34315. * Creates a new TonemapPostProcess
  34316. * @param name defines the name of the postprocess
  34317. * @param _operator defines the operator to use
  34318. * @param exposureAdjustment defines the required exposure adjustement
  34319. * @param camera defines the camera to use (can be null)
  34320. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  34321. * @param engine defines the hosting engine (can be ignore if camera is set)
  34322. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  34323. */
  34324. constructor(name: string, _operator: TonemappingOperator,
  34325. /** Defines the required exposure adjustement */
  34326. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  34327. }
  34328. }
  34329. declare module BABYLON {
  34330. /**
  34331. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  34332. */
  34333. class VolumetricLightScatteringPostProcess extends PostProcess {
  34334. private _volumetricLightScatteringPass;
  34335. private _volumetricLightScatteringRTT;
  34336. private _viewPort;
  34337. private _screenCoordinates;
  34338. private _cachedDefines;
  34339. /**
  34340. * If not undefined, the mesh position is computed from the attached node position
  34341. */
  34342. attachedNode: {
  34343. position: Vector3;
  34344. };
  34345. /**
  34346. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  34347. */
  34348. customMeshPosition: Vector3;
  34349. /**
  34350. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  34351. */
  34352. useCustomMeshPosition: boolean;
  34353. /**
  34354. * If the post-process should inverse the light scattering direction
  34355. */
  34356. invert: boolean;
  34357. /**
  34358. * The internal mesh used by the post-process
  34359. */
  34360. mesh: Mesh;
  34361. /**
  34362. * @hidden
  34363. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  34364. */
  34365. useDiffuseColor: boolean;
  34366. /**
  34367. * Array containing the excluded meshes not rendered in the internal pass
  34368. */
  34369. excludedMeshes: AbstractMesh[];
  34370. /**
  34371. * Controls the overall intensity of the post-process
  34372. */
  34373. exposure: number;
  34374. /**
  34375. * Dissipates each sample's contribution in range [0, 1]
  34376. */
  34377. decay: number;
  34378. /**
  34379. * Controls the overall intensity of each sample
  34380. */
  34381. weight: number;
  34382. /**
  34383. * Controls the density of each sample
  34384. */
  34385. density: number;
  34386. /**
  34387. * @constructor
  34388. * @param name The post-process name
  34389. * @param ratio The size of the post-process and/or internal pass (0.5 means that your postprocess will have a width = canvas.width 0.5 and a height = canvas.height 0.5)
  34390. * @param camera The camera that the post-process will be attached to
  34391. * @param mesh The mesh used to create the light scattering
  34392. * @param samples The post-process quality, default 100
  34393. * @param samplingModeThe post-process filtering mode
  34394. * @param engine The babylon engine
  34395. * @param reusable If the post-process is reusable
  34396. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  34397. */
  34398. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  34399. /**
  34400. * Returns the string "VolumetricLightScatteringPostProcess"
  34401. * @returns "VolumetricLightScatteringPostProcess"
  34402. */
  34403. getClassName(): string;
  34404. private _isReady;
  34405. /**
  34406. * Sets the new light position for light scattering effect
  34407. * @param position The new custom light position
  34408. */
  34409. setCustomMeshPosition(position: Vector3): void;
  34410. /**
  34411. * Returns the light position for light scattering effect
  34412. * @return Vector3 The custom light position
  34413. */
  34414. getCustomMeshPosition(): Vector3;
  34415. /**
  34416. * Disposes the internal assets and detaches the post-process from the camera
  34417. */
  34418. dispose(camera: Camera): void;
  34419. /**
  34420. * Returns the render target texture used by the post-process
  34421. * @return the render target texture used by the post-process
  34422. */
  34423. getPass(): RenderTargetTexture;
  34424. private _meshExcluded;
  34425. private _createPass;
  34426. private _updateMeshScreenCoordinates;
  34427. /**
  34428. * Creates a default mesh for the Volumeric Light Scattering post-process
  34429. * @param name The mesh name
  34430. * @param scene The scene where to create the mesh
  34431. * @return the default mesh
  34432. */
  34433. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  34434. }
  34435. }
  34436. declare module BABYLON {
  34437. /**
  34438. * VRDistortionCorrectionPostProcess used for mobile VR
  34439. */
  34440. class VRDistortionCorrectionPostProcess extends PostProcess {
  34441. private _isRightEye;
  34442. private _distortionFactors;
  34443. private _postProcessScaleFactor;
  34444. private _lensCenterOffset;
  34445. private _scaleIn;
  34446. private _scaleFactor;
  34447. private _lensCenter;
  34448. /**
  34449. * Initializes the VRDistortionCorrectionPostProcess
  34450. * @param name The name of the effect.
  34451. * @param camera The camera to apply the render pass to.
  34452. * @param isRightEye If this is for the right eye distortion
  34453. * @param vrMetrics All the required metrics for the VR camera
  34454. */
  34455. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  34456. }
  34457. }
  34458. declare module BABYLON {
  34459. interface Scene {
  34460. /** @hidden (Backing field) */
  34461. /** @hidden (Backing field) */
  34462. /**
  34463. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  34464. */
  34465. forceShowBoundingBoxes: boolean;
  34466. /**
  34467. * Gets the bounding box renderer associated with the scene
  34468. * @returns a BoundingBoxRenderer
  34469. */
  34470. getBoundingBoxRenderer(): BoundingBoxRenderer;
  34471. }
  34472. interface AbstractMesh {
  34473. /** @hidden (Backing field) */
  34474. /**
  34475. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  34476. */
  34477. showBoundingBox: boolean;
  34478. }
  34479. /**
  34480. * Component responsible of rendering the bounding box of the meshes in a scene.
  34481. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  34482. */
  34483. class BoundingBoxRenderer implements ISceneComponent {
  34484. /**
  34485. * The component name helpfull to identify the component in the list of scene components.
  34486. */
  34487. readonly name: string;
  34488. /**
  34489. * The scene the component belongs to.
  34490. */
  34491. scene: Scene;
  34492. /**
  34493. * Color of the bounding box lines placed in front of an object
  34494. */
  34495. frontColor: Color3;
  34496. /**
  34497. * Color of the bounding box lines placed behind an object
  34498. */
  34499. backColor: Color3;
  34500. /**
  34501. * Defines if the renderer should show the back lines or not
  34502. */
  34503. showBackLines: boolean;
  34504. /**
  34505. * @hidden
  34506. */
  34507. renderList: SmartArray<BoundingBox>;
  34508. private _colorShader;
  34509. private _vertexBuffers;
  34510. private _indexBuffer;
  34511. /**
  34512. * Instantiates a new bounding box renderer in a scene.
  34513. * @param scene the scene the renderer renders in
  34514. */
  34515. constructor(scene: Scene);
  34516. /**
  34517. * Registers the component in a given scene
  34518. */
  34519. register(): void;
  34520. private _evaluateSubMesh;
  34521. private _activeMesh;
  34522. private _prepareRessources;
  34523. private _createIndexBuffer;
  34524. /**
  34525. * Rebuilds the elements related to this component in case of
  34526. * context lost for instance.
  34527. */
  34528. rebuild(): void;
  34529. /**
  34530. * @hidden
  34531. */
  34532. reset(): void;
  34533. /**
  34534. * Render the bounding boxes of a specific rendering group
  34535. * @param renderingGroupId defines the rendering group to render
  34536. */
  34537. render(renderingGroupId: number): void;
  34538. /**
  34539. * In case of occlusion queries, we can render the occlusion bounding box through this method
  34540. * @param mesh Define the mesh to render the occlusion bounding box for
  34541. */
  34542. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  34543. /**
  34544. * Dispose and release the resources attached to this renderer.
  34545. */
  34546. dispose(): void;
  34547. }
  34548. }
  34549. declare module BABYLON {
  34550. /**
  34551. * This represents a depth renderer in Babylon.
  34552. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  34553. */
  34554. class DepthRenderer {
  34555. private _scene;
  34556. private _depthMap;
  34557. private _effect;
  34558. private _cachedDefines;
  34559. private _camera;
  34560. /**
  34561. * Specifiess that the depth renderer will only be used within
  34562. * the camera it is created for.
  34563. * This can help forcing its rendering during the camera processing.
  34564. */
  34565. useOnlyInActiveCamera: boolean;
  34566. /**
  34567. * Instantiates a depth renderer
  34568. * @param scene The scene the renderer belongs to
  34569. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  34570. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  34571. */
  34572. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  34573. /**
  34574. * Creates the depth rendering effect and checks if the effect is ready.
  34575. * @param subMesh The submesh to be used to render the depth map of
  34576. * @param useInstances If multiple world instances should be used
  34577. * @returns if the depth renderer is ready to render the depth map
  34578. */
  34579. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  34580. /**
  34581. * Gets the texture which the depth map will be written to.
  34582. * @returns The depth map texture
  34583. */
  34584. getDepthMap(): RenderTargetTexture;
  34585. /**
  34586. * Disposes of the depth renderer.
  34587. */
  34588. dispose(): void;
  34589. }
  34590. }
  34591. declare module BABYLON {
  34592. interface Scene {
  34593. /** @hidden (Backing field) */
  34594. ;
  34595. /**
  34596. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  34597. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  34598. * @returns the created depth renderer
  34599. */
  34600. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  34601. /**
  34602. * Disables a depth renderer for a given camera
  34603. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  34604. */
  34605. disableDepthRenderer(camera?: Nullable<Camera>): void;
  34606. }
  34607. /**
  34608. * Defines the Depth Renderer scene component responsible to manage a depth buffer usefull
  34609. * in several rendering techniques.
  34610. */
  34611. class DepthRendererSceneComponent implements ISceneComponent {
  34612. /**
  34613. * The component name helpfull to identify the component in the list of scene components.
  34614. */
  34615. readonly name: string;
  34616. /**
  34617. * The scene the component belongs to.
  34618. */
  34619. scene: Scene;
  34620. /**
  34621. * Creates a new instance of the component for the given scene
  34622. * @param scene Defines the scene to register the component in
  34623. */
  34624. constructor(scene: Scene);
  34625. /**
  34626. * Registers the component in a given scene
  34627. */
  34628. register(): void;
  34629. /**
  34630. * Rebuilds the elements related to this component in case of
  34631. * context lost for instance.
  34632. */
  34633. rebuild(): void;
  34634. /**
  34635. * Disposes the component and the associated ressources
  34636. */
  34637. dispose(): void;
  34638. private _gatherRenderTargets;
  34639. private _gatherActiveCameraRenderTargets;
  34640. }
  34641. }
  34642. declare module BABYLON {
  34643. interface AbstractMesh {
  34644. /**
  34645. * Disables the mesh edge rendering mode
  34646. * @returns the currentAbstractMesh
  34647. */
  34648. disableEdgesRendering(): AbstractMesh;
  34649. /**
  34650. * Enables the edge rendering mode on the mesh.
  34651. * This mode makes the mesh edges visible
  34652. * @param epsilon defines the maximal distance between two angles to detect a face
  34653. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  34654. * @returns the currentAbstractMesh
  34655. * @see https://www.babylonjs-playground.com/#19O9TU#0
  34656. */
  34657. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  34658. /**
  34659. * Gets the edgesRenderer associated with the mesh
  34660. */
  34661. edgesRenderer: Nullable<EdgesRenderer>;
  34662. }
  34663. interface LinesMesh {
  34664. /**
  34665. * Enables the edge rendering mode on the mesh.
  34666. * This mode makes the mesh edges visible
  34667. * @param epsilon defines the maximal distance between two angles to detect a face
  34668. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  34669. * @returns the currentAbstractMesh
  34670. * @see https://www.babylonjs-playground.com/#19O9TU#0
  34671. */
  34672. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  34673. }
  34674. /**
  34675. * Defines the minimum contract an Edges renderer should follow.
  34676. */
  34677. interface IEdgesRenderer extends IDisposable {
  34678. /**
  34679. * Gets or sets a boolean indicating if the edgesRenderer is active
  34680. */
  34681. isEnabled: boolean;
  34682. /**
  34683. * Renders the edges of the attached mesh,
  34684. */
  34685. render(): void;
  34686. /**
  34687. * Checks wether or not the edges renderer is ready to render.
  34688. * @return true if ready, otherwise false.
  34689. */
  34690. isReady(): boolean;
  34691. }
  34692. /**
  34693. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  34694. */
  34695. class EdgesRenderer implements IEdgesRenderer {
  34696. /**
  34697. * Define the size of the edges with an orthographic camera
  34698. */
  34699. edgesWidthScalerForOrthographic: number;
  34700. /**
  34701. * Define the size of the edges with a perspective camera
  34702. */
  34703. edgesWidthScalerForPerspective: number;
  34704. protected _source: AbstractMesh;
  34705. protected _linesPositions: number[];
  34706. protected _linesNormals: number[];
  34707. protected _linesIndices: number[];
  34708. protected _epsilon: number;
  34709. protected _indicesCount: number;
  34710. protected _lineShader: ShaderMaterial;
  34711. protected _ib: WebGLBuffer;
  34712. protected _buffers: {
  34713. [key: string]: Nullable<VertexBuffer>;
  34714. };
  34715. protected _checkVerticesInsteadOfIndices: boolean;
  34716. private _meshRebuildObserver;
  34717. private _meshDisposeObserver;
  34718. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  34719. isEnabled: boolean;
  34720. /**
  34721. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  34722. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  34723. * @param source Mesh used to create edges
  34724. * @param epsilon sum of angles in adjacency to check for edge
  34725. * @param checkVerticesInsteadOfIndices
  34726. * @param generateEdgesLines - should generate Lines or only prepare resources.
  34727. */
  34728. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  34729. protected _prepareRessources(): void;
  34730. /** @hidden */
  34731. /**
  34732. * Releases the required resources for the edges renderer
  34733. */
  34734. dispose(): void;
  34735. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  34736. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  34737. /**
  34738. * Checks if the pair of p0 and p1 is en edge
  34739. * @param faceIndex
  34740. * @param edge
  34741. * @param faceNormals
  34742. * @param p0
  34743. * @param p1
  34744. * @private
  34745. */
  34746. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  34747. /**
  34748. * Generates lines edges from adjacencjes
  34749. * @private
  34750. */
  34751. /**
  34752. * Checks wether or not the edges renderer is ready to render.
  34753. * @return true if ready, otherwise false.
  34754. */
  34755. isReady(): boolean;
  34756. /**
  34757. * Renders the edges of the attached mesh,
  34758. */
  34759. render(): void;
  34760. }
  34761. }
  34762. declare module BABYLON {
  34763. /**
  34764. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  34765. */
  34766. class GeometryBufferRenderer {
  34767. private _scene;
  34768. private _multiRenderTarget;
  34769. private _ratio;
  34770. private _enablePosition;
  34771. protected _effect: Effect;
  34772. protected _cachedDefines: string;
  34773. /**
  34774. * Set the render list (meshes to be rendered) used in the G buffer.
  34775. */
  34776. renderList: Mesh[];
  34777. /**
  34778. * Gets wether or not G buffer are supported by the running hardware.
  34779. * This requires draw buffer supports
  34780. */
  34781. readonly isSupported: boolean;
  34782. /**
  34783. * Gets wether or not position are enabled for the G buffer.
  34784. */
  34785. /**
  34786. * Sets wether or not position are enabled for the G buffer.
  34787. */
  34788. enablePosition: boolean;
  34789. /**
  34790. * Gets the scene associated with the buffer.
  34791. */
  34792. readonly scene: Scene;
  34793. /**
  34794. * Gets the ratio used by the buffer during its creation.
  34795. * How big is the buffer related to the main canvas.
  34796. */
  34797. readonly ratio: number;
  34798. /**
  34799. * Creates a new G Buffer for the scene
  34800. * @param scene The scene the buffer belongs to
  34801. * @param ratio How big is the buffer related to the main canvas.
  34802. */
  34803. constructor(scene: Scene, ratio?: number);
  34804. /**
  34805. * Checks wether everything is ready to render a submesh to the G buffer.
  34806. * @param subMesh the submesh to check readiness for
  34807. * @param useInstances is the mesh drawn using instance or not
  34808. * @returns true if ready otherwise false
  34809. */
  34810. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  34811. /**
  34812. * Gets the current underlying G Buffer.
  34813. * @returns the buffer
  34814. */
  34815. getGBuffer(): MultiRenderTarget;
  34816. /**
  34817. * Gets the number of samples used to render the buffer (anti aliasing).
  34818. */
  34819. /**
  34820. * Sets the number of samples used to render the buffer (anti aliasing).
  34821. */
  34822. samples: number;
  34823. /**
  34824. * Disposes the renderer and frees up associated resources.
  34825. */
  34826. dispose(): void;
  34827. protected _createRenderTargets(): void;
  34828. }
  34829. }
  34830. declare module BABYLON {
  34831. interface Scene {
  34832. /** @hidden (Backing field) */
  34833. /**
  34834. * Gets or Sets the current geometry buffer associated to the scene.
  34835. */
  34836. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  34837. /**
  34838. * Enables a GeometryBufferRender and associates it with the scene
  34839. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  34840. * @returns the GeometryBufferRenderer
  34841. */
  34842. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  34843. /**
  34844. * Disables the GeometryBufferRender associated with the scene
  34845. */
  34846. disableGeometryBufferRenderer(): void;
  34847. }
  34848. /**
  34849. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  34850. * in several rendering techniques.
  34851. */
  34852. class GeometryBufferRendererSceneComponent implements ISceneComponent {
  34853. /**
  34854. * The component name helpful to identify the component in the list of scene components.
  34855. */
  34856. readonly name: string;
  34857. /**
  34858. * The scene the component belongs to.
  34859. */
  34860. scene: Scene;
  34861. /**
  34862. * Creates a new instance of the component for the given scene
  34863. * @param scene Defines the scene to register the component in
  34864. */
  34865. constructor(scene: Scene);
  34866. /**
  34867. * Registers the component in a given scene
  34868. */
  34869. register(): void;
  34870. /**
  34871. * Rebuilds the elements related to this component in case of
  34872. * context lost for instance.
  34873. */
  34874. rebuild(): void;
  34875. /**
  34876. * Disposes the component and the associated ressources
  34877. */
  34878. dispose(): void;
  34879. private _gatherRenderTargets;
  34880. }
  34881. }
  34882. declare module BABYLON {
  34883. /**
  34884. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  34885. */
  34886. class LineEdgesRenderer extends EdgesRenderer {
  34887. /**
  34888. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  34889. * @param source LineMesh used to generate edges
  34890. * @param epsilon not important (specified angle for edge detection)
  34891. * @param checkVerticesInsteadOfIndices not important for LineMesh
  34892. */
  34893. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  34894. /**
  34895. * Always create the edge since its a line so only important things are p0 and p1
  34896. * @param faceIndex not important for LineMesh
  34897. * @param edge not important for LineMesh
  34898. * @param faceNormals not important for LineMesh
  34899. * @param p0 beginnig of line
  34900. * @param p1 end of line
  34901. */
  34902. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  34903. /**
  34904. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  34905. */
  34906. }
  34907. }
  34908. declare module BABYLON {
  34909. interface Scene {
  34910. /** @hidden */
  34911. /**
  34912. * Gets the outline renderer associated with the scene
  34913. * @returns a OutlineRenderer
  34914. */
  34915. getOutlineRenderer(): OutlineRenderer;
  34916. }
  34917. interface AbstractMesh {
  34918. /** @hidden (Backing field) */
  34919. /**
  34920. * Gets or sets a boolean indicating if the outline must be rendered as well
  34921. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  34922. */
  34923. renderOutline: boolean;
  34924. /** @hidden (Backing field) */
  34925. /**
  34926. * Gets or sets a boolean indicating if the overlay must be rendered as well
  34927. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  34928. */
  34929. renderOverlay: boolean;
  34930. }
  34931. /**
  34932. * This class is responsible to draw bothe outline/overlay of meshes.
  34933. * It should not be used directly but through the available method on mesh.
  34934. */
  34935. class OutlineRenderer implements ISceneComponent {
  34936. /**
  34937. * The name of the component. Each component must have a unique name.
  34938. */
  34939. name: string;
  34940. /**
  34941. * The scene the component belongs to.
  34942. */
  34943. scene: Scene;
  34944. /**
  34945. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  34946. */
  34947. zOffset: number;
  34948. private _engine;
  34949. private _effect;
  34950. private _cachedDefines;
  34951. private _savedDepthWrite;
  34952. /**
  34953. * Instantiates a new outline renderer. (There could be only one per scene).
  34954. * @param scene Defines the scene it belongs to
  34955. */
  34956. constructor(scene: Scene);
  34957. /**
  34958. * Register the component to one instance of a scene.
  34959. */
  34960. register(): void;
  34961. /**
  34962. * Rebuilds the elements related to this component in case of
  34963. * context lost for instance.
  34964. */
  34965. rebuild(): void;
  34966. /**
  34967. * Disposes the component and the associated ressources.
  34968. */
  34969. dispose(): void;
  34970. /**
  34971. * Renders the outline in the canvas.
  34972. * @param subMesh Defines the sumesh to render
  34973. * @param batch Defines the batch of meshes in case of instances
  34974. * @param useOverlay Defines if the rendering is for the overlay or the outline
  34975. */
  34976. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  34977. /**
  34978. * Returns whether or not the outline renderer is ready for a given submesh.
  34979. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  34980. * @param subMesh Defines the submesh to check readyness for
  34981. * @param useInstances Defines wheter wee are trying to render instances or not
  34982. * @returns true if ready otherwise false
  34983. */
  34984. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  34985. private _beforeRenderingMesh;
  34986. private _afterRenderingMesh;
  34987. }
  34988. }
  34989. declare module BABYLON {
  34990. /**
  34991. * This represents the object necessary to create a rendering group.
  34992. * This is exclusively used and created by the rendering manager.
  34993. * To modify the behavior, you use the available helpers in your scene or meshes.
  34994. * @hidden
  34995. */
  34996. class RenderingGroup {
  34997. index: number;
  34998. private _scene;
  34999. private _opaqueSubMeshes;
  35000. private _transparentSubMeshes;
  35001. private _alphaTestSubMeshes;
  35002. private _depthOnlySubMeshes;
  35003. private _particleSystems;
  35004. private _spriteManagers;
  35005. private _opaqueSortCompareFn;
  35006. private _alphaTestSortCompareFn;
  35007. private _transparentSortCompareFn;
  35008. private _renderOpaque;
  35009. private _renderAlphaTest;
  35010. private _renderTransparent;
  35011. private _edgesRenderers;
  35012. onBeforeTransparentRendering: () => void;
  35013. /**
  35014. * Set the opaque sort comparison function.
  35015. * If null the sub meshes will be render in the order they were created
  35016. */
  35017. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  35018. /**
  35019. * Set the alpha test sort comparison function.
  35020. * If null the sub meshes will be render in the order they were created
  35021. */
  35022. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  35023. /**
  35024. * Set the transparent sort comparison function.
  35025. * If null the sub meshes will be render in the order they were created
  35026. */
  35027. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  35028. /**
  35029. * Creates a new rendering group.
  35030. * @param index The rendering group index
  35031. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  35032. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  35033. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  35034. */
  35035. 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>);
  35036. /**
  35037. * Render all the sub meshes contained in the group.
  35038. * @param customRenderFunction Used to override the default render behaviour of the group.
  35039. * @returns true if rendered some submeshes.
  35040. */
  35041. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  35042. /**
  35043. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  35044. * @param subMeshes The submeshes to render
  35045. */
  35046. private renderOpaqueSorted;
  35047. /**
  35048. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  35049. * @param subMeshes The submeshes to render
  35050. */
  35051. private renderAlphaTestSorted;
  35052. /**
  35053. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  35054. * @param subMeshes The submeshes to render
  35055. */
  35056. private renderTransparentSorted;
  35057. /**
  35058. * Renders the submeshes in a specified order.
  35059. * @param subMeshes The submeshes to sort before render
  35060. * @param sortCompareFn The comparison function use to sort
  35061. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  35062. * @param transparent Specifies to activate blending if true
  35063. */
  35064. private static renderSorted;
  35065. /**
  35066. * Renders the submeshes in the order they were dispatched (no sort applied).
  35067. * @param subMeshes The submeshes to render
  35068. */
  35069. private static renderUnsorted;
  35070. /**
  35071. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  35072. * are rendered back to front if in the same alpha index.
  35073. *
  35074. * @param a The first submesh
  35075. * @param b The second submesh
  35076. * @returns The result of the comparison
  35077. */
  35078. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  35079. /**
  35080. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  35081. * are rendered back to front.
  35082. *
  35083. * @param a The first submesh
  35084. * @param b The second submesh
  35085. * @returns The result of the comparison
  35086. */
  35087. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  35088. /**
  35089. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  35090. * are rendered front to back (prevent overdraw).
  35091. *
  35092. * @param a The first submesh
  35093. * @param b The second submesh
  35094. * @returns The result of the comparison
  35095. */
  35096. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  35097. /**
  35098. * Resets the different lists of submeshes to prepare a new frame.
  35099. */
  35100. prepare(): void;
  35101. dispose(): void;
  35102. /**
  35103. * Inserts the submesh in its correct queue depending on its material.
  35104. * @param subMesh The submesh to dispatch
  35105. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  35106. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  35107. */
  35108. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  35109. dispatchSprites(spriteManager: ISpriteManager): void;
  35110. dispatchParticles(particleSystem: IParticleSystem): void;
  35111. private _renderParticles;
  35112. private _renderSprites;
  35113. }
  35114. }
  35115. declare module BABYLON {
  35116. /**
  35117. * Interface describing the different options available in the rendering manager
  35118. * regarding Auto Clear between groups.
  35119. */
  35120. interface IRenderingManagerAutoClearSetup {
  35121. /**
  35122. * Defines whether or not autoclear is enable.
  35123. */
  35124. autoClear: boolean;
  35125. /**
  35126. * Defines whether or not to autoclear the depth buffer.
  35127. */
  35128. depth: boolean;
  35129. /**
  35130. * Defines whether or not to autoclear the stencil buffer.
  35131. */
  35132. stencil: boolean;
  35133. }
  35134. /**
  35135. * This is the manager responsible of all the rendering for meshes sprites and particles.
  35136. * It is enable to manage the different groups as well as the different necessary sort functions.
  35137. * This should not be used directly aside of the few static configurations
  35138. */
  35139. class RenderingManager {
  35140. /**
  35141. * The max id used for rendering groups (not included)
  35142. */
  35143. static MAX_RENDERINGGROUPS: number;
  35144. /**
  35145. * The min id used for rendering groups (included)
  35146. */
  35147. static MIN_RENDERINGGROUPS: number;
  35148. /**
  35149. * Used to globally prevent autoclearing scenes.
  35150. */
  35151. static AUTOCLEAR: boolean;
  35152. /**
  35153. * @hidden
  35154. */
  35155. private _scene;
  35156. private _renderingGroups;
  35157. private _depthStencilBufferAlreadyCleaned;
  35158. private _autoClearDepthStencil;
  35159. private _customOpaqueSortCompareFn;
  35160. private _customAlphaTestSortCompareFn;
  35161. private _customTransparentSortCompareFn;
  35162. private _renderingGroupInfo;
  35163. /**
  35164. * Instantiates a new rendering group for a particular scene
  35165. * @param scene Defines the scene the groups belongs to
  35166. */
  35167. constructor(scene: Scene);
  35168. private _clearDepthStencilBuffer;
  35169. /**
  35170. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  35171. * @hidden
  35172. */
  35173. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  35174. /**
  35175. * Resets the different information of the group to prepare a new frame
  35176. * @hidden
  35177. */
  35178. reset(): void;
  35179. /**
  35180. * Dispose and release the group and its associated resources.
  35181. * @hidden
  35182. */
  35183. dispose(): void;
  35184. /**
  35185. * Clear the info related to rendering groups preventing retention points during dispose.
  35186. */
  35187. freeRenderingGroups(): void;
  35188. private _prepareRenderingGroup;
  35189. /**
  35190. * Add a sprite manager to the rendering manager in order to render it this frame.
  35191. * @param spriteManager Define the sprite manager to render
  35192. */
  35193. dispatchSprites(spriteManager: ISpriteManager): void;
  35194. /**
  35195. * Add a particle system to the rendering manager in order to render it this frame.
  35196. * @param particleSystem Define the particle system to render
  35197. */
  35198. dispatchParticles(particleSystem: IParticleSystem): void;
  35199. /**
  35200. * Add a submesh to the manager in order to render it this frame
  35201. * @param subMesh The submesh to dispatch
  35202. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  35203. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  35204. */
  35205. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  35206. /**
  35207. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  35208. * This allowed control for front to back rendering or reversly depending of the special needs.
  35209. *
  35210. * @param renderingGroupId The rendering group id corresponding to its index
  35211. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  35212. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  35213. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  35214. */
  35215. 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;
  35216. /**
  35217. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  35218. *
  35219. * @param renderingGroupId The rendering group id corresponding to its index
  35220. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  35221. * @param depth Automatically clears depth between groups if true and autoClear is true.
  35222. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  35223. */
  35224. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  35225. /**
  35226. * Gets the current auto clear configuration for one rendering group of the rendering
  35227. * manager.
  35228. * @param index the rendering group index to get the information for
  35229. * @returns The auto clear setup for the requested rendering group
  35230. */
  35231. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  35232. }
  35233. }
  35234. declare module BABYLON {
  35235. /**
  35236. * Renders a layer on top of an existing scene
  35237. */
  35238. class UtilityLayerRenderer implements IDisposable {
  35239. /** the original scene that will be rendered on top of */
  35240. originalScene: Scene;
  35241. private _pointerCaptures;
  35242. private _lastPointerEvents;
  35243. private static _DefaultUtilityLayer;
  35244. private static _DefaultKeepDepthUtilityLayer;
  35245. /**
  35246. * 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)
  35247. */
  35248. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  35249. /**
  35250. * 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)
  35251. */
  35252. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  35253. /**
  35254. * The scene that is rendered on top of the original scene
  35255. */
  35256. utilityLayerScene: Scene;
  35257. /**
  35258. * If the utility layer should automatically be rendered on top of existing scene
  35259. */
  35260. shouldRender: boolean;
  35261. /**
  35262. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  35263. */
  35264. onlyCheckPointerDownEvents: boolean;
  35265. /**
  35266. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  35267. */
  35268. processAllEvents: boolean;
  35269. /**
  35270. * Observable raised when the pointer move from the utility layer scene to the main scene
  35271. */
  35272. onPointerOutObservable: Observable<number>;
  35273. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  35274. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  35275. private _afterRenderObserver;
  35276. private _sceneDisposeObserver;
  35277. private _originalPointerObserver;
  35278. /**
  35279. * Instantiates a UtilityLayerRenderer
  35280. * @param originalScene the original scene that will be rendered on top of
  35281. */
  35282. constructor(
  35283. /** the original scene that will be rendered on top of */
  35284. originalScene: Scene);
  35285. private _notifyObservers;
  35286. /**
  35287. * Renders the utility layers scene on top of the original scene
  35288. */
  35289. render(): void;
  35290. /**
  35291. * Disposes of the renderer
  35292. */
  35293. dispose(): void;
  35294. private _updateCamera;
  35295. }
  35296. }
  35297. declare module BABYLON {
  35298. /**
  35299. * Class used to represent a sprite
  35300. * @see http://doc.babylonjs.com/babylon101/sprites
  35301. */
  35302. class Sprite {
  35303. /** defines the name */
  35304. name: string;
  35305. /** Gets or sets the current world position */
  35306. position: Vector3;
  35307. /** Gets or sets the main color */
  35308. color: Color4;
  35309. /** Gets or sets the width */
  35310. width: number;
  35311. /** Gets or sets the height */
  35312. height: number;
  35313. /** Gets or sets rotation angle */
  35314. angle: number;
  35315. /** Gets or sets the cell index in the sprite sheet */
  35316. cellIndex: number;
  35317. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  35318. invertU: number;
  35319. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  35320. invertV: number;
  35321. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  35322. disposeWhenFinishedAnimating: boolean;
  35323. /** Gets the list of attached animations */
  35324. animations: Animation[];
  35325. /** Gets or sets a boolean indicating if the sprite can be picked */
  35326. isPickable: boolean;
  35327. /**
  35328. * Gets or sets the associated action manager
  35329. */
  35330. actionManager: Nullable<ActionManager>;
  35331. private _animationStarted;
  35332. private _loopAnimation;
  35333. private _fromIndex;
  35334. private _toIndex;
  35335. private _delay;
  35336. private _direction;
  35337. private _manager;
  35338. private _time;
  35339. private _onAnimationEnd;
  35340. /**
  35341. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  35342. */
  35343. isVisible: boolean;
  35344. /**
  35345. * Gets or sets the sprite size
  35346. */
  35347. size: number;
  35348. /**
  35349. * Creates a new Sprite
  35350. * @param name defines the name
  35351. * @param manager defines the manager
  35352. */
  35353. constructor(
  35354. /** defines the name */
  35355. name: string, manager: ISpriteManager);
  35356. /**
  35357. * Starts an animation
  35358. * @param from defines the initial key
  35359. * @param to defines the end key
  35360. * @param loop defines if the animation must loop
  35361. * @param delay defines the start delay (in ms)
  35362. * @param onAnimationEnd defines a callback to call when animation ends
  35363. */
  35364. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  35365. /** Stops current animation (if any) */
  35366. stopAnimation(): void;
  35367. /** @hidden */
  35368. /** Release associated resources */
  35369. dispose(): void;
  35370. }
  35371. }
  35372. declare module BABYLON {
  35373. /**
  35374. * Defines the minimum interface to fullfil in order to be a sprite manager.
  35375. */
  35376. interface ISpriteManager extends IDisposable {
  35377. /**
  35378. * Restricts the camera to viewing objects with the same layerMask.
  35379. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  35380. */
  35381. layerMask: number;
  35382. /**
  35383. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  35384. */
  35385. isPickable: boolean;
  35386. /**
  35387. * Specifies the rendering group id for this mesh (0 by default)
  35388. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  35389. */
  35390. renderingGroupId: number;
  35391. /**
  35392. * Defines the list of sprites managed by the manager.
  35393. */
  35394. sprites: Array<Sprite>;
  35395. /**
  35396. * Tests the intersection of a sprite with a specific ray.
  35397. * @param ray The ray we are sending to test the collision
  35398. * @param camera The camera space we are sending rays in
  35399. * @param predicate A predicate allowing excluding sprites from the list of object to test
  35400. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  35401. * @returns picking info or null.
  35402. */
  35403. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  35404. /**
  35405. * Renders the list of sprites on screen.
  35406. */
  35407. render(): void;
  35408. }
  35409. /**
  35410. * Class used to manage multiple sprites on the same spritesheet
  35411. * @see http://doc.babylonjs.com/babylon101/sprites
  35412. */
  35413. class SpriteManager implements ISpriteManager {
  35414. /** defines the manager's name */
  35415. name: string;
  35416. /** Gets the list of sprites */
  35417. sprites: Sprite[];
  35418. /** Gets or sets the rendering group id (0 by default) */
  35419. renderingGroupId: number;
  35420. /** Gets or sets camera layer mask */
  35421. layerMask: number;
  35422. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  35423. fogEnabled: boolean;
  35424. /** Gets or sets a boolean indicating if the sprites are pickable */
  35425. isPickable: boolean;
  35426. /** Defines the default width of a cell in the spritesheet */
  35427. cellWidth: number;
  35428. /** Defines the default height of a cell in the spritesheet */
  35429. cellHeight: number;
  35430. /**
  35431. * An event triggered when the manager is disposed.
  35432. */
  35433. onDisposeObservable: Observable<SpriteManager>;
  35434. private _onDisposeObserver;
  35435. /**
  35436. * Callback called when the manager is disposed
  35437. */
  35438. onDispose: () => void;
  35439. private _capacity;
  35440. private _spriteTexture;
  35441. private _epsilon;
  35442. private _scene;
  35443. private _vertexData;
  35444. private _buffer;
  35445. private _vertexBuffers;
  35446. private _indexBuffer;
  35447. private _effectBase;
  35448. private _effectFog;
  35449. /**
  35450. * Gets or sets the spritesheet texture
  35451. */
  35452. texture: Texture;
  35453. /**
  35454. * Creates a new sprite manager
  35455. * @param name defines the manager's name
  35456. * @param imgUrl defines the sprite sheet url
  35457. * @param capacity defines the maximum allowed number of sprites
  35458. * @param cellSize defines the size of a sprite cell
  35459. * @param scene defines the hosting scene
  35460. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  35461. * @param samplingMode defines the smapling mode to use with spritesheet
  35462. */
  35463. constructor(
  35464. /** defines the manager's name */
  35465. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  35466. private _appendSpriteVertex;
  35467. /**
  35468. * Intersects the sprites with a ray
  35469. * @param ray defines the ray to intersect with
  35470. * @param camera defines the current active camera
  35471. * @param predicate defines a predicate used to select candidate sprites
  35472. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  35473. * @returns null if no hit or a PickingInfo
  35474. */
  35475. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  35476. /**
  35477. * Render all child sprites
  35478. */
  35479. render(): void;
  35480. /**
  35481. * Release associated resources
  35482. */
  35483. dispose(): void;
  35484. }
  35485. }
  35486. declare module BABYLON {
  35487. interface Scene {
  35488. /** @hidden */
  35489. /** @hidden */
  35490. /** @hidden */
  35491. /**
  35492. * All of the sprite managers added to this scene
  35493. * @see http://doc.babylonjs.com/babylon101/sprites
  35494. */
  35495. spriteManagers: Array<ISpriteManager>;
  35496. /**
  35497. * An event triggered when sprites rendering is about to start
  35498. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  35499. */
  35500. onBeforeSpritesRenderingObservable: Observable<Scene>;
  35501. /**
  35502. * An event triggered when sprites rendering is done
  35503. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  35504. */
  35505. onAfterSpritesRenderingObservable: Observable<Scene>;
  35506. /** @hidden */
  35507. /** Launch a ray to try to pick a sprite in the scene
  35508. * @param x position on screen
  35509. * @param y position on screen
  35510. * @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
  35511. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  35512. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  35513. * @returns a PickingInfo
  35514. */
  35515. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  35516. /** Use the given ray to pick a sprite in the scene
  35517. * @param ray The ray (in world space) to use to pick meshes
  35518. * @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
  35519. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  35520. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  35521. * @returns a PickingInfo
  35522. */
  35523. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  35524. /**
  35525. * Force the sprite under the pointer
  35526. * @param sprite defines the sprite to use
  35527. */
  35528. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  35529. /**
  35530. * Gets the sprite under the pointer
  35531. * @returns a Sprite or null if no sprite is under the pointer
  35532. */
  35533. getPointerOverSprite(): Nullable<Sprite>;
  35534. }
  35535. /**
  35536. * Defines the sprite scene component responsible to manage sprites
  35537. * in a given scene.
  35538. */
  35539. class SpriteSceneComponent implements ISceneComponent {
  35540. /**
  35541. * The component name helpfull to identify the component in the list of scene components.
  35542. */
  35543. readonly name: string;
  35544. /**
  35545. * The scene the component belongs to.
  35546. */
  35547. scene: Scene;
  35548. /** @hidden */
  35549. private _spritePredicate;
  35550. /**
  35551. * Creates a new instance of the component for the given scene
  35552. * @param scene Defines the scene to register the component in
  35553. */
  35554. constructor(scene: Scene);
  35555. /**
  35556. * Registers the component in a given scene
  35557. */
  35558. register(): void;
  35559. /**
  35560. * Rebuilds the elements related to this component in case of
  35561. * context lost for instance.
  35562. */
  35563. rebuild(): void;
  35564. /**
  35565. * Disposes the component and the associated ressources.
  35566. */
  35567. dispose(): void;
  35568. private _pickSpriteButKeepRay;
  35569. private _pointerMove;
  35570. private _pointerDown;
  35571. private _pointerUp;
  35572. }
  35573. }
  35574. declare module BABYLON {
  35575. /**
  35576. * @hidden
  35577. **/
  35578. class _AlphaState {
  35579. private _isAlphaBlendDirty;
  35580. private _isBlendFunctionParametersDirty;
  35581. private _isBlendEquationParametersDirty;
  35582. private _isBlendConstantsDirty;
  35583. private _alphaBlend;
  35584. private _blendFunctionParameters;
  35585. private _blendEquationParameters;
  35586. private _blendConstants;
  35587. /**
  35588. * Initializes the state.
  35589. */
  35590. constructor();
  35591. readonly isDirty: boolean;
  35592. alphaBlend: boolean;
  35593. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  35594. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  35595. setAlphaEquationParameters(rgb: number, alpha: number): void;
  35596. reset(): void;
  35597. apply(gl: WebGLRenderingContext): void;
  35598. }
  35599. }
  35600. declare module BABYLON {
  35601. /**
  35602. * @hidden
  35603. **/
  35604. class _DepthCullingState {
  35605. private _isDepthTestDirty;
  35606. private _isDepthMaskDirty;
  35607. private _isDepthFuncDirty;
  35608. private _isCullFaceDirty;
  35609. private _isCullDirty;
  35610. private _isZOffsetDirty;
  35611. private _isFrontFaceDirty;
  35612. private _depthTest;
  35613. private _depthMask;
  35614. private _depthFunc;
  35615. private _cull;
  35616. private _cullFace;
  35617. private _zOffset;
  35618. private _frontFace;
  35619. /**
  35620. * Initializes the state.
  35621. */
  35622. constructor();
  35623. readonly isDirty: boolean;
  35624. zOffset: number;
  35625. cullFace: Nullable<number>;
  35626. cull: Nullable<boolean>;
  35627. depthFunc: Nullable<number>;
  35628. depthMask: boolean;
  35629. depthTest: boolean;
  35630. frontFace: Nullable<number>;
  35631. reset(): void;
  35632. apply(gl: WebGLRenderingContext): void;
  35633. }
  35634. }
  35635. declare module BABYLON {
  35636. /**
  35637. * @hidden
  35638. **/
  35639. class _StencilState {
  35640. private _isStencilTestDirty;
  35641. private _isStencilMaskDirty;
  35642. private _isStencilFuncDirty;
  35643. private _isStencilOpDirty;
  35644. private _stencilTest;
  35645. private _stencilMask;
  35646. private _stencilFunc;
  35647. private _stencilFuncRef;
  35648. private _stencilFuncMask;
  35649. private _stencilOpStencilFail;
  35650. private _stencilOpDepthFail;
  35651. private _stencilOpStencilDepthPass;
  35652. readonly isDirty: boolean;
  35653. stencilFunc: number;
  35654. stencilFuncRef: number;
  35655. stencilFuncMask: number;
  35656. stencilOpStencilFail: number;
  35657. stencilOpDepthFail: number;
  35658. stencilOpStencilDepthPass: number;
  35659. stencilMask: number;
  35660. stencilTest: boolean;
  35661. constructor();
  35662. reset(): void;
  35663. apply(gl: WebGLRenderingContext): void;
  35664. }
  35665. }
  35666. declare module BABYLON {
  35667. /**
  35668. * Class used to evalaute queries containing `and` and `or` operators
  35669. */
  35670. class AndOrNotEvaluator {
  35671. /**
  35672. * Evaluate a query
  35673. * @param query defines the query to evaluate
  35674. * @param evaluateCallback defines the callback used to filter result
  35675. * @returns true if the query matches
  35676. */
  35677. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  35678. private static _HandleParenthesisContent;
  35679. private static _SimplifyNegation;
  35680. }
  35681. }
  35682. declare module BABYLON {
  35683. /**
  35684. * Defines the list of states available for a task inside a AssetsManager
  35685. */
  35686. enum AssetTaskState {
  35687. /**
  35688. * Initialization
  35689. */
  35690. INIT = 0,
  35691. /**
  35692. * Running
  35693. */
  35694. RUNNING = 1,
  35695. /**
  35696. * Done
  35697. */
  35698. DONE = 2,
  35699. /**
  35700. * Error
  35701. */
  35702. ERROR = 3
  35703. }
  35704. /**
  35705. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  35706. */
  35707. abstract class AbstractAssetTask {
  35708. /**
  35709. * Task name
  35710. */ name: string;
  35711. /**
  35712. * Callback called when the task is successful
  35713. */
  35714. onSuccess: (task: any) => void;
  35715. /**
  35716. * Callback called when the task is not successful
  35717. */
  35718. onError: (task: any, message?: string, exception?: any) => void;
  35719. /**
  35720. * Creates a new AssetsManager
  35721. * @param name defines the name of the task
  35722. */
  35723. constructor(
  35724. /**
  35725. * Task name
  35726. */ name: string);
  35727. private _isCompleted;
  35728. private _taskState;
  35729. private _errorObject;
  35730. /**
  35731. * Get if the task is completed
  35732. */
  35733. readonly isCompleted: boolean;
  35734. /**
  35735. * Gets the current state of the task
  35736. */
  35737. readonly taskState: AssetTaskState;
  35738. /**
  35739. * Gets the current error object (if task is in error)
  35740. */
  35741. readonly errorObject: {
  35742. message?: string;
  35743. exception?: any;
  35744. };
  35745. /**
  35746. * Internal only
  35747. * @hidden
  35748. */
  35749. /**
  35750. * Execute the current task
  35751. * @param scene defines the scene where you want your assets to be loaded
  35752. * @param onSuccess is a callback called when the task is successfully executed
  35753. * @param onError is a callback called if an error occurs
  35754. */
  35755. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  35756. /**
  35757. * Execute the current task
  35758. * @param scene defines the scene where you want your assets to be loaded
  35759. * @param onSuccess is a callback called when the task is successfully executed
  35760. * @param onError is a callback called if an error occurs
  35761. */
  35762. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  35763. /**
  35764. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  35765. * This can be used with failed tasks that have the reason for failure fixed.
  35766. */
  35767. reset(): void;
  35768. private onErrorCallback;
  35769. private onDoneCallback;
  35770. }
  35771. /**
  35772. * Define the interface used by progress events raised during assets loading
  35773. */
  35774. interface IAssetsProgressEvent {
  35775. /**
  35776. * Defines the number of remaining tasks to process
  35777. */
  35778. remainingCount: number;
  35779. /**
  35780. * Defines the total number of tasks
  35781. */
  35782. totalCount: number;
  35783. /**
  35784. * Defines the task that was just processed
  35785. */
  35786. task: AbstractAssetTask;
  35787. }
  35788. /**
  35789. * Class used to share progress information about assets loading
  35790. */
  35791. class AssetsProgressEvent implements IAssetsProgressEvent {
  35792. /**
  35793. * Defines the number of remaining tasks to process
  35794. */
  35795. remainingCount: number;
  35796. /**
  35797. * Defines the total number of tasks
  35798. */
  35799. totalCount: number;
  35800. /**
  35801. * Defines the task that was just processed
  35802. */
  35803. task: AbstractAssetTask;
  35804. /**
  35805. * Creates a AssetsProgressEvent
  35806. * @param remainingCount defines the number of remaining tasks to process
  35807. * @param totalCount defines the total number of tasks
  35808. * @param task defines the task that was just processed
  35809. */
  35810. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  35811. }
  35812. /**
  35813. * Define a task used by AssetsManager to load meshes
  35814. */
  35815. class MeshAssetTask extends AbstractAssetTask {
  35816. /**
  35817. * Defines the name of the task
  35818. */
  35819. name: string;
  35820. /**
  35821. * Defines the list of mesh's names you want to load
  35822. */
  35823. meshesNames: any;
  35824. /**
  35825. * Defines the root url to use as a base to load your meshes and associated resources
  35826. */
  35827. rootUrl: string;
  35828. /**
  35829. * Defines the filename of the scene to load from
  35830. */
  35831. sceneFilename: string;
  35832. /**
  35833. * Gets the list of loaded meshes
  35834. */
  35835. loadedMeshes: Array<AbstractMesh>;
  35836. /**
  35837. * Gets the list of loaded particle systems
  35838. */
  35839. loadedParticleSystems: Array<IParticleSystem>;
  35840. /**
  35841. * Gets the list of loaded skeletons
  35842. */
  35843. loadedSkeletons: Array<Skeleton>;
  35844. /**
  35845. * Callback called when the task is successful
  35846. */
  35847. onSuccess: (task: MeshAssetTask) => void;
  35848. /**
  35849. * Callback called when the task is successful
  35850. */
  35851. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  35852. /**
  35853. * Creates a new MeshAssetTask
  35854. * @param name defines the name of the task
  35855. * @param meshesNames defines the list of mesh's names you want to load
  35856. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  35857. * @param sceneFilename defines the filename of the scene to load from
  35858. */
  35859. constructor(
  35860. /**
  35861. * Defines the name of the task
  35862. */
  35863. name: string,
  35864. /**
  35865. * Defines the list of mesh's names you want to load
  35866. */
  35867. meshesNames: any,
  35868. /**
  35869. * Defines the root url to use as a base to load your meshes and associated resources
  35870. */
  35871. rootUrl: string,
  35872. /**
  35873. * Defines the filename of the scene to load from
  35874. */
  35875. sceneFilename: string);
  35876. /**
  35877. * Execute the current task
  35878. * @param scene defines the scene where you want your assets to be loaded
  35879. * @param onSuccess is a callback called when the task is successfully executed
  35880. * @param onError is a callback called if an error occurs
  35881. */
  35882. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  35883. }
  35884. /**
  35885. * Define a task used by AssetsManager to load text content
  35886. */
  35887. class TextFileAssetTask extends AbstractAssetTask {
  35888. /**
  35889. * Defines the name of the task
  35890. */
  35891. name: string;
  35892. /**
  35893. * Defines the location of the file to load
  35894. */
  35895. url: string;
  35896. /**
  35897. * Gets the loaded text string
  35898. */
  35899. text: string;
  35900. /**
  35901. * Callback called when the task is successful
  35902. */
  35903. onSuccess: (task: TextFileAssetTask) => void;
  35904. /**
  35905. * Callback called when the task is successful
  35906. */
  35907. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  35908. /**
  35909. * Creates a new TextFileAssetTask object
  35910. * @param name defines the name of the task
  35911. * @param url defines the location of the file to load
  35912. */
  35913. constructor(
  35914. /**
  35915. * Defines the name of the task
  35916. */
  35917. name: string,
  35918. /**
  35919. * Defines the location of the file to load
  35920. */
  35921. url: string);
  35922. /**
  35923. * Execute the current task
  35924. * @param scene defines the scene where you want your assets to be loaded
  35925. * @param onSuccess is a callback called when the task is successfully executed
  35926. * @param onError is a callback called if an error occurs
  35927. */
  35928. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  35929. }
  35930. /**
  35931. * Define a task used by AssetsManager to load binary data
  35932. */
  35933. class BinaryFileAssetTask extends AbstractAssetTask {
  35934. /**
  35935. * Defines the name of the task
  35936. */
  35937. name: string;
  35938. /**
  35939. * Defines the location of the file to load
  35940. */
  35941. url: string;
  35942. /**
  35943. * Gets the lodaded data (as an array buffer)
  35944. */
  35945. data: ArrayBuffer;
  35946. /**
  35947. * Callback called when the task is successful
  35948. */
  35949. onSuccess: (task: BinaryFileAssetTask) => void;
  35950. /**
  35951. * Callback called when the task is successful
  35952. */
  35953. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  35954. /**
  35955. * Creates a new BinaryFileAssetTask object
  35956. * @param name defines the name of the new task
  35957. * @param url defines the location of the file to load
  35958. */
  35959. constructor(
  35960. /**
  35961. * Defines the name of the task
  35962. */
  35963. name: string,
  35964. /**
  35965. * Defines the location of the file to load
  35966. */
  35967. url: string);
  35968. /**
  35969. * Execute the current task
  35970. * @param scene defines the scene where you want your assets to be loaded
  35971. * @param onSuccess is a callback called when the task is successfully executed
  35972. * @param onError is a callback called if an error occurs
  35973. */
  35974. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  35975. }
  35976. /**
  35977. * Define a task used by AssetsManager to load images
  35978. */
  35979. class ImageAssetTask extends AbstractAssetTask {
  35980. /**
  35981. * Defines the name of the task
  35982. */
  35983. name: string;
  35984. /**
  35985. * Defines the location of the image to load
  35986. */
  35987. url: string;
  35988. /**
  35989. * Gets the loaded images
  35990. */
  35991. image: HTMLImageElement;
  35992. /**
  35993. * Callback called when the task is successful
  35994. */
  35995. onSuccess: (task: ImageAssetTask) => void;
  35996. /**
  35997. * Callback called when the task is successful
  35998. */
  35999. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  36000. /**
  36001. * Creates a new ImageAssetTask
  36002. * @param name defines the name of the task
  36003. * @param url defines the location of the image to load
  36004. */
  36005. constructor(
  36006. /**
  36007. * Defines the name of the task
  36008. */
  36009. name: string,
  36010. /**
  36011. * Defines the location of the image to load
  36012. */
  36013. url: string);
  36014. /**
  36015. * Execute the current task
  36016. * @param scene defines the scene where you want your assets to be loaded
  36017. * @param onSuccess is a callback called when the task is successfully executed
  36018. * @param onError is a callback called if an error occurs
  36019. */
  36020. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  36021. }
  36022. /**
  36023. * Defines the interface used by texture loading tasks
  36024. */
  36025. interface ITextureAssetTask<TEX extends BaseTexture> {
  36026. /**
  36027. * Gets the loaded texture
  36028. */
  36029. texture: TEX;
  36030. }
  36031. /**
  36032. * Define a task used by AssetsManager to load 2D textures
  36033. */
  36034. class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  36035. /**
  36036. * Defines the name of the task
  36037. */
  36038. name: string;
  36039. /**
  36040. * Defines the location of the file to load
  36041. */
  36042. url: string;
  36043. /**
  36044. * Defines if mipmap should not be generated (default is false)
  36045. */
  36046. noMipmap?: boolean | undefined;
  36047. /**
  36048. * Defines if texture must be inverted on Y axis (default is false)
  36049. */
  36050. invertY?: boolean | undefined;
  36051. /**
  36052. * Defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  36053. */
  36054. samplingMode: number;
  36055. /**
  36056. * Gets the loaded texture
  36057. */
  36058. texture: Texture;
  36059. /**
  36060. * Callback called when the task is successful
  36061. */
  36062. onSuccess: (task: TextureAssetTask) => void;
  36063. /**
  36064. * Callback called when the task is successful
  36065. */
  36066. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  36067. /**
  36068. * Creates a new TextureAssetTask object
  36069. * @param name defines the name of the task
  36070. * @param url defines the location of the file to load
  36071. * @param noMipmap defines if mipmap should not be generated (default is false)
  36072. * @param invertY defines if texture must be inverted on Y axis (default is false)
  36073. * @param samplingMode defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  36074. */
  36075. constructor(
  36076. /**
  36077. * Defines the name of the task
  36078. */
  36079. name: string,
  36080. /**
  36081. * Defines the location of the file to load
  36082. */
  36083. url: string,
  36084. /**
  36085. * Defines if mipmap should not be generated (default is false)
  36086. */
  36087. noMipmap?: boolean | undefined,
  36088. /**
  36089. * Defines if texture must be inverted on Y axis (default is false)
  36090. */
  36091. invertY?: boolean | undefined,
  36092. /**
  36093. * Defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  36094. */
  36095. samplingMode?: number);
  36096. /**
  36097. * Execute the current task
  36098. * @param scene defines the scene where you want your assets to be loaded
  36099. * @param onSuccess is a callback called when the task is successfully executed
  36100. * @param onError is a callback called if an error occurs
  36101. */
  36102. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  36103. }
  36104. /**
  36105. * Define a task used by AssetsManager to load cube textures
  36106. */
  36107. class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  36108. /**
  36109. * Defines the name of the task
  36110. */
  36111. name: string;
  36112. /**
  36113. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  36114. */
  36115. url: string;
  36116. /**
  36117. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  36118. */
  36119. extensions?: string[] | undefined;
  36120. /**
  36121. * Defines if mipmaps should not be generated (default is false)
  36122. */
  36123. noMipmap?: boolean | undefined;
  36124. /**
  36125. * Defines the explicit list of files (undefined by default)
  36126. */
  36127. files?: string[] | undefined;
  36128. /**
  36129. * Gets the loaded texture
  36130. */
  36131. texture: CubeTexture;
  36132. /**
  36133. * Callback called when the task is successful
  36134. */
  36135. onSuccess: (task: CubeTextureAssetTask) => void;
  36136. /**
  36137. * Callback called when the task is successful
  36138. */
  36139. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  36140. /**
  36141. * Creates a new CubeTextureAssetTask
  36142. * @param name defines the name of the task
  36143. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  36144. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  36145. * @param noMipmap defines if mipmaps should not be generated (default is false)
  36146. * @param files defines the explicit list of files (undefined by default)
  36147. */
  36148. constructor(
  36149. /**
  36150. * Defines the name of the task
  36151. */
  36152. name: string,
  36153. /**
  36154. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  36155. */
  36156. url: string,
  36157. /**
  36158. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  36159. */
  36160. extensions?: string[] | undefined,
  36161. /**
  36162. * Defines if mipmaps should not be generated (default is false)
  36163. */
  36164. noMipmap?: boolean | undefined,
  36165. /**
  36166. * Defines the explicit list of files (undefined by default)
  36167. */
  36168. files?: string[] | undefined);
  36169. /**
  36170. * Execute the current task
  36171. * @param scene defines the scene where you want your assets to be loaded
  36172. * @param onSuccess is a callback called when the task is successfully executed
  36173. * @param onError is a callback called if an error occurs
  36174. */
  36175. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  36176. }
  36177. /**
  36178. * Define a task used by AssetsManager to load HDR cube textures
  36179. */
  36180. class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  36181. /**
  36182. * Defines the name of the task
  36183. */
  36184. name: string;
  36185. /**
  36186. * Defines the location of the file to load
  36187. */
  36188. url: string;
  36189. /**
  36190. * Defines the desired size (the more it increases the longer the generation will be)
  36191. */
  36192. size: number;
  36193. /**
  36194. * Defines if mipmaps should not be generated (default is false)
  36195. */
  36196. noMipmap: boolean;
  36197. /**
  36198. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  36199. */
  36200. generateHarmonics: boolean;
  36201. /**
  36202. * 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)
  36203. */
  36204. gammaSpace: boolean;
  36205. /**
  36206. * Internal Use Only
  36207. */
  36208. reserved: boolean;
  36209. /**
  36210. * Gets the loaded texture
  36211. */
  36212. texture: HDRCubeTexture;
  36213. /**
  36214. * Callback called when the task is successful
  36215. */
  36216. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  36217. /**
  36218. * Callback called when the task is successful
  36219. */
  36220. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  36221. /**
  36222. * Creates a new HDRCubeTextureAssetTask object
  36223. * @param name defines the name of the task
  36224. * @param url defines the location of the file to load
  36225. * @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.
  36226. * @param noMipmap defines if mipmaps should not be generated (default is false)
  36227. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  36228. * @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)
  36229. * @param reserved Internal use only
  36230. */
  36231. constructor(
  36232. /**
  36233. * Defines the name of the task
  36234. */
  36235. name: string,
  36236. /**
  36237. * Defines the location of the file to load
  36238. */
  36239. url: string,
  36240. /**
  36241. * Defines the desired size (the more it increases the longer the generation will be)
  36242. */
  36243. size: number,
  36244. /**
  36245. * Defines if mipmaps should not be generated (default is false)
  36246. */
  36247. noMipmap?: boolean,
  36248. /**
  36249. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  36250. */
  36251. generateHarmonics?: boolean,
  36252. /**
  36253. * 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)
  36254. */
  36255. gammaSpace?: boolean,
  36256. /**
  36257. * Internal Use Only
  36258. */
  36259. reserved?: boolean);
  36260. /**
  36261. * Execute the current task
  36262. * @param scene defines the scene where you want your assets to be loaded
  36263. * @param onSuccess is a callback called when the task is successfully executed
  36264. * @param onError is a callback called if an error occurs
  36265. */
  36266. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  36267. }
  36268. /**
  36269. * This class can be used to easily import assets into a scene
  36270. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  36271. */
  36272. class AssetsManager {
  36273. private _scene;
  36274. private _isLoading;
  36275. protected _tasks: AbstractAssetTask[];
  36276. protected _waitingTasksCount: number;
  36277. protected _totalTasksCount: number;
  36278. /**
  36279. * Callback called when all tasks are processed
  36280. */
  36281. onFinish: (tasks: AbstractAssetTask[]) => void;
  36282. /**
  36283. * Callback called when a task is successful
  36284. */
  36285. onTaskSuccess: (task: AbstractAssetTask) => void;
  36286. /**
  36287. * Callback called when a task had an error
  36288. */
  36289. onTaskError: (task: AbstractAssetTask) => void;
  36290. /**
  36291. * Callback called when a task is done (whatever the result is)
  36292. */
  36293. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  36294. /**
  36295. * Observable called when all tasks are processed
  36296. */
  36297. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  36298. /**
  36299. * Observable called when a task had an error
  36300. */
  36301. onTaskErrorObservable: Observable<AbstractAssetTask>;
  36302. /**
  36303. * Observable called when a task is successful
  36304. */
  36305. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  36306. /**
  36307. * Observable called when a task is done (whatever the result is)
  36308. */
  36309. onProgressObservable: Observable<IAssetsProgressEvent>;
  36310. /**
  36311. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  36312. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  36313. */
  36314. useDefaultLoadingScreen: boolean;
  36315. /**
  36316. * Creates a new AssetsManager
  36317. * @param scene defines the scene to work on
  36318. */
  36319. constructor(scene: Scene);
  36320. /**
  36321. * Add a MeshAssetTask to the list of active tasks
  36322. * @param taskName defines the name of the new task
  36323. * @param meshesNames defines the name of meshes to load
  36324. * @param rootUrl defines the root url to use to locate files
  36325. * @param sceneFilename defines the filename of the scene file
  36326. * @returns a new MeshAssetTask object
  36327. */
  36328. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  36329. /**
  36330. * Add a TextFileAssetTask to the list of active tasks
  36331. * @param taskName defines the name of the new task
  36332. * @param url defines the url of the file to load
  36333. * @returns a new TextFileAssetTask object
  36334. */
  36335. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  36336. /**
  36337. * Add a BinaryFileAssetTask to the list of active tasks
  36338. * @param taskName defines the name of the new task
  36339. * @param url defines the url of the file to load
  36340. * @returns a new BinaryFileAssetTask object
  36341. */
  36342. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  36343. /**
  36344. * Add a ImageAssetTask to the list of active tasks
  36345. * @param taskName defines the name of the new task
  36346. * @param url defines the url of the file to load
  36347. * @returns a new ImageAssetTask object
  36348. */
  36349. addImageTask(taskName: string, url: string): ImageAssetTask;
  36350. /**
  36351. * Add a TextureAssetTask to the list of active tasks
  36352. * @param taskName defines the name of the new task
  36353. * @param url defines the url of the file to load
  36354. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  36355. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  36356. * @param samplingMode defines the sampling mode to use (BABYLON.Texture.TRILINEAR_SAMPLINGMODE by default)
  36357. * @returns a new TextureAssetTask object
  36358. */
  36359. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  36360. /**
  36361. * Add a CubeTextureAssetTask to the list of active tasks
  36362. * @param taskName defines the name of the new task
  36363. * @param url defines the url of the file to load
  36364. * @param extensions defines the extension to use to load the cube map (can be null)
  36365. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  36366. * @param files defines the list of files to load (can be null)
  36367. * @returns a new CubeTextureAssetTask object
  36368. */
  36369. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  36370. /**
  36371. *
  36372. * Add a HDRCubeTextureAssetTask to the list of active tasks
  36373. * @param taskName defines the name of the new task
  36374. * @param url defines the url of the file to load
  36375. * @param size defines the size you want for the cubemap (can be null)
  36376. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  36377. * @param generateHarmonics defines if you want to automatically generate (true by default)
  36378. * @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)
  36379. * @param reserved Internal use only
  36380. * @returns a new HDRCubeTextureAssetTask object
  36381. */
  36382. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  36383. /**
  36384. * Remove a task from the assets manager.
  36385. * @param task the task to remove
  36386. */
  36387. removeTask(task: AbstractAssetTask): void;
  36388. private _decreaseWaitingTasksCount;
  36389. private _runTask;
  36390. /**
  36391. * Reset the AssetsManager and remove all tasks
  36392. * @return the current instance of the AssetsManager
  36393. */
  36394. reset(): AssetsManager;
  36395. /**
  36396. * Start the loading process
  36397. * @return the current instance of the AssetsManager
  36398. */
  36399. load(): AssetsManager;
  36400. }
  36401. }
  36402. declare module BABYLON {
  36403. /**
  36404. * Class used to enable access to IndexedDB
  36405. * @see @https://developer.mozilla.org/en-US/docs/Web/API/IndexedDB_API
  36406. */
  36407. class Database {
  36408. private callbackManifestChecked;
  36409. private currentSceneUrl;
  36410. private db;
  36411. private _enableSceneOffline;
  36412. private _enableTexturesOffline;
  36413. private manifestVersionFound;
  36414. private mustUpdateRessources;
  36415. private hasReachedQuota;
  36416. private isSupported;
  36417. private idbFactory;
  36418. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  36419. static IsUASupportingBlobStorage: boolean;
  36420. /** Gets a boolean indicating if Database storate is enabled */
  36421. static IDBStorageEnabled: boolean;
  36422. /**
  36423. * Gets a boolean indicating if scene must be saved in the database
  36424. */
  36425. readonly enableSceneOffline: boolean;
  36426. /**
  36427. * Gets a boolean indicating if textures must be saved in the database
  36428. */
  36429. readonly enableTexturesOffline: boolean;
  36430. /**
  36431. * Creates a new Database
  36432. * @param urlToScene defines the url to load the scene
  36433. * @param callbackManifestChecked defines the callback to use when manifest is checked
  36434. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  36435. */
  36436. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  36437. private static _ParseURL;
  36438. private static _ReturnFullUrlLocation;
  36439. private _checkManifestFile;
  36440. /**
  36441. * Open the database and make it available
  36442. * @param successCallback defines the callback to call on success
  36443. * @param errorCallback defines the callback to call on error
  36444. */
  36445. openAsync(successCallback: () => void, errorCallback: () => void): void;
  36446. /**
  36447. * Loads an image from the database
  36448. * @param url defines the url to load from
  36449. * @param image defines the target DOM image
  36450. */
  36451. loadImageFromDB(url: string, image: HTMLImageElement): void;
  36452. private _loadImageFromDBAsync;
  36453. private _saveImageIntoDBAsync;
  36454. private _checkVersionFromDB;
  36455. private _loadVersionFromDBAsync;
  36456. private _saveVersionIntoDBAsync;
  36457. /**
  36458. * Loads a file from database
  36459. * @param url defines the URL to load from
  36460. * @param sceneLoaded defines a callback to call on success
  36461. * @param progressCallBack defines a callback to call when progress changed
  36462. * @param errorCallback defines a callback to call on error
  36463. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  36464. */
  36465. loadFileFromDB(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  36466. private _loadFileFromDBAsync;
  36467. private _saveFileIntoDBAsync;
  36468. }
  36469. }
  36470. declare module BABYLON {
  36471. /**
  36472. * Direct draw surface info
  36473. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  36474. */
  36475. interface DDSInfo {
  36476. /**
  36477. * Width of the texture
  36478. */
  36479. width: number;
  36480. /**
  36481. * Width of the texture
  36482. */
  36483. height: number;
  36484. /**
  36485. * Number of Mipmaps for the texture
  36486. * @see https://en.wikipedia.org/wiki/Mipmap
  36487. */
  36488. mipmapCount: number;
  36489. /**
  36490. * If the textures format is a known fourCC format
  36491. * @see https://www.fourcc.org/
  36492. */
  36493. isFourCC: boolean;
  36494. /**
  36495. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  36496. */
  36497. isRGB: boolean;
  36498. /**
  36499. * If the texture is a lumincance format
  36500. */
  36501. isLuminance: boolean;
  36502. /**
  36503. * If this is a cube texture
  36504. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  36505. */
  36506. isCube: boolean;
  36507. /**
  36508. * If the texture is a compressed format eg. FOURCC_DXT1
  36509. */
  36510. isCompressed: boolean;
  36511. /**
  36512. * The dxgiFormat of the texture
  36513. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  36514. */
  36515. dxgiFormat: number;
  36516. /**
  36517. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  36518. */
  36519. textureType: number;
  36520. /**
  36521. * Sphericle polynomial created for the dds texture
  36522. */
  36523. sphericalPolynomial?: SphericalPolynomial;
  36524. }
  36525. /**
  36526. * Class used to provide DDS decompression tools
  36527. */
  36528. class DDSTools {
  36529. /**
  36530. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  36531. */
  36532. static StoreLODInAlphaChannel: boolean;
  36533. /**
  36534. * Gets DDS information from an array buffer
  36535. * @param arrayBuffer defines the array buffer to read data from
  36536. * @returns the DDS information
  36537. */
  36538. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  36539. private static _FloatView;
  36540. private static _Int32View;
  36541. private static _ToHalfFloat;
  36542. private static _FromHalfFloat;
  36543. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  36544. private static _GetHalfFloatRGBAArrayBuffer;
  36545. private static _GetFloatRGBAArrayBuffer;
  36546. private static _GetFloatAsUIntRGBAArrayBuffer;
  36547. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  36548. private static _GetRGBAArrayBuffer;
  36549. private static _ExtractLongWordOrder;
  36550. private static _GetRGBArrayBuffer;
  36551. private static _GetLuminanceArrayBuffer;
  36552. /**
  36553. * Uploads DDS Levels to a Babylon Texture
  36554. * @hidden
  36555. */
  36556. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  36557. }
  36558. }
  36559. declare module BABYLON {
  36560. function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  36561. function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36562. function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36563. function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36564. function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36565. function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36566. function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36567. function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36568. function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36569. function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36570. function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36571. function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36572. /**
  36573. * Decorator used to define property that can be serialized as reference to a camera
  36574. * @param sourceName defines the name of the property to decorate
  36575. */
  36576. function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36577. /**
  36578. * Class used to help serialization objects
  36579. */
  36580. class SerializationHelper {
  36581. /**
  36582. * Static function used to serialized a specific entity
  36583. * @param entity defines the entity to serialize
  36584. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  36585. * @returns a JSON compatible object representing the serialization of the entity
  36586. */
  36587. static Serialize<T>(entity: T, serializationObject?: any): any;
  36588. /**
  36589. * Creates a new entity from a serialization data object
  36590. * @param creationFunction defines a function used to instanciated the new entity
  36591. * @param source defines the source serialization data
  36592. * @param scene defines the hosting scene
  36593. * @param rootUrl defines the root url for resources
  36594. * @returns a new entity
  36595. */
  36596. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  36597. /**
  36598. * Clones an object
  36599. * @param creationFunction defines the function used to instanciate the new object
  36600. * @param source defines the source object
  36601. * @returns the cloned object
  36602. */
  36603. static Clone<T>(creationFunction: () => T, source: T): T;
  36604. /**
  36605. * Instanciates a new object based on a source one (some data will be shared between both object)
  36606. * @param creationFunction defines the function used to instanciate the new object
  36607. * @param source defines the source object
  36608. * @returns the new object
  36609. */
  36610. static Instanciate<T>(creationFunction: () => T, source: T): T;
  36611. }
  36612. }
  36613. declare module BABYLON {
  36614. /**
  36615. * Wrapper class for promise with external resolve and reject.
  36616. */
  36617. class Deferred<T> {
  36618. /**
  36619. * The promise associated with this deferred object.
  36620. */
  36621. readonly promise: Promise<T>;
  36622. private _resolve;
  36623. private _reject;
  36624. /**
  36625. * The resolve method of the promise associated with this deferred object.
  36626. */
  36627. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  36628. /**
  36629. * The reject method of the promise associated with this deferred object.
  36630. */
  36631. readonly reject: (reason?: any) => void;
  36632. /**
  36633. * Constructor for this deferred object.
  36634. */
  36635. constructor();
  36636. }
  36637. }
  36638. declare module BABYLON {
  36639. /**
  36640. * Raw texture data and descriptor sufficient for WebGL texture upload
  36641. */
  36642. interface EnvironmentTextureInfo {
  36643. /**
  36644. * Version of the environment map
  36645. */
  36646. version: number;
  36647. /**
  36648. * Width of image
  36649. */
  36650. width: number;
  36651. /**
  36652. * Irradiance information stored in the file.
  36653. */
  36654. irradiance: any;
  36655. /**
  36656. * Specular information stored in the file.
  36657. */
  36658. specular: any;
  36659. }
  36660. /**
  36661. * Sets of helpers addressing the serialization and deserialization of environment texture
  36662. * stored in a BabylonJS env file.
  36663. * Those files are usually stored as .env files.
  36664. */
  36665. class EnvironmentTextureTools {
  36666. /**
  36667. * Magic number identifying the env file.
  36668. */
  36669. private static _MagicBytes;
  36670. /**
  36671. * Gets the environment info from an env file.
  36672. * @param data The array buffer containing the .env bytes.
  36673. * @returns the environment file info (the json header) if successfully parsed.
  36674. */
  36675. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  36676. /**
  36677. * Creates an environment texture from a loaded cube texture.
  36678. * @param texture defines the cube texture to convert in env file
  36679. * @return a promise containing the environment data if succesfull.
  36680. */
  36681. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  36682. /**
  36683. * Creates a JSON representation of the spherical data.
  36684. * @param texture defines the texture containing the polynomials
  36685. * @return the JSON representation of the spherical info
  36686. */
  36687. private static _CreateEnvTextureIrradiance;
  36688. /**
  36689. * Uploads the texture info contained in the env file to the GPU.
  36690. * @param texture defines the internal texture to upload to
  36691. * @param arrayBuffer defines the buffer cotaining the data to load
  36692. * @param info defines the texture info retrieved through the GetEnvInfo method
  36693. * @returns a promise
  36694. */
  36695. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  36696. /**
  36697. * Uploads the levels of image data to the GPU.
  36698. * @param texture defines the internal texture to upload to
  36699. * @param imageData defines the array buffer views of image data [mipmap][face]
  36700. * @returns a promise
  36701. */
  36702. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  36703. /**
  36704. * Uploads spherical polynomials information to the texture.
  36705. * @param texture defines the texture we are trying to upload the information to
  36706. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  36707. */
  36708. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  36709. }
  36710. }
  36711. declare module BABYLON {
  36712. /**
  36713. * Class used to help managing file picking and drag'n'drop
  36714. */
  36715. class FilesInput {
  36716. /**
  36717. * List of files ready to be loaded
  36718. */
  36719. static FilesToLoad: {
  36720. [key: string]: File;
  36721. };
  36722. /**
  36723. * Callback called when a file is processed
  36724. */
  36725. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  36726. private _engine;
  36727. private _currentScene;
  36728. private _sceneLoadedCallback;
  36729. private _progressCallback;
  36730. private _additionalRenderLoopLogicCallback;
  36731. private _textureLoadingCallback;
  36732. private _startingProcessingFilesCallback;
  36733. private _onReloadCallback;
  36734. private _errorCallback;
  36735. private _elementToMonitor;
  36736. private _sceneFileToLoad;
  36737. private _filesToLoad;
  36738. /**
  36739. * Creates a new FilesInput
  36740. * @param engine defines the rendering engine
  36741. * @param scene defines the hosting scene
  36742. * @param sceneLoadedCallback callback called when scene is loaded
  36743. * @param progressCallback callback called to track progress
  36744. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  36745. * @param textureLoadingCallback callback called when a texture is loading
  36746. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  36747. * @param onReloadCallback callback called when a reload is requested
  36748. * @param errorCallback callback call if an error occurs
  36749. */
  36750. 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);
  36751. private _dragEnterHandler;
  36752. private _dragOverHandler;
  36753. private _dropHandler;
  36754. /**
  36755. * Calls this function to listen to drag'n'drop events on a specific DOM element
  36756. * @param elementToMonitor defines the DOM element to track
  36757. */
  36758. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  36759. /**
  36760. * Release all associated resources
  36761. */
  36762. dispose(): void;
  36763. private renderFunction;
  36764. private drag;
  36765. private drop;
  36766. private _traverseFolder;
  36767. private _processFiles;
  36768. /**
  36769. * Load files from a drop event
  36770. * @param event defines the drop event to use as source
  36771. */
  36772. loadFiles(event: any): void;
  36773. private _processReload;
  36774. /**
  36775. * Reload the current scene from the loaded files
  36776. */
  36777. reload(): void;
  36778. }
  36779. }
  36780. declare module BABYLON {
  36781. /**
  36782. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  36783. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  36784. */
  36785. class KhronosTextureContainer {
  36786. /** contents of the KTX container file */
  36787. arrayBuffer: any;
  36788. private static HEADER_LEN;
  36789. private static COMPRESSED_2D;
  36790. private static COMPRESSED_3D;
  36791. private static TEX_2D;
  36792. private static TEX_3D;
  36793. /**
  36794. * Gets the openGL type
  36795. */
  36796. glType: number;
  36797. /**
  36798. * Gets the openGL type size
  36799. */
  36800. glTypeSize: number;
  36801. /**
  36802. * Gets the openGL format
  36803. */
  36804. glFormat: number;
  36805. /**
  36806. * Gets the openGL internal format
  36807. */
  36808. glInternalFormat: number;
  36809. /**
  36810. * Gets the base internal format
  36811. */
  36812. glBaseInternalFormat: number;
  36813. /**
  36814. * Gets image width in pixel
  36815. */
  36816. pixelWidth: number;
  36817. /**
  36818. * Gets image height in pixel
  36819. */
  36820. pixelHeight: number;
  36821. /**
  36822. * Gets image depth in pixels
  36823. */
  36824. pixelDepth: number;
  36825. /**
  36826. * Gets the number of array elements
  36827. */
  36828. numberOfArrayElements: number;
  36829. /**
  36830. * Gets the number of faces
  36831. */
  36832. numberOfFaces: number;
  36833. /**
  36834. * Gets the number of mipmap levels
  36835. */
  36836. numberOfMipmapLevels: number;
  36837. /**
  36838. * Gets the bytes of key value data
  36839. */
  36840. bytesOfKeyValueData: number;
  36841. /**
  36842. * Gets the load type
  36843. */
  36844. loadType: number;
  36845. /**
  36846. * Creates a new KhronosTextureContainer
  36847. * @param arrayBuffer contents of the KTX container file
  36848. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  36849. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  36850. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  36851. */
  36852. constructor(
  36853. /** contents of the KTX container file */
  36854. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  36855. /**
  36856. * Revert the endianness of a value.
  36857. * Not as fast hardware based, but will probably never need to use
  36858. * @param val defines the value to convert
  36859. * @returns the new value
  36860. */
  36861. switchEndianness(val: number): number;
  36862. /**
  36863. * Uploads KTX content to a Babylon Texture.
  36864. * It is assumed that the texture has already been created & is currently bound
  36865. * @hidden
  36866. */
  36867. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  36868. private _upload2DCompressedLevels;
  36869. }
  36870. }
  36871. declare module BABYLON {
  36872. /**
  36873. * A class serves as a medium between the observable and its observers
  36874. */
  36875. class EventState {
  36876. /**
  36877. * Create a new EventState
  36878. * @param mask defines the mask associated with this state
  36879. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  36880. * @param target defines the original target of the state
  36881. * @param currentTarget defines the current target of the state
  36882. */
  36883. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  36884. /**
  36885. * Initialize the current event state
  36886. * @param mask defines the mask associated with this state
  36887. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  36888. * @param target defines the original target of the state
  36889. * @param currentTarget defines the current target of the state
  36890. * @returns the current event state
  36891. */
  36892. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  36893. /**
  36894. * An Observer can set this property to true to prevent subsequent observers of being notified
  36895. */
  36896. skipNextObservers: boolean;
  36897. /**
  36898. * Get the mask value that were used to trigger the event corresponding to this EventState object
  36899. */
  36900. mask: number;
  36901. /**
  36902. * The object that originally notified the event
  36903. */
  36904. target?: any;
  36905. /**
  36906. * The current object in the bubbling phase
  36907. */
  36908. currentTarget?: any;
  36909. /**
  36910. * This will be populated with the return value of the last function that was executed.
  36911. * If it is the first function in the callback chain it will be the event data.
  36912. */
  36913. lastReturnValue?: any;
  36914. }
  36915. /**
  36916. * Represent an Observer registered to a given Observable object.
  36917. */
  36918. class Observer<T> {
  36919. /**
  36920. * Defines the callback to call when the observer is notified
  36921. */
  36922. callback: (eventData: T, eventState: EventState) => void;
  36923. /**
  36924. * Defines the mask of the observer (used to filter notifications)
  36925. */
  36926. mask: number;
  36927. /**
  36928. * Defines the current scope used to restore the JS context
  36929. */
  36930. scope: any;
  36931. /** @hidden */
  36932. /**
  36933. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  36934. */
  36935. unregisterOnNextCall: boolean;
  36936. /**
  36937. * Creates a new observer
  36938. * @param callback defines the callback to call when the observer is notified
  36939. * @param mask defines the mask of the observer (used to filter notifications)
  36940. * @param scope defines the current scope used to restore the JS context
  36941. */
  36942. constructor(
  36943. /**
  36944. * Defines the callback to call when the observer is notified
  36945. */
  36946. callback: (eventData: T, eventState: EventState) => void,
  36947. /**
  36948. * Defines the mask of the observer (used to filter notifications)
  36949. */
  36950. mask: number,
  36951. /**
  36952. * Defines the current scope used to restore the JS context
  36953. */
  36954. scope?: any);
  36955. }
  36956. /**
  36957. * Represent a list of observers registered to multiple Observables object.
  36958. */
  36959. class MultiObserver<T> {
  36960. private _observers;
  36961. private _observables;
  36962. /**
  36963. * Release associated resources
  36964. */
  36965. dispose(): void;
  36966. /**
  36967. * Raise a callback when one of the observable will notify
  36968. * @param observables defines a list of observables to watch
  36969. * @param callback defines the callback to call on notification
  36970. * @param mask defines the mask used to filter notifications
  36971. * @param scope defines the current scope used to restore the JS context
  36972. * @returns the new MultiObserver
  36973. */
  36974. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  36975. }
  36976. /**
  36977. * The Observable class is a simple implementation of the Observable pattern.
  36978. *
  36979. * 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.
  36980. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  36981. * 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).
  36982. * 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.
  36983. */
  36984. class Observable<T> {
  36985. private _observers;
  36986. private _eventState;
  36987. private _onObserverAdded;
  36988. /**
  36989. * Creates a new observable
  36990. * @param onObserverAdded defines a callback to call when a new observer is added
  36991. */
  36992. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  36993. /**
  36994. * Create a new Observer with the specified callback
  36995. * @param callback the callback that will be executed for that Observer
  36996. * @param mask the mask used to filter observers
  36997. * @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.
  36998. * @param scope optional scope for the callback to be called from
  36999. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  37000. * @returns the new observer created for the callback
  37001. */
  37002. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  37003. /**
  37004. * Create a new Observer with the specified callback and unregisters after the next notification
  37005. * @param callback the callback that will be executed for that Observer
  37006. * @returns the new observer created for the callback
  37007. */
  37008. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  37009. /**
  37010. * Remove an Observer from the Observable object
  37011. * @param observer the instance of the Observer to remove
  37012. * @returns false if it doesn't belong to this Observable
  37013. */
  37014. remove(observer: Nullable<Observer<T>>): boolean;
  37015. /**
  37016. * Remove a callback from the Observable object
  37017. * @param callback the callback to remove
  37018. * @param scope optional scope. If used only the callbacks with this scope will be removed
  37019. * @returns false if it doesn't belong to this Observable
  37020. */
  37021. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  37022. private _deferUnregister;
  37023. private _remove;
  37024. /**
  37025. * Notify all Observers by calling their respective callback with the given data
  37026. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  37027. * @param eventData defines the data to send to all observers
  37028. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  37029. * @param target defines the original target of the state
  37030. * @param currentTarget defines the current target of the state
  37031. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  37032. */
  37033. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  37034. /**
  37035. * Calling this will execute each callback, expecting it to be a promise or return a value.
  37036. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  37037. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  37038. * and it is crucial that all callbacks will be executed.
  37039. * The order of the callbacks is kept, callbacks are not executed parallel.
  37040. *
  37041. * @param eventData The data to be sent to each callback
  37042. * @param mask is used to filter observers defaults to -1
  37043. * @param target defines the callback target (see EventState)
  37044. * @param currentTarget defines he current object in the bubbling phase
  37045. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  37046. */
  37047. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  37048. /**
  37049. * Notify a specific observer
  37050. * @param observer defines the observer to notify
  37051. * @param eventData defines the data to be sent to each callback
  37052. * @param mask is used to filter observers defaults to -1
  37053. */
  37054. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  37055. /**
  37056. * Gets a boolean indicating if the observable has at least one observer
  37057. * @returns true is the Observable has at least one Observer registered
  37058. */
  37059. hasObservers(): boolean;
  37060. /**
  37061. * Clear the list of observers
  37062. */
  37063. clear(): void;
  37064. /**
  37065. * Clone the current observable
  37066. * @returns a new observable
  37067. */
  37068. clone(): Observable<T>;
  37069. /**
  37070. * Does this observable handles observer registered with a given mask
  37071. * @param mask defines the mask to be tested
  37072. * @return whether or not one observer registered with the given mask is handeled
  37073. **/
  37074. hasSpecificMask(mask?: number): boolean;
  37075. }
  37076. }
  37077. declare module BABYLON {
  37078. /**
  37079. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  37080. */
  37081. class PerformanceMonitor {
  37082. private _enabled;
  37083. private _rollingFrameTime;
  37084. private _lastFrameTimeMs;
  37085. /**
  37086. * constructor
  37087. * @param frameSampleSize The number of samples required to saturate the sliding window
  37088. */
  37089. constructor(frameSampleSize?: number);
  37090. /**
  37091. * Samples current frame
  37092. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  37093. */
  37094. sampleFrame(timeMs?: number): void;
  37095. /**
  37096. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  37097. */
  37098. readonly averageFrameTime: number;
  37099. /**
  37100. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  37101. */
  37102. readonly averageFrameTimeVariance: number;
  37103. /**
  37104. * Returns the frame time of the most recent frame
  37105. */
  37106. readonly instantaneousFrameTime: number;
  37107. /**
  37108. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  37109. */
  37110. readonly averageFPS: number;
  37111. /**
  37112. * Returns the average framerate in frames per second using the most recent frame time
  37113. */
  37114. readonly instantaneousFPS: number;
  37115. /**
  37116. * Returns true if enough samples have been taken to completely fill the sliding window
  37117. */
  37118. readonly isSaturated: boolean;
  37119. /**
  37120. * Enables contributions to the sliding window sample set
  37121. */
  37122. enable(): void;
  37123. /**
  37124. * Disables contributions to the sliding window sample set
  37125. * Samples will not be interpolated over the disabled period
  37126. */
  37127. disable(): void;
  37128. /**
  37129. * Returns true if sampling is enabled
  37130. */
  37131. readonly isEnabled: boolean;
  37132. /**
  37133. * Resets performance monitor
  37134. */
  37135. reset(): void;
  37136. }
  37137. /**
  37138. * RollingAverage
  37139. *
  37140. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  37141. */
  37142. class RollingAverage {
  37143. /**
  37144. * Current average
  37145. */
  37146. average: number;
  37147. /**
  37148. * Current variance
  37149. */
  37150. variance: number;
  37151. protected _samples: Array<number>;
  37152. protected _sampleCount: number;
  37153. protected _pos: number;
  37154. protected _m2: number;
  37155. /**
  37156. * constructor
  37157. * @param length The number of samples required to saturate the sliding window
  37158. */
  37159. constructor(length: number);
  37160. /**
  37161. * Adds a sample to the sample set
  37162. * @param v The sample value
  37163. */
  37164. add(v: number): void;
  37165. /**
  37166. * Returns previously added values or null if outside of history or outside the sliding window domain
  37167. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  37168. * @return Value previously recorded with add() or null if outside of range
  37169. */
  37170. history(i: number): number;
  37171. /**
  37172. * Returns true if enough samples have been taken to completely fill the sliding window
  37173. * @return true if sample-set saturated
  37174. */
  37175. isSaturated(): boolean;
  37176. /**
  37177. * Resets the rolling average (equivalent to 0 samples taken so far)
  37178. */
  37179. reset(): void;
  37180. /**
  37181. * Wraps a value around the sample range boundaries
  37182. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  37183. * @return Wrapped position in sample range
  37184. */
  37185. protected _wrapPosition(i: number): number;
  37186. }
  37187. }
  37188. declare module BABYLON {
  37189. /**
  37190. * Helper class that provides a small promise polyfill
  37191. */
  37192. class PromisePolyfill {
  37193. /**
  37194. * Static function used to check if the polyfill is required
  37195. * If this is the case then the function will inject the polyfill to window.Promise
  37196. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  37197. */
  37198. static Apply(force?: boolean): void;
  37199. }
  37200. }
  37201. declare module BABYLON {
  37202. /**
  37203. * Defines the root class used to create scene optimization to use with SceneOptimizer
  37204. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  37205. */
  37206. class SceneOptimization {
  37207. /**
  37208. * Defines the priority of this optimization (0 by default which means first in the list)
  37209. */
  37210. priority: number;
  37211. /**
  37212. * Gets a string describing the action executed by the current optimization
  37213. * @returns description string
  37214. */
  37215. getDescription(): string;
  37216. /**
  37217. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  37218. * @param scene defines the current scene where to apply this optimization
  37219. * @param optimizer defines the current optimizer
  37220. * @returns true if everything that can be done was applied
  37221. */
  37222. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  37223. /**
  37224. * Creates the SceneOptimization object
  37225. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  37226. * @param desc defines the description associated with the optimization
  37227. */
  37228. constructor(
  37229. /**
  37230. * Defines the priority of this optimization (0 by default which means first in the list)
  37231. */
  37232. priority?: number);
  37233. }
  37234. /**
  37235. * Defines an optimization used to reduce the size of render target textures
  37236. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  37237. */
  37238. class TextureOptimization extends SceneOptimization {
  37239. /**
  37240. * Defines the priority of this optimization (0 by default which means first in the list)
  37241. */
  37242. priority: number;
  37243. /**
  37244. * 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
  37245. */
  37246. maximumSize: number;
  37247. /**
  37248. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  37249. */
  37250. step: number;
  37251. /**
  37252. * Gets a string describing the action executed by the current optimization
  37253. * @returns description string
  37254. */
  37255. getDescription(): string;
  37256. /**
  37257. * Creates the TextureOptimization object
  37258. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  37259. * @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
  37260. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  37261. */
  37262. constructor(
  37263. /**
  37264. * Defines the priority of this optimization (0 by default which means first in the list)
  37265. */
  37266. priority?: number,
  37267. /**
  37268. * 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
  37269. */
  37270. maximumSize?: number,
  37271. /**
  37272. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  37273. */
  37274. step?: number);
  37275. /**
  37276. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  37277. * @param scene defines the current scene where to apply this optimization
  37278. * @param optimizer defines the current optimizer
  37279. * @returns true if everything that can be done was applied
  37280. */
  37281. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  37282. }
  37283. /**
  37284. * Defines an optimization used to increase or decrease the rendering resolution
  37285. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  37286. */
  37287. class HardwareScalingOptimization extends SceneOptimization {
  37288. /**
  37289. * Defines the priority of this optimization (0 by default which means first in the list)
  37290. */
  37291. priority: number;
  37292. /**
  37293. * Defines the maximum scale to use (2 by default)
  37294. */
  37295. maximumScale: number;
  37296. /**
  37297. * Defines the step to use between two passes (0.5 by default)
  37298. */
  37299. step: number;
  37300. private _currentScale;
  37301. private _directionOffset;
  37302. /**
  37303. * Gets a string describing the action executed by the current optimization
  37304. * @return description string
  37305. */
  37306. getDescription(): string;
  37307. /**
  37308. * Creates the HardwareScalingOptimization object
  37309. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  37310. * @param maximumScale defines the maximum scale to use (2 by default)
  37311. * @param step defines the step to use between two passes (0.5 by default)
  37312. */
  37313. constructor(
  37314. /**
  37315. * Defines the priority of this optimization (0 by default which means first in the list)
  37316. */
  37317. priority?: number,
  37318. /**
  37319. * Defines the maximum scale to use (2 by default)
  37320. */
  37321. maximumScale?: number,
  37322. /**
  37323. * Defines the step to use between two passes (0.5 by default)
  37324. */
  37325. step?: number);
  37326. /**
  37327. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  37328. * @param scene defines the current scene where to apply this optimization
  37329. * @param optimizer defines the current optimizer
  37330. * @returns true if everything that can be done was applied
  37331. */
  37332. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  37333. }
  37334. /**
  37335. * Defines an optimization used to remove shadows
  37336. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  37337. */
  37338. class ShadowsOptimization extends SceneOptimization {
  37339. /**
  37340. * Gets a string describing the action executed by the current optimization
  37341. * @return description string
  37342. */
  37343. getDescription(): string;
  37344. /**
  37345. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  37346. * @param scene defines the current scene where to apply this optimization
  37347. * @param optimizer defines the current optimizer
  37348. * @returns true if everything that can be done was applied
  37349. */
  37350. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  37351. }
  37352. /**
  37353. * Defines an optimization used to turn post-processes off
  37354. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  37355. */
  37356. class PostProcessesOptimization extends SceneOptimization {
  37357. /**
  37358. * Gets a string describing the action executed by the current optimization
  37359. * @return description string
  37360. */
  37361. getDescription(): string;
  37362. /**
  37363. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  37364. * @param scene defines the current scene where to apply this optimization
  37365. * @param optimizer defines the current optimizer
  37366. * @returns true if everything that can be done was applied
  37367. */
  37368. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  37369. }
  37370. /**
  37371. * Defines an optimization used to turn lens flares off
  37372. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  37373. */
  37374. class LensFlaresOptimization extends SceneOptimization {
  37375. /**
  37376. * Gets a string describing the action executed by the current optimization
  37377. * @return description string
  37378. */
  37379. getDescription(): string;
  37380. /**
  37381. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  37382. * @param scene defines the current scene where to apply this optimization
  37383. * @param optimizer defines the current optimizer
  37384. * @returns true if everything that can be done was applied
  37385. */
  37386. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  37387. }
  37388. /**
  37389. * Defines an optimization based on user defined callback.
  37390. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  37391. */
  37392. class CustomOptimization extends SceneOptimization {
  37393. /**
  37394. * Callback called to apply the custom optimization.
  37395. */
  37396. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  37397. /**
  37398. * Callback called to get custom description
  37399. */
  37400. onGetDescription: () => string;
  37401. /**
  37402. * Gets a string describing the action executed by the current optimization
  37403. * @returns description string
  37404. */
  37405. getDescription(): string;
  37406. /**
  37407. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  37408. * @param scene defines the current scene where to apply this optimization
  37409. * @param optimizer defines the current optimizer
  37410. * @returns true if everything that can be done was applied
  37411. */
  37412. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  37413. }
  37414. /**
  37415. * Defines an optimization used to turn particles off
  37416. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  37417. */
  37418. class ParticlesOptimization extends SceneOptimization {
  37419. /**
  37420. * Gets a string describing the action executed by the current optimization
  37421. * @return description string
  37422. */
  37423. getDescription(): string;
  37424. /**
  37425. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  37426. * @param scene defines the current scene where to apply this optimization
  37427. * @param optimizer defines the current optimizer
  37428. * @returns true if everything that can be done was applied
  37429. */
  37430. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  37431. }
  37432. /**
  37433. * Defines an optimization used to turn render targets off
  37434. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  37435. */
  37436. class RenderTargetsOptimization extends SceneOptimization {
  37437. /**
  37438. * Gets a string describing the action executed by the current optimization
  37439. * @return description string
  37440. */
  37441. getDescription(): string;
  37442. /**
  37443. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  37444. * @param scene defines the current scene where to apply this optimization
  37445. * @param optimizer defines the current optimizer
  37446. * @returns true if everything that can be done was applied
  37447. */
  37448. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  37449. }
  37450. /**
  37451. * Defines an optimization used to merge meshes with compatible materials
  37452. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  37453. */
  37454. class MergeMeshesOptimization extends SceneOptimization {
  37455. private static _UpdateSelectionTree;
  37456. /**
  37457. * Gets or sets a boolean which defines if optimization octree has to be updated
  37458. */
  37459. /**
  37460. * Gets or sets a boolean which defines if optimization octree has to be updated
  37461. */
  37462. static UpdateSelectionTree: boolean;
  37463. /**
  37464. * Gets a string describing the action executed by the current optimization
  37465. * @return description string
  37466. */
  37467. getDescription(): string;
  37468. private _canBeMerged;
  37469. /**
  37470. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  37471. * @param scene defines the current scene where to apply this optimization
  37472. * @param optimizer defines the current optimizer
  37473. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  37474. * @returns true if everything that can be done was applied
  37475. */
  37476. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  37477. }
  37478. /**
  37479. * Defines a list of options used by SceneOptimizer
  37480. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  37481. */
  37482. class SceneOptimizerOptions {
  37483. /**
  37484. * Defines the target frame rate to reach (60 by default)
  37485. */
  37486. targetFrameRate: number;
  37487. /**
  37488. * Defines the interval between two checkes (2000ms by default)
  37489. */
  37490. trackerDuration: number;
  37491. /**
  37492. * Gets the list of optimizations to apply
  37493. */
  37494. optimizations: SceneOptimization[];
  37495. /**
  37496. * Creates a new list of options used by SceneOptimizer
  37497. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  37498. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  37499. */
  37500. constructor(
  37501. /**
  37502. * Defines the target frame rate to reach (60 by default)
  37503. */
  37504. targetFrameRate?: number,
  37505. /**
  37506. * Defines the interval between two checkes (2000ms by default)
  37507. */
  37508. trackerDuration?: number);
  37509. /**
  37510. * Add a new optimization
  37511. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  37512. * @returns the current SceneOptimizerOptions
  37513. */
  37514. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  37515. /**
  37516. * Add a new custom optimization
  37517. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  37518. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  37519. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  37520. * @returns the current SceneOptimizerOptions
  37521. */
  37522. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  37523. /**
  37524. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  37525. * @param targetFrameRate defines the target frame rate (60 by default)
  37526. * @returns a SceneOptimizerOptions object
  37527. */
  37528. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  37529. /**
  37530. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  37531. * @param targetFrameRate defines the target frame rate (60 by default)
  37532. * @returns a SceneOptimizerOptions object
  37533. */
  37534. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  37535. /**
  37536. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  37537. * @param targetFrameRate defines the target frame rate (60 by default)
  37538. * @returns a SceneOptimizerOptions object
  37539. */
  37540. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  37541. }
  37542. /**
  37543. * Class used to run optimizations in order to reach a target frame rate
  37544. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  37545. */
  37546. class SceneOptimizer implements IDisposable {
  37547. private _isRunning;
  37548. private _options;
  37549. private _scene;
  37550. private _currentPriorityLevel;
  37551. private _targetFrameRate;
  37552. private _trackerDuration;
  37553. private _currentFrameRate;
  37554. private _sceneDisposeObserver;
  37555. private _improvementMode;
  37556. /**
  37557. * Defines an observable called when the optimizer reaches the target frame rate
  37558. */
  37559. onSuccessObservable: Observable<SceneOptimizer>;
  37560. /**
  37561. * Defines an observable called when the optimizer enables an optimization
  37562. */
  37563. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  37564. /**
  37565. * Defines an observable called when the optimizer is not able to reach the target frame rate
  37566. */
  37567. onFailureObservable: Observable<SceneOptimizer>;
  37568. /**
  37569. * Gets a boolean indicating if the optimizer is in improvement mode
  37570. */
  37571. readonly isInImprovementMode: boolean;
  37572. /**
  37573. * Gets the current priority level (0 at start)
  37574. */
  37575. readonly currentPriorityLevel: number;
  37576. /**
  37577. * Gets the current frame rate checked by the SceneOptimizer
  37578. */
  37579. readonly currentFrameRate: number;
  37580. /**
  37581. * Gets or sets the current target frame rate (60 by default)
  37582. */
  37583. /**
  37584. * Gets or sets the current target frame rate (60 by default)
  37585. */
  37586. targetFrameRate: number;
  37587. /**
  37588. * Gets or sets the current interval between two checks (every 2000ms by default)
  37589. */
  37590. /**
  37591. * Gets or sets the current interval between two checks (every 2000ms by default)
  37592. */
  37593. trackerDuration: number;
  37594. /**
  37595. * Gets the list of active optimizations
  37596. */
  37597. readonly optimizations: SceneOptimization[];
  37598. /**
  37599. * Creates a new SceneOptimizer
  37600. * @param scene defines the scene to work on
  37601. * @param options defines the options to use with the SceneOptimizer
  37602. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  37603. * @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)
  37604. */
  37605. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  37606. /**
  37607. * Stops the current optimizer
  37608. */
  37609. stop(): void;
  37610. /**
  37611. * Reset the optimizer to initial step (current priority level = 0)
  37612. */
  37613. reset(): void;
  37614. /**
  37615. * Start the optimizer. By default it will try to reach a specific framerate
  37616. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  37617. */
  37618. start(): void;
  37619. private _checkCurrentState;
  37620. /**
  37621. * Release all resources
  37622. */
  37623. dispose(): void;
  37624. /**
  37625. * Helper function to create a SceneOptimizer with one single line of code
  37626. * @param scene defines the scene to work on
  37627. * @param options defines the options to use with the SceneOptimizer
  37628. * @param onSuccess defines a callback to call on success
  37629. * @param onFailure defines a callback to call on failure
  37630. * @returns the new SceneOptimizer object
  37631. */
  37632. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  37633. }
  37634. }
  37635. declare module BABYLON {
  37636. /**
  37637. * Class used to serialize a scene into a string
  37638. */
  37639. class SceneSerializer {
  37640. /**
  37641. * Clear cache used by a previous serialization
  37642. */
  37643. static ClearCache(): void;
  37644. /**
  37645. * Serialize a scene into a JSON compatible object
  37646. * @param scene defines the scene to serialize
  37647. * @returns a JSON compatible object
  37648. */
  37649. static Serialize(scene: Scene): any;
  37650. /**
  37651. * Serialize a mesh into a JSON compatible object
  37652. * @param toSerialize defines the mesh to serialize
  37653. * @param withParents defines if parents must be serialized as well
  37654. * @param withChildren defines if children must be serialized as well
  37655. * @returns a JSON compatible object
  37656. */
  37657. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  37658. }
  37659. }
  37660. declare module BABYLON {
  37661. /**
  37662. * Defines an array and its length.
  37663. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  37664. */
  37665. interface ISmartArrayLike<T> {
  37666. /**
  37667. * The data of the array.
  37668. */
  37669. data: Array<T>;
  37670. /**
  37671. * The active length of the array.
  37672. */
  37673. length: number;
  37674. }
  37675. /**
  37676. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  37677. */
  37678. class SmartArray<T> implements ISmartArrayLike<T> {
  37679. /**
  37680. * The full set of data from the array.
  37681. */
  37682. data: Array<T>;
  37683. /**
  37684. * The active length of the array.
  37685. */
  37686. length: number;
  37687. protected _id: number;
  37688. /**
  37689. * Instantiates a Smart Array.
  37690. * @param capacity defines the default capacity of the array.
  37691. */
  37692. constructor(capacity: number);
  37693. /**
  37694. * Pushes a value at the end of the active data.
  37695. * @param value defines the object to push in the array.
  37696. */
  37697. push(value: T): void;
  37698. /**
  37699. * Iterates over the active data and apply the lambda to them.
  37700. * @param func defines the action to apply on each value.
  37701. */
  37702. forEach(func: (content: T) => void): void;
  37703. /**
  37704. * Sorts the full sets of data.
  37705. * @param compareFn defines the comparison function to apply.
  37706. */
  37707. sort(compareFn: (a: T, b: T) => number): void;
  37708. /**
  37709. * Resets the active data to an empty array.
  37710. */
  37711. reset(): void;
  37712. /**
  37713. * Releases all the data from the array as well as the array.
  37714. */
  37715. dispose(): void;
  37716. /**
  37717. * Concats the active data with a given array.
  37718. * @param array defines the data to concatenate with.
  37719. */
  37720. concat(array: any): void;
  37721. /**
  37722. * Returns the position of a value in the active data.
  37723. * @param value defines the value to find the index for
  37724. * @returns the index if found in the active data otherwise -1
  37725. */
  37726. indexOf(value: T): number;
  37727. /**
  37728. * Returns whether an element is part of the active data.
  37729. * @param value defines the value to look for
  37730. * @returns true if found in the active data otherwise false
  37731. */
  37732. contains(value: T): boolean;
  37733. private static _GlobalId;
  37734. }
  37735. /**
  37736. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  37737. * The data in this array can only be present once
  37738. */
  37739. class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  37740. private _duplicateId;
  37741. /**
  37742. * Pushes a value at the end of the active data.
  37743. * THIS DOES NOT PREVENT DUPPLICATE DATA
  37744. * @param value defines the object to push in the array.
  37745. */
  37746. push(value: T): void;
  37747. /**
  37748. * Pushes a value at the end of the active data.
  37749. * If the data is already present, it won t be added again
  37750. * @param value defines the object to push in the array.
  37751. * @returns true if added false if it was already present
  37752. */
  37753. pushNoDuplicate(value: T): boolean;
  37754. /**
  37755. * Resets the active data to an empty array.
  37756. */
  37757. reset(): void;
  37758. /**
  37759. * Concats the active data with a given array.
  37760. * This ensures no dupplicate will be present in the result.
  37761. * @param array defines the data to concatenate with.
  37762. */
  37763. concatWithNoDuplicate(array: any): void;
  37764. }
  37765. }
  37766. declare module BABYLON {
  37767. /**
  37768. * This class implement a typical dictionary using a string as key and the generic type T as value.
  37769. * The underlying implementation relies on an associative array to ensure the best performances.
  37770. * The value can be anything including 'null' but except 'undefined'
  37771. */
  37772. class StringDictionary<T> {
  37773. /**
  37774. * This will clear this dictionary and copy the content from the 'source' one.
  37775. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  37776. * @param source the dictionary to take the content from and copy to this dictionary
  37777. */
  37778. copyFrom(source: StringDictionary<T>): void;
  37779. /**
  37780. * Get a value based from its key
  37781. * @param key the given key to get the matching value from
  37782. * @return the value if found, otherwise undefined is returned
  37783. */
  37784. get(key: string): T | undefined;
  37785. /**
  37786. * Get a value from its key or add it if it doesn't exist.
  37787. * This method will ensure you that a given key/data will be present in the dictionary.
  37788. * @param key the given key to get the matching value from
  37789. * @param factory the factory that will create the value if the key is not present in the dictionary.
  37790. * The factory will only be invoked if there's no data for the given key.
  37791. * @return the value corresponding to the key.
  37792. */
  37793. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  37794. /**
  37795. * Get a value from its key if present in the dictionary otherwise add it
  37796. * @param key the key to get the value from
  37797. * @param val if there's no such key/value pair in the dictionary add it with this value
  37798. * @return the value corresponding to the key
  37799. */
  37800. getOrAdd(key: string, val: T): T;
  37801. /**
  37802. * Check if there's a given key in the dictionary
  37803. * @param key the key to check for
  37804. * @return true if the key is present, false otherwise
  37805. */
  37806. contains(key: string): boolean;
  37807. /**
  37808. * Add a new key and its corresponding value
  37809. * @param key the key to add
  37810. * @param value the value corresponding to the key
  37811. * @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
  37812. */
  37813. add(key: string, value: T): boolean;
  37814. /**
  37815. * Update a specific value associated to a key
  37816. * @param key defines the key to use
  37817. * @param value defines the value to store
  37818. * @returns true if the value was updated (or false if the key was not found)
  37819. */
  37820. set(key: string, value: T): boolean;
  37821. /**
  37822. * Get the element of the given key and remove it from the dictionary
  37823. * @param key defines the key to search
  37824. * @returns the value associated with the key or null if not found
  37825. */
  37826. getAndRemove(key: string): Nullable<T>;
  37827. /**
  37828. * Remove a key/value from the dictionary.
  37829. * @param key the key to remove
  37830. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  37831. */
  37832. remove(key: string): boolean;
  37833. /**
  37834. * Clear the whole content of the dictionary
  37835. */
  37836. clear(): void;
  37837. /**
  37838. * Gets the current count
  37839. */
  37840. readonly count: number;
  37841. /**
  37842. * Execute a callback on each key/val of the dictionary.
  37843. * Note that you can remove any element in this dictionary in the callback implementation
  37844. * @param callback the callback to execute on a given key/value pair
  37845. */
  37846. forEach(callback: (key: string, val: T) => void): void;
  37847. /**
  37848. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  37849. * If the callback returns null or undefined the method will iterate to the next key/value pair
  37850. * Note that you can remove any element in this dictionary in the callback implementation
  37851. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  37852. * @returns the first item
  37853. */
  37854. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  37855. private _count;
  37856. private _data;
  37857. }
  37858. }
  37859. declare module BABYLON {
  37860. /**
  37861. * Class used to store custom tags
  37862. */
  37863. class Tags {
  37864. /**
  37865. * Adds support for tags on the given object
  37866. * @param obj defines the object to use
  37867. */
  37868. static EnableFor(obj: any): void;
  37869. /**
  37870. * Removes tags support
  37871. * @param obj defines the object to use
  37872. */
  37873. static DisableFor(obj: any): void;
  37874. /**
  37875. * Gets a boolean indicating if the given object has tags
  37876. * @param obj defines the object to use
  37877. * @returns a boolean
  37878. */
  37879. static HasTags(obj: any): boolean;
  37880. /**
  37881. * Gets the tags available on a given object
  37882. * @param obj defines the object to use
  37883. * @param asString defines if the tags must be returned as a string instead of an array of strings
  37884. * @returns the tags
  37885. */
  37886. static GetTags(obj: any, asString?: boolean): any;
  37887. /**
  37888. * Adds tags to an object
  37889. * @param obj defines the object to use
  37890. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  37891. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  37892. */
  37893. static AddTagsTo(obj: any, tagsString: string): void;
  37894. /**
  37895. * @hidden
  37896. */
  37897. private static _AddTagTo(obj: any, tag: string): void;
  37898. /**
  37899. * Removes specific tags from a specific object
  37900. * @param obj defines the object to use
  37901. * @param tagsString defines the tags to remove
  37902. */
  37903. static RemoveTagsFrom(obj: any, tagsString: string): void;
  37904. /**
  37905. * @hidden
  37906. */
  37907. private static _RemoveTagFrom(obj: any, tag: string): void;
  37908. /**
  37909. * Defines if tags hosted on an object match a given query
  37910. * @param obj defines the object to use
  37911. * @param tagsQuery defines the tag query
  37912. * @returns a boolean
  37913. */
  37914. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  37915. }
  37916. }
  37917. declare module BABYLON {
  37918. /**
  37919. * Class used to host texture specific utilities
  37920. */
  37921. class TextureTools {
  37922. /**
  37923. * Uses the GPU to create a copy texture rescaled at a given size
  37924. * @param texture Texture to copy from
  37925. * @param width defines the desired width
  37926. * @param height defines the desired height
  37927. * @param useBilinearMode defines if bilinear mode has to be used
  37928. * @return the generated texture
  37929. */
  37930. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  37931. /**
  37932. * Gets an environment BRDF texture for a given scene
  37933. * @param scene defines the hosting scene
  37934. * @returns the environment BRDF texture
  37935. */
  37936. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  37937. private static _environmentBRDFBase64Texture;
  37938. }
  37939. }
  37940. declare module BABYLON {
  37941. /**
  37942. * Based on jsTGALoader - Javascript loader for TGA file
  37943. * By Vincent Thibault
  37944. * @see http://blog.robrowser.com/javascript-tga-loader.html
  37945. */
  37946. class TGATools {
  37947. private static _TYPE_INDEXED;
  37948. private static _TYPE_RGB;
  37949. private static _TYPE_GREY;
  37950. private static _TYPE_RLE_INDEXED;
  37951. private static _TYPE_RLE_RGB;
  37952. private static _TYPE_RLE_GREY;
  37953. private static _ORIGIN_MASK;
  37954. private static _ORIGIN_SHIFT;
  37955. private static _ORIGIN_BL;
  37956. private static _ORIGIN_BR;
  37957. private static _ORIGIN_UL;
  37958. private static _ORIGIN_UR;
  37959. /**
  37960. * Gets the header of a TGA file
  37961. * @param data defines the TGA data
  37962. * @returns the header
  37963. */
  37964. static GetTGAHeader(data: Uint8Array): any;
  37965. /**
  37966. * Uploads TGA content to a Babylon Texture
  37967. * @hidden
  37968. */
  37969. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  37970. /** @hidden */
  37971. 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;
  37972. /** @hidden */
  37973. 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;
  37974. /** @hidden */
  37975. 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;
  37976. /** @hidden */
  37977. 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;
  37978. /** @hidden */
  37979. 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;
  37980. /** @hidden */
  37981. 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;
  37982. }
  37983. }
  37984. declare module BABYLON {
  37985. /**
  37986. * Interface containing an array of animations
  37987. */
  37988. interface IAnimatable {
  37989. /**
  37990. * Array of animations
  37991. */
  37992. animations: Array<Animation>;
  37993. }
  37994. /** Interface used by value gradients (color, factor, ...) */
  37995. interface IValueGradient {
  37996. /**
  37997. * Gets or sets the gradient value (between 0 and 1)
  37998. */
  37999. gradient: number;
  38000. }
  38001. /** Class used to store color4 gradient */
  38002. class ColorGradient implements IValueGradient {
  38003. /**
  38004. * Gets or sets the gradient value (between 0 and 1)
  38005. */
  38006. gradient: number;
  38007. /**
  38008. * Gets or sets first associated color
  38009. */
  38010. color1: Color4;
  38011. /**
  38012. * Gets or sets second associated color
  38013. */
  38014. color2?: Color4;
  38015. /**
  38016. * Will get a color picked randomly between color1 and color2.
  38017. * If color2 is undefined then color1 will be used
  38018. * @param result defines the target Color4 to store the result in
  38019. */
  38020. getColorToRef(result: Color4): void;
  38021. }
  38022. /** Class used to store color 3 gradient */
  38023. class Color3Gradient implements IValueGradient {
  38024. /**
  38025. * Gets or sets the gradient value (between 0 and 1)
  38026. */
  38027. gradient: number;
  38028. /**
  38029. * Gets or sets the associated color
  38030. */
  38031. color: Color3;
  38032. }
  38033. /** Class used to store factor gradient */
  38034. class FactorGradient implements IValueGradient {
  38035. /**
  38036. * Gets or sets the gradient value (between 0 and 1)
  38037. */
  38038. gradient: number;
  38039. /**
  38040. * Gets or sets first associated factor
  38041. */
  38042. factor1: number;
  38043. /**
  38044. * Gets or sets second associated factor
  38045. */
  38046. factor2?: number;
  38047. /**
  38048. * Will get a number picked randomly between factor1 and factor2.
  38049. * If factor2 is undefined then factor1 will be used
  38050. * @returns the picked number
  38051. */
  38052. getFactor(): number;
  38053. }
  38054. /**
  38055. * @ignore
  38056. * Application error to support additional information when loading a file
  38057. */
  38058. class LoadFileError extends Error {
  38059. /** defines the optional XHR request */
  38060. request?: XMLHttpRequest | undefined;
  38061. private static _setPrototypeOf;
  38062. /**
  38063. * Creates a new LoadFileError
  38064. * @param message defines the message of the error
  38065. * @param request defines the optional XHR request
  38066. */
  38067. constructor(message: string,
  38068. /** defines the optional XHR request */
  38069. request?: XMLHttpRequest | undefined);
  38070. }
  38071. /**
  38072. * Class used to define a retry strategy when error happens while loading assets
  38073. */
  38074. class RetryStrategy {
  38075. /**
  38076. * Function used to defines an exponential back off strategy
  38077. * @param maxRetries defines the maximum number of retries (3 by default)
  38078. * @param baseInterval defines the interval between retries
  38079. * @returns the strategy function to use
  38080. */
  38081. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  38082. }
  38083. /**
  38084. * File request interface
  38085. */
  38086. interface IFileRequest {
  38087. /**
  38088. * Raised when the request is complete (success or error).
  38089. */
  38090. onCompleteObservable: Observable<IFileRequest>;
  38091. /**
  38092. * Aborts the request for a file.
  38093. */
  38094. abort: () => void;
  38095. }
  38096. /**
  38097. * Class containing a set of static utilities functions
  38098. */
  38099. class Tools {
  38100. /**
  38101. * Gets or sets the base URL to use to load assets
  38102. */
  38103. static BaseUrl: string;
  38104. /**
  38105. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  38106. */
  38107. static DefaultRetryStrategy: (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  38108. /**
  38109. * Default behaviour for cors in the application.
  38110. * It can be a string if the expected behavior is identical in the entire app.
  38111. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  38112. */
  38113. static CorsBehavior: string | ((url: string | string[]) => string);
  38114. /**
  38115. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  38116. * @ignorenaming
  38117. */
  38118. static UseFallbackTexture: boolean;
  38119. /**
  38120. * Use this object to register external classes like custom textures or material
  38121. * to allow the laoders to instantiate them
  38122. */
  38123. static RegisteredExternalClasses: {
  38124. [key: string]: Object;
  38125. };
  38126. /**
  38127. * Texture content used if a texture cannot loaded
  38128. * @ignorenaming
  38129. */
  38130. static fallbackTexture: string;
  38131. /**
  38132. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  38133. * @param u defines the coordinate on X axis
  38134. * @param v defines the coordinate on Y axis
  38135. * @param width defines the width of the source data
  38136. * @param height defines the height of the source data
  38137. * @param pixels defines the source byte array
  38138. * @param color defines the output color
  38139. */
  38140. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  38141. /**
  38142. * Interpolates between a and b via alpha
  38143. * @param a The lower value (returned when alpha = 0)
  38144. * @param b The upper value (returned when alpha = 1)
  38145. * @param alpha The interpolation-factor
  38146. * @return The mixed value
  38147. */
  38148. static Mix(a: number, b: number, alpha: number): number;
  38149. /**
  38150. * Tries to instantiate a new object from a given class name
  38151. * @param className defines the class name to instantiate
  38152. * @returns the new object or null if the system was not able to do the instantiation
  38153. */
  38154. static Instantiate(className: string): any;
  38155. /**
  38156. * Provides a slice function that will work even on IE
  38157. * @param data defines the array to slice
  38158. * @param start defines the start of the data (optional)
  38159. * @param end defines the end of the data (optional)
  38160. * @returns the new sliced array
  38161. */
  38162. static Slice<T>(data: T, start?: number, end?: number): T;
  38163. /**
  38164. * Polyfill for setImmediate
  38165. * @param action defines the action to execute after the current execution block
  38166. */
  38167. static SetImmediate(action: () => void): void;
  38168. /**
  38169. * Function indicating if a number is an exponent of 2
  38170. * @param value defines the value to test
  38171. * @returns true if the value is an exponent of 2
  38172. */
  38173. static IsExponentOfTwo(value: number): boolean;
  38174. private static _tmpFloatArray;
  38175. /**
  38176. * Returns the nearest 32-bit single precision float representation of a Number
  38177. * @param value A Number. If the parameter is of a different type, it will get converted
  38178. * to a number or to NaN if it cannot be converted
  38179. * @returns number
  38180. */
  38181. static FloatRound(value: number): number;
  38182. /**
  38183. * Find the next highest power of two.
  38184. * @param x Number to start search from.
  38185. * @return Next highest power of two.
  38186. */
  38187. static CeilingPOT(x: number): number;
  38188. /**
  38189. * Find the next lowest power of two.
  38190. * @param x Number to start search from.
  38191. * @return Next lowest power of two.
  38192. */
  38193. static FloorPOT(x: number): number;
  38194. /**
  38195. * Find the nearest power of two.
  38196. * @param x Number to start search from.
  38197. * @return Next nearest power of two.
  38198. */
  38199. static NearestPOT(x: number): number;
  38200. /**
  38201. * Get the closest exponent of two
  38202. * @param value defines the value to approximate
  38203. * @param max defines the maximum value to return
  38204. * @param mode defines how to define the closest value
  38205. * @returns closest exponent of two of the given value
  38206. */
  38207. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  38208. /**
  38209. * Extracts the filename from a path
  38210. * @param path defines the path to use
  38211. * @returns the filename
  38212. */
  38213. static GetFilename(path: string): string;
  38214. /**
  38215. * Extracts the "folder" part of a path (everything before the filename).
  38216. * @param uri The URI to extract the info from
  38217. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  38218. * @returns The "folder" part of the path
  38219. */
  38220. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  38221. /**
  38222. * Extracts text content from a DOM element hierarchy
  38223. * @param element defines the root element
  38224. * @returns a string
  38225. */
  38226. static GetDOMTextContent(element: HTMLElement): string;
  38227. /**
  38228. * Convert an angle in radians to degrees
  38229. * @param angle defines the angle to convert
  38230. * @returns the angle in degrees
  38231. */
  38232. static ToDegrees(angle: number): number;
  38233. /**
  38234. * Convert an angle in degrees to radians
  38235. * @param angle defines the angle to convert
  38236. * @returns the angle in radians
  38237. */
  38238. static ToRadians(angle: number): number;
  38239. /**
  38240. * Encode a buffer to a base64 string
  38241. * @param buffer defines the buffer to encode
  38242. * @returns the encoded string
  38243. */
  38244. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  38245. /**
  38246. * Extracts minimum and maximum values from a list of indexed positions
  38247. * @param positions defines the positions to use
  38248. * @param indices defines the indices to the positions
  38249. * @param indexStart defines the start index
  38250. * @param indexCount defines the end index
  38251. * @param bias defines bias value to add to the result
  38252. * @return minimum and maximum values
  38253. */
  38254. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  38255. minimum: Vector3;
  38256. maximum: Vector3;
  38257. };
  38258. /**
  38259. * Extracts minimum and maximum values from a list of positions
  38260. * @param positions defines the positions to use
  38261. * @param start defines the start index in the positions array
  38262. * @param count defines the number of positions to handle
  38263. * @param bias defines bias value to add to the result
  38264. * @param stride defines the stride size to use (distance between two positions in the positions array)
  38265. * @return minimum and maximum values
  38266. */
  38267. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  38268. minimum: Vector3;
  38269. maximum: Vector3;
  38270. };
  38271. /**
  38272. * Returns an array if obj is not an array
  38273. * @param obj defines the object to evaluate as an array
  38274. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  38275. * @returns either obj directly if obj is an array or a new array containing obj
  38276. */
  38277. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  38278. /**
  38279. * Gets the pointer prefix to use
  38280. * @returns "pointer" if touch is enabled. Else returns "mouse"
  38281. */
  38282. static GetPointerPrefix(): string;
  38283. /**
  38284. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  38285. * @param func - the function to be called
  38286. * @param requester - the object that will request the next frame. Falls back to window.
  38287. * @returns frame number
  38288. */
  38289. static QueueNewFrame(func: () => void, requester?: any): number;
  38290. /**
  38291. * Ask the browser to promote the current element to fullscreen rendering mode
  38292. * @param element defines the DOM element to promote
  38293. */
  38294. static RequestFullscreen(element: HTMLElement): void;
  38295. /**
  38296. * Asks the browser to exit fullscreen mode
  38297. */
  38298. static ExitFullscreen(): void;
  38299. /**
  38300. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  38301. * @param url define the url we are trying
  38302. * @param element define the dom element where to configure the cors policy
  38303. */
  38304. static SetCorsBehavior(url: string | string[], element: {
  38305. crossOrigin: string | null;
  38306. }): void;
  38307. /**
  38308. * Removes unwanted characters from an url
  38309. * @param url defines the url to clean
  38310. * @returns the cleaned url
  38311. */
  38312. static CleanUrl(url: string): string;
  38313. /**
  38314. * Gets or sets a function used to pre-process url before using them to load assets
  38315. */
  38316. static PreprocessUrl: (url: string) => string;
  38317. /**
  38318. * Loads an image as an HTMLImageElement.
  38319. * @param input url string, ArrayBuffer, or Blob to load
  38320. * @param onLoad callback called when the image successfully loads
  38321. * @param onError callback called when the image fails to load
  38322. * @param database database for caching
  38323. * @returns the HTMLImageElement of the loaded image
  38324. */
  38325. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, database: Nullable<Database>): HTMLImageElement;
  38326. /**
  38327. * Loads a file
  38328. * @param url url string, ArrayBuffer, or Blob to load
  38329. * @param onSuccess callback called when the file successfully loads
  38330. * @param onProgress callback called while file is loading (if the server supports this mode)
  38331. * @param database database for caching
  38332. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  38333. * @param onError callback called when the file fails to load
  38334. * @returns a file request object
  38335. */
  38336. 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;
  38337. /**
  38338. * Load a script (identified by an url). When the url returns, the
  38339. * content of this file is added into a new script element, attached to the DOM (body element)
  38340. * @param scriptUrl defines the url of the script to laod
  38341. * @param onSuccess defines the callback called when the script is loaded
  38342. * @param onError defines the callback to call if an error occurs
  38343. */
  38344. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void): void;
  38345. /**
  38346. * Loads a file from a blob
  38347. * @param fileToLoad defines the blob to use
  38348. * @param callback defines the callback to call when data is loaded
  38349. * @param progressCallback defines the callback to call during loading process
  38350. * @returns a file request object
  38351. */
  38352. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  38353. /**
  38354. * Loads a file
  38355. * @param fileToLoad defines the file to load
  38356. * @param callback defines the callback to call when data is loaded
  38357. * @param progressCallBack defines the callback to call during loading process
  38358. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  38359. * @returns a file request object
  38360. */
  38361. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  38362. /**
  38363. * Creates a data url from a given string content
  38364. * @param content defines the content to convert
  38365. * @returns the new data url link
  38366. */
  38367. static FileAsURL(content: string): string;
  38368. /**
  38369. * Format the given number to a specific decimal format
  38370. * @param value defines the number to format
  38371. * @param decimals defines the number of decimals to use
  38372. * @returns the formatted string
  38373. */
  38374. static Format(value: number, decimals?: number): string;
  38375. /**
  38376. * Checks if a given vector is inside a specific range
  38377. * @param v defines the vector to test
  38378. * @param min defines the minimum range
  38379. * @param max defines the maximum range
  38380. */
  38381. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  38382. /**
  38383. * Tries to copy an object by duplicating every property
  38384. * @param source defines the source object
  38385. * @param destination defines the target object
  38386. * @param doNotCopyList defines a list of properties to avoid
  38387. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  38388. */
  38389. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  38390. /**
  38391. * Gets a boolean indicating if the given object has no own property
  38392. * @param obj defines the object to test
  38393. * @returns true if object has no own property
  38394. */
  38395. static IsEmpty(obj: any): boolean;
  38396. /**
  38397. * Function used to register events at window level
  38398. * @param events defines the events to register
  38399. */
  38400. static RegisterTopRootEvents(events: {
  38401. name: string;
  38402. handler: Nullable<(e: FocusEvent) => any>;
  38403. }[]): void;
  38404. /**
  38405. * Function used to unregister events from window level
  38406. * @param events defines the events to unregister
  38407. */
  38408. static UnregisterTopRootEvents(events: {
  38409. name: string;
  38410. handler: Nullable<(e: FocusEvent) => any>;
  38411. }[]): void;
  38412. /**
  38413. * Dumps the current bound framebuffer
  38414. * @param width defines the rendering width
  38415. * @param height defines the rendering height
  38416. * @param engine defines the hosting engine
  38417. * @param successCallback defines the callback triggered once the data are available
  38418. * @param mimeType defines the mime type of the result
  38419. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  38420. */
  38421. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  38422. /**
  38423. * Converts the canvas data to blob.
  38424. * This acts as a polyfill for browsers not supporting the to blob function.
  38425. * @param canvas Defines the canvas to extract the data from
  38426. * @param successCallback Defines the callback triggered once the data are available
  38427. * @param mimeType Defines the mime type of the result
  38428. */
  38429. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  38430. /**
  38431. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  38432. * @param successCallback defines the callback triggered once the data are available
  38433. * @param mimeType defines the mime type of the result
  38434. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  38435. */
  38436. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  38437. /**
  38438. * Downloads a blob in the browser
  38439. * @param blob defines the blob to download
  38440. * @param fileName defines the name of the downloaded file
  38441. */
  38442. static Download(blob: Blob, fileName: string): void;
  38443. /**
  38444. * Captures a screenshot of the current rendering
  38445. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  38446. * @param engine defines the rendering engine
  38447. * @param camera defines the source camera
  38448. * @param size This parameter can be set to a single number or to an object with the
  38449. * following (optional) properties: precision, width, height. If a single number is passed,
  38450. * it will be used for both width and height. If an object is passed, the screenshot size
  38451. * will be derived from the parameters. The precision property is a multiplier allowing
  38452. * rendering at a higher or lower resolution
  38453. * @param successCallback defines the callback receives a single parameter which contains the
  38454. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  38455. * src parameter of an <img> to display it
  38456. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  38457. * Check your browser for supported MIME types
  38458. */
  38459. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  38460. /**
  38461. * Generates an image screenshot from the specified camera.
  38462. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  38463. * @param engine The engine to use for rendering
  38464. * @param camera The camera to use for rendering
  38465. * @param size This parameter can be set to a single number or to an object with the
  38466. * following (optional) properties: precision, width, height. If a single number is passed,
  38467. * it will be used for both width and height. If an object is passed, the screenshot size
  38468. * will be derived from the parameters. The precision property is a multiplier allowing
  38469. * rendering at a higher or lower resolution
  38470. * @param successCallback The callback receives a single parameter which contains the
  38471. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  38472. * src parameter of an <img> to display it
  38473. * @param mimeType The MIME type of the screenshot image (default: image/png).
  38474. * Check your browser for supported MIME types
  38475. * @param samples Texture samples (default: 1)
  38476. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  38477. * @param fileName A name for for the downloaded file.
  38478. */
  38479. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  38480. /**
  38481. * Validates if xhr data is correct
  38482. * @param xhr defines the request to validate
  38483. * @param dataType defines the expected data type
  38484. * @returns true if data is correct
  38485. */
  38486. static ValidateXHRData(xhr: XMLHttpRequest, dataType?: number): boolean;
  38487. /**
  38488. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  38489. * Be aware Math.random() could cause collisions, but:
  38490. * "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"
  38491. * @returns a pseudo random id
  38492. */
  38493. static RandomId(): string;
  38494. /**
  38495. * Test if the given uri is a base64 string
  38496. * @param uri The uri to test
  38497. * @return True if the uri is a base64 string or false otherwise
  38498. */
  38499. static IsBase64(uri: string): boolean;
  38500. /**
  38501. * Decode the given base64 uri.
  38502. * @param uri The uri to decode
  38503. * @return The decoded base64 data.
  38504. */
  38505. static DecodeBase64(uri: string): ArrayBuffer;
  38506. /**
  38507. * No log
  38508. */
  38509. static readonly NoneLogLevel: number;
  38510. /**
  38511. * Only message logs
  38512. */
  38513. static readonly MessageLogLevel: number;
  38514. /**
  38515. * Only warning logs
  38516. */
  38517. static readonly WarningLogLevel: number;
  38518. /**
  38519. * Only error logs
  38520. */
  38521. static readonly ErrorLogLevel: number;
  38522. /**
  38523. * All logs
  38524. */
  38525. static readonly AllLogLevel: number;
  38526. private static _LogCache;
  38527. /**
  38528. * Gets a value indicating the number of loading errors
  38529. * @ignorenaming
  38530. */
  38531. static errorsCount: number;
  38532. /**
  38533. * Callback called when a new log is added
  38534. */
  38535. static OnNewCacheEntry: (entry: string) => void;
  38536. private static _AddLogEntry;
  38537. private static _FormatMessage;
  38538. private static _LogDisabled;
  38539. private static _LogEnabled;
  38540. private static _WarnDisabled;
  38541. private static _WarnEnabled;
  38542. private static _ErrorDisabled;
  38543. private static _ErrorEnabled;
  38544. /**
  38545. * Log a message to the console
  38546. */
  38547. static Log: (message: string) => void;
  38548. /**
  38549. * Write a warning message to the console
  38550. */
  38551. static Warn: (message: string) => void;
  38552. /**
  38553. * Write an error message to the console
  38554. */
  38555. static Error: (message: string) => void;
  38556. /**
  38557. * Gets current log cache (list of logs)
  38558. */
  38559. static readonly LogCache: string;
  38560. /**
  38561. * Clears the log cache
  38562. */
  38563. static ClearLogCache(): void;
  38564. /**
  38565. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  38566. */
  38567. static LogLevels: number;
  38568. /**
  38569. * Checks if the loaded document was accessed via `file:`-Protocol.
  38570. * @returns boolean
  38571. */
  38572. static IsFileURL(): boolean;
  38573. /**
  38574. * Checks if the window object exists
  38575. * @returns true if the window object exists
  38576. */
  38577. static IsWindowObjectExist(): boolean;
  38578. /**
  38579. * No performance log
  38580. */
  38581. static readonly PerformanceNoneLogLevel: number;
  38582. /**
  38583. * Use user marks to log performance
  38584. */
  38585. static readonly PerformanceUserMarkLogLevel: number;
  38586. /**
  38587. * Log performance to the console
  38588. */
  38589. static readonly PerformanceConsoleLogLevel: number;
  38590. private static _performance;
  38591. /**
  38592. * Sets the current performance log level
  38593. */
  38594. static PerformanceLogLevel: number;
  38595. private static _StartPerformanceCounterDisabled;
  38596. private static _EndPerformanceCounterDisabled;
  38597. private static _StartUserMark;
  38598. private static _EndUserMark;
  38599. private static _StartPerformanceConsole;
  38600. private static _EndPerformanceConsole;
  38601. /**
  38602. * Starts a performance counter
  38603. */
  38604. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  38605. /**
  38606. * Ends a specific performance coutner
  38607. */
  38608. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  38609. /**
  38610. * Gets either window.performance.now() if supported or Date.now() else
  38611. */
  38612. static readonly Now: number;
  38613. /**
  38614. * This method will return the name of the class used to create the instance of the given object.
  38615. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  38616. * @param object the object to get the class name from
  38617. * @param isType defines if the object is actually a type
  38618. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  38619. */
  38620. static GetClassName(object: any, isType?: boolean): string;
  38621. /**
  38622. * Gets the first element of an array satisfying a given predicate
  38623. * @param array defines the array to browse
  38624. * @param predicate defines the predicate to use
  38625. * @returns null if not found or the element
  38626. */
  38627. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  38628. /**
  38629. * This method will return the name of the full name of the class, including its owning module (if any).
  38630. * 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).
  38631. * @param object the object to get the class name from
  38632. * @param isType defines if the object is actually a type
  38633. * @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.
  38634. * @ignorenaming
  38635. */
  38636. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  38637. /**
  38638. * Returns a promise that resolves after the given amount of time.
  38639. * @param delay Number of milliseconds to delay
  38640. * @returns Promise that resolves after the given amount of time
  38641. */
  38642. static DelayAsync(delay: number): Promise<void>;
  38643. /**
  38644. * Gets the current gradient from an array of IValueGradient
  38645. * @param ratio defines the current ratio to get
  38646. * @param gradients defines the array of IValueGradient
  38647. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  38648. */
  38649. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  38650. }
  38651. /**
  38652. * This class is used to track a performance counter which is number based.
  38653. * The user has access to many properties which give statistics of different nature.
  38654. *
  38655. * The implementer can track two kinds of Performance Counter: time and count.
  38656. * 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.
  38657. * 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.
  38658. */
  38659. class PerfCounter {
  38660. /**
  38661. * Gets or sets a global boolean to turn on and off all the counters
  38662. */
  38663. static Enabled: boolean;
  38664. /**
  38665. * Returns the smallest value ever
  38666. */
  38667. readonly min: number;
  38668. /**
  38669. * Returns the biggest value ever
  38670. */
  38671. readonly max: number;
  38672. /**
  38673. * Returns the average value since the performance counter is running
  38674. */
  38675. readonly average: number;
  38676. /**
  38677. * Returns the average value of the last second the counter was monitored
  38678. */
  38679. readonly lastSecAverage: number;
  38680. /**
  38681. * Returns the current value
  38682. */
  38683. readonly current: number;
  38684. /**
  38685. * Gets the accumulated total
  38686. */
  38687. readonly total: number;
  38688. /**
  38689. * Gets the total value count
  38690. */
  38691. readonly count: number;
  38692. /**
  38693. * Creates a new counter
  38694. */
  38695. constructor();
  38696. /**
  38697. * Call this method to start monitoring a new frame.
  38698. * 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.
  38699. */
  38700. fetchNewFrame(): void;
  38701. /**
  38702. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  38703. * @param newCount the count value to add to the monitored count
  38704. * @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.
  38705. */
  38706. addCount(newCount: number, fetchResult: boolean): void;
  38707. /**
  38708. * Start monitoring this performance counter
  38709. */
  38710. beginMonitoring(): void;
  38711. /**
  38712. * Compute the time lapsed since the previous beginMonitoring() call.
  38713. * @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
  38714. */
  38715. endMonitoring(newFrame?: boolean): void;
  38716. private _fetchResult;
  38717. private _startMonitoringTime;
  38718. private _min;
  38719. private _max;
  38720. private _average;
  38721. private _current;
  38722. private _totalValueCount;
  38723. private _totalAccumulated;
  38724. private _lastSecAverage;
  38725. private _lastSecAccumulated;
  38726. private _lastSecTime;
  38727. private _lastSecValueCount;
  38728. }
  38729. /**
  38730. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  38731. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  38732. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  38733. * @param name The name of the class, case should be preserved
  38734. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  38735. */
  38736. function className(name: string, module?: string): (target: Object) => void;
  38737. /**
  38738. * An implementation of a loop for asynchronous functions.
  38739. */
  38740. class AsyncLoop {
  38741. /**
  38742. * Defines the number of iterations for the loop
  38743. */
  38744. iterations: number;
  38745. /**
  38746. * Defines the current index of the loop.
  38747. */
  38748. index: number;
  38749. private _done;
  38750. private _fn;
  38751. private _successCallback;
  38752. /**
  38753. * Constructor.
  38754. * @param iterations the number of iterations.
  38755. * @param func the function to run each iteration
  38756. * @param successCallback the callback that will be called upon succesful execution
  38757. * @param offset starting offset.
  38758. */
  38759. constructor(
  38760. /**
  38761. * Defines the number of iterations for the loop
  38762. */
  38763. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  38764. /**
  38765. * Execute the next iteration. Must be called after the last iteration was finished.
  38766. */
  38767. executeNext(): void;
  38768. /**
  38769. * Break the loop and run the success callback.
  38770. */
  38771. breakLoop(): void;
  38772. /**
  38773. * Create and run an async loop.
  38774. * @param iterations the number of iterations.
  38775. * @param fn the function to run each iteration
  38776. * @param successCallback the callback that will be called upon succesful execution
  38777. * @param offset starting offset.
  38778. * @returns the created async loop object
  38779. */
  38780. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  38781. /**
  38782. * A for-loop that will run a given number of iterations synchronous and the rest async.
  38783. * @param iterations total number of iterations
  38784. * @param syncedIterations number of synchronous iterations in each async iteration.
  38785. * @param fn the function to call each iteration.
  38786. * @param callback a success call back that will be called when iterating stops.
  38787. * @param breakFunction a break condition (optional)
  38788. * @param timeout timeout settings for the setTimeout function. default - 0.
  38789. * @returns the created async loop object
  38790. */
  38791. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  38792. }
  38793. }
  38794. interface HTMLCanvasElement {
  38795. /** Track wether a record is in progress */
  38796. isRecording: boolean;
  38797. /** Capture Stream method defined by some browsers */
  38798. captureStream(fps?: number): MediaStream;
  38799. }
  38800. interface MediaRecorder {
  38801. /** Starts recording */
  38802. start(timeSlice: number): void;
  38803. /** Stops recording */
  38804. stop(): void;
  38805. /** Event raised when an error arised. */
  38806. onerror: (event: ErrorEvent) => void;
  38807. /** Event raised when the recording stops. */
  38808. onstop: (event: Event) => void;
  38809. /** Event raised when a new chunk of data is available and should be tracked. */
  38810. ondataavailable: (event: Event) => void;
  38811. }
  38812. interface MediaRecorderOptions {
  38813. /** The mime type you want to use as the recording container for the new MediaRecorder */
  38814. mimeType?: string;
  38815. /** The chosen bitrate for the audio component of the media. */
  38816. audioBitsPerSecond?: number;
  38817. /** The chosen bitrate for the video component of the media. */
  38818. videoBitsPerSecond?: number;
  38819. /** 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. */
  38820. bitsPerSecond?: number;
  38821. }
  38822. interface MediaRecorderConstructor {
  38823. /**
  38824. * A reference to the prototype.
  38825. */
  38826. readonly prototype: MediaRecorder;
  38827. /**
  38828. * Creates a new MediaRecorder.
  38829. * @param stream Defines the stream to record.
  38830. * @param options Defines the options for the recorder available in the type MediaRecorderOptions.
  38831. */
  38832. new (stream: MediaStream, options?: MediaRecorderOptions): MediaRecorder;
  38833. }
  38834. /**
  38835. * MediaRecoreder object available in some browsers.
  38836. */
  38837. declare var MediaRecorder: MediaRecorderConstructor;
  38838. declare module BABYLON {
  38839. /**
  38840. * This represents the different options avilable for the video capture.
  38841. */
  38842. interface VideoRecorderOptions {
  38843. /** Defines the mime type of the video */
  38844. mimeType: string;
  38845. /** Defines the video the video should be recorded at */
  38846. fps: number;
  38847. /** Defines the chunk size for the recording data */
  38848. recordChunckSize: number;
  38849. }
  38850. /**
  38851. * This can helps recording videos from BabylonJS.
  38852. * This is based on the available WebRTC functionalities of the browser.
  38853. *
  38854. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  38855. */
  38856. class VideoRecorder {
  38857. private static readonly _defaultOptions;
  38858. /**
  38859. * Returns wehther or not the VideoRecorder is available in your browser.
  38860. * @param engine Defines the Babylon Engine to check the support for
  38861. * @returns true if supported otherwise false
  38862. */
  38863. static IsSupported(engine: Engine): boolean;
  38864. private readonly _options;
  38865. private _canvas;
  38866. private _mediaRecorder;
  38867. private _recordedChunks;
  38868. private _fileName;
  38869. private _resolve;
  38870. private _reject;
  38871. /**
  38872. * True wether a recording is already in progress.
  38873. */
  38874. readonly isRecording: boolean;
  38875. /**
  38876. * Create a new VideoCapture object which can help converting what you see in Babylon to
  38877. * a video file.
  38878. * @param engine Defines the BabylonJS Engine you wish to record
  38879. * @param options Defines options that can be used to customized the capture
  38880. */
  38881. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  38882. /**
  38883. * Stops the current recording before the default capture timeout passed in the startRecording
  38884. * functions.
  38885. */
  38886. stopRecording(): void;
  38887. /**
  38888. * Starts recording the canvas for a max duration specified in parameters.
  38889. * @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.
  38890. * @param maxDuration Defines the maximum recording time in seconds.
  38891. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  38892. * @return a promise callback at the end of the recording with the video data in Blob.
  38893. */
  38894. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  38895. /**
  38896. * Releases internal resources used during the recording.
  38897. */
  38898. dispose(): void;
  38899. private _handleDataAvailable;
  38900. private _handleError;
  38901. private _handleStop;
  38902. }
  38903. }
  38904. declare module BABYLON {
  38905. /**
  38906. * Defines the potential axis of a Joystick
  38907. */
  38908. enum JoystickAxis {
  38909. /** X axis */
  38910. X = 0,
  38911. /** Y axis */
  38912. Y = 1,
  38913. /** Z axis */
  38914. Z = 2
  38915. }
  38916. /**
  38917. * Class used to define virtual joystick (used in touch mode)
  38918. */
  38919. class VirtualJoystick {
  38920. /**
  38921. * Gets or sets a boolean indicating that left and right values must be inverted
  38922. */
  38923. reverseLeftRight: boolean;
  38924. /**
  38925. * Gets or sets a boolean indicating that up and down values must be inverted
  38926. */
  38927. reverseUpDown: boolean;
  38928. /**
  38929. * Gets the offset value for the position (ie. the change of the position value)
  38930. */
  38931. deltaPosition: Vector3;
  38932. /**
  38933. * Gets a boolean indicating if the virtual joystick was pressed
  38934. */
  38935. pressed: boolean;
  38936. private static _globalJoystickIndex;
  38937. private static vjCanvas;
  38938. private static vjCanvasContext;
  38939. private static vjCanvasWidth;
  38940. private static vjCanvasHeight;
  38941. private static halfWidth;
  38942. private _action;
  38943. private _axisTargetedByLeftAndRight;
  38944. private _axisTargetedByUpAndDown;
  38945. private _joystickSensibility;
  38946. private _inversedSensibility;
  38947. private _joystickPointerID;
  38948. private _joystickColor;
  38949. private _joystickPointerPos;
  38950. private _joystickPreviousPointerPos;
  38951. private _joystickPointerStartPos;
  38952. private _deltaJoystickVector;
  38953. private _leftJoystick;
  38954. private _touches;
  38955. private _onPointerDownHandlerRef;
  38956. private _onPointerMoveHandlerRef;
  38957. private _onPointerUpHandlerRef;
  38958. private _onResize;
  38959. /**
  38960. * Creates a new virtual joystick
  38961. * @param leftJoystick defines that the joystick is for left hand (false by default)
  38962. */
  38963. constructor(leftJoystick?: boolean);
  38964. /**
  38965. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  38966. * @param newJoystickSensibility defines the new sensibility
  38967. */
  38968. setJoystickSensibility(newJoystickSensibility: number): void;
  38969. private _onPointerDown;
  38970. private _onPointerMove;
  38971. private _onPointerUp;
  38972. /**
  38973. * Change the color of the virtual joystick
  38974. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  38975. */
  38976. setJoystickColor(newColor: string): void;
  38977. /**
  38978. * Defines a callback to call when the joystick is touched
  38979. * @param action defines the callback
  38980. */
  38981. setActionOnTouch(action: () => any): void;
  38982. /**
  38983. * Defines which axis you'd like to control for left & right
  38984. * @param axis defines the axis to use
  38985. */
  38986. setAxisForLeftRight(axis: JoystickAxis): void;
  38987. /**
  38988. * Defines which axis you'd like to control for up & down
  38989. * @param axis defines the axis to use
  38990. */
  38991. setAxisForUpDown(axis: JoystickAxis): void;
  38992. private _drawVirtualJoystick;
  38993. /**
  38994. * Release internal HTML canvas
  38995. */
  38996. releaseCanvas(): void;
  38997. }
  38998. }
  38999. declare module BABYLON {
  39000. /**
  39001. * Helper class to push actions to a pool of workers.
  39002. */
  39003. class WorkerPool implements IDisposable {
  39004. private _workerInfos;
  39005. private _pendingActions;
  39006. /**
  39007. * Constructor
  39008. * @param workers Array of workers to use for actions
  39009. */
  39010. constructor(workers: Array<Worker>);
  39011. /**
  39012. * Terminates all workers and clears any pending actions.
  39013. */
  39014. dispose(): void;
  39015. /**
  39016. * Pushes an action to the worker pool. If all the workers are active, the action will be
  39017. * pended until a worker has completed its action.
  39018. * @param action The action to perform. Call onComplete when the action is complete.
  39019. */
  39020. push(action: (worker: Worker, onComplete: () => void) => void): void;
  39021. private _execute;
  39022. }
  39023. }
  39024. declare module BABYLON {
  39025. /**
  39026. * The autoRotation behavior (BABYLON.AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  39027. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39028. */
  39029. class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  39030. /**
  39031. * Gets the name of the behavior.
  39032. */
  39033. readonly name: string;
  39034. private _zoomStopsAnimation;
  39035. private _idleRotationSpeed;
  39036. private _idleRotationWaitTime;
  39037. private _idleRotationSpinupTime;
  39038. /**
  39039. * Sets the flag that indicates if user zooming should stop animation.
  39040. */
  39041. /**
  39042. * Gets the flag that indicates if user zooming should stop animation.
  39043. */
  39044. zoomStopsAnimation: boolean;
  39045. /**
  39046. * Sets the default speed at which the camera rotates around the model.
  39047. */
  39048. /**
  39049. * Gets the default speed at which the camera rotates around the model.
  39050. */
  39051. idleRotationSpeed: number;
  39052. /**
  39053. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  39054. */
  39055. /**
  39056. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  39057. */
  39058. idleRotationWaitTime: number;
  39059. /**
  39060. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  39061. */
  39062. /**
  39063. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  39064. */
  39065. idleRotationSpinupTime: number;
  39066. /**
  39067. * Gets a value indicating if the camera is currently rotating because of this behavior
  39068. */
  39069. readonly rotationInProgress: boolean;
  39070. private _onPrePointerObservableObserver;
  39071. private _onAfterCheckInputsObserver;
  39072. private _attachedCamera;
  39073. private _isPointerDown;
  39074. private _lastFrameTime;
  39075. private _lastInteractionTime;
  39076. private _cameraRotationSpeed;
  39077. /**
  39078. * Initializes the behavior.
  39079. */
  39080. init(): void;
  39081. /**
  39082. * Attaches the behavior to its arc rotate camera.
  39083. * @param camera Defines the camera to attach the behavior to
  39084. */
  39085. attach(camera: ArcRotateCamera): void;
  39086. /**
  39087. * Detaches the behavior from its current arc rotate camera.
  39088. */
  39089. detach(): void;
  39090. /**
  39091. * Returns true if user is scrolling.
  39092. * @return true if user is scrolling.
  39093. */
  39094. private _userIsZooming;
  39095. private _lastFrameRadius;
  39096. private _shouldAnimationStopForInteraction;
  39097. /**
  39098. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  39099. */
  39100. private _applyUserInteraction;
  39101. private _userIsMoving;
  39102. }
  39103. }
  39104. declare module BABYLON {
  39105. /**
  39106. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  39107. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  39108. */
  39109. class BouncingBehavior implements Behavior<ArcRotateCamera> {
  39110. /**
  39111. * Gets the name of the behavior.
  39112. */
  39113. readonly name: string;
  39114. /**
  39115. * The easing function used by animations
  39116. */
  39117. static EasingFunction: BackEase;
  39118. /**
  39119. * The easing mode used by animations
  39120. */
  39121. static EasingMode: number;
  39122. /**
  39123. * The duration of the animation, in milliseconds
  39124. */
  39125. transitionDuration: number;
  39126. /**
  39127. * Length of the distance animated by the transition when lower radius is reached
  39128. */
  39129. lowerRadiusTransitionRange: number;
  39130. /**
  39131. * Length of the distance animated by the transition when upper radius is reached
  39132. */
  39133. upperRadiusTransitionRange: number;
  39134. private _autoTransitionRange;
  39135. /**
  39136. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  39137. */
  39138. /**
  39139. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  39140. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  39141. */
  39142. autoTransitionRange: boolean;
  39143. private _attachedCamera;
  39144. private _onAfterCheckInputsObserver;
  39145. private _onMeshTargetChangedObserver;
  39146. /**
  39147. * Initializes the behavior.
  39148. */
  39149. init(): void;
  39150. /**
  39151. * Attaches the behavior to its arc rotate camera.
  39152. * @param camera Defines the camera to attach the behavior to
  39153. */
  39154. attach(camera: ArcRotateCamera): void;
  39155. /**
  39156. * Detaches the behavior from its current arc rotate camera.
  39157. */
  39158. detach(): void;
  39159. private _radiusIsAnimating;
  39160. private _radiusBounceTransition;
  39161. private _animatables;
  39162. private _cachedWheelPrecision;
  39163. /**
  39164. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  39165. * @param radiusLimit The limit to check against.
  39166. * @return Bool to indicate if at limit.
  39167. */
  39168. private _isRadiusAtLimit;
  39169. /**
  39170. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  39171. * @param radiusDelta The delta by which to animate to. Can be negative.
  39172. */
  39173. private _applyBoundRadiusAnimation;
  39174. /**
  39175. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  39176. */
  39177. protected _clearAnimationLocks(): void;
  39178. /**
  39179. * Stops and removes all animations that have been applied to the camera
  39180. */
  39181. stopAllAnimations(): void;
  39182. }
  39183. }
  39184. declare module BABYLON {
  39185. /**
  39186. * 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.
  39187. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  39188. */
  39189. class FramingBehavior implements Behavior<ArcRotateCamera> {
  39190. /**
  39191. * Gets the name of the behavior.
  39192. */
  39193. readonly name: string;
  39194. private _mode;
  39195. private _radiusScale;
  39196. private _positionScale;
  39197. private _defaultElevation;
  39198. private _elevationReturnTime;
  39199. private _elevationReturnWaitTime;
  39200. private _zoomStopsAnimation;
  39201. private _framingTime;
  39202. /**
  39203. * The easing function used by animations
  39204. */
  39205. static EasingFunction: ExponentialEase;
  39206. /**
  39207. * The easing mode used by animations
  39208. */
  39209. static EasingMode: number;
  39210. /**
  39211. * Sets the current mode used by the behavior
  39212. */
  39213. /**
  39214. * Gets current mode used by the behavior.
  39215. */
  39216. mode: number;
  39217. /**
  39218. * Sets the scale applied to the radius (1 by default)
  39219. */
  39220. /**
  39221. * Gets the scale applied to the radius
  39222. */
  39223. radiusScale: number;
  39224. /**
  39225. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  39226. */
  39227. /**
  39228. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  39229. */
  39230. positionScale: number;
  39231. /**
  39232. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  39233. * behaviour is triggered, in radians.
  39234. */
  39235. /**
  39236. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  39237. * behaviour is triggered, in radians.
  39238. */
  39239. defaultElevation: number;
  39240. /**
  39241. * Sets the time (in milliseconds) taken to return to the default beta position.
  39242. * Negative value indicates camera should not return to default.
  39243. */
  39244. /**
  39245. * Gets the time (in milliseconds) taken to return to the default beta position.
  39246. * Negative value indicates camera should not return to default.
  39247. */
  39248. elevationReturnTime: number;
  39249. /**
  39250. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  39251. */
  39252. /**
  39253. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  39254. */
  39255. elevationReturnWaitTime: number;
  39256. /**
  39257. * Sets the flag that indicates if user zooming should stop animation.
  39258. */
  39259. /**
  39260. * Gets the flag that indicates if user zooming should stop animation.
  39261. */
  39262. zoomStopsAnimation: boolean;
  39263. /**
  39264. * Sets the transition time when framing the mesh, in milliseconds
  39265. */
  39266. /**
  39267. * Gets the transition time when framing the mesh, in milliseconds
  39268. */
  39269. framingTime: number;
  39270. /**
  39271. * Define if the behavior should automatically change the configured
  39272. * camera limits and sensibilities.
  39273. */
  39274. autoCorrectCameraLimitsAndSensibility: boolean;
  39275. private _onPrePointerObservableObserver;
  39276. private _onAfterCheckInputsObserver;
  39277. private _onMeshTargetChangedObserver;
  39278. private _attachedCamera;
  39279. private _isPointerDown;
  39280. private _lastInteractionTime;
  39281. /**
  39282. * Initializes the behavior.
  39283. */
  39284. init(): void;
  39285. /**
  39286. * Attaches the behavior to its arc rotate camera.
  39287. * @param camera Defines the camera to attach the behavior to
  39288. */
  39289. attach(camera: ArcRotateCamera): void;
  39290. /**
  39291. * Detaches the behavior from its current arc rotate camera.
  39292. */
  39293. detach(): void;
  39294. private _animatables;
  39295. private _betaIsAnimating;
  39296. private _betaTransition;
  39297. private _radiusTransition;
  39298. private _vectorTransition;
  39299. /**
  39300. * Targets the given mesh and updates zoom level accordingly.
  39301. * @param mesh The mesh to target.
  39302. * @param radius Optional. If a cached radius position already exists, overrides default.
  39303. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  39304. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39305. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39306. */
  39307. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39308. /**
  39309. * Targets the given mesh with its children and updates zoom level accordingly.
  39310. * @param mesh The mesh to target.
  39311. * @param radius Optional. If a cached radius position already exists, overrides default.
  39312. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  39313. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39314. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39315. */
  39316. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39317. /**
  39318. * Targets the given meshes with their children and updates zoom level accordingly.
  39319. * @param meshes The mesh to target.
  39320. * @param radius Optional. If a cached radius position already exists, overrides default.
  39321. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  39322. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39323. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39324. */
  39325. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39326. /**
  39327. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  39328. * @param minimumWorld Determines the smaller position of the bounding box extend
  39329. * @param maximumWorld Determines the bigger position of the bounding box extend
  39330. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39331. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39332. */
  39333. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39334. /**
  39335. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  39336. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  39337. * frustum width.
  39338. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  39339. * to fully enclose the mesh in the viewing frustum.
  39340. */
  39341. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  39342. /**
  39343. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  39344. * is automatically returned to its default position (expected to be above ground plane).
  39345. */
  39346. private _maintainCameraAboveGround;
  39347. /**
  39348. * Returns the frustum slope based on the canvas ratio and camera FOV
  39349. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  39350. */
  39351. private _getFrustumSlope;
  39352. /**
  39353. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  39354. */
  39355. private _clearAnimationLocks;
  39356. /**
  39357. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  39358. */
  39359. private _applyUserInteraction;
  39360. /**
  39361. * Stops and removes all animations that have been applied to the camera
  39362. */
  39363. stopAllAnimations(): void;
  39364. /**
  39365. * Gets a value indicating if the user is moving the camera
  39366. */
  39367. readonly isUserIsMoving: boolean;
  39368. /**
  39369. * The camera can move all the way towards the mesh.
  39370. */
  39371. static IgnoreBoundsSizeMode: number;
  39372. /**
  39373. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  39374. */
  39375. static FitFrustumSidesMode: number;
  39376. }
  39377. }
  39378. declare module BABYLON {
  39379. /**
  39380. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  39381. */
  39382. class AttachToBoxBehavior implements BABYLON.Behavior<BABYLON.Mesh> {
  39383. private ui;
  39384. /**
  39385. * The name of the behavior
  39386. */
  39387. name: string;
  39388. /**
  39389. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  39390. */
  39391. distanceAwayFromFace: number;
  39392. /**
  39393. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  39394. */
  39395. distanceAwayFromBottomOfFace: number;
  39396. private _faceVectors;
  39397. private _target;
  39398. private _scene;
  39399. private _onRenderObserver;
  39400. private _tmpMatrix;
  39401. private _tmpVector;
  39402. /**
  39403. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  39404. * @param ui The transform node that should be attched to the mesh
  39405. */
  39406. constructor(ui: BABYLON.TransformNode);
  39407. /**
  39408. * Initializes the behavior
  39409. */
  39410. init(): void;
  39411. private _closestFace;
  39412. private _zeroVector;
  39413. private _lookAtTmpMatrix;
  39414. private _lookAtToRef;
  39415. /**
  39416. * Attaches the AttachToBoxBehavior to the passed in mesh
  39417. * @param target The mesh that the specified node will be attached to
  39418. */
  39419. attach(target: BABYLON.Mesh): void;
  39420. /**
  39421. * Detaches the behavior from the mesh
  39422. */
  39423. detach(): void;
  39424. }
  39425. }
  39426. declare module BABYLON {
  39427. /**
  39428. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  39429. */
  39430. class FadeInOutBehavior implements Behavior<Mesh> {
  39431. /**
  39432. * Time in milliseconds to delay before fading in (Default: 0)
  39433. */
  39434. delay: number;
  39435. /**
  39436. * Time in milliseconds for the mesh to fade in (Default: 300)
  39437. */
  39438. fadeInTime: number;
  39439. private _millisecondsPerFrame;
  39440. private _hovered;
  39441. private _hoverValue;
  39442. private _ownerNode;
  39443. /**
  39444. * Instatiates the FadeInOutBehavior
  39445. */
  39446. constructor();
  39447. /**
  39448. * The name of the behavior
  39449. */
  39450. readonly name: string;
  39451. /**
  39452. * Initializes the behavior
  39453. */
  39454. init(): void;
  39455. /**
  39456. * Attaches the fade behavior on the passed in mesh
  39457. * @param ownerNode The mesh that will be faded in/out once attached
  39458. */
  39459. attach(ownerNode: Mesh): void;
  39460. /**
  39461. * Detaches the behavior from the mesh
  39462. */
  39463. detach(): void;
  39464. /**
  39465. * Triggers the mesh to begin fading in or out
  39466. * @param value if the object should fade in or out (true to fade in)
  39467. */
  39468. fadeIn(value: boolean): void;
  39469. private _update;
  39470. private _setAllVisibility;
  39471. }
  39472. }
  39473. declare module BABYLON {
  39474. /**
  39475. * A behavior that when attached to a mesh will allow the mesh to be scaled
  39476. */
  39477. class MultiPointerScaleBehavior implements Behavior<Mesh> {
  39478. private _dragBehaviorA;
  39479. private _dragBehaviorB;
  39480. private _startDistance;
  39481. private _initialScale;
  39482. private _targetScale;
  39483. private _ownerNode;
  39484. private _sceneRenderObserver;
  39485. /**
  39486. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  39487. */
  39488. constructor();
  39489. /**
  39490. * The name of the behavior
  39491. */
  39492. readonly name: string;
  39493. /**
  39494. * Initializes the behavior
  39495. */
  39496. init(): void;
  39497. private _getCurrentDistance;
  39498. /**
  39499. * Attaches the scale behavior the passed in mesh
  39500. * @param ownerNode The mesh that will be scaled around once attached
  39501. */
  39502. attach(ownerNode: Mesh): void;
  39503. /**
  39504. * Detaches the behavior from the mesh
  39505. */
  39506. detach(): void;
  39507. }
  39508. }
  39509. declare module BABYLON {
  39510. /**
  39511. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  39512. */
  39513. class PointerDragBehavior implements Behavior<Mesh> {
  39514. private static _AnyMouseID;
  39515. private _attachedNode;
  39516. private _dragPlane;
  39517. private _scene;
  39518. private _pointerObserver;
  39519. private _beforeRenderObserver;
  39520. private static _planeScene;
  39521. /**
  39522. * 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)
  39523. */
  39524. maxDragAngle: number;
  39525. /**
  39526. * @hidden
  39527. */
  39528. /**
  39529. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  39530. */
  39531. currentDraggingPointerID: number;
  39532. /**
  39533. * The last position where the pointer hit the drag plane in world space
  39534. */
  39535. lastDragPosition: Vector3;
  39536. /**
  39537. * If the behavior is currently in a dragging state
  39538. */
  39539. dragging: boolean;
  39540. /**
  39541. * 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)
  39542. */
  39543. dragDeltaRatio: number;
  39544. /**
  39545. * If the drag plane orientation should be updated during the dragging (Default: true)
  39546. */
  39547. updateDragPlane: boolean;
  39548. private _debugMode;
  39549. private _moving;
  39550. /**
  39551. * Fires each time the attached mesh is dragged with the pointer
  39552. * * delta between last drag position and current drag position in world space
  39553. * * dragDistance along the drag axis
  39554. * * dragPlaneNormal normal of the current drag plane used during the drag
  39555. * * dragPlanePoint in world space where the drag intersects the drag plane
  39556. */
  39557. onDragObservable: Observable<{
  39558. delta: Vector3;
  39559. dragPlanePoint: Vector3;
  39560. dragPlaneNormal: Vector3;
  39561. dragDistance: number;
  39562. pointerId: number;
  39563. }>;
  39564. /**
  39565. * Fires each time a drag begins (eg. mouse down on mesh)
  39566. */
  39567. onDragStartObservable: Observable<{
  39568. dragPlanePoint: Vector3;
  39569. pointerId: number;
  39570. }>;
  39571. /**
  39572. * Fires each time a drag ends (eg. mouse release after drag)
  39573. */
  39574. onDragEndObservable: Observable<{
  39575. dragPlanePoint: Vector3;
  39576. pointerId: number;
  39577. }>;
  39578. /**
  39579. * If the attached mesh should be moved when dragged
  39580. */
  39581. moveAttached: boolean;
  39582. /**
  39583. * If the drag behavior will react to drag events (Default: true)
  39584. */
  39585. enabled: boolean;
  39586. /**
  39587. * If camera controls should be detached during the drag
  39588. */
  39589. detachCameraControls: boolean;
  39590. /**
  39591. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  39592. */
  39593. useObjectOrienationForDragging: boolean;
  39594. private _options;
  39595. /**
  39596. * Creates a pointer drag behavior that can be attached to a mesh
  39597. * @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)
  39598. */
  39599. constructor(options?: {
  39600. dragAxis?: Vector3;
  39601. dragPlaneNormal?: Vector3;
  39602. });
  39603. /**
  39604. * The name of the behavior
  39605. */
  39606. readonly name: string;
  39607. /**
  39608. * Initializes the behavior
  39609. */
  39610. init(): void;
  39611. private _tmpVector;
  39612. private _alternatePickedPoint;
  39613. private _worldDragAxis;
  39614. private _targetPosition;
  39615. private _attachedElement;
  39616. /**
  39617. * Attaches the drag behavior the passed in mesh
  39618. * @param ownerNode The mesh that will be dragged around once attached
  39619. */
  39620. attach(ownerNode: Mesh): void;
  39621. /**
  39622. * Force relase the drag action by code.
  39623. */
  39624. releaseDrag(): void;
  39625. private _startDragRay;
  39626. private _lastPointerRay;
  39627. /**
  39628. * Simulates the start of a pointer drag event on the behavior
  39629. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  39630. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  39631. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  39632. */
  39633. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  39634. private _startDrag;
  39635. private _dragDelta;
  39636. private _moveDrag;
  39637. private _pickWithRayOnDragPlane;
  39638. private _pointA;
  39639. private _pointB;
  39640. private _pointC;
  39641. private _lineA;
  39642. private _lineB;
  39643. private _localAxis;
  39644. private _lookAt;
  39645. private _updateDragPlanePosition;
  39646. /**
  39647. * Detaches the behavior from the mesh
  39648. */
  39649. detach(): void;
  39650. }
  39651. }
  39652. declare module BABYLON {
  39653. /**
  39654. * 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
  39655. */
  39656. class SixDofDragBehavior implements Behavior<Mesh> {
  39657. private static _virtualScene;
  39658. private _ownerNode;
  39659. private _sceneRenderObserver;
  39660. private _scene;
  39661. private _targetPosition;
  39662. private _virtualOriginMesh;
  39663. private _virtualDragMesh;
  39664. private _pointerObserver;
  39665. private _moving;
  39666. private _startingOrientation;
  39667. /**
  39668. * 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)
  39669. */
  39670. private zDragFactor;
  39671. /**
  39672. * If the behavior is currently in a dragging state
  39673. */
  39674. dragging: boolean;
  39675. /**
  39676. * 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)
  39677. */
  39678. dragDeltaRatio: number;
  39679. /**
  39680. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  39681. */
  39682. currentDraggingPointerID: number;
  39683. /**
  39684. * If camera controls should be detached during the drag
  39685. */
  39686. detachCameraControls: boolean;
  39687. /**
  39688. * Fires each time a drag starts
  39689. */
  39690. onDragStartObservable: Observable<{}>;
  39691. /**
  39692. * Fires each time a drag ends (eg. mouse release after drag)
  39693. */
  39694. onDragEndObservable: Observable<{}>;
  39695. /**
  39696. * 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
  39697. */
  39698. constructor();
  39699. /**
  39700. * The name of the behavior
  39701. */
  39702. readonly name: string;
  39703. /**
  39704. * Initializes the behavior
  39705. */
  39706. init(): void;
  39707. /**
  39708. * Attaches the scale behavior the passed in mesh
  39709. * @param ownerNode The mesh that will be scaled around once attached
  39710. */
  39711. attach(ownerNode: Mesh): void;
  39712. /**
  39713. * Detaches the behavior from the mesh
  39714. */
  39715. detach(): void;
  39716. }
  39717. }
  39718. declare module BABYLON {
  39719. /**
  39720. * Manage the gamepad inputs to control an arc rotate camera.
  39721. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39722. */
  39723. class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  39724. /**
  39725. * Defines the camera the input is attached to.
  39726. */
  39727. camera: ArcRotateCamera;
  39728. /**
  39729. * Defines the gamepad the input is gathering event from.
  39730. */
  39731. gamepad: Nullable<Gamepad>;
  39732. /**
  39733. * Defines the gamepad rotation sensiblity.
  39734. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  39735. */
  39736. gamepadRotationSensibility: number;
  39737. /**
  39738. * Defines the gamepad move sensiblity.
  39739. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  39740. */
  39741. gamepadMoveSensibility: number;
  39742. private _onGamepadConnectedObserver;
  39743. private _onGamepadDisconnectedObserver;
  39744. /**
  39745. * Attach the input controls to a specific dom element to get the input from.
  39746. * @param element Defines the element the controls should be listened from
  39747. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39748. */
  39749. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39750. /**
  39751. * Detach the current controls from the specified dom element.
  39752. * @param element Defines the element to stop listening the inputs from
  39753. */
  39754. detachControl(element: Nullable<HTMLElement>): void;
  39755. /**
  39756. * Update the current camera state depending on the inputs that have been used this frame.
  39757. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39758. */
  39759. checkInputs(): void;
  39760. /**
  39761. * Gets the class name of the current intput.
  39762. * @returns the class name
  39763. */
  39764. getClassName(): string;
  39765. /**
  39766. * Get the friendly name associated with the input class.
  39767. * @returns the input friendly name
  39768. */
  39769. getSimpleName(): string;
  39770. }
  39771. }
  39772. declare module BABYLON {
  39773. /**
  39774. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  39775. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39776. */
  39777. class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  39778. /**
  39779. * Defines the camera the input is attached to.
  39780. */
  39781. camera: ArcRotateCamera;
  39782. /**
  39783. * Defines the list of key codes associated with the up action (increase alpha)
  39784. */
  39785. keysUp: number[];
  39786. /**
  39787. * Defines the list of key codes associated with the down action (decrease alpha)
  39788. */
  39789. keysDown: number[];
  39790. /**
  39791. * Defines the list of key codes associated with the left action (increase beta)
  39792. */
  39793. keysLeft: number[];
  39794. /**
  39795. * Defines the list of key codes associated with the right action (decrease beta)
  39796. */
  39797. keysRight: number[];
  39798. /**
  39799. * Defines the list of key codes associated with the reset action.
  39800. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  39801. */
  39802. keysReset: number[];
  39803. /**
  39804. * Defines the panning sensibility of the inputs.
  39805. * (How fast is the camera paning)
  39806. */
  39807. panningSensibility: number;
  39808. /**
  39809. * Defines the zooming sensibility of the inputs.
  39810. * (How fast is the camera zooming)
  39811. */
  39812. zoomingSensibility: number;
  39813. /**
  39814. * Defines wether maintaining the alt key down switch the movement mode from
  39815. * orientation to zoom.
  39816. */
  39817. useAltToZoom: boolean;
  39818. /**
  39819. * Rotation speed of the camera
  39820. */
  39821. angularSpeed: number;
  39822. private _keys;
  39823. private _ctrlPressed;
  39824. private _altPressed;
  39825. private _onCanvasBlurObserver;
  39826. private _onKeyboardObserver;
  39827. private _engine;
  39828. private _scene;
  39829. /**
  39830. * Attach the input controls to a specific dom element to get the input from.
  39831. * @param element Defines the element the controls should be listened from
  39832. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39833. */
  39834. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39835. /**
  39836. * Detach the current controls from the specified dom element.
  39837. * @param element Defines the element to stop listening the inputs from
  39838. */
  39839. detachControl(element: Nullable<HTMLElement>): void;
  39840. /**
  39841. * Update the current camera state depending on the inputs that have been used this frame.
  39842. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39843. */
  39844. checkInputs(): void;
  39845. /**
  39846. * Gets the class name of the current intput.
  39847. * @returns the class name
  39848. */
  39849. getClassName(): string;
  39850. /**
  39851. * Get the friendly name associated with the input class.
  39852. * @returns the input friendly name
  39853. */
  39854. getSimpleName(): string;
  39855. }
  39856. }
  39857. declare module BABYLON {
  39858. /**
  39859. * Manage the mouse wheel inputs to control an arc rotate camera.
  39860. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39861. */
  39862. class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  39863. /**
  39864. * Defines the camera the input is attached to.
  39865. */
  39866. camera: ArcRotateCamera;
  39867. /**
  39868. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  39869. */
  39870. wheelPrecision: number;
  39871. /**
  39872. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  39873. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  39874. */
  39875. wheelDeltaPercentage: number;
  39876. private _wheel;
  39877. private _observer;
  39878. /**
  39879. * Attach the input controls to a specific dom element to get the input from.
  39880. * @param element Defines the element the controls should be listened from
  39881. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39882. */
  39883. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39884. /**
  39885. * Detach the current controls from the specified dom element.
  39886. * @param element Defines the element to stop listening the inputs from
  39887. */
  39888. detachControl(element: Nullable<HTMLElement>): void;
  39889. /**
  39890. * Gets the class name of the current intput.
  39891. * @returns the class name
  39892. */
  39893. getClassName(): string;
  39894. /**
  39895. * Get the friendly name associated with the input class.
  39896. * @returns the input friendly name
  39897. */
  39898. getSimpleName(): string;
  39899. }
  39900. }
  39901. declare module BABYLON {
  39902. /**
  39903. * Manage the pointers inputs to control an arc rotate camera.
  39904. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39905. */
  39906. class ArcRotateCameraPointersInput implements ICameraInput<ArcRotateCamera> {
  39907. /**
  39908. * Defines the camera the input is attached to.
  39909. */
  39910. camera: ArcRotateCamera;
  39911. /**
  39912. * Defines the buttons associated with the input to handle camera move.
  39913. */
  39914. buttons: number[];
  39915. /**
  39916. * Defines the pointer angular sensibility along the X axis or how fast is the camera rotating.
  39917. */
  39918. angularSensibilityX: number;
  39919. /**
  39920. * Defines the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  39921. */
  39922. angularSensibilityY: number;
  39923. /**
  39924. * Defines the pointer pinch precision or how fast is the camera zooming.
  39925. */
  39926. pinchPrecision: number;
  39927. /**
  39928. * pinchDeltaPercentage will be used instead of pinchPrecision if different from 0.
  39929. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  39930. */
  39931. pinchDeltaPercentage: number;
  39932. /**
  39933. * Defines the pointer panning sensibility or how fast is the camera moving.
  39934. */
  39935. panningSensibility: number;
  39936. /**
  39937. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  39938. */
  39939. multiTouchPanning: boolean;
  39940. /**
  39941. * Defines whether panning is enabled for both pan (2 fingers swipe) and zoom (pinch) through multitouch.
  39942. */
  39943. multiTouchPanAndZoom: boolean;
  39944. /**
  39945. * Revers pinch action direction.
  39946. */
  39947. pinchInwards: boolean;
  39948. private _isPanClick;
  39949. private _pointerInput;
  39950. private _observer;
  39951. private _onMouseMove;
  39952. private _onGestureStart;
  39953. private _onGesture;
  39954. private _MSGestureHandler;
  39955. private _onLostFocus;
  39956. private _onContextMenu;
  39957. /**
  39958. * Attach the input controls to a specific dom element to get the input from.
  39959. * @param element Defines the element the controls should be listened from
  39960. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39961. */
  39962. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39963. /**
  39964. * Detach the current controls from the specified dom element.
  39965. * @param element Defines the element to stop listening the inputs from
  39966. */
  39967. detachControl(element: Nullable<HTMLElement>): void;
  39968. /**
  39969. * Gets the class name of the current intput.
  39970. * @returns the class name
  39971. */
  39972. getClassName(): string;
  39973. /**
  39974. * Get the friendly name associated with the input class.
  39975. * @returns the input friendly name
  39976. */
  39977. getSimpleName(): string;
  39978. }
  39979. }
  39980. declare module BABYLON {
  39981. /**
  39982. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  39983. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39984. */
  39985. class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  39986. /**
  39987. * Defines the camera the input is attached to.
  39988. */
  39989. camera: ArcRotateCamera;
  39990. /**
  39991. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  39992. */
  39993. alphaCorrection: number;
  39994. /**
  39995. * Defines a correction factor applied on the beta value retrieved from the orientation events.
  39996. */
  39997. betaCorrection: number;
  39998. /**
  39999. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  40000. */
  40001. gammaCorrection: number;
  40002. private _alpha;
  40003. private _gamma;
  40004. private _dirty;
  40005. private _deviceOrientationHandler;
  40006. /**
  40007. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  40008. */
  40009. constructor();
  40010. /**
  40011. * Attach the input controls to a specific dom element to get the input from.
  40012. * @param element Defines the element the controls should be listened from
  40013. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40014. */
  40015. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40016. /** @hidden */
  40017. /**
  40018. * Update the current camera state depending on the inputs that have been used this frame.
  40019. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40020. */
  40021. checkInputs(): void;
  40022. /**
  40023. * Detach the current controls from the specified dom element.
  40024. * @param element Defines the element to stop listening the inputs from
  40025. */
  40026. detachControl(element: Nullable<HTMLElement>): void;
  40027. /**
  40028. * Gets the class name of the current intput.
  40029. * @returns the class name
  40030. */
  40031. getClassName(): string;
  40032. /**
  40033. * Get the friendly name associated with the input class.
  40034. * @returns the input friendly name
  40035. */
  40036. getSimpleName(): string;
  40037. }
  40038. }
  40039. declare module BABYLON {
  40040. /**
  40041. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  40042. * Screen rotation is taken into account.
  40043. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40044. */
  40045. class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  40046. private _camera;
  40047. private _screenOrientationAngle;
  40048. private _constantTranform;
  40049. private _screenQuaternion;
  40050. private _alpha;
  40051. private _beta;
  40052. private _gamma;
  40053. /**
  40054. * Instantiates a new input
  40055. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40056. */
  40057. constructor();
  40058. /**
  40059. * Define the camera controlled by the input.
  40060. */
  40061. camera: FreeCamera;
  40062. /**
  40063. * Attach the input controls to a specific dom element to get the input from.
  40064. * @param element Defines the element the controls should be listened from
  40065. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40066. */
  40067. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40068. private _orientationChanged;
  40069. private _deviceOrientation;
  40070. /**
  40071. * Detach the current controls from the specified dom element.
  40072. * @param element Defines the element to stop listening the inputs from
  40073. */
  40074. detachControl(element: Nullable<HTMLElement>): void;
  40075. /**
  40076. * Update the current camera state depending on the inputs that have been used this frame.
  40077. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40078. */
  40079. checkInputs(): void;
  40080. /**
  40081. * Gets the class name of the current intput.
  40082. * @returns the class name
  40083. */
  40084. getClassName(): string;
  40085. /**
  40086. * Get the friendly name associated with the input class.
  40087. * @returns the input friendly name
  40088. */
  40089. getSimpleName(): string;
  40090. }
  40091. }
  40092. declare module BABYLON {
  40093. /**
  40094. * Manage the gamepad inputs to control a free camera.
  40095. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40096. */
  40097. class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  40098. /**
  40099. * Define the camera the input is attached to.
  40100. */
  40101. camera: FreeCamera;
  40102. /**
  40103. * Define the Gamepad controlling the input
  40104. */
  40105. gamepad: Nullable<Gamepad>;
  40106. /**
  40107. * Defines the gamepad rotation sensiblity.
  40108. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  40109. */
  40110. gamepadAngularSensibility: number;
  40111. /**
  40112. * Defines the gamepad move sensiblity.
  40113. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  40114. */
  40115. gamepadMoveSensibility: number;
  40116. private _onGamepadConnectedObserver;
  40117. private _onGamepadDisconnectedObserver;
  40118. private _cameraTransform;
  40119. private _deltaTransform;
  40120. private _vector3;
  40121. private _vector2;
  40122. /**
  40123. * Attach the input controls to a specific dom element to get the input from.
  40124. * @param element Defines the element the controls should be listened from
  40125. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40126. */
  40127. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40128. /**
  40129. * Detach the current controls from the specified dom element.
  40130. * @param element Defines the element to stop listening the inputs from
  40131. */
  40132. detachControl(element: Nullable<HTMLElement>): void;
  40133. /**
  40134. * Update the current camera state depending on the inputs that have been used this frame.
  40135. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40136. */
  40137. checkInputs(): void;
  40138. /**
  40139. * Gets the class name of the current intput.
  40140. * @returns the class name
  40141. */
  40142. getClassName(): string;
  40143. /**
  40144. * Get the friendly name associated with the input class.
  40145. * @returns the input friendly name
  40146. */
  40147. getSimpleName(): string;
  40148. }
  40149. }
  40150. declare module BABYLON {
  40151. /**
  40152. * Manage the keyboard inputs to control the movement of a free camera.
  40153. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40154. */
  40155. class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  40156. /**
  40157. * Defines the camera the input is attached to.
  40158. */
  40159. camera: FreeCamera;
  40160. /**
  40161. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  40162. */
  40163. keysUp: number[];
  40164. /**
  40165. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  40166. */
  40167. keysDown: number[];
  40168. /**
  40169. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  40170. */
  40171. keysLeft: number[];
  40172. /**
  40173. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  40174. */
  40175. keysRight: number[];
  40176. private _keys;
  40177. private _onCanvasBlurObserver;
  40178. private _onKeyboardObserver;
  40179. private _engine;
  40180. private _scene;
  40181. /**
  40182. * Attach the input controls to a specific dom element to get the input from.
  40183. * @param element Defines the element the controls should be listened from
  40184. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40185. */
  40186. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40187. /**
  40188. * Detach the current controls from the specified dom element.
  40189. * @param element Defines the element to stop listening the inputs from
  40190. */
  40191. detachControl(element: Nullable<HTMLElement>): void;
  40192. /**
  40193. * Update the current camera state depending on the inputs that have been used this frame.
  40194. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40195. */
  40196. checkInputs(): void;
  40197. /**
  40198. * Gets the class name of the current intput.
  40199. * @returns the class name
  40200. */
  40201. getClassName(): string;
  40202. /** @hidden */
  40203. /**
  40204. * Get the friendly name associated with the input class.
  40205. * @returns the input friendly name
  40206. */
  40207. getSimpleName(): string;
  40208. }
  40209. }
  40210. declare module BABYLON {
  40211. /**
  40212. * Manage the mouse inputs to control the movement of a free camera.
  40213. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40214. */
  40215. class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  40216. /**
  40217. * Define if touch is enabled in the mouse input
  40218. */
  40219. touchEnabled: boolean;
  40220. /**
  40221. * Defines the camera the input is attached to.
  40222. */
  40223. camera: FreeCamera;
  40224. /**
  40225. * Defines the buttons associated with the input to handle camera move.
  40226. */
  40227. buttons: number[];
  40228. /**
  40229. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  40230. */
  40231. angularSensibility: number;
  40232. private _pointerInput;
  40233. private _onMouseMove;
  40234. private _observer;
  40235. private previousPosition;
  40236. /**
  40237. * Manage the mouse inputs to control the movement of a free camera.
  40238. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40239. * @param touchEnabled Defines if touch is enabled or not
  40240. */
  40241. constructor(
  40242. /**
  40243. * Define if touch is enabled in the mouse input
  40244. */
  40245. touchEnabled?: boolean);
  40246. /**
  40247. * Attach the input controls to a specific dom element to get the input from.
  40248. * @param element Defines the element the controls should be listened from
  40249. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40250. */
  40251. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40252. /**
  40253. * Detach the current controls from the specified dom element.
  40254. * @param element Defines the element to stop listening the inputs from
  40255. */
  40256. detachControl(element: Nullable<HTMLElement>): void;
  40257. /**
  40258. * Gets the class name of the current intput.
  40259. * @returns the class name
  40260. */
  40261. getClassName(): string;
  40262. /**
  40263. * Get the friendly name associated with the input class.
  40264. * @returns the input friendly name
  40265. */
  40266. getSimpleName(): string;
  40267. }
  40268. }
  40269. declare module BABYLON {
  40270. /**
  40271. * Manage the touch inputs to control the movement of a free camera.
  40272. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40273. */
  40274. class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  40275. /**
  40276. * Defines the camera the input is attached to.
  40277. */
  40278. camera: FreeCamera;
  40279. /**
  40280. * Defines the touch sensibility for rotation.
  40281. * The higher the faster.
  40282. */
  40283. touchAngularSensibility: number;
  40284. /**
  40285. * Defines the touch sensibility for move.
  40286. * The higher the faster.
  40287. */
  40288. touchMoveSensibility: number;
  40289. private _offsetX;
  40290. private _offsetY;
  40291. private _pointerPressed;
  40292. private _pointerInput;
  40293. private _observer;
  40294. private _onLostFocus;
  40295. /**
  40296. * Attach the input controls to a specific dom element to get the input from.
  40297. * @param element Defines the element the controls should be listened from
  40298. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40299. */
  40300. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40301. /**
  40302. * Detach the current controls from the specified dom element.
  40303. * @param element Defines the element to stop listening the inputs from
  40304. */
  40305. detachControl(element: Nullable<HTMLElement>): void;
  40306. /**
  40307. * Update the current camera state depending on the inputs that have been used this frame.
  40308. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40309. */
  40310. checkInputs(): void;
  40311. /**
  40312. * Gets the class name of the current intput.
  40313. * @returns the class name
  40314. */
  40315. getClassName(): string;
  40316. /**
  40317. * Get the friendly name associated with the input class.
  40318. * @returns the input friendly name
  40319. */
  40320. getSimpleName(): string;
  40321. }
  40322. }
  40323. declare module BABYLON {
  40324. /**
  40325. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  40326. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40327. */
  40328. class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  40329. /**
  40330. * Defines the camera the input is attached to.
  40331. */
  40332. camera: FreeCamera;
  40333. private _leftjoystick;
  40334. private _rightjoystick;
  40335. /**
  40336. * Gets the left stick of the virtual joystick.
  40337. * @returns The virtual Joystick
  40338. */
  40339. getLeftJoystick(): VirtualJoystick;
  40340. /**
  40341. * Gets the right stick of the virtual joystick.
  40342. * @returns The virtual Joystick
  40343. */
  40344. getRightJoystick(): VirtualJoystick;
  40345. /**
  40346. * Update the current camera state depending on the inputs that have been used this frame.
  40347. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40348. */
  40349. checkInputs(): void;
  40350. /**
  40351. * Attach the input controls to a specific dom element to get the input from.
  40352. * @param element Defines the element the controls should be listened from
  40353. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40354. */
  40355. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40356. /**
  40357. * Detach the current controls from the specified dom element.
  40358. * @param element Defines the element to stop listening the inputs from
  40359. */
  40360. detachControl(element: Nullable<HTMLElement>): void;
  40361. /**
  40362. * Gets the class name of the current intput.
  40363. * @returns the class name
  40364. */
  40365. getClassName(): string;
  40366. /**
  40367. * Get the friendly name associated with the input class.
  40368. * @returns the input friendly name
  40369. */
  40370. getSimpleName(): string;
  40371. }
  40372. }
  40373. declare module BABYLON {
  40374. /**
  40375. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  40376. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40377. */
  40378. class AnaglyphArcRotateCamera extends ArcRotateCamera {
  40379. /**
  40380. * Creates a new AnaglyphArcRotateCamera
  40381. * @param name defines camera name
  40382. * @param alpha defines alpha angle (in radians)
  40383. * @param beta defines beta angle (in radians)
  40384. * @param radius defines radius
  40385. * @param target defines camera target
  40386. * @param interaxialDistance defines distance between each color axis
  40387. * @param scene defines the hosting scene
  40388. */
  40389. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  40390. /**
  40391. * Gets camera class name
  40392. * @returns AnaglyphArcRotateCamera
  40393. */
  40394. getClassName(): string;
  40395. }
  40396. }
  40397. declare module BABYLON {
  40398. /**
  40399. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  40400. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40401. */
  40402. class AnaglyphFreeCamera extends FreeCamera {
  40403. /**
  40404. * Creates a new AnaglyphFreeCamera
  40405. * @param name defines camera name
  40406. * @param position defines initial position
  40407. * @param interaxialDistance defines distance between each color axis
  40408. * @param scene defines the hosting scene
  40409. */
  40410. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  40411. /**
  40412. * Gets camera class name
  40413. * @returns AnaglyphFreeCamera
  40414. */
  40415. getClassName(): string;
  40416. }
  40417. }
  40418. declare module BABYLON {
  40419. /**
  40420. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  40421. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40422. */
  40423. class AnaglyphGamepadCamera extends GamepadCamera {
  40424. /**
  40425. * Creates a new AnaglyphGamepadCamera
  40426. * @param name defines camera name
  40427. * @param position defines initial position
  40428. * @param interaxialDistance defines distance between each color axis
  40429. * @param scene defines the hosting scene
  40430. */
  40431. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  40432. /**
  40433. * Gets camera class name
  40434. * @returns AnaglyphGamepadCamera
  40435. */
  40436. getClassName(): string;
  40437. }
  40438. }
  40439. declare module BABYLON {
  40440. /**
  40441. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  40442. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40443. */
  40444. class AnaglyphUniversalCamera extends UniversalCamera {
  40445. /**
  40446. * Creates a new AnaglyphUniversalCamera
  40447. * @param name defines camera name
  40448. * @param position defines initial position
  40449. * @param interaxialDistance defines distance between each color axis
  40450. * @param scene defines the hosting scene
  40451. */
  40452. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  40453. /**
  40454. * Gets camera class name
  40455. * @returns AnaglyphUniversalCamera
  40456. */
  40457. getClassName(): string;
  40458. }
  40459. }
  40460. declare module BABYLON {
  40461. /**
  40462. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  40463. * @see http://doc.babylonjs.com/features/cameras
  40464. */
  40465. class StereoscopicArcRotateCamera extends ArcRotateCamera {
  40466. /**
  40467. * Creates a new StereoscopicArcRotateCamera
  40468. * @param name defines camera name
  40469. * @param alpha defines alpha angle (in radians)
  40470. * @param beta defines beta angle (in radians)
  40471. * @param radius defines radius
  40472. * @param target defines camera target
  40473. * @param interaxialDistance defines distance between each color axis
  40474. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40475. * @param scene defines the hosting scene
  40476. */
  40477. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40478. /**
  40479. * Gets camera class name
  40480. * @returns StereoscopicArcRotateCamera
  40481. */
  40482. getClassName(): string;
  40483. }
  40484. }
  40485. declare module BABYLON {
  40486. /**
  40487. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  40488. * @see http://doc.babylonjs.com/features/cameras
  40489. */
  40490. class StereoscopicFreeCamera extends FreeCamera {
  40491. /**
  40492. * Creates a new StereoscopicFreeCamera
  40493. * @param name defines camera name
  40494. * @param position defines initial position
  40495. * @param interaxialDistance defines distance between each color axis
  40496. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40497. * @param scene defines the hosting scene
  40498. */
  40499. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40500. /**
  40501. * Gets camera class name
  40502. * @returns StereoscopicFreeCamera
  40503. */
  40504. getClassName(): string;
  40505. }
  40506. }
  40507. declare module BABYLON {
  40508. /**
  40509. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  40510. * @see http://doc.babylonjs.com/features/cameras
  40511. */
  40512. class StereoscopicGamepadCamera extends GamepadCamera {
  40513. /**
  40514. * Creates a new StereoscopicGamepadCamera
  40515. * @param name defines camera name
  40516. * @param position defines initial position
  40517. * @param interaxialDistance defines distance between each color axis
  40518. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40519. * @param scene defines the hosting scene
  40520. */
  40521. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40522. /**
  40523. * Gets camera class name
  40524. * @returns StereoscopicGamepadCamera
  40525. */
  40526. getClassName(): string;
  40527. }
  40528. }
  40529. declare module BABYLON {
  40530. /**
  40531. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  40532. * @see http://doc.babylonjs.com/features/cameras
  40533. */
  40534. class StereoscopicUniversalCamera extends UniversalCamera {
  40535. /**
  40536. * Creates a new StereoscopicUniversalCamera
  40537. * @param name defines camera name
  40538. * @param position defines initial position
  40539. * @param interaxialDistance defines distance between each color axis
  40540. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40541. * @param scene defines the hosting scene
  40542. */
  40543. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40544. /**
  40545. * Gets camera class name
  40546. * @returns StereoscopicUniversalCamera
  40547. */
  40548. getClassName(): string;
  40549. }
  40550. }
  40551. declare module BABYLON {
  40552. /**
  40553. * This represents all the required metrics to create a VR camera.
  40554. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  40555. */
  40556. class VRCameraMetrics {
  40557. /**
  40558. * Define the horizontal resolution off the screen.
  40559. */
  40560. hResolution: number;
  40561. /**
  40562. * Define the vertical resolution off the screen.
  40563. */
  40564. vResolution: number;
  40565. /**
  40566. * Define the horizontal screen size.
  40567. */
  40568. hScreenSize: number;
  40569. /**
  40570. * Define the vertical screen size.
  40571. */
  40572. vScreenSize: number;
  40573. /**
  40574. * Define the vertical screen center position.
  40575. */
  40576. vScreenCenter: number;
  40577. /**
  40578. * Define the distance of the eyes to the screen.
  40579. */
  40580. eyeToScreenDistance: number;
  40581. /**
  40582. * Define the distance between both lenses
  40583. */
  40584. lensSeparationDistance: number;
  40585. /**
  40586. * Define the distance between both viewer's eyes.
  40587. */
  40588. interpupillaryDistance: number;
  40589. /**
  40590. * Define the distortion factor of the VR postprocess.
  40591. * Please, touch with care.
  40592. */
  40593. distortionK: number[];
  40594. /**
  40595. * Define the chromatic aberration correction factors for the VR post process.
  40596. */
  40597. chromaAbCorrection: number[];
  40598. /**
  40599. * Define the scale factor of the post process.
  40600. * The smaller the better but the slower.
  40601. */
  40602. postProcessScaleFactor: number;
  40603. /**
  40604. * Define an offset for the lens center.
  40605. */
  40606. lensCenterOffset: number;
  40607. /**
  40608. * Define if the current vr camera should compensate the distortion of the lense or not.
  40609. */
  40610. compensateDistortion: boolean;
  40611. /**
  40612. * Gets the rendering aspect ratio based on the provided resolutions.
  40613. */
  40614. readonly aspectRatio: number;
  40615. /**
  40616. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  40617. */
  40618. readonly aspectRatioFov: number;
  40619. /**
  40620. * @hidden
  40621. */
  40622. readonly leftHMatrix: Matrix;
  40623. /**
  40624. * @hidden
  40625. */
  40626. readonly rightHMatrix: Matrix;
  40627. /**
  40628. * @hidden
  40629. */
  40630. readonly leftPreViewMatrix: Matrix;
  40631. /**
  40632. * @hidden
  40633. */
  40634. readonly rightPreViewMatrix: Matrix;
  40635. /**
  40636. * Get the default VRMetrics based on the most generic setup.
  40637. * @returns the default vr metrics
  40638. */
  40639. static GetDefault(): VRCameraMetrics;
  40640. }
  40641. }
  40642. declare module BABYLON {
  40643. /**
  40644. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  40645. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  40646. */
  40647. class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  40648. /**
  40649. * Creates a new VRDeviceOrientationArcRotateCamera
  40650. * @param name defines camera name
  40651. * @param alpha defines the camera rotation along the logitudinal axis
  40652. * @param beta defines the camera rotation along the latitudinal axis
  40653. * @param radius defines the camera distance from its target
  40654. * @param target defines the camera target
  40655. * @param scene defines the scene the camera belongs to
  40656. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  40657. * @param vrCameraMetrics defines the vr metrics associated to the camera
  40658. */
  40659. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  40660. /**
  40661. * Gets camera class name
  40662. * @returns VRDeviceOrientationArcRotateCamera
  40663. */
  40664. getClassName(): string;
  40665. }
  40666. }
  40667. declare module BABYLON {
  40668. /**
  40669. * Camera used to simulate VR rendering (based on FreeCamera)
  40670. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  40671. */
  40672. class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  40673. /**
  40674. * Creates a new VRDeviceOrientationFreeCamera
  40675. * @param name defines camera name
  40676. * @param position defines the start position of the camera
  40677. * @param scene defines the scene the camera belongs to
  40678. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  40679. * @param vrCameraMetrics defines the vr metrics associated to the camera
  40680. */
  40681. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  40682. /**
  40683. * Gets camera class name
  40684. * @returns VRDeviceOrientationFreeCamera
  40685. */
  40686. getClassName(): string;
  40687. }
  40688. }
  40689. declare module BABYLON {
  40690. /**
  40691. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  40692. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  40693. */
  40694. class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  40695. /**
  40696. * Creates a new VRDeviceOrientationGamepadCamera
  40697. * @param name defines camera name
  40698. * @param position defines the start position of the camera
  40699. * @param scene defines the scene the camera belongs to
  40700. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  40701. * @param vrCameraMetrics defines the vr metrics associated to the camera
  40702. */
  40703. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  40704. /**
  40705. * Gets camera class name
  40706. * @returns VRDeviceOrientationGamepadCamera
  40707. */
  40708. getClassName(): string;
  40709. }
  40710. }
  40711. declare module BABYLON {
  40712. /**
  40713. * Options to modify the vr teleportation behavior.
  40714. */
  40715. interface VRTeleportationOptions {
  40716. /**
  40717. * The name of the mesh which should be used as the teleportation floor. (default: null)
  40718. */
  40719. floorMeshName?: string;
  40720. /**
  40721. * A list of meshes to be used as the teleportation floor. (default: empty)
  40722. */
  40723. floorMeshes?: Mesh[];
  40724. }
  40725. /**
  40726. * Options to modify the vr experience helper's behavior.
  40727. */
  40728. interface VRExperienceHelperOptions extends WebVROptions {
  40729. /**
  40730. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  40731. */
  40732. createDeviceOrientationCamera?: boolean;
  40733. /**
  40734. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  40735. */
  40736. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  40737. /**
  40738. * Uses the main button on the controller to toggle the laser casted. (default: true)
  40739. */
  40740. laserToggle?: boolean;
  40741. /**
  40742. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  40743. */
  40744. floorMeshes?: Mesh[];
  40745. }
  40746. /**
  40747. * Helps to quickly add VR support to an existing scene.
  40748. * See http://doc.babylonjs.com/how_to/webvr_helper
  40749. */
  40750. class VRExperienceHelper {
  40751. /** Options to modify the vr experience helper's behavior. */
  40752. webVROptions: VRExperienceHelperOptions;
  40753. private _scene;
  40754. private _position;
  40755. private _btnVR;
  40756. private _btnVRDisplayed;
  40757. private _webVRsupported;
  40758. private _webVRready;
  40759. private _webVRrequesting;
  40760. private _webVRpresenting;
  40761. private _hasEnteredVR;
  40762. private _fullscreenVRpresenting;
  40763. private _canvas;
  40764. private _webVRCamera;
  40765. private _vrDeviceOrientationCamera;
  40766. private _deviceOrientationCamera;
  40767. private _existingCamera;
  40768. private _onKeyDown;
  40769. private _onVrDisplayPresentChange;
  40770. private _onVRDisplayChanged;
  40771. private _onVRRequestPresentStart;
  40772. private _onVRRequestPresentComplete;
  40773. /**
  40774. * Observable raised when entering VR.
  40775. */
  40776. onEnteringVRObservable: Observable<VRExperienceHelper>;
  40777. /**
  40778. * Observable raised when exiting VR.
  40779. */
  40780. onExitingVRObservable: Observable<VRExperienceHelper>;
  40781. /**
  40782. * Observable raised when controller mesh is loaded.
  40783. */
  40784. onControllerMeshLoadedObservable: Observable<WebVRController>;
  40785. /** Return this.onEnteringVRObservable
  40786. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  40787. */
  40788. readonly onEnteringVR: Observable<VRExperienceHelper>;
  40789. /** Return this.onExitingVRObservable
  40790. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  40791. */
  40792. readonly onExitingVR: Observable<VRExperienceHelper>;
  40793. /** Return this.onControllerMeshLoadedObservable
  40794. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  40795. */
  40796. readonly onControllerMeshLoaded: Observable<WebVRController>;
  40797. private _rayLength;
  40798. private _useCustomVRButton;
  40799. private _teleportationRequested;
  40800. private _teleportActive;
  40801. private _floorMeshName;
  40802. private _floorMeshesCollection;
  40803. private _rotationAllowed;
  40804. private _teleportBackwardsVector;
  40805. private _teleportationTarget;
  40806. private _isDefaultTeleportationTarget;
  40807. private _postProcessMove;
  40808. private _teleportationFillColor;
  40809. private _teleportationBorderColor;
  40810. private _rotationAngle;
  40811. private _haloCenter;
  40812. private _cameraGazer;
  40813. private _padSensibilityUp;
  40814. private _padSensibilityDown;
  40815. private _leftController;
  40816. private _rightController;
  40817. /**
  40818. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  40819. */
  40820. onNewMeshSelected: Observable<AbstractMesh>;
  40821. /**
  40822. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  40823. */
  40824. onNewMeshPicked: Observable<PickingInfo>;
  40825. private _circleEase;
  40826. /**
  40827. * Observable raised before camera teleportation
  40828. */
  40829. onBeforeCameraTeleport: Observable<Vector3>;
  40830. /**
  40831. * Observable raised after camera teleportation
  40832. */
  40833. onAfterCameraTeleport: Observable<Vector3>;
  40834. /**
  40835. * Observable raised when current selected mesh gets unselected
  40836. */
  40837. onSelectedMeshUnselected: Observable<AbstractMesh>;
  40838. private _raySelectionPredicate;
  40839. /**
  40840. * To be optionaly changed by user to define custom ray selection
  40841. */
  40842. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  40843. /**
  40844. * To be optionaly changed by user to define custom selection logic (after ray selection)
  40845. */
  40846. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  40847. /**
  40848. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  40849. */
  40850. teleportationEnabled: boolean;
  40851. private _defaultHeight;
  40852. private _teleportationInitialized;
  40853. private _interactionsEnabled;
  40854. private _interactionsRequested;
  40855. private _displayGaze;
  40856. private _displayLaserPointer;
  40857. /**
  40858. * The mesh used to display where the user is going to teleport.
  40859. */
  40860. /**
  40861. * Sets the mesh to be used to display where the user is going to teleport.
  40862. */
  40863. teleportationTarget: Mesh;
  40864. /**
  40865. * 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
  40866. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  40867. * See http://doc.babylonjs.com/resources/baking_transformations
  40868. */
  40869. gazeTrackerMesh: Mesh;
  40870. /**
  40871. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  40872. */
  40873. updateGazeTrackerScale: boolean;
  40874. /**
  40875. * The gaze tracking mesh corresponding to the left controller
  40876. */
  40877. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  40878. /**
  40879. * The gaze tracking mesh corresponding to the right controller
  40880. */
  40881. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  40882. /**
  40883. * If the ray of the gaze should be displayed.
  40884. */
  40885. /**
  40886. * Sets if the ray of the gaze should be displayed.
  40887. */
  40888. displayGaze: boolean;
  40889. /**
  40890. * If the ray of the LaserPointer should be displayed.
  40891. */
  40892. /**
  40893. * Sets if the ray of the LaserPointer should be displayed.
  40894. */
  40895. displayLaserPointer: boolean;
  40896. /**
  40897. * The deviceOrientationCamera used as the camera when not in VR.
  40898. */
  40899. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  40900. /**
  40901. * Based on the current WebVR support, returns the current VR camera used.
  40902. */
  40903. readonly currentVRCamera: Nullable<Camera>;
  40904. /**
  40905. * The webVRCamera which is used when in VR.
  40906. */
  40907. readonly webVRCamera: WebVRFreeCamera;
  40908. /**
  40909. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  40910. */
  40911. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  40912. private readonly _teleportationRequestInitiated;
  40913. /**
  40914. * Instantiates a VRExperienceHelper.
  40915. * Helps to quickly add VR support to an existing scene.
  40916. * @param scene The scene the VRExperienceHelper belongs to.
  40917. * @param webVROptions Options to modify the vr experience helper's behavior.
  40918. */
  40919. constructor(scene: Scene,
  40920. /** Options to modify the vr experience helper's behavior. */
  40921. webVROptions?: VRExperienceHelperOptions);
  40922. private _onDefaultMeshLoaded;
  40923. private _onResize;
  40924. private _onFullscreenChange;
  40925. /**
  40926. * Gets a value indicating if we are currently in VR mode.
  40927. */
  40928. readonly isInVRMode: boolean;
  40929. private onVrDisplayPresentChange;
  40930. private onVRDisplayChanged;
  40931. private moveButtonToBottomRight;
  40932. private displayVRButton;
  40933. private updateButtonVisibility;
  40934. /**
  40935. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  40936. * Otherwise, will use the fullscreen API.
  40937. */
  40938. enterVR(): void;
  40939. /**
  40940. * Attempt to exit VR, or fullscreen.
  40941. */
  40942. exitVR(): void;
  40943. /**
  40944. * The position of the vr experience helper.
  40945. */
  40946. /**
  40947. * Sets the position of the vr experience helper.
  40948. */
  40949. position: Vector3;
  40950. /**
  40951. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  40952. */
  40953. enableInteractions(): void;
  40954. private readonly _noControllerIsActive;
  40955. private beforeRender;
  40956. private _isTeleportationFloor;
  40957. /**
  40958. * Adds a floor mesh to be used for teleportation.
  40959. * @param floorMesh the mesh to be used for teleportation.
  40960. */
  40961. addFloorMesh(floorMesh: Mesh): void;
  40962. /**
  40963. * Removes a floor mesh from being used for teleportation.
  40964. * @param floorMesh the mesh to be removed.
  40965. */
  40966. removeFloorMesh(floorMesh: Mesh): void;
  40967. /**
  40968. * Enables interactions and teleportation using the VR controllers and gaze.
  40969. * @param vrTeleportationOptions options to modify teleportation behavior.
  40970. */
  40971. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  40972. private _onNewGamepadConnected;
  40973. private _tryEnableInteractionOnController;
  40974. private _onNewGamepadDisconnected;
  40975. private _enableInteractionOnController;
  40976. private _checkTeleportWithRay;
  40977. private _checkRotate;
  40978. private _checkTeleportBackwards;
  40979. private _enableTeleportationOnController;
  40980. private _createTeleportationCircles;
  40981. private _displayTeleportationTarget;
  40982. private _hideTeleportationTarget;
  40983. private _rotateCamera;
  40984. private _moveTeleportationSelectorTo;
  40985. private _workingVector;
  40986. private _workingQuaternion;
  40987. private _workingMatrix;
  40988. /**
  40989. * Teleports the users feet to the desired location
  40990. * @param location The location where the user's feet should be placed
  40991. */
  40992. teleportCamera(location: Vector3): void;
  40993. private _convertNormalToDirectionOfRay;
  40994. private _castRayAndSelectObject;
  40995. private _notifySelectedMeshUnselected;
  40996. /**
  40997. * Sets the color of the laser ray from the vr controllers.
  40998. * @param color new color for the ray.
  40999. */
  41000. changeLaserColor(color: Color3): void;
  41001. /**
  41002. * Sets the color of the ray from the vr headsets gaze.
  41003. * @param color new color for the ray.
  41004. */
  41005. changeGazeColor(color: Color3): void;
  41006. /**
  41007. * Exits VR and disposes of the vr experience helper
  41008. */
  41009. dispose(): void;
  41010. /**
  41011. * Gets the name of the VRExperienceHelper class
  41012. * @returns "VRExperienceHelper"
  41013. */
  41014. getClassName(): string;
  41015. }
  41016. }
  41017. declare module BABYLON {
  41018. /**
  41019. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  41020. * IMPORTANT!! The data is right-hand data.
  41021. * @export
  41022. * @interface DevicePose
  41023. */
  41024. interface DevicePose {
  41025. /**
  41026. * The position of the device, values in array are [x,y,z].
  41027. */
  41028. readonly position: Nullable<Float32Array>;
  41029. /**
  41030. * The linearVelocity of the device, values in array are [x,y,z].
  41031. */
  41032. readonly linearVelocity: Nullable<Float32Array>;
  41033. /**
  41034. * The linearAcceleration of the device, values in array are [x,y,z].
  41035. */
  41036. readonly linearAcceleration: Nullable<Float32Array>;
  41037. /**
  41038. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  41039. */
  41040. readonly orientation: Nullable<Float32Array>;
  41041. /**
  41042. * The angularVelocity of the device, values in array are [x,y,z].
  41043. */
  41044. readonly angularVelocity: Nullable<Float32Array>;
  41045. /**
  41046. * The angularAcceleration of the device, values in array are [x,y,z].
  41047. */
  41048. readonly angularAcceleration: Nullable<Float32Array>;
  41049. }
  41050. /**
  41051. * Interface representing a pose controlled object in Babylon.
  41052. * A pose controlled object has both regular pose values as well as pose values
  41053. * from an external device such as a VR head mounted display
  41054. */
  41055. interface PoseControlled {
  41056. /**
  41057. * The position of the object in babylon space.
  41058. */
  41059. position: Vector3;
  41060. /**
  41061. * The rotation quaternion of the object in babylon space.
  41062. */
  41063. rotationQuaternion: Quaternion;
  41064. /**
  41065. * The position of the device in babylon space.
  41066. */
  41067. devicePosition?: Vector3;
  41068. /**
  41069. * The rotation quaternion of the device in babylon space.
  41070. */
  41071. deviceRotationQuaternion: Quaternion;
  41072. /**
  41073. * The raw pose coming from the device.
  41074. */
  41075. rawPose: Nullable<DevicePose>;
  41076. /**
  41077. * The scale of the device to be used when translating from device space to babylon space.
  41078. */
  41079. deviceScaleFactor: number;
  41080. /**
  41081. * Updates the poseControlled values based on the input device pose.
  41082. * @param poseData the pose data to update the object with
  41083. */
  41084. updateFromDevice(poseData: DevicePose): void;
  41085. }
  41086. /**
  41087. * Set of options to customize the webVRCamera
  41088. */
  41089. interface WebVROptions {
  41090. /**
  41091. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  41092. */
  41093. trackPosition?: boolean;
  41094. /**
  41095. * Sets the scale of the vrDevice in babylon space. (default: 1)
  41096. */
  41097. positionScale?: number;
  41098. /**
  41099. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  41100. */
  41101. displayName?: string;
  41102. /**
  41103. * Should the native controller meshes be initialized. (default: true)
  41104. */
  41105. controllerMeshes?: boolean;
  41106. /**
  41107. * Creating a default HemiLight only on controllers. (default: true)
  41108. */
  41109. defaultLightingOnControllers?: boolean;
  41110. /**
  41111. * If you don't want to use the default VR button of the helper. (default: false)
  41112. */
  41113. useCustomVRButton?: boolean;
  41114. /**
  41115. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  41116. */
  41117. customVRButton?: HTMLButtonElement;
  41118. /**
  41119. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  41120. */
  41121. rayLength?: number;
  41122. /**
  41123. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  41124. */
  41125. defaultHeight?: number;
  41126. }
  41127. /**
  41128. * This represents a WebVR camera.
  41129. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  41130. * @example http://doc.babylonjs.com/how_to/webvr_camera
  41131. */
  41132. class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  41133. private webVROptions;
  41134. /**
  41135. * @hidden
  41136. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  41137. */
  41138. /**
  41139. * The rawPose of the vrDevice.
  41140. */
  41141. rawPose: Nullable<DevicePose>;
  41142. private _onVREnabled;
  41143. private _specsVersion;
  41144. private _attached;
  41145. private _frameData;
  41146. protected _descendants: Array<Node>;
  41147. private _deviceRoomPosition;
  41148. /** @hidden */
  41149. private _standingMatrix;
  41150. /**
  41151. * Represents device position in babylon space.
  41152. */
  41153. devicePosition: Vector3;
  41154. /**
  41155. * Represents device rotation in babylon space.
  41156. */
  41157. deviceRotationQuaternion: Quaternion;
  41158. /**
  41159. * The scale of the device to be used when translating from device space to babylon space.
  41160. */
  41161. deviceScaleFactor: number;
  41162. private _deviceToWorld;
  41163. private _worldToDevice;
  41164. /**
  41165. * References to the webVR controllers for the vrDevice.
  41166. */
  41167. controllers: Array<WebVRController>;
  41168. /**
  41169. * Emits an event when a controller is attached.
  41170. */
  41171. onControllersAttachedObservable: Observable<WebVRController[]>;
  41172. /**
  41173. * Emits an event when a controller's mesh has been loaded;
  41174. */
  41175. onControllerMeshLoadedObservable: Observable<WebVRController>;
  41176. /**
  41177. * Emits an event when the HMD's pose has been updated.
  41178. */
  41179. onPoseUpdatedFromDeviceObservable: Observable<any>;
  41180. private _poseSet;
  41181. /**
  41182. * If the rig cameras be used as parent instead of this camera.
  41183. */
  41184. rigParenting: boolean;
  41185. private _lightOnControllers;
  41186. private _defaultHeight?;
  41187. /**
  41188. * Instantiates a WebVRFreeCamera.
  41189. * @param name The name of the WebVRFreeCamera
  41190. * @param position The starting anchor position for the camera
  41191. * @param scene The scene the camera belongs to
  41192. * @param webVROptions a set of customizable options for the webVRCamera
  41193. */
  41194. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  41195. /**
  41196. * Gets the device distance from the ground in meters.
  41197. * @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.
  41198. */
  41199. deviceDistanceToRoomGround(): number;
  41200. /**
  41201. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  41202. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  41203. */
  41204. useStandingMatrix(callback?: (bool: boolean) => void): void;
  41205. /**
  41206. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  41207. * @returns A promise with a boolean set to if the standing matrix is supported.
  41208. */
  41209. useStandingMatrixAsync(): Promise<boolean>;
  41210. /**
  41211. * Disposes the camera
  41212. */
  41213. dispose(): void;
  41214. /**
  41215. * Gets a vrController by name.
  41216. * @param name The name of the controller to retreive
  41217. * @returns the controller matching the name specified or null if not found
  41218. */
  41219. getControllerByName(name: string): Nullable<WebVRController>;
  41220. private _leftController;
  41221. /**
  41222. * The controller corrisponding to the users left hand.
  41223. */
  41224. readonly leftController: Nullable<WebVRController>;
  41225. private _rightController;
  41226. /**
  41227. * The controller corrisponding to the users right hand.
  41228. */
  41229. readonly rightController: Nullable<WebVRController>;
  41230. /**
  41231. * Casts a ray forward from the vrCamera's gaze.
  41232. * @param length Length of the ray (default: 100)
  41233. * @returns the ray corrisponding to the gaze
  41234. */
  41235. getForwardRay(length?: number): Ray;
  41236. /**
  41237. * @hidden
  41238. * Updates the camera based on device's frame data
  41239. */
  41240. /**
  41241. * Updates the poseControlled values based on the input device pose.
  41242. * @param poseData Pose coming from the device
  41243. */
  41244. updateFromDevice(poseData: DevicePose): void;
  41245. private _htmlElementAttached;
  41246. private _detachIfAttached;
  41247. /**
  41248. * WebVR's attach control will start broadcasting frames to the device.
  41249. * Note that in certain browsers (chrome for example) this function must be called
  41250. * within a user-interaction callback. Example:
  41251. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  41252. *
  41253. * @param element html element to attach the vrDevice to
  41254. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  41255. */
  41256. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41257. /**
  41258. * Detaches the camera from the html element and disables VR
  41259. *
  41260. * @param element html element to detach from
  41261. */
  41262. detachControl(element: HTMLElement): void;
  41263. /**
  41264. * @returns the name of this class
  41265. */
  41266. getClassName(): string;
  41267. /**
  41268. * Calls resetPose on the vrDisplay
  41269. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  41270. */
  41271. resetToCurrentRotation(): void;
  41272. /**
  41273. * @hidden
  41274. * Updates the rig cameras (left and right eye)
  41275. */
  41276. private _workingVector;
  41277. private _oneVector;
  41278. private _workingMatrix;
  41279. private updateCacheCalled;
  41280. private _correctPositionIfNotTrackPosition;
  41281. /**
  41282. * @hidden
  41283. * Updates the cached values of the camera
  41284. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  41285. */
  41286. /**
  41287. * @hidden
  41288. * Get current device position in babylon world
  41289. */
  41290. /**
  41291. * Updates the current device position and rotation in the babylon world
  41292. */
  41293. update(): void;
  41294. /**
  41295. * @hidden
  41296. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  41297. * @returns an identity matrix
  41298. */
  41299. private _tmpMatrix;
  41300. /**
  41301. * This function is called by the two RIG cameras.
  41302. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  41303. */
  41304. protected _getWebVRViewMatrix(): Matrix;
  41305. protected _getWebVRProjectionMatrix(): Matrix;
  41306. private _onGamepadConnectedObserver;
  41307. private _onGamepadDisconnectedObserver;
  41308. private _updateCacheWhenTrackingDisabledObserver;
  41309. /**
  41310. * Initializes the controllers and their meshes
  41311. */
  41312. initControllers(): void;
  41313. }
  41314. }
  41315. declare module BABYLON {
  41316. /**
  41317. * Contains an array of blocks representing the octree
  41318. */
  41319. interface IOctreeContainer<T> {
  41320. /**
  41321. * Blocks within the octree
  41322. */
  41323. blocks: Array<OctreeBlock<T>>;
  41324. }
  41325. /**
  41326. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  41327. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41328. */
  41329. class Octree<T> {
  41330. /** Defines the maximum depth (sub-levels) for your octree. Default value is 2, which means 8 8 8 = 512 blocks :) (This parameter takes precedence over capacity.) */
  41331. maxDepth: number;
  41332. /**
  41333. * Blocks within the octree containing objects
  41334. */
  41335. blocks: Array<OctreeBlock<T>>;
  41336. /**
  41337. * Content stored in the octree
  41338. */
  41339. dynamicContent: T[];
  41340. private _maxBlockCapacity;
  41341. private _selectionContent;
  41342. private _creationFunc;
  41343. /**
  41344. * Creates a octree
  41345. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41346. * @param creationFunc function to be used to instatiate the octree
  41347. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  41348. * @param maxDepth defines the maximum depth (sub-levels) for your octree. Default value is 2, which means 8 8 8 = 512 blocks :) (This parameter takes precedence over capacity.)
  41349. */
  41350. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  41351. /** Defines the maximum depth (sub-levels) for your octree. Default value is 2, which means 8 8 8 = 512 blocks :) (This parameter takes precedence over capacity.) */
  41352. maxDepth?: number);
  41353. /**
  41354. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  41355. * @param worldMin worldMin for the octree blocks var blockSize = new Vector3((worldMax.x - worldMin.x) / 2, (worldMax.y - worldMin.y) / 2, (worldMax.z - worldMin.z) / 2);
  41356. * @param worldMax worldMax for the octree blocks var blockSize = new Vector3((worldMax.x - worldMin.x) / 2, (worldMax.y - worldMin.y) / 2, (worldMax.z - worldMin.z) / 2);
  41357. * @param entries meshes to be added to the octree blocks
  41358. */
  41359. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  41360. /**
  41361. * Adds a mesh to the octree
  41362. * @param entry Mesh to add to the octree
  41363. */
  41364. addMesh(entry: T): void;
  41365. /**
  41366. * Selects an array of meshes within the frustum
  41367. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  41368. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  41369. * @returns array of meshes within the frustum
  41370. */
  41371. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  41372. /**
  41373. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  41374. * @param sphereCenter defines the bounding sphere center
  41375. * @param sphereRadius defines the bounding sphere radius
  41376. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41377. * @returns an array of objects that intersect the sphere
  41378. */
  41379. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  41380. /**
  41381. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  41382. * @param ray defines the ray to test with
  41383. * @returns array of intersected objects
  41384. */
  41385. intersectsRay(ray: Ray): SmartArray<T>;
  41386. /**
  41387. * @hidden
  41388. */
  41389. 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;
  41390. /**
  41391. * Adds a mesh into the octree block if it intersects the block
  41392. */
  41393. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  41394. /**
  41395. * Adds a submesh into the octree block if it intersects the block
  41396. */
  41397. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  41398. }
  41399. }
  41400. declare module BABYLON {
  41401. /**
  41402. * Class used to store a cell in an octree
  41403. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41404. */
  41405. class OctreeBlock<T> {
  41406. /**
  41407. * Gets the content of the current block
  41408. */
  41409. entries: T[];
  41410. /**
  41411. * Gets the list of block children
  41412. */
  41413. blocks: Array<OctreeBlock<T>>;
  41414. private _depth;
  41415. private _maxDepth;
  41416. private _capacity;
  41417. private _minPoint;
  41418. private _maxPoint;
  41419. private _boundingVectors;
  41420. private _creationFunc;
  41421. /**
  41422. * Creates a new block
  41423. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  41424. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  41425. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  41426. * @param depth defines the current depth of this block in the octree
  41427. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  41428. * @param creationFunc defines a callback to call when an element is added to the block
  41429. */
  41430. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  41431. /**
  41432. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  41433. */
  41434. readonly capacity: number;
  41435. /**
  41436. * Gets the minimum vector (in world space) of the block's bounding box
  41437. */
  41438. readonly minPoint: Vector3;
  41439. /**
  41440. * Gets the maximum vector (in world space) of the block's bounding box
  41441. */
  41442. readonly maxPoint: Vector3;
  41443. /**
  41444. * Add a new element to this block
  41445. * @param entry defines the element to add
  41446. */
  41447. addEntry(entry: T): void;
  41448. /**
  41449. * Add an array of elements to this block
  41450. * @param entries defines the array of elements to add
  41451. */
  41452. addEntries(entries: T[]): void;
  41453. /**
  41454. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  41455. * @param frustumPlanes defines the frustum planes to test
  41456. * @param selection defines the array to store current content if selection is positive
  41457. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41458. */
  41459. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  41460. /**
  41461. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  41462. * @param sphereCenter defines the bounding sphere center
  41463. * @param sphereRadius defines the bounding sphere radius
  41464. * @param selection defines the array to store current content if selection is positive
  41465. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41466. */
  41467. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  41468. /**
  41469. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  41470. * @param ray defines the ray to test with
  41471. * @param selection defines the array to store current content if selection is positive
  41472. */
  41473. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  41474. /**
  41475. * Subdivide the content into child blocks (this block will then be empty)
  41476. */
  41477. createInnerBlocks(): void;
  41478. }
  41479. }
  41480. declare module BABYLON {
  41481. interface Scene {
  41482. /**
  41483. * @hidden
  41484. * Backing Filed
  41485. */
  41486. /**
  41487. * Gets the octree used to boost mesh selection (picking)
  41488. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41489. */
  41490. selectionOctree: Octree<AbstractMesh>;
  41491. /**
  41492. * Creates or updates the octree used to boost selection (picking)
  41493. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41494. * @param maxCapacity defines the maximum capacity per leaf
  41495. * @param maxDepth defines the maximum depth of the octree
  41496. * @returns an octree of AbstractMesh
  41497. */
  41498. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  41499. }
  41500. interface AbstractMesh {
  41501. /**
  41502. * @hidden
  41503. * Backing Field
  41504. */
  41505. /**
  41506. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  41507. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  41508. * @param maxCapacity defines the maximum size of each block (64 by default)
  41509. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  41510. * @returns the new octree
  41511. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  41512. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41513. */
  41514. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  41515. }
  41516. /**
  41517. * Defines the octree scene component responsible to manage any octrees
  41518. * in a given scene.
  41519. */
  41520. class OctreeSceneComponent {
  41521. /**
  41522. * The component name helpfull to identify the component in the list of scene components.
  41523. */
  41524. readonly name: string;
  41525. /**
  41526. * The scene the component belongs to.
  41527. */
  41528. scene: Scene;
  41529. /**
  41530. * Indicates if the meshes have been checked to make sure they are isEnabled()
  41531. */
  41532. readonly checksIsEnabled: boolean;
  41533. /**
  41534. * Creates a new instance of the component for the given scene
  41535. * @param scene Defines the scene to register the component in
  41536. */
  41537. constructor(scene: Scene);
  41538. /**
  41539. * Registers the component in a given scene
  41540. */
  41541. register(): void;
  41542. /**
  41543. * Return the list of active meshes
  41544. * @returns the list of active meshes
  41545. */
  41546. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  41547. /**
  41548. * Return the list of active sub meshes
  41549. * @param mesh The mesh to get the candidates sub meshes from
  41550. * @returns the list of active sub meshes
  41551. */
  41552. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  41553. private _tempRay;
  41554. /**
  41555. * Return the list of sub meshes intersecting with a given local ray
  41556. * @param mesh defines the mesh to find the submesh for
  41557. * @param localRay defines the ray in local space
  41558. * @returns the list of intersecting sub meshes
  41559. */
  41560. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  41561. /**
  41562. * Return the list of sub meshes colliding with a collider
  41563. * @param mesh defines the mesh to find the submesh for
  41564. * @param collider defines the collider to evaluate the collision against
  41565. * @returns the list of colliding sub meshes
  41566. */
  41567. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  41568. /**
  41569. * Rebuilds the elements related to this component in case of
  41570. * context lost for instance.
  41571. */
  41572. rebuild(): void;
  41573. /**
  41574. * Disposes the component and the associated ressources.
  41575. */
  41576. dispose(): void;
  41577. }
  41578. }
  41579. declare module BABYLON {
  41580. /** @hidden */
  41581. class _OcclusionDataStorage {
  41582. /** @hidden */
  41583. occlusionInternalRetryCounter: number;
  41584. /** @hidden */
  41585. isOcclusionQueryInProgress: boolean;
  41586. /** @hidden */
  41587. isOccluded: boolean;
  41588. /** @hidden */
  41589. occlusionRetryCount: number;
  41590. /** @hidden */
  41591. occlusionType: number;
  41592. /** @hidden */
  41593. occlusionQueryAlgorithmType: number;
  41594. }
  41595. interface Engine {
  41596. /**
  41597. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  41598. * @return the new query
  41599. */
  41600. createQuery(): WebGLQuery;
  41601. /**
  41602. * Delete and release a webGL query
  41603. * @param query defines the query to delete
  41604. * @return the current engine
  41605. */
  41606. deleteQuery(query: WebGLQuery): Engine;
  41607. /**
  41608. * Check if a given query has resolved and got its value
  41609. * @param query defines the query to check
  41610. * @returns true if the query got its value
  41611. */
  41612. isQueryResultAvailable(query: WebGLQuery): boolean;
  41613. /**
  41614. * Gets the value of a given query
  41615. * @param query defines the query to check
  41616. * @returns the value of the query
  41617. */
  41618. getQueryResult(query: WebGLQuery): number;
  41619. /**
  41620. * Initiates an occlusion query
  41621. * @param algorithmType defines the algorithm to use
  41622. * @param query defines the query to use
  41623. * @returns the current engine
  41624. * @see http://doc.babylonjs.com/features/occlusionquery
  41625. */
  41626. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  41627. /**
  41628. * Ends an occlusion query
  41629. * @see http://doc.babylonjs.com/features/occlusionquery
  41630. * @param algorithmType defines the algorithm to use
  41631. * @returns the current engine
  41632. */
  41633. endOcclusionQuery(algorithmType: number): Engine;
  41634. /**
  41635. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  41636. * Please note that only one query can be issued at a time
  41637. * @returns a time token used to track the time span
  41638. */
  41639. startTimeQuery(): Nullable<_TimeToken>;
  41640. /**
  41641. * Ends a time query
  41642. * @param token defines the token used to measure the time span
  41643. * @returns the time spent (in ns)
  41644. */
  41645. endTimeQuery(token: _TimeToken): int;
  41646. /** @hidden */
  41647. /** @hidden */
  41648. /** @hidden */
  41649. /** @hidden */
  41650. /** @hidden */
  41651. /** @hidden */
  41652. }
  41653. interface AbstractMesh {
  41654. /**
  41655. * Backing filed
  41656. * @hidden
  41657. */
  41658. /**
  41659. * Access property
  41660. * @hidden
  41661. */
  41662. /**
  41663. * 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.
  41664. * The default value is -1 which means don't break the query and wait till the result
  41665. * @see http://doc.babylonjs.com/features/occlusionquery
  41666. */
  41667. occlusionRetryCount: number;
  41668. /**
  41669. * 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:
  41670. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  41671. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  41672. * * 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.
  41673. * @see http://doc.babylonjs.com/features/occlusionquery
  41674. */
  41675. occlusionType: number;
  41676. /**
  41677. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  41678. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  41679. * * 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.
  41680. * @see http://doc.babylonjs.com/features/occlusionquery
  41681. */
  41682. occlusionQueryAlgorithmType: number;
  41683. /**
  41684. * 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
  41685. * @see http://doc.babylonjs.com/features/occlusionquery
  41686. */
  41687. isOccluded: boolean;
  41688. /**
  41689. * Flag to check the progress status of the query
  41690. * @see http://doc.babylonjs.com/features/occlusionquery
  41691. */
  41692. isOcclusionQueryInProgress: boolean;
  41693. }
  41694. }
  41695. declare module BABYLON {
  41696. interface Engine {
  41697. /**
  41698. * Creates a webGL transform feedback object
  41699. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  41700. * @returns the webGL transform feedback object
  41701. */
  41702. createTransformFeedback(): WebGLTransformFeedback;
  41703. /**
  41704. * Delete a webGL transform feedback object
  41705. * @param value defines the webGL transform feedback object to delete
  41706. */
  41707. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  41708. /**
  41709. * Bind a webGL transform feedback object to the webgl context
  41710. * @param value defines the webGL transform feedback object to bind
  41711. */
  41712. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  41713. /**
  41714. * Begins a transform feedback operation
  41715. * @param usePoints defines if points or triangles must be used
  41716. */
  41717. beginTransformFeedback(usePoints: boolean): void;
  41718. /**
  41719. * Ends a transform feedback operation
  41720. */
  41721. endTransformFeedback(): void;
  41722. /**
  41723. * Specify the varyings to use with transform feedback
  41724. * @param program defines the associated webGL program
  41725. * @param value defines the list of strings representing the varying names
  41726. */
  41727. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  41728. /**
  41729. * Bind a webGL buffer for a transform feedback operation
  41730. * @param value defines the webGL buffer to bind
  41731. */
  41732. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  41733. }
  41734. }
  41735. declare module BABYLON {
  41736. /**
  41737. * Google Daydream controller
  41738. */
  41739. class DaydreamController extends WebVRController {
  41740. /**
  41741. * Base Url for the controller model.
  41742. */
  41743. static MODEL_BASE_URL: string;
  41744. /**
  41745. * File name for the controller model.
  41746. */
  41747. static MODEL_FILENAME: string;
  41748. /**
  41749. * Gamepad Id prefix used to identify Daydream Controller.
  41750. */
  41751. static readonly GAMEPAD_ID_PREFIX: string;
  41752. /**
  41753. * Creates a new DaydreamController from a gamepad
  41754. * @param vrGamepad the gamepad that the controller should be created from
  41755. */
  41756. constructor(vrGamepad: any);
  41757. /**
  41758. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41759. * @param scene scene in which to add meshes
  41760. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41761. */
  41762. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41763. /**
  41764. * Called once for each button that changed state since the last frame
  41765. * @param buttonIdx Which button index changed
  41766. * @param state New state of the button
  41767. * @param changes Which properties on the state changed since last frame
  41768. */
  41769. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41770. }
  41771. }
  41772. declare module BABYLON {
  41773. /**
  41774. * Gear VR Controller
  41775. */
  41776. class GearVRController extends WebVRController {
  41777. /**
  41778. * Base Url for the controller model.
  41779. */
  41780. static MODEL_BASE_URL: string;
  41781. /**
  41782. * File name for the controller model.
  41783. */
  41784. static MODEL_FILENAME: string;
  41785. /**
  41786. * Gamepad Id prefix used to identify this controller.
  41787. */
  41788. static readonly GAMEPAD_ID_PREFIX: string;
  41789. private readonly _buttonIndexToObservableNameMap;
  41790. /**
  41791. * Creates a new GearVRController from a gamepad
  41792. * @param vrGamepad the gamepad that the controller should be created from
  41793. */
  41794. constructor(vrGamepad: any);
  41795. /**
  41796. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41797. * @param scene scene in which to add meshes
  41798. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41799. */
  41800. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41801. /**
  41802. * Called once for each button that changed state since the last frame
  41803. * @param buttonIdx Which button index changed
  41804. * @param state New state of the button
  41805. * @param changes Which properties on the state changed since last frame
  41806. */
  41807. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41808. }
  41809. }
  41810. declare module BABYLON {
  41811. /**
  41812. * Generic Controller
  41813. */
  41814. class GenericController extends WebVRController {
  41815. /**
  41816. * Base Url for the controller model.
  41817. */
  41818. static readonly MODEL_BASE_URL: string;
  41819. /**
  41820. * File name for the controller model.
  41821. */
  41822. static readonly MODEL_FILENAME: string;
  41823. /**
  41824. * Creates a new GenericController from a gamepad
  41825. * @param vrGamepad the gamepad that the controller should be created from
  41826. */
  41827. constructor(vrGamepad: any);
  41828. /**
  41829. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41830. * @param scene scene in which to add meshes
  41831. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41832. */
  41833. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41834. /**
  41835. * Called once for each button that changed state since the last frame
  41836. * @param buttonIdx Which button index changed
  41837. * @param state New state of the button
  41838. * @param changes Which properties on the state changed since last frame
  41839. */
  41840. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41841. }
  41842. }
  41843. declare module BABYLON {
  41844. /**
  41845. * Oculus Touch Controller
  41846. */
  41847. class OculusTouchController extends WebVRController {
  41848. /**
  41849. * Base Url for the controller model.
  41850. */
  41851. static MODEL_BASE_URL: string;
  41852. /**
  41853. * File name for the left controller model.
  41854. */
  41855. static MODEL_LEFT_FILENAME: string;
  41856. /**
  41857. * File name for the right controller model.
  41858. */
  41859. static MODEL_RIGHT_FILENAME: string;
  41860. /**
  41861. * Fired when the secondary trigger on this controller is modified
  41862. */
  41863. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  41864. /**
  41865. * Fired when the thumb rest on this controller is modified
  41866. */
  41867. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  41868. /**
  41869. * Creates a new OculusTouchController from a gamepad
  41870. * @param vrGamepad the gamepad that the controller should be created from
  41871. */
  41872. constructor(vrGamepad: any);
  41873. /**
  41874. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41875. * @param scene scene in which to add meshes
  41876. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41877. */
  41878. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41879. /**
  41880. * Fired when the A button on this controller is modified
  41881. */
  41882. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41883. /**
  41884. * Fired when the B button on this controller is modified
  41885. */
  41886. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41887. /**
  41888. * Fired when the X button on this controller is modified
  41889. */
  41890. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41891. /**
  41892. * Fired when the Y button on this controller is modified
  41893. */
  41894. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41895. /**
  41896. * Called once for each button that changed state since the last frame
  41897. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  41898. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  41899. * 2) secondary trigger (same)
  41900. * 3) A (right) X (left), touch, pressed = value
  41901. * 4) B / Y
  41902. * 5) thumb rest
  41903. * @param buttonIdx Which button index changed
  41904. * @param state New state of the button
  41905. * @param changes Which properties on the state changed since last frame
  41906. */
  41907. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41908. }
  41909. }
  41910. declare module BABYLON {
  41911. /**
  41912. * Defines the types of pose enabled controllers that are supported
  41913. */
  41914. enum PoseEnabledControllerType {
  41915. /**
  41916. * HTC Vive
  41917. */
  41918. VIVE = 0,
  41919. /**
  41920. * Oculus Rift
  41921. */
  41922. OCULUS = 1,
  41923. /**
  41924. * Windows mixed reality
  41925. */
  41926. WINDOWS = 2,
  41927. /**
  41928. * Samsung gear VR
  41929. */
  41930. GEAR_VR = 3,
  41931. /**
  41932. * Google Daydream
  41933. */
  41934. DAYDREAM = 4,
  41935. /**
  41936. * Generic
  41937. */
  41938. GENERIC = 5
  41939. }
  41940. /**
  41941. * Defines the MutableGamepadButton interface for the state of a gamepad button
  41942. */
  41943. interface MutableGamepadButton {
  41944. /**
  41945. * Value of the button/trigger
  41946. */
  41947. value: number;
  41948. /**
  41949. * If the button/trigger is currently touched
  41950. */
  41951. touched: boolean;
  41952. /**
  41953. * If the button/trigger is currently pressed
  41954. */
  41955. pressed: boolean;
  41956. }
  41957. /**
  41958. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  41959. * @hidden
  41960. */
  41961. interface ExtendedGamepadButton extends GamepadButton {
  41962. /**
  41963. * If the button/trigger is currently pressed
  41964. */
  41965. readonly pressed: boolean;
  41966. /**
  41967. * If the button/trigger is currently touched
  41968. */
  41969. readonly touched: boolean;
  41970. /**
  41971. * Value of the button/trigger
  41972. */
  41973. readonly value: number;
  41974. }
  41975. /**
  41976. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  41977. */
  41978. class PoseEnabledControllerHelper {
  41979. /**
  41980. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  41981. * @param vrGamepad the gamepad to initialized
  41982. * @returns a vr controller of the type the gamepad identified as
  41983. */
  41984. static InitiateController(vrGamepad: any): OculusTouchController | WindowsMotionController | ViveController | GearVRController | DaydreamController | GenericController;
  41985. }
  41986. /**
  41987. * Defines the PoseEnabledController object that contains state of a vr capable controller
  41988. */
  41989. class PoseEnabledController extends Gamepad implements PoseControlled {
  41990. private _deviceRoomPosition;
  41991. private _deviceRoomRotationQuaternion;
  41992. /**
  41993. * The device position in babylon space
  41994. */
  41995. devicePosition: Vector3;
  41996. /**
  41997. * The device rotation in babylon space
  41998. */
  41999. deviceRotationQuaternion: Quaternion;
  42000. /**
  42001. * The scale factor of the device in babylon space
  42002. */
  42003. deviceScaleFactor: number;
  42004. /**
  42005. * (Likely devicePosition should be used instead) The device position in its room space
  42006. */
  42007. position: Vector3;
  42008. /**
  42009. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  42010. */
  42011. rotationQuaternion: Quaternion;
  42012. /**
  42013. * The type of controller (Eg. Windows mixed reality)
  42014. */
  42015. controllerType: PoseEnabledControllerType;
  42016. protected _calculatedPosition: Vector3;
  42017. private _calculatedRotation;
  42018. /**
  42019. * The raw pose from the device
  42020. */
  42021. rawPose: DevicePose;
  42022. private _trackPosition;
  42023. private _maxRotationDistFromHeadset;
  42024. private _draggedRoomRotation;
  42025. /**
  42026. * @hidden
  42027. */
  42028. /**
  42029. * Internal, the mesh attached to the controller
  42030. * @hidden
  42031. */
  42032. private _poseControlledCamera;
  42033. private _leftHandSystemQuaternion;
  42034. /**
  42035. * Internal, matrix used to convert room space to babylon space
  42036. * @hidden
  42037. */
  42038. /**
  42039. * Node to be used when casting a ray from the controller
  42040. * @hidden
  42041. */
  42042. /**
  42043. * Name of the child mesh that can be used to cast a ray from the controller
  42044. */
  42045. static readonly POINTING_POSE: string;
  42046. /**
  42047. * Creates a new PoseEnabledController from a gamepad
  42048. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  42049. */
  42050. constructor(browserGamepad: any);
  42051. private _workingMatrix;
  42052. /**
  42053. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  42054. */
  42055. update(): void;
  42056. /**
  42057. * Updates only the pose device and mesh without doing any button event checking
  42058. */
  42059. protected _updatePoseAndMesh(): void;
  42060. /**
  42061. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  42062. * @param poseData raw pose fromthe device
  42063. */
  42064. updateFromDevice(poseData: DevicePose): void;
  42065. /**
  42066. * @hidden
  42067. */
  42068. /**
  42069. * Attaches a mesh to the controller
  42070. * @param mesh the mesh to be attached
  42071. */
  42072. attachToMesh(mesh: AbstractMesh): void;
  42073. /**
  42074. * Attaches the controllers mesh to a camera
  42075. * @param camera the camera the mesh should be attached to
  42076. */
  42077. attachToPoseControlledCamera(camera: TargetCamera): void;
  42078. /**
  42079. * Disposes of the controller
  42080. */
  42081. dispose(): void;
  42082. /**
  42083. * The mesh that is attached to the controller
  42084. */
  42085. readonly mesh: Nullable<AbstractMesh>;
  42086. /**
  42087. * Gets the ray of the controller in the direction the controller is pointing
  42088. * @param length the length the resulting ray should be
  42089. * @returns a ray in the direction the controller is pointing
  42090. */
  42091. getForwardRay(length?: number): Ray;
  42092. }
  42093. }
  42094. declare module BABYLON {
  42095. /**
  42096. * Vive Controller
  42097. */
  42098. class ViveController extends WebVRController {
  42099. /**
  42100. * Base Url for the controller model.
  42101. */
  42102. static MODEL_BASE_URL: string;
  42103. /**
  42104. * File name for the controller model.
  42105. */
  42106. static MODEL_FILENAME: string;
  42107. /**
  42108. * Creates a new ViveController from a gamepad
  42109. * @param vrGamepad the gamepad that the controller should be created from
  42110. */
  42111. constructor(vrGamepad: any);
  42112. /**
  42113. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42114. * @param scene scene in which to add meshes
  42115. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42116. */
  42117. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42118. /**
  42119. * Fired when the left button on this controller is modified
  42120. */
  42121. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42122. /**
  42123. * Fired when the right button on this controller is modified
  42124. */
  42125. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42126. /**
  42127. * Fired when the menu button on this controller is modified
  42128. */
  42129. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42130. /**
  42131. * Called once for each button that changed state since the last frame
  42132. * Vive mapping:
  42133. * 0: touchpad
  42134. * 1: trigger
  42135. * 2: left AND right buttons
  42136. * 3: menu button
  42137. * @param buttonIdx Which button index changed
  42138. * @param state New state of the button
  42139. * @param changes Which properties on the state changed since last frame
  42140. */
  42141. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42142. }
  42143. }
  42144. declare module BABYLON {
  42145. /**
  42146. * Defines the WebVRController object that represents controllers tracked in 3D space
  42147. */
  42148. abstract class WebVRController extends PoseEnabledController {
  42149. /**
  42150. * Internal, the default controller model for the controller
  42151. */
  42152. protected _defaultModel: AbstractMesh;
  42153. /**
  42154. * Fired when the trigger state has changed
  42155. */
  42156. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  42157. /**
  42158. * Fired when the main button state has changed
  42159. */
  42160. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42161. /**
  42162. * Fired when the secondary button state has changed
  42163. */
  42164. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42165. /**
  42166. * Fired when the pad state has changed
  42167. */
  42168. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  42169. /**
  42170. * Fired when controllers stick values have changed
  42171. */
  42172. onPadValuesChangedObservable: Observable<StickValues>;
  42173. /**
  42174. * Array of button availible on the controller
  42175. */
  42176. protected _buttons: Array<MutableGamepadButton>;
  42177. private _onButtonStateChange;
  42178. /**
  42179. * Fired when a controller button's state has changed
  42180. * @param callback the callback containing the button that was modified
  42181. */
  42182. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  42183. /**
  42184. * X and Y axis corrisponding to the controllers joystick
  42185. */
  42186. pad: StickValues;
  42187. /**
  42188. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  42189. */
  42190. hand: string;
  42191. /**
  42192. * The default controller model for the controller
  42193. */
  42194. readonly defaultModel: AbstractMesh;
  42195. /**
  42196. * Creates a new WebVRController from a gamepad
  42197. * @param vrGamepad the gamepad that the WebVRController should be created from
  42198. */
  42199. constructor(vrGamepad: any);
  42200. /**
  42201. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  42202. */
  42203. update(): void;
  42204. /**
  42205. * Function to be called when a button is modified
  42206. */
  42207. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42208. /**
  42209. * Loads a mesh and attaches it to the controller
  42210. * @param scene the scene the mesh should be added to
  42211. * @param meshLoaded callback for when the mesh has been loaded
  42212. */
  42213. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42214. private _setButtonValue;
  42215. private _changes;
  42216. private _checkChanges;
  42217. /**
  42218. * Disposes of th webVRCOntroller
  42219. */
  42220. dispose(): void;
  42221. }
  42222. }
  42223. declare module BABYLON {
  42224. /**
  42225. * Defines the WindowsMotionController object that the state of the windows motion controller
  42226. */
  42227. class WindowsMotionController extends WebVRController {
  42228. /**
  42229. * The base url used to load the left and right controller models
  42230. */
  42231. static MODEL_BASE_URL: string;
  42232. /**
  42233. * The name of the left controller model file
  42234. */
  42235. static MODEL_LEFT_FILENAME: string;
  42236. /**
  42237. * The name of the right controller model file
  42238. */
  42239. static MODEL_RIGHT_FILENAME: string;
  42240. /**
  42241. * The controller name prefix for this controller type
  42242. */
  42243. static readonly GAMEPAD_ID_PREFIX: string;
  42244. /**
  42245. * The controller id pattern for this controller type
  42246. */
  42247. private static readonly GAMEPAD_ID_PATTERN;
  42248. private _loadedMeshInfo;
  42249. private readonly _mapping;
  42250. /**
  42251. * Fired when the trackpad on this controller is clicked
  42252. */
  42253. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  42254. /**
  42255. * Fired when the trackpad on this controller is modified
  42256. */
  42257. onTrackpadValuesChangedObservable: Observable<StickValues>;
  42258. /**
  42259. * The current x and y values of this controller's trackpad
  42260. */
  42261. trackpad: StickValues;
  42262. /**
  42263. * Creates a new WindowsMotionController from a gamepad
  42264. * @param vrGamepad the gamepad that the controller should be created from
  42265. */
  42266. constructor(vrGamepad: any);
  42267. /**
  42268. * Fired when the trigger on this controller is modified
  42269. */
  42270. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42271. /**
  42272. * Fired when the menu button on this controller is modified
  42273. */
  42274. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42275. /**
  42276. * Fired when the grip button on this controller is modified
  42277. */
  42278. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42279. /**
  42280. * Fired when the thumbstick button on this controller is modified
  42281. */
  42282. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42283. /**
  42284. * Fired when the touchpad button on this controller is modified
  42285. */
  42286. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42287. /**
  42288. * Fired when the touchpad values on this controller are modified
  42289. */
  42290. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  42291. private _updateTrackpad;
  42292. /**
  42293. * Called once per frame by the engine.
  42294. */
  42295. update(): void;
  42296. /**
  42297. * Called once for each button that changed state since the last frame
  42298. * @param buttonIdx Which button index changed
  42299. * @param state New state of the button
  42300. * @param changes Which properties on the state changed since last frame
  42301. */
  42302. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42303. /**
  42304. * Moves the buttons on the controller mesh based on their current state
  42305. * @param buttonName the name of the button to move
  42306. * @param buttonValue the value of the button which determines the buttons new position
  42307. */
  42308. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  42309. /**
  42310. * Moves the axis on the controller mesh based on its current state
  42311. * @param axis the index of the axis
  42312. * @param axisValue the value of the axis which determines the meshes new position
  42313. * @hidden
  42314. */
  42315. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  42316. /**
  42317. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42318. * @param scene scene in which to add meshes
  42319. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42320. */
  42321. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  42322. /**
  42323. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  42324. * can be transformed by button presses and axes values, based on this._mapping.
  42325. *
  42326. * @param scene scene in which the meshes exist
  42327. * @param meshes list of meshes that make up the controller model to process
  42328. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  42329. */
  42330. private processModel;
  42331. private createMeshInfo;
  42332. /**
  42333. * Gets the ray of the controller in the direction the controller is pointing
  42334. * @param length the length the resulting ray should be
  42335. * @returns a ray in the direction the controller is pointing
  42336. */
  42337. getForwardRay(length?: number): Ray;
  42338. /**
  42339. * Disposes of the controller
  42340. */
  42341. dispose(): void;
  42342. }
  42343. }
  42344. declare module BABYLON {
  42345. /**
  42346. * Interface to implement to create a shadow generator compatible with BJS.
  42347. */
  42348. interface IShadowGenerator {
  42349. /**
  42350. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  42351. * @returns The render target texture if present otherwise, null
  42352. */
  42353. getShadowMap(): Nullable<RenderTargetTexture>;
  42354. /**
  42355. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  42356. * @returns The render target texture if the shadow map is present otherwise, null
  42357. */
  42358. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  42359. /**
  42360. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  42361. * @param subMesh The submesh we want to render in the shadow map
  42362. * @param useInstances Defines wether will draw in the map using instances
  42363. * @returns true if ready otherwise, false
  42364. */
  42365. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  42366. /**
  42367. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  42368. * @param defines Defines of the material we want to update
  42369. * @param lightIndex Index of the light in the enabled light list of the material
  42370. */
  42371. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  42372. /**
  42373. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  42374. * defined in the generator but impacting the effect).
  42375. * It implies the unifroms available on the materials are the standard BJS ones.
  42376. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  42377. * @param effect The effect we are binfing the information for
  42378. */
  42379. bindShadowLight(lightIndex: string, effect: Effect): void;
  42380. /**
  42381. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  42382. * (eq to shadow prjection matrix * light transform matrix)
  42383. * @returns The transform matrix used to create the shadow map
  42384. */
  42385. getTransformMatrix(): Matrix;
  42386. /**
  42387. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  42388. * Cube and 2D textures for instance.
  42389. */
  42390. recreateShadowMap(): void;
  42391. /**
  42392. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  42393. * @param onCompiled Callback triggered at the and of the effects compilation
  42394. * @param options Sets of optional options forcing the compilation with different modes
  42395. */
  42396. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  42397. useInstances: boolean;
  42398. }>): void;
  42399. /**
  42400. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  42401. * @param options Sets of optional options forcing the compilation with different modes
  42402. * @returns A promise that resolves when the compilation completes
  42403. */
  42404. forceCompilationAsync(options?: Partial<{
  42405. useInstances: boolean;
  42406. }>): Promise<void>;
  42407. /**
  42408. * Serializes the shadow generator setup to a json object.
  42409. * @returns The serialized JSON object
  42410. */
  42411. serialize(): any;
  42412. /**
  42413. * Disposes the Shadow map and related Textures and effects.
  42414. */
  42415. dispose(): void;
  42416. }
  42417. /**
  42418. * Default implementation IShadowGenerator.
  42419. * This is the main object responsible of generating shadows in the framework.
  42420. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  42421. */
  42422. class ShadowGenerator implements IShadowGenerator {
  42423. /**
  42424. * Shadow generator mode None: no filtering applied.
  42425. */
  42426. static readonly FILTER_NONE: number;
  42427. /**
  42428. * Shadow generator mode ESM: Exponential Shadow Mapping.
  42429. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  42430. */
  42431. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  42432. /**
  42433. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  42434. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  42435. */
  42436. static readonly FILTER_POISSONSAMPLING: number;
  42437. /**
  42438. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  42439. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  42440. */
  42441. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  42442. /**
  42443. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  42444. * edge artifacts on steep falloff.
  42445. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  42446. */
  42447. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  42448. /**
  42449. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  42450. * edge artifacts on steep falloff.
  42451. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  42452. */
  42453. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  42454. /**
  42455. * Shadow generator mode PCF: Percentage Closer Filtering
  42456. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  42457. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  42458. */
  42459. static readonly FILTER_PCF: number;
  42460. /**
  42461. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  42462. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  42463. * Contact Hardening
  42464. */
  42465. static readonly FILTER_PCSS: number;
  42466. /**
  42467. * Reserved for PCF and PCSS
  42468. * Highest Quality.
  42469. *
  42470. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  42471. *
  42472. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  42473. */
  42474. static readonly QUALITY_HIGH: number;
  42475. /**
  42476. * Reserved for PCF and PCSS
  42477. * Good tradeoff for quality/perf cross devices
  42478. *
  42479. * Execute PCF on a 3*3 kernel.
  42480. *
  42481. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  42482. */
  42483. static readonly QUALITY_MEDIUM: number;
  42484. /**
  42485. * Reserved for PCF and PCSS
  42486. * The lowest quality but the fastest.
  42487. *
  42488. * Execute PCF on a 1*1 kernel.
  42489. *
  42490. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  42491. */
  42492. static readonly QUALITY_LOW: number;
  42493. private _bias;
  42494. /**
  42495. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  42496. */
  42497. /**
  42498. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  42499. */
  42500. bias: number;
  42501. private _normalBias;
  42502. /**
  42503. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  42504. */
  42505. /**
  42506. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  42507. */
  42508. normalBias: number;
  42509. private _blurBoxOffset;
  42510. /**
  42511. * Gets the blur box offset: offset applied during the blur pass.
  42512. * Only usefull if useKernelBlur = false
  42513. */
  42514. /**
  42515. * Sets the blur box offset: offset applied during the blur pass.
  42516. * Only usefull if useKernelBlur = false
  42517. */
  42518. blurBoxOffset: number;
  42519. private _blurScale;
  42520. /**
  42521. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  42522. * 2 means half of the size.
  42523. */
  42524. /**
  42525. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  42526. * 2 means half of the size.
  42527. */
  42528. blurScale: number;
  42529. private _blurKernel;
  42530. /**
  42531. * Gets the blur kernel: kernel size of the blur pass.
  42532. * Only usefull if useKernelBlur = true
  42533. */
  42534. /**
  42535. * Sets the blur kernel: kernel size of the blur pass.
  42536. * Only usefull if useKernelBlur = true
  42537. */
  42538. blurKernel: number;
  42539. private _useKernelBlur;
  42540. /**
  42541. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  42542. * Only usefull in filtered mode (useBlurExponentialShadowMap...)
  42543. */
  42544. /**
  42545. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  42546. * Only usefull in filtered mode (useBlurExponentialShadowMap...)
  42547. */
  42548. useKernelBlur: boolean;
  42549. private _depthScale;
  42550. /**
  42551. * Gets the depth scale used in ESM mode.
  42552. */
  42553. /**
  42554. * Sets the depth scale used in ESM mode.
  42555. * This can override the scale stored on the light.
  42556. */
  42557. depthScale: number;
  42558. private _filter;
  42559. /**
  42560. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  42561. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  42562. */
  42563. /**
  42564. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  42565. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  42566. */
  42567. filter: number;
  42568. /**
  42569. * Gets if the current filter is set to Poisson Sampling.
  42570. */
  42571. /**
  42572. * Sets the current filter to Poisson Sampling.
  42573. */
  42574. usePoissonSampling: boolean;
  42575. /**
  42576. * Gets if the current filter is set to VSM.
  42577. * DEPRECATED. Should use useExponentialShadowMap instead.
  42578. */
  42579. /**
  42580. * Sets the current filter is to VSM.
  42581. * DEPRECATED. Should use useExponentialShadowMap instead.
  42582. */
  42583. useVarianceShadowMap: boolean;
  42584. /**
  42585. * Gets if the current filter is set to blurred VSM.
  42586. * DEPRECATED. Should use useBlurExponentialShadowMap instead.
  42587. */
  42588. /**
  42589. * Sets the current filter is to blurred VSM.
  42590. * DEPRECATED. Should use useBlurExponentialShadowMap instead.
  42591. */
  42592. useBlurVarianceShadowMap: boolean;
  42593. /**
  42594. * Gets if the current filter is set to ESM.
  42595. */
  42596. /**
  42597. * Sets the current filter is to ESM.
  42598. */
  42599. useExponentialShadowMap: boolean;
  42600. /**
  42601. * Gets if the current filter is set to filtered ESM.
  42602. */
  42603. /**
  42604. * Gets if the current filter is set to filtered ESM.
  42605. */
  42606. useBlurExponentialShadowMap: boolean;
  42607. /**
  42608. * Gets if the current filter is set to "close ESM" (using the inverse of the
  42609. * exponential to prevent steep falloff artifacts).
  42610. */
  42611. /**
  42612. * Sets the current filter to "close ESM" (using the inverse of the
  42613. * exponential to prevent steep falloff artifacts).
  42614. */
  42615. useCloseExponentialShadowMap: boolean;
  42616. /**
  42617. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  42618. * exponential to prevent steep falloff artifacts).
  42619. */
  42620. /**
  42621. * Sets the current filter to filtered "close ESM" (using the inverse of the
  42622. * exponential to prevent steep falloff artifacts).
  42623. */
  42624. useBlurCloseExponentialShadowMap: boolean;
  42625. /**
  42626. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  42627. */
  42628. /**
  42629. * Sets the current filter to "PCF" (percentage closer filtering).
  42630. */
  42631. usePercentageCloserFiltering: boolean;
  42632. private _filteringQuality;
  42633. /**
  42634. * Gets the PCF or PCSS Quality.
  42635. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  42636. */
  42637. /**
  42638. * Sets the PCF or PCSS Quality.
  42639. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  42640. */
  42641. filteringQuality: number;
  42642. /**
  42643. * Gets if the current filter is set to "PCSS" (contact hardening).
  42644. */
  42645. /**
  42646. * Sets the current filter to "PCSS" (contact hardening).
  42647. */
  42648. useContactHardeningShadow: boolean;
  42649. private _contactHardeningLightSizeUVRatio;
  42650. /**
  42651. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  42652. * Using a ratio helps keeping shape stability independently of the map size.
  42653. *
  42654. * It does not account for the light projection as it was having too much
  42655. * instability during the light setup or during light position changes.
  42656. *
  42657. * Only valid if useContactHardeningShadow is true.
  42658. */
  42659. /**
  42660. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  42661. * Using a ratio helps keeping shape stability independently of the map size.
  42662. *
  42663. * It does not account for the light projection as it was having too much
  42664. * instability during the light setup or during light position changes.
  42665. *
  42666. * Only valid if useContactHardeningShadow is true.
  42667. */
  42668. contactHardeningLightSizeUVRatio: number;
  42669. private _darkness;
  42670. /**
  42671. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  42672. * 0 means strongest and 1 would means no shadow.
  42673. * @returns the darkness.
  42674. */
  42675. getDarkness(): number;
  42676. /**
  42677. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  42678. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  42679. * @returns the shadow generator allowing fluent coding.
  42680. */
  42681. setDarkness(darkness: number): ShadowGenerator;
  42682. private _transparencyShadow;
  42683. /**
  42684. * Sets the ability to have transparent shadow (boolean).
  42685. * @param transparent True if transparent else False
  42686. * @returns the shadow generator allowing fluent coding
  42687. */
  42688. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  42689. private _shadowMap;
  42690. private _shadowMap2;
  42691. /**
  42692. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  42693. * @returns The render target texture if present otherwise, null
  42694. */
  42695. getShadowMap(): Nullable<RenderTargetTexture>;
  42696. /**
  42697. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  42698. * @returns The render target texture if the shadow map is present otherwise, null
  42699. */
  42700. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  42701. /**
  42702. * Helper function to add a mesh and its descendants to the list of shadow casters.
  42703. * @param mesh Mesh to add
  42704. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  42705. * @returns the Shadow Generator itself
  42706. */
  42707. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  42708. /**
  42709. * Helper function to remove a mesh and its descendants from the list of shadow casters
  42710. * @param mesh Mesh to remove
  42711. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  42712. * @returns the Shadow Generator itself
  42713. */
  42714. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  42715. /**
  42716. * Controls the extent to which the shadows fade out at the edge of the frustum
  42717. * Used only by directionals and spots
  42718. */
  42719. frustumEdgeFalloff: number;
  42720. private _light;
  42721. /**
  42722. * Returns the associated light object.
  42723. * @returns the light generating the shadow
  42724. */
  42725. getLight(): IShadowLight;
  42726. /**
  42727. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  42728. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  42729. * It might on the other hand introduce peter panning.
  42730. */
  42731. forceBackFacesOnly: boolean;
  42732. private _scene;
  42733. private _lightDirection;
  42734. private _effect;
  42735. private _viewMatrix;
  42736. private _projectionMatrix;
  42737. private _transformMatrix;
  42738. private _cachedPosition;
  42739. private _cachedDirection;
  42740. private _cachedDefines;
  42741. private _currentRenderID;
  42742. private _boxBlurPostprocess;
  42743. private _kernelBlurXPostprocess;
  42744. private _kernelBlurYPostprocess;
  42745. private _blurPostProcesses;
  42746. private _mapSize;
  42747. private _currentFaceIndex;
  42748. private _currentFaceIndexCache;
  42749. private _textureType;
  42750. private _defaultTextureMatrix;
  42751. /**
  42752. * Creates a ShadowGenerator object.
  42753. * A ShadowGenerator is the required tool to use the shadows.
  42754. * Each light casting shadows needs to use its own ShadowGenerator.
  42755. * Documentation : http://doc.babylonjs.com/tutorials/shadows
  42756. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  42757. * @param light The light object generating the shadows.
  42758. * @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.
  42759. */
  42760. constructor(mapSize: number, light: IShadowLight, useFullFloatFirst?: boolean);
  42761. private _initializeGenerator;
  42762. private _initializeShadowMap;
  42763. private _initializeBlurRTTAndPostProcesses;
  42764. private _renderForShadowMap;
  42765. private _renderSubMeshForShadowMap;
  42766. private _applyFilterValues;
  42767. /**
  42768. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  42769. * @param onCompiled Callback triggered at the and of the effects compilation
  42770. * @param options Sets of optional options forcing the compilation with different modes
  42771. */
  42772. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  42773. useInstances: boolean;
  42774. }>): void;
  42775. /**
  42776. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  42777. * @param options Sets of optional options forcing the compilation with different modes
  42778. * @returns A promise that resolves when the compilation completes
  42779. */
  42780. forceCompilationAsync(options?: Partial<{
  42781. useInstances: boolean;
  42782. }>): Promise<void>;
  42783. /**
  42784. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  42785. * @param subMesh The submesh we want to render in the shadow map
  42786. * @param useInstances Defines wether will draw in the map using instances
  42787. * @returns true if ready otherwise, false
  42788. */
  42789. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  42790. /**
  42791. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  42792. * @param defines Defines of the material we want to update
  42793. * @param lightIndex Index of the light in the enabled light list of the material
  42794. */
  42795. prepareDefines(defines: any, lightIndex: number): void;
  42796. /**
  42797. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  42798. * defined in the generator but impacting the effect).
  42799. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  42800. * @param effect The effect we are binfing the information for
  42801. */
  42802. bindShadowLight(lightIndex: string, effect: Effect): void;
  42803. /**
  42804. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  42805. * (eq to shadow prjection matrix * light transform matrix)
  42806. * @returns The transform matrix used to create the shadow map
  42807. */
  42808. getTransformMatrix(): Matrix;
  42809. /**
  42810. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  42811. * Cube and 2D textures for instance.
  42812. */
  42813. recreateShadowMap(): void;
  42814. private _disposeBlurPostProcesses;
  42815. private _disposeRTTandPostProcesses;
  42816. /**
  42817. * Disposes the ShadowGenerator.
  42818. * Returns nothing.
  42819. */
  42820. dispose(): void;
  42821. /**
  42822. * Serializes the shadow generator setup to a json object.
  42823. * @returns The serialized JSON object
  42824. */
  42825. serialize(): any;
  42826. /**
  42827. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  42828. * @param parsedShadowGenerator The JSON object to parse
  42829. * @param scene The scene to create the shadow map for
  42830. * @returns The parsed shadow generator
  42831. */
  42832. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  42833. }
  42834. }
  42835. declare module BABYLON {
  42836. /**
  42837. * Defines the shadow generator component responsible to manage any shadow generators
  42838. * in a given scene.
  42839. */
  42840. class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  42841. /**
  42842. * The component name helpfull to identify the component in the list of scene components.
  42843. */
  42844. readonly name: string;
  42845. /**
  42846. * The scene the component belongs to.
  42847. */
  42848. scene: Scene;
  42849. /**
  42850. * Creates a new instance of the component for the given scene
  42851. * @param scene Defines the scene to register the component in
  42852. */
  42853. constructor(scene: Scene);
  42854. /**
  42855. * Registers the component in a given scene
  42856. */
  42857. register(): void;
  42858. /**
  42859. * Rebuilds the elements related to this component in case of
  42860. * context lost for instance.
  42861. */
  42862. rebuild(): void;
  42863. /**
  42864. * Serializes the component data to the specified json object
  42865. * @param serializationObject The object to serialize to
  42866. */
  42867. serialize(serializationObject: any): void;
  42868. /**
  42869. * Adds all the element from the container to the scene
  42870. * @param container the container holding the elements
  42871. */
  42872. addFromContainer(container: AbstractScene): void;
  42873. /**
  42874. * Removes all the elements in the container from the scene
  42875. * @param container contains the elements to remove
  42876. */
  42877. removeFromContainer(container: AbstractScene): void;
  42878. /**
  42879. * Rebuilds the elements related to this component in case of
  42880. * context lost for instance.
  42881. */
  42882. dispose(): void;
  42883. private _gatherRenderTargets;
  42884. }
  42885. }
  42886. declare module BABYLON {
  42887. }
  42888. declare module BABYLON {
  42889. /**
  42890. * Background material used to create an efficient environement around your scene.
  42891. */
  42892. class BackgroundMaterial extends PushMaterial {
  42893. /**
  42894. * Standard reflectance value at parallel view angle.
  42895. */
  42896. static StandardReflectance0: number;
  42897. /**
  42898. * Standard reflectance value at grazing angle.
  42899. */
  42900. static StandardReflectance90: number;
  42901. protected _primaryColor: Color3;
  42902. /**
  42903. * Key light Color (multiply against the environement texture)
  42904. */
  42905. primaryColor: Color3;
  42906. protected __perceptualColor: Nullable<Color3>;
  42907. /**
  42908. * Experimental Internal Use Only.
  42909. *
  42910. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  42911. * This acts as a helper to set the primary color to a more "human friendly" value.
  42912. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  42913. * output color as close as possible from the chosen value.
  42914. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  42915. * part of lighting setup.)
  42916. */
  42917. protected _primaryColorShadowLevel: float;
  42918. /**
  42919. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  42920. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  42921. */
  42922. primaryColorShadowLevel: float;
  42923. protected _primaryColorHighlightLevel: float;
  42924. /**
  42925. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  42926. * The primary color is used at the level chosen to define what the white area would look.
  42927. */
  42928. primaryColorHighlightLevel: float;
  42929. protected _reflectionTexture: Nullable<BaseTexture>;
  42930. /**
  42931. * Reflection Texture used in the material.
  42932. * Should be author in a specific way for the best result (refer to the documentation).
  42933. */
  42934. reflectionTexture: Nullable<BaseTexture>;
  42935. protected _reflectionBlur: float;
  42936. /**
  42937. * Reflection Texture level of blur.
  42938. *
  42939. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  42940. * texture twice.
  42941. */
  42942. reflectionBlur: float;
  42943. protected _diffuseTexture: Nullable<BaseTexture>;
  42944. /**
  42945. * Diffuse Texture used in the material.
  42946. * Should be author in a specific way for the best result (refer to the documentation).
  42947. */
  42948. diffuseTexture: Nullable<BaseTexture>;
  42949. protected _shadowLights: Nullable<IShadowLight[]>;
  42950. /**
  42951. * Specify the list of lights casting shadow on the material.
  42952. * All scene shadow lights will be included if null.
  42953. */
  42954. shadowLights: Nullable<IShadowLight[]>;
  42955. protected _shadowLevel: float;
  42956. /**
  42957. * Helps adjusting the shadow to a softer level if required.
  42958. * 0 means black shadows and 1 means no shadows.
  42959. */
  42960. shadowLevel: float;
  42961. protected _sceneCenter: Vector3;
  42962. /**
  42963. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  42964. * It is usually zero but might be interesting to modify according to your setup.
  42965. */
  42966. sceneCenter: Vector3;
  42967. protected _opacityFresnel: boolean;
  42968. /**
  42969. * This helps specifying that the material is falling off to the sky box at grazing angle.
  42970. * This helps ensuring a nice transition when the camera goes under the ground.
  42971. */
  42972. opacityFresnel: boolean;
  42973. protected _reflectionFresnel: boolean;
  42974. /**
  42975. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  42976. * This helps adding a mirror texture on the ground.
  42977. */
  42978. reflectionFresnel: boolean;
  42979. protected _reflectionFalloffDistance: number;
  42980. /**
  42981. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  42982. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  42983. */
  42984. reflectionFalloffDistance: number;
  42985. protected _reflectionAmount: number;
  42986. /**
  42987. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  42988. */
  42989. reflectionAmount: number;
  42990. protected _reflectionReflectance0: number;
  42991. /**
  42992. * This specifies the weight of the reflection at grazing angle.
  42993. */
  42994. reflectionReflectance0: number;
  42995. protected _reflectionReflectance90: number;
  42996. /**
  42997. * This specifies the weight of the reflection at a perpendicular point of view.
  42998. */
  42999. reflectionReflectance90: number;
  43000. /**
  43001. * Sets the reflection reflectance fresnel values according to the default standard
  43002. * empirically know to work well :-)
  43003. */
  43004. reflectionStandardFresnelWeight: number;
  43005. protected _useRGBColor: boolean;
  43006. /**
  43007. * Helps to directly use the maps channels instead of their level.
  43008. */
  43009. useRGBColor: boolean;
  43010. protected _enableNoise: boolean;
  43011. /**
  43012. * This helps reducing the banding effect that could occur on the background.
  43013. */
  43014. enableNoise: boolean;
  43015. /**
  43016. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  43017. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  43018. * Recommended to be keep at 1.0 except for special cases.
  43019. */
  43020. fovMultiplier: number;
  43021. private _fovMultiplier;
  43022. /**
  43023. * Enable the FOV adjustment feature controlled by fovMultiplier.
  43024. */
  43025. useEquirectangularFOV: boolean;
  43026. private _maxSimultaneousLights;
  43027. /**
  43028. * Number of Simultaneous lights allowed on the material.
  43029. */
  43030. maxSimultaneousLights: int;
  43031. /**
  43032. * Default configuration related to image processing available in the Background Material.
  43033. */
  43034. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  43035. /**
  43036. * Keep track of the image processing observer to allow dispose and replace.
  43037. */
  43038. private _imageProcessingObserver;
  43039. /**
  43040. * Attaches a new image processing configuration to the PBR Material.
  43041. * @param configuration (if null the scene configuration will be use)
  43042. */
  43043. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  43044. /**
  43045. * Gets the image processing configuration used either in this material.
  43046. */
  43047. /**
  43048. * Sets the Default image processing configuration used either in the this material.
  43049. *
  43050. * If sets to null, the scene one is in use.
  43051. */
  43052. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  43053. /**
  43054. * Gets wether the color curves effect is enabled.
  43055. */
  43056. /**
  43057. * Sets wether the color curves effect is enabled.
  43058. */
  43059. cameraColorCurvesEnabled: boolean;
  43060. /**
  43061. * Gets wether the color grading effect is enabled.
  43062. */
  43063. /**
  43064. * Gets wether the color grading effect is enabled.
  43065. */
  43066. cameraColorGradingEnabled: boolean;
  43067. /**
  43068. * Gets wether tonemapping is enabled or not.
  43069. */
  43070. /**
  43071. * Sets wether tonemapping is enabled or not
  43072. */
  43073. cameraToneMappingEnabled: boolean;
  43074. /**
  43075. * The camera exposure used on this material.
  43076. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  43077. * This corresponds to a photographic exposure.
  43078. */
  43079. /**
  43080. * The camera exposure used on this material.
  43081. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  43082. * This corresponds to a photographic exposure.
  43083. */
  43084. cameraExposure: float;
  43085. /**
  43086. * Gets The camera contrast used on this material.
  43087. */
  43088. /**
  43089. * Sets The camera contrast used on this material.
  43090. */
  43091. cameraContrast: float;
  43092. /**
  43093. * Gets the Color Grading 2D Lookup Texture.
  43094. */
  43095. /**
  43096. * Sets the Color Grading 2D Lookup Texture.
  43097. */
  43098. cameraColorGradingTexture: Nullable<BaseTexture>;
  43099. /**
  43100. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  43101. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  43102. * 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;
  43103. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  43104. */
  43105. /**
  43106. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  43107. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  43108. * 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;
  43109. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  43110. */
  43111. cameraColorCurves: Nullable<ColorCurves>;
  43112. /**
  43113. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  43114. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  43115. */
  43116. switchToBGR: boolean;
  43117. private _renderTargets;
  43118. private _reflectionControls;
  43119. private _white;
  43120. private _primaryShadowColor;
  43121. private _primaryHighlightColor;
  43122. /**
  43123. * Instantiates a Background Material in the given scene
  43124. * @param name The friendly name of the material
  43125. * @param scene The scene to add the material to
  43126. */
  43127. constructor(name: string, scene: Scene);
  43128. /**
  43129. * Gets a boolean indicating that current material needs to register RTT
  43130. */
  43131. readonly hasRenderTargetTextures: boolean;
  43132. /**
  43133. * The entire material has been created in order to prevent overdraw.
  43134. * @returns false
  43135. */
  43136. needAlphaTesting(): boolean;
  43137. /**
  43138. * The entire material has been created in order to prevent overdraw.
  43139. * @returns true if blending is enable
  43140. */
  43141. needAlphaBlending(): boolean;
  43142. /**
  43143. * Checks wether the material is ready to be rendered for a given mesh.
  43144. * @param mesh The mesh to render
  43145. * @param subMesh The submesh to check against
  43146. * @param useInstances Specify wether or not the material is used with instances
  43147. * @returns true if all the dependencies are ready (Textures, Effects...)
  43148. */
  43149. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  43150. /**
  43151. * Compute the primary color according to the chosen perceptual color.
  43152. */
  43153. private _computePrimaryColorFromPerceptualColor;
  43154. /**
  43155. * Compute the highlights and shadow colors according to their chosen levels.
  43156. */
  43157. private _computePrimaryColors;
  43158. /**
  43159. * Build the uniform buffer used in the material.
  43160. */
  43161. buildUniformLayout(): void;
  43162. /**
  43163. * Unbind the material.
  43164. */
  43165. unbind(): void;
  43166. /**
  43167. * Bind only the world matrix to the material.
  43168. * @param world The world matrix to bind.
  43169. */
  43170. bindOnlyWorldMatrix(world: Matrix): void;
  43171. /**
  43172. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  43173. * @param world The world matrix to bind.
  43174. * @param subMesh The submesh to bind for.
  43175. */
  43176. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  43177. /**
  43178. * Dispose the material.
  43179. * @param forceDisposeEffect Force disposal of the associated effect.
  43180. * @param forceDisposeTextures Force disposal of the associated textures.
  43181. */
  43182. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  43183. /**
  43184. * Clones the material.
  43185. * @param name The cloned name.
  43186. * @returns The cloned material.
  43187. */
  43188. clone(name: string): BackgroundMaterial;
  43189. /**
  43190. * Serializes the current material to its JSON representation.
  43191. * @returns The JSON representation.
  43192. */
  43193. serialize(): any;
  43194. /**
  43195. * Gets the class name of the material
  43196. * @returns "BackgroundMaterial"
  43197. */
  43198. getClassName(): string;
  43199. /**
  43200. * Parse a JSON input to create back a background material.
  43201. * @param source The JSON data to parse
  43202. * @param scene The scene to create the parsed material in
  43203. * @param rootUrl The root url of the assets the material depends upon
  43204. * @returns the instantiated BackgroundMaterial.
  43205. */
  43206. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  43207. }
  43208. }
  43209. declare module BABYLON {
  43210. /**
  43211. * The Physically based material base class of BJS.
  43212. *
  43213. * This offers the main features of a standard PBR material.
  43214. * For more information, please refer to the documentation :
  43215. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  43216. */
  43217. abstract class PBRBaseMaterial extends PushMaterial {
  43218. /**
  43219. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  43220. */
  43221. static readonly LIGHTFALLOFF_PHYSICAL: number;
  43222. /**
  43223. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  43224. * to enhance interoperability with other engines.
  43225. */
  43226. static readonly LIGHTFALLOFF_GLTF: number;
  43227. /**
  43228. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  43229. * to enhance interoperability with other materials.
  43230. */
  43231. static readonly LIGHTFALLOFF_STANDARD: number;
  43232. /**
  43233. * Intensity of the direct lights e.g. the four lights available in your scene.
  43234. * This impacts both the direct diffuse and specular highlights.
  43235. */
  43236. protected _directIntensity: number;
  43237. /**
  43238. * Intensity of the emissive part of the material.
  43239. * This helps controlling the emissive effect without modifying the emissive color.
  43240. */
  43241. protected _emissiveIntensity: number;
  43242. /**
  43243. * Intensity of the environment e.g. how much the environment will light the object
  43244. * either through harmonics for rough material or through the refelction for shiny ones.
  43245. */
  43246. protected _environmentIntensity: number;
  43247. /**
  43248. * This is a special control allowing the reduction of the specular highlights coming from the
  43249. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  43250. */
  43251. protected _specularIntensity: number;
  43252. /**
  43253. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  43254. */
  43255. private _lightingInfos;
  43256. /**
  43257. * Debug Control allowing disabling the bump map on this material.
  43258. */
  43259. protected _disableBumpMap: boolean;
  43260. /**
  43261. * AKA Diffuse Texture in standard nomenclature.
  43262. */
  43263. protected _albedoTexture: BaseTexture;
  43264. /**
  43265. * AKA Occlusion Texture in other nomenclature.
  43266. */
  43267. protected _ambientTexture: BaseTexture;
  43268. /**
  43269. * AKA Occlusion Texture Intensity in other nomenclature.
  43270. */
  43271. protected _ambientTextureStrength: number;
  43272. /**
  43273. * Defines how much the AO map is occluding the analytical lights (point spot...).
  43274. * 1 means it completely occludes it
  43275. * 0 mean it has no impact
  43276. */
  43277. protected _ambientTextureImpactOnAnalyticalLights: number;
  43278. /**
  43279. * Stores the alpha values in a texture.
  43280. */
  43281. protected _opacityTexture: BaseTexture;
  43282. /**
  43283. * Stores the reflection values in a texture.
  43284. */
  43285. protected _reflectionTexture: BaseTexture;
  43286. /**
  43287. * Stores the refraction values in a texture.
  43288. */
  43289. protected _refractionTexture: BaseTexture;
  43290. /**
  43291. * Stores the emissive values in a texture.
  43292. */
  43293. protected _emissiveTexture: BaseTexture;
  43294. /**
  43295. * AKA Specular texture in other nomenclature.
  43296. */
  43297. protected _reflectivityTexture: BaseTexture;
  43298. /**
  43299. * Used to switch from specular/glossiness to metallic/roughness workflow.
  43300. */
  43301. protected _metallicTexture: BaseTexture;
  43302. /**
  43303. * Specifies the metallic scalar of the metallic/roughness workflow.
  43304. * Can also be used to scale the metalness values of the metallic texture.
  43305. */
  43306. protected _metallic: Nullable<number>;
  43307. /**
  43308. * Specifies the roughness scalar of the metallic/roughness workflow.
  43309. * Can also be used to scale the roughness values of the metallic texture.
  43310. */
  43311. protected _roughness: Nullable<number>;
  43312. /**
  43313. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  43314. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  43315. */
  43316. protected _microSurfaceTexture: BaseTexture;
  43317. /**
  43318. * Stores surface normal data used to displace a mesh in a texture.
  43319. */
  43320. protected _bumpTexture: BaseTexture;
  43321. /**
  43322. * Stores the pre-calculated light information of a mesh in a texture.
  43323. */
  43324. protected _lightmapTexture: BaseTexture;
  43325. /**
  43326. * The color of a material in ambient lighting.
  43327. */
  43328. protected _ambientColor: Color3;
  43329. /**
  43330. * AKA Diffuse Color in other nomenclature.
  43331. */
  43332. protected _albedoColor: Color3;
  43333. /**
  43334. * AKA Specular Color in other nomenclature.
  43335. */
  43336. protected _reflectivityColor: Color3;
  43337. /**
  43338. * The color applied when light is reflected from a material.
  43339. */
  43340. protected _reflectionColor: Color3;
  43341. /**
  43342. * The color applied when light is emitted from a material.
  43343. */
  43344. protected _emissiveColor: Color3;
  43345. /**
  43346. * AKA Glossiness in other nomenclature.
  43347. */
  43348. protected _microSurface: number;
  43349. /**
  43350. * source material index of refraction (IOR)' / 'destination material IOR.
  43351. */
  43352. protected _indexOfRefraction: number;
  43353. /**
  43354. * Controls if refraction needs to be inverted on Y. This could be usefull for procedural texture.
  43355. */
  43356. protected _invertRefractionY: boolean;
  43357. /**
  43358. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  43359. * Materials half opaque for instance using refraction could benefit from this control.
  43360. */
  43361. protected _linkRefractionWithTransparency: boolean;
  43362. /**
  43363. * Specifies that the material will use the light map as a show map.
  43364. */
  43365. protected _useLightmapAsShadowmap: boolean;
  43366. /**
  43367. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  43368. * makes the reflect vector face the model (under horizon).
  43369. */
  43370. protected _useHorizonOcclusion: boolean;
  43371. /**
  43372. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  43373. * too much the area relying on ambient texture to define their ambient occlusion.
  43374. */
  43375. protected _useRadianceOcclusion: boolean;
  43376. /**
  43377. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  43378. */
  43379. protected _useAlphaFromAlbedoTexture: boolean;
  43380. /**
  43381. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  43382. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  43383. */
  43384. protected _useSpecularOverAlpha: boolean;
  43385. /**
  43386. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  43387. */
  43388. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  43389. /**
  43390. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  43391. */
  43392. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  43393. /**
  43394. * Specifies if the metallic texture contains the roughness information in its green channel.
  43395. */
  43396. protected _useRoughnessFromMetallicTextureGreen: boolean;
  43397. /**
  43398. * Specifies if the metallic texture contains the metallness information in its blue channel.
  43399. */
  43400. protected _useMetallnessFromMetallicTextureBlue: boolean;
  43401. /**
  43402. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  43403. */
  43404. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  43405. /**
  43406. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  43407. */
  43408. protected _useAmbientInGrayScale: boolean;
  43409. /**
  43410. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  43411. * The material will try to infer what glossiness each pixel should be.
  43412. */
  43413. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  43414. /**
  43415. * Defines the falloff type used in this material.
  43416. * It by default is Physical.
  43417. */
  43418. protected _lightFalloff: number;
  43419. /**
  43420. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  43421. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  43422. */
  43423. protected _useRadianceOverAlpha: boolean;
  43424. /**
  43425. * Allows using an object space normal map (instead of tangent space).
  43426. */
  43427. protected _useObjectSpaceNormalMap: boolean;
  43428. /**
  43429. * Allows using the bump map in parallax mode.
  43430. */
  43431. protected _useParallax: boolean;
  43432. /**
  43433. * Allows using the bump map in parallax occlusion mode.
  43434. */
  43435. protected _useParallaxOcclusion: boolean;
  43436. /**
  43437. * Controls the scale bias of the parallax mode.
  43438. */
  43439. protected _parallaxScaleBias: number;
  43440. /**
  43441. * If sets to true, disables all the lights affecting the material.
  43442. */
  43443. protected _disableLighting: boolean;
  43444. /**
  43445. * Number of Simultaneous lights allowed on the material.
  43446. */
  43447. protected _maxSimultaneousLights: number;
  43448. /**
  43449. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  43450. */
  43451. protected _invertNormalMapX: boolean;
  43452. /**
  43453. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  43454. */
  43455. protected _invertNormalMapY: boolean;
  43456. /**
  43457. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  43458. */
  43459. protected _twoSidedLighting: boolean;
  43460. /**
  43461. * Defines the alpha limits in alpha test mode.
  43462. */
  43463. protected _alphaCutOff: number;
  43464. /**
  43465. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  43466. */
  43467. protected _forceAlphaTest: boolean;
  43468. /**
  43469. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  43470. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  43471. */
  43472. protected _useAlphaFresnel: boolean;
  43473. /**
  43474. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  43475. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  43476. */
  43477. protected _useLinearAlphaFresnel: boolean;
  43478. /**
  43479. * The transparency mode of the material.
  43480. */
  43481. protected _transparencyMode: Nullable<number>;
  43482. /**
  43483. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  43484. * from cos thetav and roughness:
  43485. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  43486. */
  43487. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  43488. /**
  43489. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  43490. */
  43491. protected _forceIrradianceInFragment: boolean;
  43492. /**
  43493. * Force normal to face away from face.
  43494. */
  43495. protected _forceNormalForward: boolean;
  43496. /**
  43497. * Enables specular anti aliasing in the PBR shader.
  43498. * It will both interacts on the Geometry for analytical and IBL lighting.
  43499. * It also prefilter the roughness map based on the bump values.
  43500. */
  43501. protected _enableSpecularAntiAliasing: boolean;
  43502. /**
  43503. * Default configuration related to image processing available in the PBR Material.
  43504. */
  43505. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  43506. /**
  43507. * Keep track of the image processing observer to allow dispose and replace.
  43508. */
  43509. private _imageProcessingObserver;
  43510. /**
  43511. * Attaches a new image processing configuration to the PBR Material.
  43512. * @param configuration
  43513. */
  43514. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  43515. /**
  43516. * Stores the available render targets.
  43517. */
  43518. private _renderTargets;
  43519. /**
  43520. * Sets the global ambient color for the material used in lighting calculations.
  43521. */
  43522. private _globalAmbientColor;
  43523. /**
  43524. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  43525. */
  43526. private _useLogarithmicDepth;
  43527. /**
  43528. * If set to true, no lighting calculations will be applied.
  43529. */
  43530. private _unlit;
  43531. /**
  43532. * Instantiates a new PBRMaterial instance.
  43533. *
  43534. * @param name The material name
  43535. * @param scene The scene the material will be use in.
  43536. */
  43537. constructor(name: string, scene: Scene);
  43538. /**
  43539. * Gets a boolean indicating that current material needs to register RTT
  43540. */
  43541. readonly hasRenderTargetTextures: boolean;
  43542. /**
  43543. * Gets the name of the material class.
  43544. */
  43545. getClassName(): string;
  43546. /**
  43547. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  43548. */
  43549. /**
  43550. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  43551. */
  43552. useLogarithmicDepth: boolean;
  43553. /**
  43554. * Gets the current transparency mode.
  43555. */
  43556. /**
  43557. * Sets the transparency mode of the material.
  43558. *
  43559. * | Value | Type | Description |
  43560. * | ----- | ----------------------------------- | ----------- |
  43561. * | 0 | OPAQUE | |
  43562. * | 1 | ALPHATEST | |
  43563. * | 2 | ALPHABLEND | |
  43564. * | 3 | ALPHATESTANDBLEND | |
  43565. *
  43566. */
  43567. transparencyMode: Nullable<number>;
  43568. /**
  43569. * Returns true if alpha blending should be disabled.
  43570. */
  43571. private readonly _disableAlphaBlending;
  43572. /**
  43573. * Specifies whether or not this material should be rendered in alpha blend mode.
  43574. */
  43575. needAlphaBlending(): boolean;
  43576. /**
  43577. * Specifies if the mesh will require alpha blending.
  43578. * @param mesh - BJS mesh.
  43579. */
  43580. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  43581. /**
  43582. * Specifies whether or not this material should be rendered in alpha test mode.
  43583. */
  43584. needAlphaTesting(): boolean;
  43585. /**
  43586. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  43587. */
  43588. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  43589. /**
  43590. * Gets the texture used for the alpha test.
  43591. */
  43592. getAlphaTestTexture(): BaseTexture;
  43593. /**
  43594. * Stores the reflectivity values based on metallic roughness workflow.
  43595. */
  43596. private static _scaledReflectivity;
  43597. /**
  43598. * Specifies that the submesh is ready to be used.
  43599. * @param mesh - BJS mesh.
  43600. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  43601. * @param useInstances - Specifies that instances should be used.
  43602. * @returns - boolean indicating that the submesh is ready or not.
  43603. */
  43604. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  43605. /**
  43606. * Specifies if the material uses metallic roughness workflow.
  43607. * @returns boolean specifiying if the material uses metallic roughness workflow.
  43608. */
  43609. isMetallicWorkflow(): boolean;
  43610. private _prepareEffect;
  43611. private _prepareDefines;
  43612. /**
  43613. * Force shader compilation
  43614. */
  43615. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  43616. clipPlane: boolean;
  43617. }>): void;
  43618. /**
  43619. * Initializes the uniform buffer layout for the shader.
  43620. */
  43621. buildUniformLayout(): void;
  43622. /**
  43623. * Unbinds the textures.
  43624. */
  43625. unbind(): void;
  43626. /**
  43627. * Binds the submesh data.
  43628. * @param world - The world matrix.
  43629. * @param mesh - The BJS mesh.
  43630. * @param subMesh - A submesh of the BJS mesh.
  43631. */
  43632. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  43633. /**
  43634. * Returns the animatable textures.
  43635. * @returns - Array of animatable textures.
  43636. */
  43637. getAnimatables(): IAnimatable[];
  43638. /**
  43639. * Returns the texture used for reflections.
  43640. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  43641. */
  43642. private _getReflectionTexture;
  43643. /**
  43644. * Returns the texture used for refraction or null if none is used.
  43645. * @returns - Refection texture if present. If no refraction texture and refraction
  43646. * is linked with transparency, returns environment texture. Otherwise, returns null.
  43647. */
  43648. private _getRefractionTexture;
  43649. /**
  43650. * Disposes the resources of the material.
  43651. * @param forceDisposeEffect - Forces the disposal of effects.
  43652. * @param forceDisposeTextures - Forces the disposal of all textures.
  43653. */
  43654. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  43655. }
  43656. }
  43657. declare module BABYLON {
  43658. /**
  43659. * The Physically based simple base material of BJS.
  43660. *
  43661. * This enables better naming and convention enforcements on top of the pbrMaterial.
  43662. * It is used as the base class for both the specGloss and metalRough conventions.
  43663. */
  43664. abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  43665. /**
  43666. * Number of Simultaneous lights allowed on the material.
  43667. */
  43668. maxSimultaneousLights: number;
  43669. /**
  43670. * If sets to true, disables all the lights affecting the material.
  43671. */
  43672. disableLighting: boolean;
  43673. /**
  43674. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  43675. */
  43676. environmentTexture: BaseTexture;
  43677. /**
  43678. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  43679. */
  43680. invertNormalMapX: boolean;
  43681. /**
  43682. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  43683. */
  43684. invertNormalMapY: boolean;
  43685. /**
  43686. * Normal map used in the model.
  43687. */
  43688. normalTexture: BaseTexture;
  43689. /**
  43690. * Emissivie color used to self-illuminate the model.
  43691. */
  43692. emissiveColor: Color3;
  43693. /**
  43694. * Emissivie texture used to self-illuminate the model.
  43695. */
  43696. emissiveTexture: BaseTexture;
  43697. /**
  43698. * Occlusion Channel Strenght.
  43699. */
  43700. occlusionStrength: number;
  43701. /**
  43702. * Occlusion Texture of the material (adding extra occlusion effects).
  43703. */
  43704. occlusionTexture: BaseTexture;
  43705. /**
  43706. * Defines the alpha limits in alpha test mode.
  43707. */
  43708. alphaCutOff: number;
  43709. /**
  43710. * Gets the current double sided mode.
  43711. */
  43712. /**
  43713. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  43714. */
  43715. doubleSided: boolean;
  43716. /**
  43717. * Stores the pre-calculated light information of a mesh in a texture.
  43718. */
  43719. lightmapTexture: BaseTexture;
  43720. /**
  43721. * If true, the light map contains occlusion information instead of lighting info.
  43722. */
  43723. useLightmapAsShadowmap: boolean;
  43724. /**
  43725. * Return the active textures of the material.
  43726. */
  43727. getActiveTextures(): BaseTexture[];
  43728. hasTexture(texture: BaseTexture): boolean;
  43729. /**
  43730. * Instantiates a new PBRMaterial instance.
  43731. *
  43732. * @param name The material name
  43733. * @param scene The scene the material will be use in.
  43734. */
  43735. constructor(name: string, scene: Scene);
  43736. getClassName(): string;
  43737. }
  43738. }
  43739. declare module BABYLON {
  43740. /**
  43741. * The Physically based material of BJS.
  43742. *
  43743. * This offers the main features of a standard PBR material.
  43744. * For more information, please refer to the documentation :
  43745. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  43746. */
  43747. class PBRMaterial extends PBRBaseMaterial {
  43748. /**
  43749. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  43750. */
  43751. static readonly PBRMATERIAL_OPAQUE: number;
  43752. /**
  43753. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  43754. */
  43755. static readonly PBRMATERIAL_ALPHATEST: number;
  43756. /**
  43757. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  43758. */
  43759. static readonly PBRMATERIAL_ALPHABLEND: number;
  43760. /**
  43761. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  43762. * They are also discarded below the alpha cutoff threshold to improve performances.
  43763. */
  43764. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  43765. /**
  43766. * Defines the default value of how much AO map is occluding the analytical lights
  43767. * (point spot...).
  43768. */
  43769. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  43770. /**
  43771. * Intensity of the direct lights e.g. the four lights available in your scene.
  43772. * This impacts both the direct diffuse and specular highlights.
  43773. */
  43774. directIntensity: number;
  43775. /**
  43776. * Intensity of the emissive part of the material.
  43777. * This helps controlling the emissive effect without modifying the emissive color.
  43778. */
  43779. emissiveIntensity: number;
  43780. /**
  43781. * Intensity of the environment e.g. how much the environment will light the object
  43782. * either through harmonics for rough material or through the refelction for shiny ones.
  43783. */
  43784. environmentIntensity: number;
  43785. /**
  43786. * This is a special control allowing the reduction of the specular highlights coming from the
  43787. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  43788. */
  43789. specularIntensity: number;
  43790. /**
  43791. * Debug Control allowing disabling the bump map on this material.
  43792. */
  43793. disableBumpMap: boolean;
  43794. /**
  43795. * AKA Diffuse Texture in standard nomenclature.
  43796. */
  43797. albedoTexture: BaseTexture;
  43798. /**
  43799. * AKA Occlusion Texture in other nomenclature.
  43800. */
  43801. ambientTexture: BaseTexture;
  43802. /**
  43803. * AKA Occlusion Texture Intensity in other nomenclature.
  43804. */
  43805. ambientTextureStrength: number;
  43806. /**
  43807. * Defines how much the AO map is occluding the analytical lights (point spot...).
  43808. * 1 means it completely occludes it
  43809. * 0 mean it has no impact
  43810. */
  43811. ambientTextureImpactOnAnalyticalLights: number;
  43812. /**
  43813. * Stores the alpha values in a texture.
  43814. */
  43815. opacityTexture: BaseTexture;
  43816. /**
  43817. * Stores the reflection values in a texture.
  43818. */
  43819. reflectionTexture: Nullable<BaseTexture>;
  43820. /**
  43821. * Stores the emissive values in a texture.
  43822. */
  43823. emissiveTexture: BaseTexture;
  43824. /**
  43825. * AKA Specular texture in other nomenclature.
  43826. */
  43827. reflectivityTexture: BaseTexture;
  43828. /**
  43829. * Used to switch from specular/glossiness to metallic/roughness workflow.
  43830. */
  43831. metallicTexture: BaseTexture;
  43832. /**
  43833. * Specifies the metallic scalar of the metallic/roughness workflow.
  43834. * Can also be used to scale the metalness values of the metallic texture.
  43835. */
  43836. metallic: Nullable<number>;
  43837. /**
  43838. * Specifies the roughness scalar of the metallic/roughness workflow.
  43839. * Can also be used to scale the roughness values of the metallic texture.
  43840. */
  43841. roughness: Nullable<number>;
  43842. /**
  43843. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  43844. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  43845. */
  43846. microSurfaceTexture: BaseTexture;
  43847. /**
  43848. * Stores surface normal data used to displace a mesh in a texture.
  43849. */
  43850. bumpTexture: BaseTexture;
  43851. /**
  43852. * Stores the pre-calculated light information of a mesh in a texture.
  43853. */
  43854. lightmapTexture: BaseTexture;
  43855. /**
  43856. * Stores the refracted light information in a texture.
  43857. */
  43858. refractionTexture: BaseTexture;
  43859. /**
  43860. * The color of a material in ambient lighting.
  43861. */
  43862. ambientColor: Color3;
  43863. /**
  43864. * AKA Diffuse Color in other nomenclature.
  43865. */
  43866. albedoColor: Color3;
  43867. /**
  43868. * AKA Specular Color in other nomenclature.
  43869. */
  43870. reflectivityColor: Color3;
  43871. /**
  43872. * The color reflected from the material.
  43873. */
  43874. reflectionColor: Color3;
  43875. /**
  43876. * The color emitted from the material.
  43877. */
  43878. emissiveColor: Color3;
  43879. /**
  43880. * AKA Glossiness in other nomenclature.
  43881. */
  43882. microSurface: number;
  43883. /**
  43884. * source material index of refraction (IOR)' / 'destination material IOR.
  43885. */
  43886. indexOfRefraction: number;
  43887. /**
  43888. * Controls if refraction needs to be inverted on Y. This could be usefull for procedural texture.
  43889. */
  43890. invertRefractionY: boolean;
  43891. /**
  43892. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  43893. * Materials half opaque for instance using refraction could benefit from this control.
  43894. */
  43895. linkRefractionWithTransparency: boolean;
  43896. /**
  43897. * If true, the light map contains occlusion information instead of lighting info.
  43898. */
  43899. useLightmapAsShadowmap: boolean;
  43900. /**
  43901. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  43902. */
  43903. useAlphaFromAlbedoTexture: boolean;
  43904. /**
  43905. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  43906. */
  43907. forceAlphaTest: boolean;
  43908. /**
  43909. * Defines the alpha limits in alpha test mode.
  43910. */
  43911. alphaCutOff: number;
  43912. /**
  43913. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  43914. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  43915. */
  43916. useSpecularOverAlpha: boolean;
  43917. /**
  43918. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  43919. */
  43920. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  43921. /**
  43922. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  43923. */
  43924. useRoughnessFromMetallicTextureAlpha: boolean;
  43925. /**
  43926. * Specifies if the metallic texture contains the roughness information in its green channel.
  43927. */
  43928. useRoughnessFromMetallicTextureGreen: boolean;
  43929. /**
  43930. * Specifies if the metallic texture contains the metallness information in its blue channel.
  43931. */
  43932. useMetallnessFromMetallicTextureBlue: boolean;
  43933. /**
  43934. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  43935. */
  43936. useAmbientOcclusionFromMetallicTextureRed: boolean;
  43937. /**
  43938. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  43939. */
  43940. useAmbientInGrayScale: boolean;
  43941. /**
  43942. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  43943. * The material will try to infer what glossiness each pixel should be.
  43944. */
  43945. useAutoMicroSurfaceFromReflectivityMap: boolean;
  43946. /**
  43947. * BJS is using an harcoded light falloff based on a manually sets up range.
  43948. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  43949. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  43950. */
  43951. /**
  43952. * BJS is using an harcoded light falloff based on a manually sets up range.
  43953. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  43954. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  43955. */
  43956. usePhysicalLightFalloff: boolean;
  43957. /**
  43958. * In order to support the falloff compatibility with gltf, a special mode has been added
  43959. * to reproduce the gltf light falloff.
  43960. */
  43961. /**
  43962. * In order to support the falloff compatibility with gltf, a special mode has been added
  43963. * to reproduce the gltf light falloff.
  43964. */
  43965. useGLTFLightFalloff: boolean;
  43966. /**
  43967. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  43968. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  43969. */
  43970. useRadianceOverAlpha: boolean;
  43971. /**
  43972. * Allows using an object space normal map (instead of tangent space).
  43973. */
  43974. useObjectSpaceNormalMap: boolean;
  43975. /**
  43976. * Allows using the bump map in parallax mode.
  43977. */
  43978. useParallax: boolean;
  43979. /**
  43980. * Allows using the bump map in parallax occlusion mode.
  43981. */
  43982. useParallaxOcclusion: boolean;
  43983. /**
  43984. * Controls the scale bias of the parallax mode.
  43985. */
  43986. parallaxScaleBias: number;
  43987. /**
  43988. * If sets to true, disables all the lights affecting the material.
  43989. */
  43990. disableLighting: boolean;
  43991. /**
  43992. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  43993. */
  43994. forceIrradianceInFragment: boolean;
  43995. /**
  43996. * Number of Simultaneous lights allowed on the material.
  43997. */
  43998. maxSimultaneousLights: number;
  43999. /**
  44000. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  44001. */
  44002. invertNormalMapX: boolean;
  44003. /**
  44004. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  44005. */
  44006. invertNormalMapY: boolean;
  44007. /**
  44008. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  44009. */
  44010. twoSidedLighting: boolean;
  44011. /**
  44012. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  44013. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  44014. */
  44015. useAlphaFresnel: boolean;
  44016. /**
  44017. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  44018. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  44019. */
  44020. useLinearAlphaFresnel: boolean;
  44021. /**
  44022. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  44023. * And/Or occlude the blended part.
  44024. */
  44025. environmentBRDFTexture: Nullable<BaseTexture>;
  44026. /**
  44027. * Force normal to face away from face.
  44028. */
  44029. forceNormalForward: boolean;
  44030. /**
  44031. * Enables specular anti aliasing in the PBR shader.
  44032. * It will both interacts on the Geometry for analytical and IBL lighting.
  44033. * It also prefilter the roughness map based on the bump values.
  44034. */
  44035. enableSpecularAntiAliasing: boolean;
  44036. /**
  44037. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  44038. * makes the reflect vector face the model (under horizon).
  44039. */
  44040. useHorizonOcclusion: boolean;
  44041. /**
  44042. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  44043. * too much the area relying on ambient texture to define their ambient occlusion.
  44044. */
  44045. useRadianceOcclusion: boolean;
  44046. /**
  44047. * If set to true, no lighting calculations will be applied.
  44048. */
  44049. unlit: boolean;
  44050. /**
  44051. * Gets the image processing configuration used either in this material.
  44052. */
  44053. /**
  44054. * Sets the Default image processing configuration used either in the this material.
  44055. *
  44056. * If sets to null, the scene one is in use.
  44057. */
  44058. imageProcessingConfiguration: ImageProcessingConfiguration;
  44059. /**
  44060. * Gets wether the color curves effect is enabled.
  44061. */
  44062. /**
  44063. * Sets wether the color curves effect is enabled.
  44064. */
  44065. cameraColorCurvesEnabled: boolean;
  44066. /**
  44067. * Gets wether the color grading effect is enabled.
  44068. */
  44069. /**
  44070. * Gets wether the color grading effect is enabled.
  44071. */
  44072. cameraColorGradingEnabled: boolean;
  44073. /**
  44074. * Gets wether tonemapping is enabled or not.
  44075. */
  44076. /**
  44077. * Sets wether tonemapping is enabled or not
  44078. */
  44079. cameraToneMappingEnabled: boolean;
  44080. /**
  44081. * The camera exposure used on this material.
  44082. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  44083. * This corresponds to a photographic exposure.
  44084. */
  44085. /**
  44086. * The camera exposure used on this material.
  44087. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  44088. * This corresponds to a photographic exposure.
  44089. */
  44090. cameraExposure: number;
  44091. /**
  44092. * Gets The camera contrast used on this material.
  44093. */
  44094. /**
  44095. * Sets The camera contrast used on this material.
  44096. */
  44097. cameraContrast: number;
  44098. /**
  44099. * Gets the Color Grading 2D Lookup Texture.
  44100. */
  44101. /**
  44102. * Sets the Color Grading 2D Lookup Texture.
  44103. */
  44104. cameraColorGradingTexture: Nullable<BaseTexture>;
  44105. /**
  44106. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  44107. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  44108. * 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;
  44109. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  44110. */
  44111. /**
  44112. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  44113. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  44114. * 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;
  44115. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  44116. */
  44117. cameraColorCurves: Nullable<ColorCurves>;
  44118. /**
  44119. * Instantiates a new PBRMaterial instance.
  44120. *
  44121. * @param name The material name
  44122. * @param scene The scene the material will be use in.
  44123. */
  44124. constructor(name: string, scene: Scene);
  44125. /**
  44126. * Returns the name of this material class.
  44127. */
  44128. getClassName(): string;
  44129. /**
  44130. * Returns an array of the actively used textures.
  44131. * @returns - Array of BaseTextures
  44132. */
  44133. getActiveTextures(): BaseTexture[];
  44134. /**
  44135. * Checks to see if a texture is used in the material.
  44136. * @param texture - Base texture to use.
  44137. * @returns - Boolean specifying if a texture is used in the material.
  44138. */
  44139. hasTexture(texture: BaseTexture): boolean;
  44140. /**
  44141. * Makes a duplicate of the current material.
  44142. * @param name - name to use for the new material.
  44143. */
  44144. clone(name: string): PBRMaterial;
  44145. /**
  44146. * Serializes this PBR Material.
  44147. * @returns - An object with the serialized material.
  44148. */
  44149. serialize(): any;
  44150. /**
  44151. * Parses a PBR Material from a serialized object.
  44152. * @param source - Serialized object.
  44153. * @param scene - BJS scene instance.
  44154. * @param rootUrl - url for the scene object
  44155. * @returns - PBRMaterial
  44156. */
  44157. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  44158. }
  44159. }
  44160. declare module BABYLON {
  44161. /**
  44162. * The PBR material of BJS following the metal roughness convention.
  44163. *
  44164. * This fits to the PBR convention in the GLTF definition:
  44165. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  44166. */
  44167. class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  44168. /**
  44169. * The base color has two different interpretations depending on the value of metalness.
  44170. * When the material is a metal, the base color is the specific measured reflectance value
  44171. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  44172. * of the material.
  44173. */
  44174. baseColor: Color3;
  44175. /**
  44176. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  44177. * well as opacity information in the alpha channel.
  44178. */
  44179. baseTexture: BaseTexture;
  44180. /**
  44181. * Specifies the metallic scalar value of the material.
  44182. * Can also be used to scale the metalness values of the metallic texture.
  44183. */
  44184. metallic: number;
  44185. /**
  44186. * Specifies the roughness scalar value of the material.
  44187. * Can also be used to scale the roughness values of the metallic texture.
  44188. */
  44189. roughness: number;
  44190. /**
  44191. * Texture containing both the metallic value in the B channel and the
  44192. * roughness value in the G channel to keep better precision.
  44193. */
  44194. metallicRoughnessTexture: BaseTexture;
  44195. /**
  44196. * Instantiates a new PBRMetalRoughnessMaterial instance.
  44197. *
  44198. * @param name The material name
  44199. * @param scene The scene the material will be use in.
  44200. */
  44201. constructor(name: string, scene: Scene);
  44202. /**
  44203. * Return the currrent class name of the material.
  44204. */
  44205. getClassName(): string;
  44206. /**
  44207. * Return the active textures of the material.
  44208. */
  44209. getActiveTextures(): BaseTexture[];
  44210. /**
  44211. * Checks to see if a texture is used in the material.
  44212. * @param texture - Base texture to use.
  44213. * @returns - Boolean specifying if a texture is used in the material.
  44214. */
  44215. hasTexture(texture: BaseTexture): boolean;
  44216. /**
  44217. * Makes a duplicate of the current material.
  44218. * @param name - name to use for the new material.
  44219. */
  44220. clone(name: string): PBRMetallicRoughnessMaterial;
  44221. /**
  44222. * Serialize the material to a parsable JSON object.
  44223. */
  44224. serialize(): any;
  44225. /**
  44226. * Parses a JSON object correponding to the serialize function.
  44227. */
  44228. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  44229. }
  44230. }
  44231. declare module BABYLON {
  44232. /**
  44233. * The PBR material of BJS following the specular glossiness convention.
  44234. *
  44235. * This fits to the PBR convention in the GLTF definition:
  44236. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  44237. */
  44238. class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  44239. /**
  44240. * Specifies the diffuse color of the material.
  44241. */
  44242. diffuseColor: Color3;
  44243. /**
  44244. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  44245. * channel.
  44246. */
  44247. diffuseTexture: BaseTexture;
  44248. /**
  44249. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  44250. */
  44251. specularColor: Color3;
  44252. /**
  44253. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  44254. */
  44255. glossiness: number;
  44256. /**
  44257. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  44258. */
  44259. specularGlossinessTexture: BaseTexture;
  44260. /**
  44261. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  44262. *
  44263. * @param name The material name
  44264. * @param scene The scene the material will be use in.
  44265. */
  44266. constructor(name: string, scene: Scene);
  44267. /**
  44268. * Return the currrent class name of the material.
  44269. */
  44270. getClassName(): string;
  44271. /**
  44272. * Return the active textures of the material.
  44273. */
  44274. getActiveTextures(): BaseTexture[];
  44275. /**
  44276. * Checks to see if a texture is used in the material.
  44277. * @param texture - Base texture to use.
  44278. * @returns - Boolean specifying if a texture is used in the material.
  44279. */
  44280. hasTexture(texture: BaseTexture): boolean;
  44281. /**
  44282. * Makes a duplicate of the current material.
  44283. * @param name - name to use for the new material.
  44284. */
  44285. clone(name: string): PBRSpecularGlossinessMaterial;
  44286. /**
  44287. * Serialize the material to a parsable JSON object.
  44288. */
  44289. serialize(): any;
  44290. /**
  44291. * Parses a JSON object correponding to the serialize function.
  44292. */
  44293. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  44294. }
  44295. }
  44296. declare module BABYLON {
  44297. /**
  44298. * Base class of all the textures in babylon.
  44299. * It groups all the common properties the materials, post process, lights... might need
  44300. * in order to make a correct use of the texture.
  44301. */
  44302. class BaseTexture {
  44303. /**
  44304. * Default anisotropic filtering level for the application.
  44305. * It is set to 4 as a good tradeoff between perf and quality.
  44306. */
  44307. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  44308. /**
  44309. * Define the name of the texture.
  44310. */
  44311. name: string;
  44312. private _hasAlpha;
  44313. /**
  44314. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  44315. */
  44316. hasAlpha: boolean;
  44317. /**
  44318. * Defines if the alpha value should be determined via the rgb values.
  44319. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  44320. */
  44321. getAlphaFromRGB: boolean;
  44322. /**
  44323. * Intensity or strength of the texture.
  44324. * It is commonly used by materials to fine tune the intensity of the texture
  44325. */
  44326. level: number;
  44327. /**
  44328. * Define the UV chanel to use starting from 0 and defaulting to 0.
  44329. * This is part of the texture as textures usually maps to one uv set.
  44330. */
  44331. coordinatesIndex: number;
  44332. private _coordinatesMode;
  44333. /**
  44334. * How a texture is mapped.
  44335. *
  44336. * | Value | Type | Description |
  44337. * | ----- | ----------------------------------- | ----------- |
  44338. * | 0 | EXPLICIT_MODE | |
  44339. * | 1 | SPHERICAL_MODE | |
  44340. * | 2 | PLANAR_MODE | |
  44341. * | 3 | CUBIC_MODE | |
  44342. * | 4 | PROJECTION_MODE | |
  44343. * | 5 | SKYBOX_MODE | |
  44344. * | 6 | INVCUBIC_MODE | |
  44345. * | 7 | EQUIRECTANGULAR_MODE | |
  44346. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  44347. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  44348. */
  44349. coordinatesMode: number;
  44350. /**
  44351. * | Value | Type | Description |
  44352. * | ----- | ------------------ | ----------- |
  44353. * | 0 | CLAMP_ADDRESSMODE | |
  44354. * | 1 | WRAP_ADDRESSMODE | |
  44355. * | 2 | MIRROR_ADDRESSMODE | |
  44356. */
  44357. wrapU: number;
  44358. /**
  44359. * | Value | Type | Description |
  44360. * | ----- | ------------------ | ----------- |
  44361. * | 0 | CLAMP_ADDRESSMODE | |
  44362. * | 1 | WRAP_ADDRESSMODE | |
  44363. * | 2 | MIRROR_ADDRESSMODE | |
  44364. */
  44365. wrapV: number;
  44366. /**
  44367. * | Value | Type | Description |
  44368. * | ----- | ------------------ | ----------- |
  44369. * | 0 | CLAMP_ADDRESSMODE | |
  44370. * | 1 | WRAP_ADDRESSMODE | |
  44371. * | 2 | MIRROR_ADDRESSMODE | |
  44372. */
  44373. wrapR: number;
  44374. /**
  44375. * With compliant hardware and browser (supporting anisotropic filtering)
  44376. * this defines the level of anisotropic filtering in the texture.
  44377. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  44378. */
  44379. anisotropicFilteringLevel: number;
  44380. /**
  44381. * Define if the texture is a cube texture or if false a 2d texture.
  44382. */
  44383. isCube: boolean;
  44384. /**
  44385. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  44386. */
  44387. is3D: boolean;
  44388. /**
  44389. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  44390. * HDR texture are usually stored in linear space.
  44391. * This only impacts the PBR and Background materials
  44392. */
  44393. gammaSpace: boolean;
  44394. /**
  44395. * Gets whether or not the texture contains RGBD data.
  44396. */
  44397. readonly isRGBD: boolean;
  44398. /**
  44399. * Is Z inverted in the texture (useful in a cube texture).
  44400. */
  44401. invertZ: boolean;
  44402. /**
  44403. * @hidden
  44404. */
  44405. lodLevelInAlpha: boolean;
  44406. /**
  44407. * With prefiltered texture, defined the offset used during the prefiltering steps.
  44408. */
  44409. lodGenerationOffset: number;
  44410. /**
  44411. * With prefiltered texture, defined the scale used during the prefiltering steps.
  44412. */
  44413. lodGenerationScale: number;
  44414. /**
  44415. * Define if the texture is a render target.
  44416. */
  44417. isRenderTarget: boolean;
  44418. /**
  44419. * Define the unique id of the texture in the scene.
  44420. */
  44421. readonly uid: string;
  44422. /**
  44423. * Return a string representation of the texture.
  44424. * @returns the texture as a string
  44425. */
  44426. toString(): string;
  44427. /**
  44428. * Get the class name of the texture.
  44429. * @returns "BaseTexture"
  44430. */
  44431. getClassName(): string;
  44432. /**
  44433. * Define the list of animation attached to the texture.
  44434. */
  44435. animations: Animation[];
  44436. /**
  44437. * An event triggered when the texture is disposed.
  44438. */
  44439. onDisposeObservable: Observable<BaseTexture>;
  44440. private _onDisposeObserver;
  44441. /**
  44442. * Callback triggered when the texture has been disposed.
  44443. * Kept for back compatibility, you can use the onDisposeObservable instead.
  44444. */
  44445. onDispose: () => void;
  44446. /**
  44447. * Define the current state of the loading sequence when in delayed load mode.
  44448. */
  44449. delayLoadState: number;
  44450. private _scene;
  44451. /** @hidden */
  44452. private _uid;
  44453. /**
  44454. * Define if the texture is preventinga material to render or not.
  44455. * If not and the texture is not ready, the engine will use a default black texture instead.
  44456. */
  44457. readonly isBlocking: boolean;
  44458. /**
  44459. * Instantiates a new BaseTexture.
  44460. * Base class of all the textures in babylon.
  44461. * It groups all the common properties the materials, post process, lights... might need
  44462. * in order to make a correct use of the texture.
  44463. * @param scene Define the scene the texture blongs to
  44464. */
  44465. constructor(scene: Nullable<Scene>);
  44466. /**
  44467. * Get the scene the texture belongs to.
  44468. * @returns the scene or null if undefined
  44469. */
  44470. getScene(): Nullable<Scene>;
  44471. /**
  44472. * Get the texture transform matrix used to offset tile the texture for istance.
  44473. * @returns the transformation matrix
  44474. */
  44475. getTextureMatrix(): Matrix;
  44476. /**
  44477. * Get the texture reflection matrix used to rotate/transform the reflection.
  44478. * @returns the reflection matrix
  44479. */
  44480. getReflectionTextureMatrix(): Matrix;
  44481. /**
  44482. * Get the underlying lower level texture from Babylon.
  44483. * @returns the insternal texture
  44484. */
  44485. getInternalTexture(): Nullable<InternalTexture>;
  44486. /**
  44487. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  44488. * @returns true if ready or not blocking
  44489. */
  44490. isReadyOrNotBlocking(): boolean;
  44491. /**
  44492. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  44493. * @returns true if fully ready
  44494. */
  44495. isReady(): boolean;
  44496. private _cachedSize;
  44497. /**
  44498. * Get the size of the texture.
  44499. * @returns the texture size.
  44500. */
  44501. getSize(): ISize;
  44502. /**
  44503. * Get the base size of the texture.
  44504. * It can be different from the size if the texture has been resized for POT for instance
  44505. * @returns the base size
  44506. */
  44507. getBaseSize(): ISize;
  44508. /**
  44509. * Scales the texture if is `canRescale()`
  44510. * @param ratio the resize factor we want to use to rescale
  44511. */
  44512. scale(ratio: number): void;
  44513. /**
  44514. * Get if the texture can rescale.
  44515. */
  44516. readonly canRescale: boolean;
  44517. /** @hidden */
  44518. /** @hidden */
  44519. /**
  44520. * Triggers the load sequence in delayed load mode.
  44521. */
  44522. delayLoad(): void;
  44523. /**
  44524. * Clones the texture.
  44525. * @returns the cloned texture
  44526. */
  44527. clone(): Nullable<BaseTexture>;
  44528. /**
  44529. * Get the texture underlying type (INT, FLOAT...)
  44530. */
  44531. readonly textureType: number;
  44532. /**
  44533. * Get the texture underlying format (RGB, RGBA...)
  44534. */
  44535. readonly textureFormat: number;
  44536. /**
  44537. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  44538. * This will returns an RGBA array buffer containing either in values (0-255) or
  44539. * float values (0-1) depending of the underlying buffer type.
  44540. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  44541. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  44542. * @param buffer defines a user defined buffer to fill with data (can be null)
  44543. * @returns The Array buffer containing the pixels data.
  44544. */
  44545. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  44546. /**
  44547. * Release and destroy the underlying lower level texture aka internalTexture.
  44548. */
  44549. releaseInternalTexture(): void;
  44550. /**
  44551. * Get the polynomial representation of the texture data.
  44552. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  44553. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  44554. */
  44555. sphericalPolynomial: Nullable<SphericalPolynomial>;
  44556. /** @hidden */
  44557. protected readonly _lodTextureHigh: Nullable<BaseTexture>;
  44558. /** @hidden */
  44559. protected readonly _lodTextureMid: Nullable<BaseTexture>;
  44560. /** @hidden */
  44561. protected readonly _lodTextureLow: Nullable<BaseTexture>;
  44562. /**
  44563. * Dispose the texture and release its associated resources.
  44564. */
  44565. dispose(): void;
  44566. /**
  44567. * Serialize the texture into a JSON representation that can be parsed later on.
  44568. * @returns the JSON representation of the texture
  44569. */
  44570. serialize(): any;
  44571. /**
  44572. * Helper function to be called back once a list of texture contains only ready textures.
  44573. * @param textures Define the list of textures to wait for
  44574. * @param callback Define the callback triggered once the entire list will be ready
  44575. */
  44576. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  44577. }
  44578. }
  44579. declare module BABYLON {
  44580. /**
  44581. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  44582. * It can help converting any input color in a desired output one. This can then be used to create effects
  44583. * from sepia, black and white to sixties or futuristic rendering...
  44584. *
  44585. * The only supported format is currently 3dl.
  44586. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  44587. */
  44588. class ColorGradingTexture extends BaseTexture {
  44589. /**
  44590. * The current texture matrix. (will always be identity in color grading texture)
  44591. */
  44592. private _textureMatrix;
  44593. /**
  44594. * The texture URL.
  44595. */
  44596. url: string;
  44597. /**
  44598. * Empty line regex stored for GC.
  44599. */
  44600. private static _noneEmptyLineRegex;
  44601. private _engine;
  44602. /**
  44603. * Instantiates a ColorGradingTexture from the following parameters.
  44604. *
  44605. * @param url The location of the color gradind data (currently only supporting 3dl)
  44606. * @param scene The scene the texture will be used in
  44607. */
  44608. constructor(url: string, scene: Scene);
  44609. /**
  44610. * Returns the texture matrix used in most of the material.
  44611. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  44612. */
  44613. getTextureMatrix(): Matrix;
  44614. /**
  44615. * Occurs when the file being loaded is a .3dl LUT file.
  44616. */
  44617. private load3dlTexture;
  44618. /**
  44619. * Starts the loading process of the texture.
  44620. */
  44621. private loadTexture;
  44622. /**
  44623. * Clones the color gradind texture.
  44624. */
  44625. clone(): ColorGradingTexture;
  44626. /**
  44627. * Called during delayed load for textures.
  44628. */
  44629. delayLoad(): void;
  44630. /**
  44631. * Parses a color grading texture serialized by Babylon.
  44632. * @param parsedTexture The texture information being parsedTexture
  44633. * @param scene The scene to load the texture in
  44634. * @param rootUrl The root url of the data assets to load
  44635. * @return A color gradind texture
  44636. */
  44637. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<ColorGradingTexture>;
  44638. /**
  44639. * Serializes the LUT texture to json format.
  44640. */
  44641. serialize(): any;
  44642. }
  44643. }
  44644. declare module BABYLON {
  44645. /**
  44646. * Class for creating a cube texture
  44647. */
  44648. class CubeTexture extends BaseTexture {
  44649. /**
  44650. * The url of the texture
  44651. */
  44652. url: string;
  44653. /**
  44654. * Gets or sets the center of the bounding box associated with the cube texture.
  44655. * It must define where the camera used to render the texture was set
  44656. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  44657. */
  44658. boundingBoxPosition: Vector3;
  44659. private _boundingBoxSize;
  44660. /**
  44661. * Gets or sets the size of the bounding box associated with the cube texture
  44662. * When defined, the cubemap will switch to local mode
  44663. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  44664. * @example https://www.babylonjs-playground.com/#RNASML
  44665. */
  44666. /**
  44667. * Returns the bounding box size
  44668. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  44669. */
  44670. boundingBoxSize: Vector3;
  44671. protected _rotationY: number;
  44672. /**
  44673. * Sets texture matrix rotation angle around Y axis in radians.
  44674. */
  44675. /**
  44676. * Gets texture matrix rotation angle around Y axis radians.
  44677. */
  44678. rotationY: number;
  44679. private _noMipmap;
  44680. private _files;
  44681. private _extensions;
  44682. private _textureMatrix;
  44683. private _format;
  44684. private _createPolynomials;
  44685. /** @hidden */
  44686. protected readonly _prefiltered: boolean;
  44687. /**
  44688. * Creates a cube texture from an array of image urls
  44689. * @param files defines an array of image urls
  44690. * @param scene defines the hosting scene
  44691. * @param noMipmap specifies if mip maps are not used
  44692. * @returns a cube texture
  44693. */
  44694. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  44695. /**
  44696. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  44697. * @param url defines the url of the prefiltered texture
  44698. * @param scene defines the scene the texture is attached to
  44699. * @param forcedExtension defines the extension of the file if different from the url
  44700. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  44701. * @return the prefiltered texture
  44702. */
  44703. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  44704. /**
  44705. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  44706. * as prefiltered data.
  44707. * @param rootUrl defines the url of the texture or the root name of the six images
  44708. * @param scene defines the scene the texture is attached to
  44709. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  44710. * @param noMipmap defines if mipmaps should be created or not
  44711. * @param files defines the six files to load for the different faces
  44712. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  44713. * @param onError defines a callback triggered in case of error during load
  44714. * @param format defines the internal format to use for the texture once loaded
  44715. * @param prefiltered defines whether or not the texture is created from prefiltered data
  44716. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  44717. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  44718. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  44719. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  44720. * @return the cube texture
  44721. */
  44722. 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);
  44723. /**
  44724. * Delays loading of the cube texture
  44725. */
  44726. delayLoad(): void;
  44727. /**
  44728. * Returns the reflection texture matrix
  44729. * @returns the reflection texture matrix
  44730. */
  44731. getReflectionTextureMatrix(): Matrix;
  44732. /**
  44733. * Sets the reflection texture matrix
  44734. * @param value Reflection texture matrix
  44735. */
  44736. setReflectionTextureMatrix(value: Matrix): void;
  44737. /**
  44738. * Parses text to create a cube texture
  44739. * @param parsedTexture define the serialized text to read from
  44740. * @param scene defines the hosting scene
  44741. * @param rootUrl defines the root url of the cube texture
  44742. * @returns a cube texture
  44743. */
  44744. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  44745. /**
  44746. * Makes a clone, or deep copy, of the cube texture
  44747. * @returns a new cube texture
  44748. */
  44749. clone(): CubeTexture;
  44750. }
  44751. }
  44752. declare module BABYLON {
  44753. /**
  44754. * A class extending Texture allowing drawing on a texture
  44755. * @see http://doc.babylonjs.com/how_to/dynamictexture
  44756. */
  44757. class DynamicTexture extends Texture {
  44758. private _generateMipMaps;
  44759. private _canvas;
  44760. private _context;
  44761. private _engine;
  44762. /**
  44763. * Creates a DynamicTexture
  44764. * @param name defines the name of the texture
  44765. * @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
  44766. * @param scene defines the scene where you want the texture
  44767. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  44768. * @param samplingMode defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  44769. * @param format defines the texture format to use (default is BABYLON.Engine.TEXTUREFORMAT_RGBA)
  44770. */
  44771. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  44772. /**
  44773. * Gets the current state of canRescale
  44774. */
  44775. readonly canRescale: boolean;
  44776. private _recreate;
  44777. /**
  44778. * Scales the texture
  44779. * @param ratio the scale factor to apply to both width and height
  44780. */
  44781. scale(ratio: number): void;
  44782. /**
  44783. * Resizes the texture
  44784. * @param width the new width
  44785. * @param height the new height
  44786. */
  44787. scaleTo(width: number, height: number): void;
  44788. /**
  44789. * Gets the context of the canvas used by the texture
  44790. * @returns the canvas context of the dynamic texture
  44791. */
  44792. getContext(): CanvasRenderingContext2D;
  44793. /**
  44794. * Clears the texture
  44795. */
  44796. clear(): void;
  44797. /**
  44798. * Updates the texture
  44799. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  44800. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  44801. */
  44802. update(invertY?: boolean, premulAlpha?: boolean): void;
  44803. /**
  44804. * Draws text onto the texture
  44805. * @param text defines the text to be drawn
  44806. * @param x defines the placement of the text from the left
  44807. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  44808. * @param font defines the font to be used with font-style, font-size, font-name
  44809. * @param color defines the color used for the text
  44810. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  44811. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  44812. * @param update defines whether texture is immediately update (default is true)
  44813. */
  44814. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  44815. /**
  44816. * Clones the texture
  44817. * @returns the clone of the texture.
  44818. */
  44819. clone(): DynamicTexture;
  44820. /**
  44821. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  44822. * @returns a serialized dynamic texture object
  44823. */
  44824. serialize(): any;
  44825. /** @hidden */
  44826. }
  44827. }
  44828. declare module BABYLON {
  44829. /**
  44830. * This represents a texture coming from an HDR input.
  44831. *
  44832. * The only supported format is currently panorama picture stored in RGBE format.
  44833. * Example of such files can be found on HDRLib: http://hdrlib.com/
  44834. */
  44835. class HDRCubeTexture extends BaseTexture {
  44836. private static _facesMapping;
  44837. private _generateHarmonics;
  44838. private _noMipmap;
  44839. private _textureMatrix;
  44840. private _size;
  44841. private _onLoad;
  44842. private _onError;
  44843. /**
  44844. * The texture URL.
  44845. */
  44846. url: string;
  44847. /**
  44848. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  44849. */
  44850. coordinatesMode: number;
  44851. protected _isBlocking: boolean;
  44852. /**
  44853. * Sets wether or not the texture is blocking during loading.
  44854. */
  44855. /**
  44856. * Gets wether or not the texture is blocking during loading.
  44857. */
  44858. isBlocking: boolean;
  44859. protected _rotationY: number;
  44860. /**
  44861. * Sets texture matrix rotation angle around Y axis in radians.
  44862. */
  44863. /**
  44864. * Gets texture matrix rotation angle around Y axis radians.
  44865. */
  44866. rotationY: number;
  44867. /**
  44868. * Gets or sets the center of the bounding box associated with the cube texture
  44869. * It must define where the camera used to render the texture was set
  44870. */
  44871. boundingBoxPosition: Vector3;
  44872. private _boundingBoxSize;
  44873. /**
  44874. * Gets or sets the size of the bounding box associated with the cube texture
  44875. * When defined, the cubemap will switch to local mode
  44876. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  44877. * @example https://www.babylonjs-playground.com/#RNASML
  44878. */
  44879. boundingBoxSize: Vector3;
  44880. /**
  44881. * Instantiates an HDRTexture from the following parameters.
  44882. *
  44883. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  44884. * @param scene The scene the texture will be used in
  44885. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  44886. * @param noMipmap Forces to not generate the mipmap if true
  44887. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  44888. * @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)
  44889. * @param reserved Reserved flag for internal use.
  44890. */
  44891. 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>);
  44892. /**
  44893. * Occurs when the file is raw .hdr file.
  44894. */
  44895. private loadTexture;
  44896. clone(): HDRCubeTexture;
  44897. delayLoad(): void;
  44898. /**
  44899. * Get the texture reflection matrix used to rotate/transform the reflection.
  44900. * @returns the reflection matrix
  44901. */
  44902. getReflectionTextureMatrix(): Matrix;
  44903. /**
  44904. * Set the texture reflection matrix used to rotate/transform the reflection.
  44905. * @param value Define the reflection matrix to set
  44906. */
  44907. setReflectionTextureMatrix(value: Matrix): void;
  44908. /**
  44909. * Parses a JSON representation of an HDR Texture in order to create the texture
  44910. * @param parsedTexture Define the JSON representation
  44911. * @param scene Define the scene the texture should be created in
  44912. * @param rootUrl Define the root url in case we need to load relative dependencies
  44913. * @returns the newly created texture after parsing
  44914. */
  44915. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  44916. serialize(): any;
  44917. }
  44918. }
  44919. declare module BABYLON {
  44920. /**
  44921. * Class used to store data associated with WebGL texture data for the engine
  44922. * This class should not be used directly
  44923. */
  44924. class InternalTexture implements IInternalTextureTracker {
  44925. /**
  44926. * The source of the texture data is unknown
  44927. */
  44928. static DATASOURCE_UNKNOWN: number;
  44929. /**
  44930. * Texture data comes from an URL
  44931. */
  44932. static DATASOURCE_URL: number;
  44933. /**
  44934. * Texture data is only used for temporary storage
  44935. */
  44936. static DATASOURCE_TEMP: number;
  44937. /**
  44938. * Texture data comes from raw data (ArrayBuffer)
  44939. */
  44940. static DATASOURCE_RAW: number;
  44941. /**
  44942. * Texture content is dynamic (video or dynamic texture)
  44943. */
  44944. static DATASOURCE_DYNAMIC: number;
  44945. /**
  44946. * Texture content is generated by rendering to it
  44947. */
  44948. static DATASOURCE_RENDERTARGET: number;
  44949. /**
  44950. * Texture content is part of a multi render target process
  44951. */
  44952. static DATASOURCE_MULTIRENDERTARGET: number;
  44953. /**
  44954. * Texture data comes from a cube data file
  44955. */
  44956. static DATASOURCE_CUBE: number;
  44957. /**
  44958. * Texture data comes from a raw cube data
  44959. */
  44960. static DATASOURCE_CUBERAW: number;
  44961. /**
  44962. * Texture data come from a prefiltered cube data file
  44963. */
  44964. static DATASOURCE_CUBEPREFILTERED: number;
  44965. /**
  44966. * Texture content is raw 3D data
  44967. */
  44968. static DATASOURCE_RAW3D: number;
  44969. /**
  44970. * Texture content is a depth texture
  44971. */
  44972. static DATASOURCE_DEPTHTEXTURE: number;
  44973. /**
  44974. * Texture data comes from a raw cube data encoded with RGBD
  44975. */
  44976. static DATASOURCE_CUBERAW_RGBD: number;
  44977. /**
  44978. * Defines if the texture is ready
  44979. */
  44980. isReady: boolean;
  44981. /**
  44982. * Defines if the texture is a cube texture
  44983. */
  44984. isCube: boolean;
  44985. /**
  44986. * Defines if the texture contains 3D data
  44987. */
  44988. is3D: boolean;
  44989. /**
  44990. * Gets the URL used to load this texture
  44991. */
  44992. url: string;
  44993. /**
  44994. * Gets the sampling mode of the texture
  44995. */
  44996. samplingMode: number;
  44997. /**
  44998. * Gets a boolean indicating if the texture needs mipmaps generation
  44999. */
  45000. generateMipMaps: boolean;
  45001. /**
  45002. * Gets the number of samples used by the texture (WebGL2+ only)
  45003. */
  45004. samples: number;
  45005. /**
  45006. * Gets the type of the texture (int, float...)
  45007. */
  45008. type: number;
  45009. /**
  45010. * Gets the format of the texture (RGB, RGBA...)
  45011. */
  45012. format: number;
  45013. /**
  45014. * Observable called when the texture is loaded
  45015. */
  45016. onLoadedObservable: Observable<InternalTexture>;
  45017. /**
  45018. * Gets the width of the texture
  45019. */
  45020. width: number;
  45021. /**
  45022. * Gets the height of the texture
  45023. */
  45024. height: number;
  45025. /**
  45026. * Gets the depth of the texture
  45027. */
  45028. depth: number;
  45029. /**
  45030. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  45031. */
  45032. baseWidth: number;
  45033. /**
  45034. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  45035. */
  45036. baseHeight: number;
  45037. /**
  45038. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  45039. */
  45040. baseDepth: number;
  45041. /**
  45042. * Gets a boolean indicating if the texture is inverted on Y axis
  45043. */
  45044. invertY: boolean;
  45045. /**
  45046. * Gets or set the previous tracker in the list
  45047. */
  45048. previous: Nullable<IInternalTextureTracker>;
  45049. /**
  45050. * Gets or set the next tracker in the list
  45051. */
  45052. next: Nullable<IInternalTextureTracker>;
  45053. /** @hidden */
  45054. /** @hidden */
  45055. /** @hidden */
  45056. /** @hidden */
  45057. /** @hidden */
  45058. /** @hidden */
  45059. /** @hidden */
  45060. /** @hidden */
  45061. /** @hidden */
  45062. /** @hidden */
  45063. /** @hidden */
  45064. /** @hidden */
  45065. /** @hidden */
  45066. /** @hidden */
  45067. /** @hidden */
  45068. /** @hidden */
  45069. /** @hidden */
  45070. /** @hidden */
  45071. /** @hidden */
  45072. /** @hidden */
  45073. /** @hidden */
  45074. /** @hidden */
  45075. /** @hidden */
  45076. /** @hidden */
  45077. /** @hidden */
  45078. /** @hidden */
  45079. /** @hidden */
  45080. /** @hidden */
  45081. /** @hidden */
  45082. /** @hidden */
  45083. /** @hidden */
  45084. /** @hidden */
  45085. /** @hidden */
  45086. /** @hidden */
  45087. /** @hidden */
  45088. /** @hidden */
  45089. private _engine;
  45090. /**
  45091. * Gets the Engine the texture belongs to.
  45092. * @returns The babylon engine
  45093. */
  45094. getEngine(): Engine;
  45095. /**
  45096. * Gets the data source type of the texture (can be one of the BABYLON.InternalTexture.DATASOURCE_XXXX)
  45097. */
  45098. readonly dataSource: number;
  45099. /**
  45100. * Creates a new InternalTexture
  45101. * @param engine defines the engine to use
  45102. * @param dataSource defines the type of data that will be used
  45103. */
  45104. constructor(engine: Engine, dataSource: number);
  45105. /**
  45106. * Increments the number of references (ie. the number of Texture that point to it)
  45107. */
  45108. incrementReferences(): void;
  45109. /**
  45110. * Change the size of the texture (not the size of the content)
  45111. * @param width defines the new width
  45112. * @param height defines the new height
  45113. * @param depth defines the new depth (1 by default)
  45114. */
  45115. updateSize(width: int, height: int, depth?: int): void;
  45116. /** @hidden */
  45117. /** @hidden */
  45118. /**
  45119. * Dispose the current allocated resources
  45120. */
  45121. dispose(): void;
  45122. }
  45123. }
  45124. declare module BABYLON {
  45125. /**
  45126. * This represents the required contract to create a new type of texture loader.
  45127. */
  45128. interface IInternalTextureLoader {
  45129. /**
  45130. * Defines wether the loader supports cascade loading the different faces.
  45131. */
  45132. supportCascades: boolean;
  45133. /**
  45134. * This returns if the loader support the current file information.
  45135. * @param extension defines the file extension of the file being loaded
  45136. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45137. * @param fallback defines the fallback internal texture if any
  45138. * @param isBase64 defines whether the texture is encoded as a base64
  45139. * @param isBuffer defines whether the texture data are stored as a buffer
  45140. * @returns true if the loader can load the specified file
  45141. */
  45142. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  45143. /**
  45144. * Transform the url before loading if required.
  45145. * @param rootUrl the url of the texture
  45146. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45147. * @returns the transformed texture
  45148. */
  45149. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  45150. /**
  45151. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  45152. * @param rootUrl the url of the texture
  45153. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45154. * @returns the fallback texture
  45155. */
  45156. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  45157. /**
  45158. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  45159. * @param data contains the texture data
  45160. * @param texture defines the BabylonJS internal texture
  45161. * @param createPolynomials will be true if polynomials have been requested
  45162. * @param onLoad defines the callback to trigger once the texture is ready
  45163. * @param onError defines the callback to trigger in case of error
  45164. */
  45165. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  45166. /**
  45167. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  45168. * @param data contains the texture data
  45169. * @param texture defines the BabylonJS internal texture
  45170. * @param callback defines the method to call once ready to upload
  45171. */
  45172. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  45173. }
  45174. }
  45175. declare module BABYLON {
  45176. /**
  45177. * Internal interface used to track InternalTexture already bound to the GL context
  45178. */
  45179. interface IInternalTextureTracker {
  45180. /**
  45181. * Gets or set the previous tracker in the list
  45182. */
  45183. previous: Nullable<IInternalTextureTracker>;
  45184. /**
  45185. * Gets or set the next tracker in the list
  45186. */
  45187. next: Nullable<IInternalTextureTracker>;
  45188. }
  45189. /**
  45190. * Internal class used by the engine to get list of InternalTexture already bound to the GL context
  45191. */
  45192. class DummyInternalTextureTracker {
  45193. /**
  45194. * Gets or set the previous tracker in the list
  45195. */
  45196. previous: Nullable<IInternalTextureTracker>;
  45197. /**
  45198. * Gets or set the next tracker in the list
  45199. */
  45200. next: Nullable<IInternalTextureTracker>;
  45201. }
  45202. }
  45203. declare module BABYLON {
  45204. /**
  45205. * Mirror texture can be used to simulate the view from a mirror in a scene.
  45206. * It will dynamically be rendered every frame to adapt to the camera point of view.
  45207. * You can then easily use it as a reflectionTexture on a flat surface.
  45208. * In case the surface is not a plane, please consider relying on reflection probes.
  45209. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  45210. */
  45211. class MirrorTexture extends RenderTargetTexture {
  45212. private scene;
  45213. /**
  45214. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  45215. * It is possible to directly set the mirrorPlane by directly using a BABYLON.Plane(a, b, c, d) where a, b and c give the plane normal vector (a, b, c) and d is a scalar displacement from the mirrorPlane to the origin. However in all but the very simplest of situations it is more straight forward to set it to the reflector as stated in the doc.
  45216. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  45217. */
  45218. mirrorPlane: Plane;
  45219. /**
  45220. * Define the blur ratio used to blur the reflection if needed.
  45221. */
  45222. blurRatio: number;
  45223. /**
  45224. * Define the adaptive blur kernel used to blur the reflection if needed.
  45225. * This will autocompute the closest best match for the `blurKernel`
  45226. */
  45227. adaptiveBlurKernel: number;
  45228. /**
  45229. * Define the blur kernel used to blur the reflection if needed.
  45230. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  45231. */
  45232. blurKernel: number;
  45233. /**
  45234. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  45235. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  45236. */
  45237. blurKernelX: number;
  45238. /**
  45239. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  45240. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  45241. */
  45242. blurKernelY: number;
  45243. private _autoComputeBlurKernel;
  45244. protected _onRatioRescale(): void;
  45245. private _updateGammaSpace;
  45246. private _imageProcessingConfigChangeObserver;
  45247. private _transformMatrix;
  45248. private _mirrorMatrix;
  45249. private _savedViewMatrix;
  45250. private _blurX;
  45251. private _blurY;
  45252. private _adaptiveBlurKernel;
  45253. private _blurKernelX;
  45254. private _blurKernelY;
  45255. private _blurRatio;
  45256. /**
  45257. * Instantiates a Mirror Texture.
  45258. * Mirror texture can be used to simulate the view from a mirror in a scene.
  45259. * It will dynamically be rendered every frame to adapt to the camera point of view.
  45260. * You can then easily use it as a reflectionTexture on a flat surface.
  45261. * In case the surface is not a plane, please consider relying on reflection probes.
  45262. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  45263. * @param name
  45264. * @param size
  45265. * @param scene
  45266. * @param generateMipMaps
  45267. * @param type
  45268. * @param samplingMode
  45269. * @param generateDepthBuffer
  45270. */
  45271. constructor(name: string, size: number | {
  45272. width: number;
  45273. height: number;
  45274. } | {
  45275. ratio: number;
  45276. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  45277. private _preparePostProcesses;
  45278. /**
  45279. * Clone the mirror texture.
  45280. * @returns the cloned texture
  45281. */
  45282. clone(): MirrorTexture;
  45283. /**
  45284. * Serialize the texture to a JSON representation you could use in Parse later on
  45285. * @returns the serialized JSON representation
  45286. */
  45287. serialize(): any;
  45288. /**
  45289. * Dispose the texture and release its associated resources.
  45290. */
  45291. dispose(): void;
  45292. }
  45293. }
  45294. declare module BABYLON {
  45295. /**
  45296. * Creation options of the multi render target texture.
  45297. */
  45298. interface IMultiRenderTargetOptions {
  45299. /**
  45300. * Define if the texture needs to create mip maps after render.
  45301. */
  45302. generateMipMaps?: boolean;
  45303. /**
  45304. * Define the types of all the draw buffers we want to create
  45305. */
  45306. types?: number[];
  45307. /**
  45308. * Define the sampling modes of all the draw buffers we want to create
  45309. */
  45310. samplingModes?: number[];
  45311. /**
  45312. * Define if a depth buffer is required
  45313. */
  45314. generateDepthBuffer?: boolean;
  45315. /**
  45316. * Define if a stencil buffer is required
  45317. */
  45318. generateStencilBuffer?: boolean;
  45319. /**
  45320. * Define if a depth texture is required instead of a depth buffer
  45321. */
  45322. generateDepthTexture?: boolean;
  45323. /**
  45324. * Define the number of desired draw buffers
  45325. */
  45326. textureCount?: number;
  45327. /**
  45328. * Define if aspect ratio should be adapted to the texture or stay the scene one
  45329. */
  45330. doNotChangeAspectRatio?: boolean;
  45331. /**
  45332. * Define the default type of the buffers we are creating
  45333. */
  45334. defaultType?: number;
  45335. }
  45336. /**
  45337. * A multi render target, like a render target provides the ability to render to a texture.
  45338. * Unlike the render target, it can render to several draw buffers in one draw.
  45339. * This is specially interesting in deferred rendering or for any effects requiring more than
  45340. * just one color from a single pass.
  45341. */
  45342. class MultiRenderTarget extends RenderTargetTexture {
  45343. private _internalTextures;
  45344. private _textures;
  45345. private _multiRenderTargetOptions;
  45346. /**
  45347. * Get if draw buffers are currently supported by the used hardware and browser.
  45348. */
  45349. readonly isSupported: boolean;
  45350. /**
  45351. * Get the list of textures generated by the multi render target.
  45352. */
  45353. readonly textures: Texture[];
  45354. /**
  45355. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  45356. */
  45357. readonly depthTexture: Texture;
  45358. /**
  45359. * Set the wrapping mode on U of all the textures we are rendering to.
  45360. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  45361. */
  45362. wrapU: number;
  45363. /**
  45364. * Set the wrapping mode on V of all the textures we are rendering to.
  45365. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  45366. */
  45367. wrapV: number;
  45368. /**
  45369. * Instantiate a new multi render target texture.
  45370. * A multi render target, like a render target provides the ability to render to a texture.
  45371. * Unlike the render target, it can render to several draw buffers in one draw.
  45372. * This is specially interesting in deferred rendering or for any effects requiring more than
  45373. * just one color from a single pass.
  45374. * @param name Define the name of the texture
  45375. * @param size Define the size of the buffers to render to
  45376. * @param count Define the number of target we are rendering into
  45377. * @param scene Define the scene the texture belongs to
  45378. * @param options Define the options used to create the multi render target
  45379. */
  45380. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  45381. /** @hidden */
  45382. private _createInternalTextures;
  45383. private _createTextures;
  45384. /**
  45385. * Define the number of samples used if MSAA is enabled.
  45386. */
  45387. samples: number;
  45388. /**
  45389. * Resize all the textures in the multi render target.
  45390. * Be carrefull as it will recreate all the data in the new texture.
  45391. * @param size Define the new size
  45392. */
  45393. resize(size: any): void;
  45394. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  45395. /**
  45396. * Dispose the render targets and their associated resources
  45397. */
  45398. dispose(): void;
  45399. /**
  45400. * Release all the underlying texture used as draw buffers.
  45401. */
  45402. releaseInternalTextures(): void;
  45403. }
  45404. }
  45405. declare module BABYLON {
  45406. /**
  45407. * Raw cube texture where the raw buffers are passed in
  45408. */
  45409. class RawCubeTexture extends CubeTexture {
  45410. /**
  45411. * Creates a cube texture where the raw buffers are passed in.
  45412. * @param scene defines the scene the texture is attached to
  45413. * @param data defines the array of data to use to create each face
  45414. * @param size defines the size of the textures
  45415. * @param format defines the format of the data
  45416. * @param type defines the type of the data (like BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT)
  45417. * @param generateMipMaps defines if the engine should generate the mip levels
  45418. * @param invertY defines if data must be stored with Y axis inverted
  45419. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  45420. * @param compression defines the compression used (null by default)
  45421. */
  45422. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  45423. /**
  45424. * Updates the raw cube texture.
  45425. * @param data defines the data to store
  45426. * @param format defines the data format
  45427. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  45428. * @param invertY defines if data must be stored with Y axis inverted
  45429. * @param compression defines the compression used (null by default)
  45430. * @param level defines which level of the texture to update
  45431. */
  45432. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  45433. /**
  45434. * Updates a raw cube texture with RGBD encoded data.
  45435. * @param data defines the array of data [mipmap][face] to use to create each face
  45436. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  45437. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  45438. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  45439. * @returns a promsie that resolves when the operation is complete
  45440. */
  45441. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  45442. /**
  45443. * Clones the raw cube texture.
  45444. * @return a new cube texture
  45445. */
  45446. clone(): CubeTexture;
  45447. /** @hidden */
  45448. private static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  45449. }
  45450. }
  45451. declare module BABYLON {
  45452. /**
  45453. * Raw texture can help creating a texture directly from an array of data.
  45454. * This can be super useful if you either get the data from an uncompressed source or
  45455. * if you wish to create your texture pixel by pixel.
  45456. */
  45457. class RawTexture extends Texture {
  45458. /**
  45459. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  45460. */
  45461. format: number;
  45462. private _engine;
  45463. /**
  45464. * Instantiates a new RawTexture.
  45465. * Raw texture can help creating a texture directly from an array of data.
  45466. * This can be super useful if you either get the data from an uncompressed source or
  45467. * if you wish to create your texture pixel by pixel.
  45468. * @param data define the array of data to use to create the texture
  45469. * @param width define the width of the texture
  45470. * @param height define the height of the texture
  45471. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  45472. * @param scene define the scene the texture belongs to
  45473. * @param generateMipMaps define whether mip maps should be generated or not
  45474. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  45475. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  45476. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  45477. */
  45478. constructor(data: ArrayBufferView, width: number, height: number,
  45479. /**
  45480. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  45481. */
  45482. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  45483. /**
  45484. * Updates the texture underlying data.
  45485. * @param data Define the new data of the texture
  45486. */
  45487. update(data: ArrayBufferView): void;
  45488. /**
  45489. * Creates a luminance texture from some data.
  45490. * @param data Define the texture data
  45491. * @param width Define the width of the texture
  45492. * @param height Define the height of the texture
  45493. * @param scene Define the scene the texture belongs to
  45494. * @param generateMipMaps Define whether or not to create mip maps for the texture
  45495. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  45496. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  45497. * @returns the luminance texture
  45498. */
  45499. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  45500. /**
  45501. * Creates a luminance alpha texture from some data.
  45502. * @param data Define the texture data
  45503. * @param width Define the width of the texture
  45504. * @param height Define the height of the texture
  45505. * @param scene Define the scene the texture belongs to
  45506. * @param generateMipMaps Define whether or not to create mip maps for the texture
  45507. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  45508. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  45509. * @returns the luminance alpha texture
  45510. */
  45511. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  45512. /**
  45513. * Creates an alpha texture from some data.
  45514. * @param data Define the texture data
  45515. * @param width Define the width of the texture
  45516. * @param height Define the height of the texture
  45517. * @param scene Define the scene the texture belongs to
  45518. * @param generateMipMaps Define whether or not to create mip maps for the texture
  45519. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  45520. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  45521. * @returns the alpha texture
  45522. */
  45523. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  45524. /**
  45525. * Creates a RGB texture from some data.
  45526. * @param data Define the texture data
  45527. * @param width Define the width of the texture
  45528. * @param height Define the height of the texture
  45529. * @param scene Define the scene the texture belongs to
  45530. * @param generateMipMaps Define whether or not to create mip maps for the texture
  45531. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  45532. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  45533. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  45534. * @returns the RGB alpha texture
  45535. */
  45536. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  45537. /**
  45538. * Creates a RGBA texture from some data.
  45539. * @param data Define the texture data
  45540. * @param width Define the width of the texture
  45541. * @param height Define the height of the texture
  45542. * @param scene Define the scene the texture belongs to
  45543. * @param generateMipMaps Define whether or not to create mip maps for the texture
  45544. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  45545. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  45546. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  45547. * @returns the RGBA texture
  45548. */
  45549. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  45550. /**
  45551. * Creates a R texture from some data.
  45552. * @param data Define the texture data
  45553. * @param width Define the width of the texture
  45554. * @param height Define the height of the texture
  45555. * @param scene Define the scene the texture belongs to
  45556. * @param generateMipMaps Define whether or not to create mip maps for the texture
  45557. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  45558. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  45559. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  45560. * @returns the R texture
  45561. */
  45562. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  45563. }
  45564. }
  45565. declare module BABYLON {
  45566. /**
  45567. * Class used to store 3D textures containing user data
  45568. */
  45569. class RawTexture3D extends Texture {
  45570. /** Gets or sets the texture format to use */
  45571. format: number;
  45572. private _engine;
  45573. /**
  45574. * Create a new RawTexture3D
  45575. * @param data defines the data of the texture
  45576. * @param width defines the width of the texture
  45577. * @param height defines the height of the texture
  45578. * @param depth defines the depth of the texture
  45579. * @param format defines the texture format to use
  45580. * @param scene defines the hosting scene
  45581. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  45582. * @param invertY defines if texture must be stored with Y axis inverted
  45583. * @param samplingMode defines the sampling mode to use (BABYLON.Texture.TRILINEAR_SAMPLINGMODE by default)
  45584. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  45585. */
  45586. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  45587. /** Gets or sets the texture format to use */
  45588. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  45589. /**
  45590. * Update the texture with new data
  45591. * @param data defines the data to store in the texture
  45592. */
  45593. update(data: ArrayBufferView): void;
  45594. }
  45595. }
  45596. declare module BABYLON {
  45597. /**
  45598. * Creates a refraction texture used by refraction channel of the standard material.
  45599. * It is like a mirror but to see through a material.
  45600. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  45601. */
  45602. class RefractionTexture extends RenderTargetTexture {
  45603. /**
  45604. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  45605. * It is possible to directly set the refractionPlane by directly using a BABYLON.Plane(a, b, c, d) where a, b and c give the plane normal vector (a, b, c) and d is a scalar displacement from the refractionPlane to the origin. However in all but the very simplest of situations it is more straight forward to set it to the refractor as stated in the doc.
  45606. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  45607. */
  45608. refractionPlane: Plane;
  45609. /**
  45610. * Define how deep under the surface we should see.
  45611. */
  45612. depth: number;
  45613. /**
  45614. * Creates a refraction texture used by refraction channel of the standard material.
  45615. * It is like a mirror but to see through a material.
  45616. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  45617. * @param name Define the texture name
  45618. * @param size Define the size of the underlying texture
  45619. * @param scene Define the scene the refraction belongs to
  45620. * @param generateMipMaps Define if we need to generate mips level for the refraction
  45621. */
  45622. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  45623. /**
  45624. * Clone the refraction texture.
  45625. * @returns the cloned texture
  45626. */
  45627. clone(): RefractionTexture;
  45628. /**
  45629. * Serialize the texture to a JSON representation you could use in Parse later on
  45630. * @returns the serialized JSON representation
  45631. */
  45632. serialize(): any;
  45633. }
  45634. }
  45635. declare module BABYLON {
  45636. /**
  45637. * This Helps creating a texture that will be created from a camera in your scene.
  45638. * It is basically a dynamic texture that could be used to create special effects for instance.
  45639. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  45640. */
  45641. class RenderTargetTexture extends Texture {
  45642. isCube: boolean;
  45643. /**
  45644. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  45645. */
  45646. static readonly REFRESHRATE_RENDER_ONCE: number;
  45647. /**
  45648. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  45649. */
  45650. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  45651. /**
  45652. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  45653. * the central point of your effect and can save a lot of performances.
  45654. */
  45655. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  45656. /**
  45657. * Use this predicate to dynamically define the list of mesh you want to render.
  45658. * If set, the renderList property will be overwritten.
  45659. */
  45660. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  45661. private _renderList;
  45662. /**
  45663. * Use this list to define the list of mesh you want to render.
  45664. */
  45665. renderList: Nullable<Array<AbstractMesh>>;
  45666. private _hookArray;
  45667. /**
  45668. * Define if particles should be rendered in your texture.
  45669. */
  45670. renderParticles: boolean;
  45671. /**
  45672. * Define if sprites should be rendered in your texture.
  45673. */
  45674. renderSprites: boolean;
  45675. /**
  45676. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  45677. */
  45678. coordinatesMode: number;
  45679. /**
  45680. * Define the camera used to render the texture.
  45681. */
  45682. activeCamera: Nullable<Camera>;
  45683. /**
  45684. * Override the render function of the texture with your own one.
  45685. */
  45686. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  45687. /**
  45688. * Define if camera post processes should be use while rendering the texture.
  45689. */
  45690. useCameraPostProcesses: boolean;
  45691. /**
  45692. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  45693. */
  45694. ignoreCameraViewport: boolean;
  45695. private _postProcessManager;
  45696. private _postProcesses;
  45697. private _resizeObserver;
  45698. /**
  45699. * An event triggered when the texture is unbind.
  45700. */
  45701. onBeforeBindObservable: Observable<RenderTargetTexture>;
  45702. /**
  45703. * An event triggered when the texture is unbind.
  45704. */
  45705. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  45706. private _onAfterUnbindObserver;
  45707. /**
  45708. * Set a after unbind callback in the texture.
  45709. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  45710. */
  45711. onAfterUnbind: () => void;
  45712. /**
  45713. * An event triggered before rendering the texture
  45714. */
  45715. onBeforeRenderObservable: Observable<number>;
  45716. private _onBeforeRenderObserver;
  45717. /**
  45718. * Set a before render callback in the texture.
  45719. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  45720. */
  45721. onBeforeRender: (faceIndex: number) => void;
  45722. /**
  45723. * An event triggered after rendering the texture
  45724. */
  45725. onAfterRenderObservable: Observable<number>;
  45726. private _onAfterRenderObserver;
  45727. /**
  45728. * Set a after render callback in the texture.
  45729. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  45730. */
  45731. onAfterRender: (faceIndex: number) => void;
  45732. /**
  45733. * An event triggered after the texture clear
  45734. */
  45735. onClearObservable: Observable<Engine>;
  45736. private _onClearObserver;
  45737. /**
  45738. * Set a clear callback in the texture.
  45739. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  45740. */
  45741. onClear: (Engine: Engine) => void;
  45742. /**
  45743. * Define the clear color of the Render Target if it should be different from the scene.
  45744. */
  45745. clearColor: Color4;
  45746. protected _size: number | {
  45747. width: number;
  45748. height: number;
  45749. };
  45750. protected _initialSizeParameter: number | {
  45751. width: number;
  45752. height: number;
  45753. } | {
  45754. ratio: number;
  45755. };
  45756. protected _sizeRatio: Nullable<number>;
  45757. /** @hidden */
  45758. protected _renderingManager: RenderingManager;
  45759. /** @hidden */
  45760. protected _doNotChangeAspectRatio: boolean;
  45761. protected _currentRefreshId: number;
  45762. protected _refreshRate: number;
  45763. protected _textureMatrix: Matrix;
  45764. protected _samples: number;
  45765. protected _renderTargetOptions: RenderTargetCreationOptions;
  45766. /**
  45767. * Gets render target creation options that were used.
  45768. */
  45769. readonly renderTargetOptions: RenderTargetCreationOptions;
  45770. protected _engine: Engine;
  45771. protected _onRatioRescale(): void;
  45772. /**
  45773. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  45774. * It must define where the camera used to render the texture is set
  45775. */
  45776. boundingBoxPosition: Vector3;
  45777. private _boundingBoxSize;
  45778. /**
  45779. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  45780. * When defined, the cubemap will switch to local mode
  45781. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  45782. * @example https://www.babylonjs-playground.com/#RNASML
  45783. */
  45784. boundingBoxSize: Vector3;
  45785. /**
  45786. * In case the RTT has been created with a depth texture, get the associated
  45787. * depth texture.
  45788. * Otherwise, return null.
  45789. */
  45790. depthStencilTexture: Nullable<InternalTexture>;
  45791. /**
  45792. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  45793. * or used a shadow, depth texture...
  45794. * @param name The friendly name of the texture
  45795. * @param size The size of the RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  45796. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  45797. * @param generateMipMaps True if mip maps need to be generated after render.
  45798. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  45799. * @param type The type of the buffer in the RTT (int, half float, float...)
  45800. * @param isCube True if a cube texture needs to be created
  45801. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  45802. * @param generateDepthBuffer True to generate a depth buffer
  45803. * @param generateStencilBuffer True to generate a stencil buffer
  45804. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  45805. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  45806. */
  45807. constructor(name: string, size: number | {
  45808. width: number;
  45809. height: number;
  45810. } | {
  45811. ratio: number;
  45812. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number);
  45813. /**
  45814. * Creates a depth stencil texture.
  45815. * This is only available in WebGL 2 or with the depth texture extension available.
  45816. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  45817. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  45818. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  45819. */
  45820. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  45821. private _processSizeParameter;
  45822. /**
  45823. * Define the number of samples to use in case of MSAA.
  45824. * It defaults to one meaning no MSAA has been enabled.
  45825. */
  45826. samples: number;
  45827. /**
  45828. * Resets the refresh counter of the texture and start bak from scratch.
  45829. * Could be usefull to regenerate the texture if it is setup to render only once.
  45830. */
  45831. resetRefreshCounter(): void;
  45832. /**
  45833. * Define the refresh rate of the texture or the rendering frequency.
  45834. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  45835. */
  45836. refreshRate: number;
  45837. /**
  45838. * Adds a post process to the render target rendering passes.
  45839. * @param postProcess define the post process to add
  45840. */
  45841. addPostProcess(postProcess: PostProcess): void;
  45842. /**
  45843. * Clear all the post processes attached to the render target
  45844. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  45845. */
  45846. clearPostProcesses(dispose?: boolean): void;
  45847. /**
  45848. * Remove one of the post process from the list of attached post processes to the texture
  45849. * @param postProcess define the post process to remove from the list
  45850. */
  45851. removePostProcess(postProcess: PostProcess): void;
  45852. /** @hidden */
  45853. /**
  45854. * Gets the actual render size of the texture.
  45855. * @returns the width of the render size
  45856. */
  45857. getRenderSize(): number;
  45858. /**
  45859. * Gets the actual render width of the texture.
  45860. * @returns the width of the render size
  45861. */
  45862. getRenderWidth(): number;
  45863. /**
  45864. * Gets the actual render height of the texture.
  45865. * @returns the height of the render size
  45866. */
  45867. getRenderHeight(): number;
  45868. /**
  45869. * Get if the texture can be rescaled or not.
  45870. */
  45871. readonly canRescale: boolean;
  45872. /**
  45873. * Resize the texture using a ratio.
  45874. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  45875. */
  45876. scale(ratio: number): void;
  45877. /**
  45878. * Get the texture reflection matrix used to rotate/transform the reflection.
  45879. * @returns the reflection matrix
  45880. */
  45881. getReflectionTextureMatrix(): Matrix;
  45882. /**
  45883. * Resize the texture to a new desired size.
  45884. * Be carrefull as it will recreate all the data in the new texture.
  45885. * @param size Define the new size. It can be:
  45886. * - a number for squared texture,
  45887. * - an object containing { width: number, height: number }
  45888. * - or an object containing a ratio { ratio: number }
  45889. */
  45890. resize(size: number | {
  45891. width: number;
  45892. height: number;
  45893. } | {
  45894. ratio: number;
  45895. }): void;
  45896. /**
  45897. * Renders all the objects from the render list into the texture.
  45898. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  45899. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  45900. */
  45901. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  45902. private _bestReflectionRenderTargetDimension;
  45903. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  45904. private renderToTarget;
  45905. /**
  45906. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  45907. * This allowed control for front to back rendering or reversly depending of the special needs.
  45908. *
  45909. * @param renderingGroupId The rendering group id corresponding to its index
  45910. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  45911. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  45912. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  45913. */
  45914. 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;
  45915. /**
  45916. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  45917. *
  45918. * @param renderingGroupId The rendering group id corresponding to its index
  45919. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  45920. */
  45921. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  45922. /**
  45923. * Clones the texture.
  45924. * @returns the cloned texture
  45925. */
  45926. clone(): RenderTargetTexture;
  45927. /**
  45928. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  45929. * @returns The JSON representation of the texture
  45930. */
  45931. serialize(): any;
  45932. /**
  45933. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  45934. */
  45935. disposeFramebufferObjects(): void;
  45936. /**
  45937. * Dispose the texture and release its associated resources.
  45938. */
  45939. dispose(): void;
  45940. /** @hidden */
  45941. /**
  45942. * Clear the info related to rendering groups preventing retention point in material dispose.
  45943. */
  45944. freeRenderingGroups(): void;
  45945. }
  45946. }
  45947. declare module BABYLON {
  45948. /**
  45949. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  45950. * @see http://doc.babylonjs.com/babylon101/materials#texture
  45951. */
  45952. class Texture extends BaseTexture {
  45953. /** nearest is mag = nearest and min = nearest and mip = linear */
  45954. static readonly NEAREST_SAMPLINGMODE: number;
  45955. /** nearest is mag = nearest and min = nearest and mip = linear */
  45956. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  45957. /** Bilinear is mag = linear and min = linear and mip = nearest */
  45958. static readonly BILINEAR_SAMPLINGMODE: number;
  45959. /** Bilinear is mag = linear and min = linear and mip = nearest */
  45960. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  45961. /** Trilinear is mag = linear and min = linear and mip = linear */
  45962. static readonly TRILINEAR_SAMPLINGMODE: number;
  45963. /** Trilinear is mag = linear and min = linear and mip = linear */
  45964. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  45965. /** mag = nearest and min = nearest and mip = nearest */
  45966. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  45967. /** mag = nearest and min = linear and mip = nearest */
  45968. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  45969. /** mag = nearest and min = linear and mip = linear */
  45970. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  45971. /** mag = nearest and min = linear and mip = none */
  45972. static readonly NEAREST_LINEAR: number;
  45973. /** mag = nearest and min = nearest and mip = none */
  45974. static readonly NEAREST_NEAREST: number;
  45975. /** mag = linear and min = nearest and mip = nearest */
  45976. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  45977. /** mag = linear and min = nearest and mip = linear */
  45978. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  45979. /** mag = linear and min = linear and mip = none */
  45980. static readonly LINEAR_LINEAR: number;
  45981. /** mag = linear and min = nearest and mip = none */
  45982. static readonly LINEAR_NEAREST: number;
  45983. /** Explicit coordinates mode */
  45984. static readonly EXPLICIT_MODE: number;
  45985. /** Spherical coordinates mode */
  45986. static readonly SPHERICAL_MODE: number;
  45987. /** Planar coordinates mode */
  45988. static readonly PLANAR_MODE: number;
  45989. /** Cubic coordinates mode */
  45990. static readonly CUBIC_MODE: number;
  45991. /** Projection coordinates mode */
  45992. static readonly PROJECTION_MODE: number;
  45993. /** Inverse Cubic coordinates mode */
  45994. static readonly SKYBOX_MODE: number;
  45995. /** Inverse Cubic coordinates mode */
  45996. static readonly INVCUBIC_MODE: number;
  45997. /** Equirectangular coordinates mode */
  45998. static readonly EQUIRECTANGULAR_MODE: number;
  45999. /** Equirectangular Fixed coordinates mode */
  46000. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  46001. /** Equirectangular Fixed Mirrored coordinates mode */
  46002. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  46003. /** Texture is not repeating outside of 0..1 UVs */
  46004. static readonly CLAMP_ADDRESSMODE: number;
  46005. /** Texture is repeating outside of 0..1 UVs */
  46006. static readonly WRAP_ADDRESSMODE: number;
  46007. /** Texture is repeating and mirrored */
  46008. static readonly MIRROR_ADDRESSMODE: number;
  46009. /**
  46010. * 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
  46011. */
  46012. static UseSerializedUrlIfAny: boolean;
  46013. /**
  46014. * Define the url of the texture.
  46015. */
  46016. url: Nullable<string>;
  46017. /**
  46018. * Define an offset on the texture to offset the u coordinates of the UVs
  46019. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  46020. */
  46021. uOffset: number;
  46022. /**
  46023. * Define an offset on the texture to offset the v coordinates of the UVs
  46024. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  46025. */
  46026. vOffset: number;
  46027. /**
  46028. * Define an offset on the texture to scale the u coordinates of the UVs
  46029. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  46030. */
  46031. uScale: number;
  46032. /**
  46033. * Define an offset on the texture to scale the v coordinates of the UVs
  46034. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  46035. */
  46036. vScale: number;
  46037. /**
  46038. * Define an offset on the texture to rotate around the u coordinates of the UVs
  46039. * @see http://doc.babylonjs.com/how_to/more_materials
  46040. */
  46041. uAng: number;
  46042. /**
  46043. * Define an offset on the texture to rotate around the v coordinates of the UVs
  46044. * @see http://doc.babylonjs.com/how_to/more_materials
  46045. */
  46046. vAng: number;
  46047. /**
  46048. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  46049. * @see http://doc.babylonjs.com/how_to/more_materials
  46050. */
  46051. wAng: number;
  46052. /**
  46053. * Defines the center of rotation (U)
  46054. */
  46055. uRotationCenter: number;
  46056. /**
  46057. * Defines the center of rotation (V)
  46058. */
  46059. vRotationCenter: number;
  46060. /**
  46061. * Defines the center of rotation (W)
  46062. */
  46063. wRotationCenter: number;
  46064. /**
  46065. * Are mip maps generated for this texture or not.
  46066. */
  46067. readonly noMipmap: boolean;
  46068. private _noMipmap;
  46069. /** @hidden */
  46070. private _rowGenerationMatrix;
  46071. private _cachedTextureMatrix;
  46072. private _projectionModeMatrix;
  46073. private _t0;
  46074. private _t1;
  46075. private _t2;
  46076. private _cachedUOffset;
  46077. private _cachedVOffset;
  46078. private _cachedUScale;
  46079. private _cachedVScale;
  46080. private _cachedUAng;
  46081. private _cachedVAng;
  46082. private _cachedWAng;
  46083. private _cachedProjectionMatrixId;
  46084. private _cachedCoordinatesMode;
  46085. /** @hidden */
  46086. /** @hidden */
  46087. private _deleteBuffer;
  46088. protected _format: Nullable<number>;
  46089. private _delayedOnLoad;
  46090. private _delayedOnError;
  46091. /**
  46092. * Observable triggered once the texture has been loaded.
  46093. */
  46094. onLoadObservable: Observable<Texture>;
  46095. protected _isBlocking: boolean;
  46096. /**
  46097. * Is the texture preventing material to render while loading.
  46098. * If false, a default texture will be used instead of the loading one during the preparation step.
  46099. */
  46100. isBlocking: boolean;
  46101. /**
  46102. * Get the current sampling mode associated with the texture.
  46103. */
  46104. readonly samplingMode: number;
  46105. /**
  46106. * Instantiates a new texture.
  46107. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  46108. * @see http://doc.babylonjs.com/babylon101/materials#texture
  46109. * @param url define the url of the picture to load as a texture
  46110. * @param scene define the scene the texture will belong to
  46111. * @param noMipmap define if the texture will require mip maps or not
  46112. * @param invertY define if the texture needs to be inverted on the y axis during loading
  46113. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  46114. * @param onLoad define a callback triggered when the texture has been loaded
  46115. * @param onError define a callback triggered when an error occurred during the loading session
  46116. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  46117. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  46118. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  46119. */
  46120. 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);
  46121. /**
  46122. * Update the url (and optional buffer) of this texture if url was null during construction.
  46123. * @param url the url of the texture
  46124. * @param buffer the buffer of the texture (defaults to null)
  46125. */
  46126. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>): void;
  46127. /**
  46128. * Finish the loading sequence of a texture flagged as delayed load.
  46129. * @hidden
  46130. */
  46131. delayLoad(): void;
  46132. /**
  46133. * Update the sampling mode of the texture.
  46134. * Default is Trilinear mode.
  46135. *
  46136. * | Value | Type | Description |
  46137. * | ----- | ------------------ | ----------- |
  46138. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  46139. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  46140. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  46141. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  46142. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  46143. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  46144. * | 7 | NEAREST_LINEAR | |
  46145. * | 8 | NEAREST_NEAREST | |
  46146. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  46147. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  46148. * | 11 | LINEAR_LINEAR | |
  46149. * | 12 | LINEAR_NEAREST | |
  46150. *
  46151. * > _mag_: magnification filter (close to the viewer)
  46152. * > _min_: minification filter (far from the viewer)
  46153. * > _mip_: filter used between mip map levels
  46154. *@param samplingMode Define the new sampling mode of the texture
  46155. */
  46156. updateSamplingMode(samplingMode: number): void;
  46157. private _prepareRowForTextureGeneration;
  46158. /**
  46159. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  46160. * @returns the transform matrix of the texture.
  46161. */
  46162. getTextureMatrix(): Matrix;
  46163. /**
  46164. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  46165. * @returns The reflection texture transform
  46166. */
  46167. getReflectionTextureMatrix(): Matrix;
  46168. /**
  46169. * Clones the texture.
  46170. * @returns the cloned texture
  46171. */
  46172. clone(): Texture;
  46173. /**
  46174. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  46175. * @returns The JSON representation of the texture
  46176. */
  46177. serialize(): any;
  46178. /**
  46179. * Get the current class name of the texture usefull for serialization or dynamic coding.
  46180. * @returns "Texture"
  46181. */
  46182. getClassName(): string;
  46183. /**
  46184. * Dispose the texture and release its associated resources.
  46185. */
  46186. dispose(): void;
  46187. /**
  46188. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  46189. * @param parsedTexture Define the JSON representation of the texture
  46190. * @param scene Define the scene the parsed texture should be instantiated in
  46191. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  46192. * @returns The parsed texture if successful
  46193. */
  46194. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  46195. /**
  46196. * Creates a texture from its base 64 representation.
  46197. * @param data Define the base64 payload without the data: prefix
  46198. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  46199. * @param scene Define the scene the texture should belong to
  46200. * @param noMipmap Forces the texture to not create mip map information if true
  46201. * @param invertY define if the texture needs to be inverted on the y axis during loading
  46202. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  46203. * @param onLoad define a callback triggered when the texture has been loaded
  46204. * @param onError define a callback triggered when an error occurred during the loading session
  46205. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  46206. * @returns the created texture
  46207. */
  46208. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  46209. /**
  46210. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  46211. * @param data Define the base64 payload without the data: prefix
  46212. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  46213. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  46214. * @param scene Define the scene the texture should belong to
  46215. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  46216. * @param noMipmap Forces the texture to not create mip map information if true
  46217. * @param invertY define if the texture needs to be inverted on the y axis during loading
  46218. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  46219. * @param onLoad define a callback triggered when the texture has been loaded
  46220. * @param onError define a callback triggered when an error occurred during the loading session
  46221. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  46222. * @returns the created texture
  46223. */
  46224. 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;
  46225. }
  46226. }
  46227. declare module BABYLON {
  46228. /**
  46229. * Settings for finer control over video usage
  46230. */
  46231. interface VideoTextureSettings {
  46232. /**
  46233. * Applies `autoplay` to video, if specified
  46234. */
  46235. autoPlay?: boolean;
  46236. /**
  46237. * Applies `loop` to video, if specified
  46238. */
  46239. loop?: boolean;
  46240. /**
  46241. * Automatically updates internal texture from video at every frame in the render loop
  46242. */
  46243. autoUpdateTexture: boolean;
  46244. /**
  46245. * Image src displayed during the video loading or until the user interacts with the video.
  46246. */
  46247. poster?: string;
  46248. }
  46249. /**
  46250. * If you want to display a video in your scene, this is the special texture for that.
  46251. * This special texture works similar to other textures, with the exception of a few parameters.
  46252. * @see https://doc.babylonjs.com/how_to/video_texture
  46253. */
  46254. class VideoTexture extends Texture {
  46255. /**
  46256. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  46257. */
  46258. readonly autoUpdateTexture: boolean;
  46259. /**
  46260. * The video instance used by the texture internally
  46261. */
  46262. readonly video: HTMLVideoElement;
  46263. private _onUserActionRequestedObservable;
  46264. /**
  46265. * Event triggerd when a dom action is required by the user to play the video.
  46266. * This happens due to recent changes in browser policies preventing video to auto start.
  46267. */
  46268. readonly onUserActionRequestedObservable: Observable<Texture>;
  46269. private _generateMipMaps;
  46270. private _engine;
  46271. private _stillImageCaptured;
  46272. private _poster;
  46273. /**
  46274. * Creates a video texture.
  46275. * If you want to display a video in your scene, this is the special texture for that.
  46276. * This special texture works similar to other textures, with the exception of a few parameters.
  46277. * @see https://doc.babylonjs.com/how_to/video_texture
  46278. * @param name optional name, will detect from video source, if not defined
  46279. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  46280. * @param scene is obviously the current scene.
  46281. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  46282. * @param invertY is false by default but can be used to invert video on Y axis
  46283. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  46284. * @param settings allows finer control over video usage
  46285. */
  46286. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  46287. private _getName;
  46288. private _getVideo;
  46289. private _createInternalTexture;
  46290. private reset;
  46291. /**
  46292. * @hidden Internal method to initiate `update`.
  46293. */
  46294. /**
  46295. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  46296. */
  46297. update(): void;
  46298. /**
  46299. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  46300. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  46301. */
  46302. updateTexture(isVisible: boolean): void;
  46303. protected _updateInternalTexture: (e?: Event | undefined) => void;
  46304. /**
  46305. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  46306. * @param url New url.
  46307. */
  46308. updateURL(url: string): void;
  46309. /**
  46310. * Dispose the texture and release its associated resources.
  46311. */
  46312. dispose(): void;
  46313. /**
  46314. * Creates a video texture straight from your WebCam video feed.
  46315. * @param scene Define the scene the texture should be created in
  46316. * @param onReady Define a callback to triggered once the texture will be ready
  46317. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  46318. */
  46319. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  46320. minWidth: number;
  46321. maxWidth: number;
  46322. minHeight: number;
  46323. maxHeight: number;
  46324. deviceId: string;
  46325. }): void;
  46326. }
  46327. }
  46328. declare var DracoDecoderModule: any;
  46329. declare var WebAssembly: any;
  46330. declare module BABYLON {
  46331. /**
  46332. * Configuration for Draco compression
  46333. */
  46334. interface IDracoCompressionConfiguration {
  46335. /**
  46336. * Configuration for the decoder.
  46337. */
  46338. decoder?: {
  46339. /**
  46340. * The url to the WebAssembly module.
  46341. */
  46342. wasmUrl?: string;
  46343. /**
  46344. * The url to the WebAssembly binary.
  46345. */
  46346. wasmBinaryUrl?: string;
  46347. /**
  46348. * The url to the fallback JavaScript module.
  46349. */
  46350. fallbackUrl?: string;
  46351. };
  46352. }
  46353. /**
  46354. * Draco compression (https://google.github.io/draco/)
  46355. *
  46356. * This class wraps the Draco module.
  46357. *
  46358. * **Encoder**
  46359. *
  46360. * The encoder is not currently implemented.
  46361. *
  46362. * **Decoder**
  46363. *
  46364. * 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.
  46365. *
  46366. * To update the configuration, use the following code:
  46367. * ```javascript
  46368. * BABYLON.DracoCompression.Configuration = {
  46369. * decoder: {
  46370. * wasmUrl: "<url to the WebAssembly library>",
  46371. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  46372. * fallbackUrl: "<url to the fallback JavaScript library>",
  46373. * }
  46374. * };
  46375. * ```
  46376. *
  46377. * 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.
  46378. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  46379. * Use `BABYLON.DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  46380. *
  46381. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  46382. * ```javascript
  46383. * var dracoCompression = new BABYLON.DracoCompression();
  46384. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  46385. * [BABYLON.VertexBuffer.PositionKind]: 0
  46386. * });
  46387. * ```
  46388. *
  46389. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  46390. */
  46391. class DracoCompression implements IDisposable {
  46392. private static _DecoderModulePromise;
  46393. /**
  46394. * The configuration. Defaults to the following urls:
  46395. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  46396. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  46397. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  46398. */
  46399. static Configuration: IDracoCompressionConfiguration;
  46400. /**
  46401. * Returns true if the decoder is available.
  46402. */
  46403. static readonly DecoderAvailable: boolean;
  46404. /**
  46405. * Constructor
  46406. */
  46407. constructor();
  46408. /**
  46409. * Stop all async operations and release resources.
  46410. */
  46411. dispose(): void;
  46412. /**
  46413. * Decode Draco compressed mesh data to vertex data.
  46414. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  46415. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  46416. * @returns A promise that resolves with the decoded vertex data
  46417. */
  46418. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes: {
  46419. [kind: string]: number;
  46420. }): Promise<VertexData>;
  46421. private static _GetDecoderModule;
  46422. private static _LoadScriptAsync;
  46423. private static _LoadFileAsync;
  46424. }
  46425. }
  46426. declare module BABYLON {
  46427. /**
  46428. * Particle emitter emitting particles from the inside of a box.
  46429. * It emits the particles randomly between 2 given directions.
  46430. */
  46431. class BoxParticleEmitter implements IParticleEmitterType {
  46432. /**
  46433. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  46434. */
  46435. direction1: Vector3;
  46436. /**
  46437. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  46438. */
  46439. direction2: Vector3;
  46440. /**
  46441. * 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.
  46442. */
  46443. minEmitBox: Vector3;
  46444. /**
  46445. * 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.
  46446. */
  46447. maxEmitBox: Vector3;
  46448. /**
  46449. * Creates a new instance BoxParticleEmitter
  46450. */
  46451. constructor();
  46452. /**
  46453. * Called by the particle System when the direction is computed for the created particle.
  46454. * @param worldMatrix is the world matrix of the particle system
  46455. * @param directionToUpdate is the direction vector to update with the result
  46456. * @param particle is the particle we are computed the direction for
  46457. */
  46458. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  46459. /**
  46460. * Called by the particle System when the position is computed for the created particle.
  46461. * @param worldMatrix is the world matrix of the particle system
  46462. * @param positionToUpdate is the position vector to update with the result
  46463. * @param particle is the particle we are computed the position for
  46464. */
  46465. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  46466. /**
  46467. * Clones the current emitter and returns a copy of it
  46468. * @returns the new emitter
  46469. */
  46470. clone(): BoxParticleEmitter;
  46471. /**
  46472. * Called by the GPUParticleSystem to setup the update shader
  46473. * @param effect defines the update shader
  46474. */
  46475. applyToShader(effect: Effect): void;
  46476. /**
  46477. * Returns a string to use to update the GPU particles update shader
  46478. * @returns a string containng the defines string
  46479. */
  46480. getEffectDefines(): string;
  46481. /**
  46482. * Returns the string "BoxParticleEmitter"
  46483. * @returns a string containing the class name
  46484. */
  46485. getClassName(): string;
  46486. /**
  46487. * Serializes the particle system to a JSON object.
  46488. * @returns the JSON object
  46489. */
  46490. serialize(): any;
  46491. /**
  46492. * Parse properties from a JSON object
  46493. * @param serializationObject defines the JSON object
  46494. */
  46495. parse(serializationObject: any): void;
  46496. }
  46497. }
  46498. declare module BABYLON {
  46499. /**
  46500. * Particle emitter emitting particles from the inside of a cone.
  46501. * It emits the particles alongside the cone volume from the base to the particle.
  46502. * The emission direction might be randomized.
  46503. */
  46504. class ConeParticleEmitter implements IParticleEmitterType {
  46505. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  46506. directionRandomizer: number;
  46507. private _radius;
  46508. private _angle;
  46509. private _height;
  46510. /**
  46511. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  46512. */
  46513. radiusRange: number;
  46514. /**
  46515. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  46516. */
  46517. heightRange: number;
  46518. /**
  46519. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  46520. */
  46521. emitFromSpawnPointOnly: boolean;
  46522. /**
  46523. * Gets or sets the radius of the emission cone
  46524. */
  46525. radius: number;
  46526. /**
  46527. * Gets or sets the angle of the emission cone
  46528. */
  46529. angle: number;
  46530. private _buildHeight;
  46531. /**
  46532. * Creates a new instance ConeParticleEmitter
  46533. * @param radius the radius of the emission cone (1 by default)
  46534. * @param angles the cone base angle (PI by default)
  46535. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  46536. */
  46537. constructor(radius?: number, angle?: number,
  46538. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  46539. directionRandomizer?: number);
  46540. /**
  46541. * Called by the particle System when the direction is computed for the created particle.
  46542. * @param worldMatrix is the world matrix of the particle system
  46543. * @param directionToUpdate is the direction vector to update with the result
  46544. * @param particle is the particle we are computed the direction for
  46545. */
  46546. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  46547. /**
  46548. * Called by the particle System when the position is computed for the created particle.
  46549. * @param worldMatrix is the world matrix of the particle system
  46550. * @param positionToUpdate is the position vector to update with the result
  46551. * @param particle is the particle we are computed the position for
  46552. */
  46553. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  46554. /**
  46555. * Clones the current emitter and returns a copy of it
  46556. * @returns the new emitter
  46557. */
  46558. clone(): ConeParticleEmitter;
  46559. /**
  46560. * Called by the GPUParticleSystem to setup the update shader
  46561. * @param effect defines the update shader
  46562. */
  46563. applyToShader(effect: Effect): void;
  46564. /**
  46565. * Returns a string to use to update the GPU particles update shader
  46566. * @returns a string containng the defines string
  46567. */
  46568. getEffectDefines(): string;
  46569. /**
  46570. * Returns the string "ConeParticleEmitter"
  46571. * @returns a string containing the class name
  46572. */
  46573. getClassName(): string;
  46574. /**
  46575. * Serializes the particle system to a JSON object.
  46576. * @returns the JSON object
  46577. */
  46578. serialize(): any;
  46579. /**
  46580. * Parse properties from a JSON object
  46581. * @param serializationObject defines the JSON object
  46582. */
  46583. parse(serializationObject: any): void;
  46584. }
  46585. }
  46586. declare module BABYLON {
  46587. /**
  46588. * Particle emitter emitting particles from the inside of a cylinder.
  46589. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  46590. */
  46591. class CylinderParticleEmitter implements IParticleEmitterType {
  46592. /**
  46593. * The radius of the emission cylinder.
  46594. */
  46595. radius: number;
  46596. /**
  46597. * The height of the emission cylinder.
  46598. */
  46599. height: number;
  46600. /**
  46601. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  46602. */
  46603. radiusRange: number;
  46604. /**
  46605. * How much to randomize the particle direction [0-1].
  46606. */
  46607. directionRandomizer: number;
  46608. /**
  46609. * Creates a new instance CylinderParticleEmitter
  46610. * @param radius the radius of the emission cylinder (1 by default)
  46611. * @param height the height of the emission cylinder (1 by default)
  46612. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  46613. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  46614. */
  46615. constructor(
  46616. /**
  46617. * The radius of the emission cylinder.
  46618. */
  46619. radius?: number,
  46620. /**
  46621. * The height of the emission cylinder.
  46622. */
  46623. height?: number,
  46624. /**
  46625. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  46626. */
  46627. radiusRange?: number,
  46628. /**
  46629. * How much to randomize the particle direction [0-1].
  46630. */
  46631. directionRandomizer?: number);
  46632. /**
  46633. * Called by the particle System when the direction is computed for the created particle.
  46634. * @param worldMatrix is the world matrix of the particle system
  46635. * @param directionToUpdate is the direction vector to update with the result
  46636. * @param particle is the particle we are computed the direction for
  46637. */
  46638. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  46639. /**
  46640. * Called by the particle System when the position is computed for the created particle.
  46641. * @param worldMatrix is the world matrix of the particle system
  46642. * @param positionToUpdate is the position vector to update with the result
  46643. * @param particle is the particle we are computed the position for
  46644. */
  46645. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  46646. /**
  46647. * Clones the current emitter and returns a copy of it
  46648. * @returns the new emitter
  46649. */
  46650. clone(): CylinderParticleEmitter;
  46651. /**
  46652. * Called by the GPUParticleSystem to setup the update shader
  46653. * @param effect defines the update shader
  46654. */
  46655. applyToShader(effect: Effect): void;
  46656. /**
  46657. * Returns a string to use to update the GPU particles update shader
  46658. * @returns a string containng the defines string
  46659. */
  46660. getEffectDefines(): string;
  46661. /**
  46662. * Returns the string "CylinderParticleEmitter"
  46663. * @returns a string containing the class name
  46664. */
  46665. getClassName(): string;
  46666. /**
  46667. * Serializes the particle system to a JSON object.
  46668. * @returns the JSON object
  46669. */
  46670. serialize(): any;
  46671. /**
  46672. * Parse properties from a JSON object
  46673. * @param serializationObject defines the JSON object
  46674. */
  46675. parse(serializationObject: any): void;
  46676. }
  46677. /**
  46678. * Particle emitter emitting particles from the inside of a cylinder.
  46679. * It emits the particles randomly between two vectors.
  46680. */
  46681. class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  46682. /**
  46683. * The min limit of the emission direction.
  46684. */
  46685. direction1: Vector3;
  46686. /**
  46687. * The max limit of the emission direction.
  46688. */
  46689. direction2: Vector3;
  46690. /**
  46691. * Creates a new instance CylinderDirectedParticleEmitter
  46692. * @param radius the radius of the emission cylinder (1 by default)
  46693. * @param height the height of the emission cylinder (1 by default)
  46694. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  46695. * @param direction1 the min limit of the emission direction (up vector by default)
  46696. * @param direction2 the max limit of the emission direction (up vector by default)
  46697. */
  46698. constructor(radius?: number, height?: number, radiusRange?: number,
  46699. /**
  46700. * The min limit of the emission direction.
  46701. */
  46702. direction1?: Vector3,
  46703. /**
  46704. * The max limit of the emission direction.
  46705. */
  46706. direction2?: Vector3);
  46707. /**
  46708. * Called by the particle System when the direction is computed for the created particle.
  46709. * @param worldMatrix is the world matrix of the particle system
  46710. * @param directionToUpdate is the direction vector to update with the result
  46711. * @param particle is the particle we are computed the direction for
  46712. */
  46713. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  46714. /**
  46715. * Clones the current emitter and returns a copy of it
  46716. * @returns the new emitter
  46717. */
  46718. clone(): CylinderDirectedParticleEmitter;
  46719. /**
  46720. * Called by the GPUParticleSystem to setup the update shader
  46721. * @param effect defines the update shader
  46722. */
  46723. applyToShader(effect: Effect): void;
  46724. /**
  46725. * Returns a string to use to update the GPU particles update shader
  46726. * @returns a string containng the defines string
  46727. */
  46728. getEffectDefines(): string;
  46729. /**
  46730. * Returns the string "CylinderDirectedParticleEmitter"
  46731. * @returns a string containing the class name
  46732. */
  46733. getClassName(): string;
  46734. /**
  46735. * Serializes the particle system to a JSON object.
  46736. * @returns the JSON object
  46737. */
  46738. serialize(): any;
  46739. /**
  46740. * Parse properties from a JSON object
  46741. * @param serializationObject defines the JSON object
  46742. */
  46743. parse(serializationObject: any): void;
  46744. }
  46745. }
  46746. declare module BABYLON {
  46747. /**
  46748. * Particle emitter emitting particles from the inside of a hemisphere.
  46749. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  46750. */
  46751. class HemisphericParticleEmitter implements IParticleEmitterType {
  46752. /**
  46753. * The radius of the emission hemisphere.
  46754. */
  46755. radius: number;
  46756. /**
  46757. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  46758. */
  46759. radiusRange: number;
  46760. /**
  46761. * How much to randomize the particle direction [0-1].
  46762. */
  46763. directionRandomizer: number;
  46764. /**
  46765. * Creates a new instance HemisphericParticleEmitter
  46766. * @param radius the radius of the emission hemisphere (1 by default)
  46767. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  46768. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  46769. */
  46770. constructor(
  46771. /**
  46772. * The radius of the emission hemisphere.
  46773. */
  46774. radius?: number,
  46775. /**
  46776. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  46777. */
  46778. radiusRange?: number,
  46779. /**
  46780. * How much to randomize the particle direction [0-1].
  46781. */
  46782. directionRandomizer?: number);
  46783. /**
  46784. * Called by the particle System when the direction is computed for the created particle.
  46785. * @param worldMatrix is the world matrix of the particle system
  46786. * @param directionToUpdate is the direction vector to update with the result
  46787. * @param particle is the particle we are computed the direction for
  46788. */
  46789. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  46790. /**
  46791. * Called by the particle System when the position is computed for the created particle.
  46792. * @param worldMatrix is the world matrix of the particle system
  46793. * @param positionToUpdate is the position vector to update with the result
  46794. * @param particle is the particle we are computed the position for
  46795. */
  46796. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  46797. /**
  46798. * Clones the current emitter and returns a copy of it
  46799. * @returns the new emitter
  46800. */
  46801. clone(): HemisphericParticleEmitter;
  46802. /**
  46803. * Called by the GPUParticleSystem to setup the update shader
  46804. * @param effect defines the update shader
  46805. */
  46806. applyToShader(effect: Effect): void;
  46807. /**
  46808. * Returns a string to use to update the GPU particles update shader
  46809. * @returns a string containng the defines string
  46810. */
  46811. getEffectDefines(): string;
  46812. /**
  46813. * Returns the string "HemisphericParticleEmitter"
  46814. * @returns a string containing the class name
  46815. */
  46816. getClassName(): string;
  46817. /**
  46818. * Serializes the particle system to a JSON object.
  46819. * @returns the JSON object
  46820. */
  46821. serialize(): any;
  46822. /**
  46823. * Parse properties from a JSON object
  46824. * @param serializationObject defines the JSON object
  46825. */
  46826. parse(serializationObject: any): void;
  46827. }
  46828. }
  46829. declare module BABYLON {
  46830. /**
  46831. * Particle emitter represents a volume emitting particles.
  46832. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  46833. */
  46834. interface IParticleEmitterType {
  46835. /**
  46836. * Called by the particle System when the direction is computed for the created particle.
  46837. * @param worldMatrix is the world matrix of the particle system
  46838. * @param directionToUpdate is the direction vector to update with the result
  46839. * @param particle is the particle we are computed the direction for
  46840. */
  46841. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  46842. /**
  46843. * Called by the particle System when the position is computed for the created particle.
  46844. * @param worldMatrix is the world matrix of the particle system
  46845. * @param positionToUpdate is the position vector to update with the result
  46846. * @param particle is the particle we are computed the position for
  46847. */
  46848. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  46849. /**
  46850. * Clones the current emitter and returns a copy of it
  46851. * @returns the new emitter
  46852. */
  46853. clone(): IParticleEmitterType;
  46854. /**
  46855. * Called by the GPUParticleSystem to setup the update shader
  46856. * @param effect defines the update shader
  46857. */
  46858. applyToShader(effect: Effect): void;
  46859. /**
  46860. * Returns a string to use to update the GPU particles update shader
  46861. * @returns the effect defines string
  46862. */
  46863. getEffectDefines(): string;
  46864. /**
  46865. * Returns a string representing the class name
  46866. * @returns a string containing the class name
  46867. */
  46868. getClassName(): string;
  46869. /**
  46870. * Serializes the particle system to a JSON object.
  46871. * @returns the JSON object
  46872. */
  46873. serialize(): any;
  46874. /**
  46875. * Parse properties from a JSON object
  46876. * @param serializationObject defines the JSON object
  46877. */
  46878. parse(serializationObject: any): void;
  46879. }
  46880. }
  46881. declare module BABYLON {
  46882. /**
  46883. * Particle emitter emitting particles from a point.
  46884. * It emits the particles randomly between 2 given directions.
  46885. */
  46886. class PointParticleEmitter implements IParticleEmitterType {
  46887. /**
  46888. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  46889. */
  46890. direction1: Vector3;
  46891. /**
  46892. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  46893. */
  46894. direction2: Vector3;
  46895. /**
  46896. * Creates a new instance PointParticleEmitter
  46897. */
  46898. constructor();
  46899. /**
  46900. * Called by the particle System when the direction is computed for the created particle.
  46901. * @param worldMatrix is the world matrix of the particle system
  46902. * @param directionToUpdate is the direction vector to update with the result
  46903. * @param particle is the particle we are computed the direction for
  46904. */
  46905. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  46906. /**
  46907. * Called by the particle System when the position is computed for the created particle.
  46908. * @param worldMatrix is the world matrix of the particle system
  46909. * @param positionToUpdate is the position vector to update with the result
  46910. * @param particle is the particle we are computed the position for
  46911. */
  46912. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  46913. /**
  46914. * Clones the current emitter and returns a copy of it
  46915. * @returns the new emitter
  46916. */
  46917. clone(): PointParticleEmitter;
  46918. /**
  46919. * Called by the GPUParticleSystem to setup the update shader
  46920. * @param effect defines the update shader
  46921. */
  46922. applyToShader(effect: Effect): void;
  46923. /**
  46924. * Returns a string to use to update the GPU particles update shader
  46925. * @returns a string containng the defines string
  46926. */
  46927. getEffectDefines(): string;
  46928. /**
  46929. * Returns the string "PointParticleEmitter"
  46930. * @returns a string containing the class name
  46931. */
  46932. getClassName(): string;
  46933. /**
  46934. * Serializes the particle system to a JSON object.
  46935. * @returns the JSON object
  46936. */
  46937. serialize(): any;
  46938. /**
  46939. * Parse properties from a JSON object
  46940. * @param serializationObject defines the JSON object
  46941. */
  46942. parse(serializationObject: any): void;
  46943. }
  46944. }
  46945. declare module BABYLON {
  46946. /**
  46947. * Particle emitter emitting particles from the inside of a sphere.
  46948. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  46949. */
  46950. class SphereParticleEmitter implements IParticleEmitterType {
  46951. /**
  46952. * The radius of the emission sphere.
  46953. */
  46954. radius: number;
  46955. /**
  46956. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  46957. */
  46958. radiusRange: number;
  46959. /**
  46960. * How much to randomize the particle direction [0-1].
  46961. */
  46962. directionRandomizer: number;
  46963. /**
  46964. * Creates a new instance SphereParticleEmitter
  46965. * @param radius the radius of the emission sphere (1 by default)
  46966. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  46967. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  46968. */
  46969. constructor(
  46970. /**
  46971. * The radius of the emission sphere.
  46972. */
  46973. radius?: number,
  46974. /**
  46975. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  46976. */
  46977. radiusRange?: number,
  46978. /**
  46979. * How much to randomize the particle direction [0-1].
  46980. */
  46981. directionRandomizer?: number);
  46982. /**
  46983. * Called by the particle System when the direction is computed for the created particle.
  46984. * @param worldMatrix is the world matrix of the particle system
  46985. * @param directionToUpdate is the direction vector to update with the result
  46986. * @param particle is the particle we are computed the direction for
  46987. */
  46988. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  46989. /**
  46990. * Called by the particle System when the position is computed for the created particle.
  46991. * @param worldMatrix is the world matrix of the particle system
  46992. * @param positionToUpdate is the position vector to update with the result
  46993. * @param particle is the particle we are computed the position for
  46994. */
  46995. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  46996. /**
  46997. * Clones the current emitter and returns a copy of it
  46998. * @returns the new emitter
  46999. */
  47000. clone(): SphereParticleEmitter;
  47001. /**
  47002. * Called by the GPUParticleSystem to setup the update shader
  47003. * @param effect defines the update shader
  47004. */
  47005. applyToShader(effect: Effect): void;
  47006. /**
  47007. * Returns a string to use to update the GPU particles update shader
  47008. * @returns a string containng the defines string
  47009. */
  47010. getEffectDefines(): string;
  47011. /**
  47012. * Returns the string "SphereParticleEmitter"
  47013. * @returns a string containing the class name
  47014. */
  47015. getClassName(): string;
  47016. /**
  47017. * Serializes the particle system to a JSON object.
  47018. * @returns the JSON object
  47019. */
  47020. serialize(): any;
  47021. /**
  47022. * Parse properties from a JSON object
  47023. * @param serializationObject defines the JSON object
  47024. */
  47025. parse(serializationObject: any): void;
  47026. }
  47027. /**
  47028. * Particle emitter emitting particles from the inside of a sphere.
  47029. * It emits the particles randomly between two vectors.
  47030. */
  47031. class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  47032. /**
  47033. * The min limit of the emission direction.
  47034. */
  47035. direction1: Vector3;
  47036. /**
  47037. * The max limit of the emission direction.
  47038. */
  47039. direction2: Vector3;
  47040. /**
  47041. * Creates a new instance SphereDirectedParticleEmitter
  47042. * @param radius the radius of the emission sphere (1 by default)
  47043. * @param direction1 the min limit of the emission direction (up vector by default)
  47044. * @param direction2 the max limit of the emission direction (up vector by default)
  47045. */
  47046. constructor(radius?: number,
  47047. /**
  47048. * The min limit of the emission direction.
  47049. */
  47050. direction1?: Vector3,
  47051. /**
  47052. * The max limit of the emission direction.
  47053. */
  47054. direction2?: Vector3);
  47055. /**
  47056. * Called by the particle System when the direction is computed for the created particle.
  47057. * @param worldMatrix is the world matrix of the particle system
  47058. * @param directionToUpdate is the direction vector to update with the result
  47059. * @param particle is the particle we are computed the direction for
  47060. */
  47061. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  47062. /**
  47063. * Clones the current emitter and returns a copy of it
  47064. * @returns the new emitter
  47065. */
  47066. clone(): SphereDirectedParticleEmitter;
  47067. /**
  47068. * Called by the GPUParticleSystem to setup the update shader
  47069. * @param effect defines the update shader
  47070. */
  47071. applyToShader(effect: Effect): void;
  47072. /**
  47073. * Returns a string to use to update the GPU particles update shader
  47074. * @returns a string containng the defines string
  47075. */
  47076. getEffectDefines(): string;
  47077. /**
  47078. * Returns the string "SphereDirectedParticleEmitter"
  47079. * @returns a string containing the class name
  47080. */
  47081. getClassName(): string;
  47082. /**
  47083. * Serializes the particle system to a JSON object.
  47084. * @returns the JSON object
  47085. */
  47086. serialize(): any;
  47087. /**
  47088. * Parse properties from a JSON object
  47089. * @param serializationObject defines the JSON object
  47090. */
  47091. parse(serializationObject: any): void;
  47092. }
  47093. }
  47094. declare module BABYLON {
  47095. /** @hidden */
  47096. class CannonJSPlugin implements IPhysicsEnginePlugin {
  47097. private _useDeltaForWorldStep;
  47098. world: any;
  47099. name: string;
  47100. private _physicsMaterials;
  47101. private _fixedTimeStep;
  47102. BJSCANNON: any;
  47103. constructor(_useDeltaForWorldStep?: boolean, iterations?: number);
  47104. setGravity(gravity: Vector3): void;
  47105. setTimeStep(timeStep: number): void;
  47106. getTimeStep(): number;
  47107. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  47108. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47109. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47110. generatePhysicsBody(impostor: PhysicsImpostor): void;
  47111. private _processChildMeshes;
  47112. removePhysicsBody(impostor: PhysicsImpostor): void;
  47113. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  47114. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  47115. private _addMaterial;
  47116. private _checkWithEpsilon;
  47117. private _createShape;
  47118. private _createHeightmap;
  47119. private _minus90X;
  47120. private _plus90X;
  47121. private _tmpPosition;
  47122. private _tmpDeltaPosition;
  47123. private _tmpUnityRotation;
  47124. private _updatePhysicsBodyTransformation;
  47125. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  47126. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  47127. isSupported(): boolean;
  47128. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47129. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47130. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47131. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47132. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  47133. getBodyMass(impostor: PhysicsImpostor): number;
  47134. getBodyFriction(impostor: PhysicsImpostor): number;
  47135. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  47136. getBodyRestitution(impostor: PhysicsImpostor): number;
  47137. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  47138. sleepBody(impostor: PhysicsImpostor): void;
  47139. wakeUpBody(impostor: PhysicsImpostor): void;
  47140. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  47141. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  47142. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  47143. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  47144. getRadius(impostor: PhysicsImpostor): number;
  47145. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  47146. dispose(): void;
  47147. private _extendNamespace;
  47148. }
  47149. }
  47150. declare module BABYLON {
  47151. /** @hidden */
  47152. class OimoJSPlugin implements IPhysicsEnginePlugin {
  47153. world: any;
  47154. name: string;
  47155. BJSOIMO: any;
  47156. constructor(iterations?: number);
  47157. setGravity(gravity: Vector3): void;
  47158. setTimeStep(timeStep: number): void;
  47159. getTimeStep(): number;
  47160. private _tmpImpostorsArray;
  47161. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  47162. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47163. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47164. generatePhysicsBody(impostor: PhysicsImpostor): void;
  47165. private _tmpPositionVector;
  47166. removePhysicsBody(impostor: PhysicsImpostor): void;
  47167. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  47168. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  47169. isSupported(): boolean;
  47170. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  47171. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  47172. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47173. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47174. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47175. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47176. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  47177. getBodyMass(impostor: PhysicsImpostor): number;
  47178. getBodyFriction(impostor: PhysicsImpostor): number;
  47179. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  47180. getBodyRestitution(impostor: PhysicsImpostor): number;
  47181. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  47182. sleepBody(impostor: PhysicsImpostor): void;
  47183. wakeUpBody(impostor: PhysicsImpostor): void;
  47184. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  47185. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  47186. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  47187. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  47188. getRadius(impostor: PhysicsImpostor): number;
  47189. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  47190. dispose(): void;
  47191. }
  47192. }
  47193. declare module BABYLON {
  47194. /**
  47195. * This represents a set of one or more post processes in Babylon.
  47196. * A post process can be used to apply a shader to a texture after it is rendered.
  47197. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  47198. */
  47199. class PostProcessRenderEffect {
  47200. private _postProcesses;
  47201. private _getPostProcesses;
  47202. private _singleInstance;
  47203. private _cameras;
  47204. private _indicesForCamera;
  47205. /**
  47206. * Name of the effect
  47207. * @hidden
  47208. */
  47209. /**
  47210. * Instantiates a post process render effect.
  47211. * A post process can be used to apply a shader to a texture after it is rendered.
  47212. * @param engine The engine the effect is tied to
  47213. * @param name The name of the effect
  47214. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  47215. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  47216. */
  47217. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  47218. /**
  47219. * Checks if all the post processes in the effect are supported.
  47220. */
  47221. readonly isSupported: boolean;
  47222. /**
  47223. * Updates the current state of the effect
  47224. * @hidden
  47225. */
  47226. /**
  47227. * Attaches the effect on cameras
  47228. * @param cameras The camera to attach to.
  47229. * @hidden
  47230. */
  47231. /**
  47232. * Attaches the effect on cameras
  47233. * @param cameras The camera to attach to.
  47234. * @hidden
  47235. */
  47236. /**
  47237. * Detatches the effect on cameras
  47238. * @param cameras The camera to detatch from.
  47239. * @hidden
  47240. */
  47241. /**
  47242. * Detatches the effect on cameras
  47243. * @param cameras The camera to detatch from.
  47244. * @hidden
  47245. */
  47246. /**
  47247. * Enables the effect on given cameras
  47248. * @param cameras The camera to enable.
  47249. * @hidden
  47250. */
  47251. /**
  47252. * Enables the effect on given cameras
  47253. * @param cameras The camera to enable.
  47254. * @hidden
  47255. */
  47256. /**
  47257. * Disables the effect on the given cameras
  47258. * @param cameras The camera to disable.
  47259. * @hidden
  47260. */
  47261. /**
  47262. * Disables the effect on the given cameras
  47263. * @param cameras The camera to disable.
  47264. * @hidden
  47265. */
  47266. /**
  47267. * Gets a list of the post processes contained in the effect.
  47268. * @param camera The camera to get the post processes on.
  47269. * @returns The list of the post processes in the effect.
  47270. */
  47271. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  47272. }
  47273. }
  47274. declare module BABYLON {
  47275. /**
  47276. * PostProcessRenderPipeline
  47277. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  47278. */
  47279. class PostProcessRenderPipeline {
  47280. private engine;
  47281. private _renderEffects;
  47282. private _renderEffectsForIsolatedPass;
  47283. /**
  47284. * @hidden
  47285. */
  47286. protected _cameras: Camera[];
  47287. /** @hidden */
  47288. /**
  47289. * Initializes a PostProcessRenderPipeline
  47290. * @param engine engine to add the pipeline to
  47291. * @param name name of the pipeline
  47292. */
  47293. constructor(engine: Engine, name: string);
  47294. /**
  47295. * "PostProcessRenderPipeline"
  47296. * @returns "PostProcessRenderPipeline"
  47297. */
  47298. getClassName(): string;
  47299. /**
  47300. * If all the render effects in the pipeline are support
  47301. */
  47302. readonly isSupported: boolean;
  47303. /**
  47304. * Adds an effect to the pipeline
  47305. * @param renderEffect the effect to add
  47306. */
  47307. addEffect(renderEffect: PostProcessRenderEffect): void;
  47308. /** @hidden */
  47309. /** @hidden */
  47310. /** @hidden */
  47311. /** @hidden */
  47312. /** @hidden */
  47313. /** @hidden */
  47314. /** @hidden */
  47315. /** @hidden */
  47316. /** @hidden */
  47317. /** @hidden */
  47318. /** @hidden */
  47319. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  47320. /**
  47321. * Disposes of the pipeline
  47322. */
  47323. dispose(): void;
  47324. }
  47325. }
  47326. declare module BABYLON {
  47327. /**
  47328. * PostProcessRenderPipelineManager class
  47329. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  47330. */
  47331. class PostProcessRenderPipelineManager {
  47332. private _renderPipelines;
  47333. /**
  47334. * Initializes a PostProcessRenderPipelineManager
  47335. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  47336. */
  47337. constructor();
  47338. /**
  47339. * Adds a pipeline to the manager
  47340. * @param renderPipeline The pipeline to add
  47341. */
  47342. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  47343. /**
  47344. * Attaches a camera to the pipeline
  47345. * @param renderPipelineName The name of the pipeline to attach to
  47346. * @param cameras the camera to attach
  47347. * @param unique if the camera can be attached multiple times to the pipeline
  47348. */
  47349. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  47350. /**
  47351. * Detaches a camera from the pipeline
  47352. * @param renderPipelineName The name of the pipeline to detach from
  47353. * @param cameras the camera to detach
  47354. */
  47355. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  47356. /**
  47357. * Enables an effect by name on a pipeline
  47358. * @param renderPipelineName the name of the pipeline to enable the effect in
  47359. * @param renderEffectName the name of the effect to enable
  47360. * @param cameras the cameras that the effect should be enabled on
  47361. */
  47362. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  47363. /**
  47364. * Disables an effect by name on a pipeline
  47365. * @param renderPipelineName the name of the pipeline to disable the effect in
  47366. * @param renderEffectName the name of the effect to disable
  47367. * @param cameras the cameras that the effect should be disabled on
  47368. */
  47369. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  47370. /**
  47371. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  47372. */
  47373. update(): void;
  47374. /** @hidden */
  47375. /**
  47376. * Disposes of the manager and pipelines
  47377. */
  47378. dispose(): void;
  47379. }
  47380. }
  47381. declare module BABYLON {
  47382. interface Scene {
  47383. /** @hidden (Backing field) */
  47384. /**
  47385. * Gets the postprocess render pipeline manager
  47386. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  47387. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  47388. */
  47389. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  47390. }
  47391. /**
  47392. * Defines the Render Pipeline scene component responsible to rendering pipelines
  47393. */
  47394. class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  47395. /**
  47396. * The component name helpfull to identify the component in the list of scene components.
  47397. */
  47398. readonly name: string;
  47399. /**
  47400. * The scene the component belongs to.
  47401. */
  47402. scene: Scene;
  47403. /**
  47404. * Creates a new instance of the component for the given scene
  47405. * @param scene Defines the scene to register the component in
  47406. */
  47407. constructor(scene: Scene);
  47408. /**
  47409. * Registers the component in a given scene
  47410. */
  47411. register(): void;
  47412. /**
  47413. * Rebuilds the elements related to this component in case of
  47414. * context lost for instance.
  47415. */
  47416. rebuild(): void;
  47417. /**
  47418. * Disposes the component and the associated ressources
  47419. */
  47420. dispose(): void;
  47421. private _gatherRenderTargets;
  47422. }
  47423. }
  47424. declare module BABYLON {
  47425. /**
  47426. * Helper class dealing with the extraction of spherical polynomial dataArray
  47427. * from a cube map.
  47428. */
  47429. class CubeMapToSphericalPolynomialTools {
  47430. private static FileFaces;
  47431. /**
  47432. * Converts a texture to the according Spherical Polynomial data.
  47433. * This extracts the first 3 orders only as they are the only one used in the lighting.
  47434. *
  47435. * @param texture The texture to extract the information from.
  47436. * @return The Spherical Polynomial data.
  47437. */
  47438. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  47439. /**
  47440. * Converts a cubemap to the according Spherical Polynomial data.
  47441. * This extracts the first 3 orders only as they are the only one used in the lighting.
  47442. *
  47443. * @param cubeInfo The Cube map to extract the information from.
  47444. * @return The Spherical Polynomial data.
  47445. */
  47446. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  47447. }
  47448. }
  47449. declare module BABYLON {
  47450. /**
  47451. * Header information of HDR texture files.
  47452. */
  47453. interface HDRInfo {
  47454. /**
  47455. * The height of the texture in pixels.
  47456. */
  47457. height: number;
  47458. /**
  47459. * The width of the texture in pixels.
  47460. */
  47461. width: number;
  47462. /**
  47463. * The index of the beginning of the data in the binary file.
  47464. */
  47465. dataPosition: number;
  47466. }
  47467. /**
  47468. * This groups tools to convert HDR texture to native colors array.
  47469. */
  47470. class HDRTools {
  47471. private static Ldexp;
  47472. private static Rgbe2float;
  47473. private static readStringLine;
  47474. /**
  47475. * Reads header information from an RGBE texture stored in a native array.
  47476. * More information on this format are available here:
  47477. * https://en.wikipedia.org/wiki/RGBE_image_format
  47478. *
  47479. * @param uint8array The binary file stored in native array.
  47480. * @return The header information.
  47481. */
  47482. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  47483. /**
  47484. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  47485. * This RGBE texture needs to store the information as a panorama.
  47486. *
  47487. * More information on this format are available here:
  47488. * https://en.wikipedia.org/wiki/RGBE_image_format
  47489. *
  47490. * @param buffer The binary file stored in an array buffer.
  47491. * @param size The expected size of the extracted cubemap.
  47492. * @return The Cube Map information.
  47493. */
  47494. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  47495. /**
  47496. * Returns the pixels data extracted from an RGBE texture.
  47497. * This pixels will be stored left to right up to down in the R G B order in one array.
  47498. *
  47499. * More information on this format are available here:
  47500. * https://en.wikipedia.org/wiki/RGBE_image_format
  47501. *
  47502. * @param uint8array The binary file stored in an array buffer.
  47503. * @param hdrInfo The header information of the file.
  47504. * @return The pixels data in RGB right to left up to down order.
  47505. */
  47506. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  47507. private static RGBE_ReadPixels_RLE;
  47508. }
  47509. }
  47510. declare module BABYLON {
  47511. /**
  47512. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  47513. */
  47514. interface CubeMapInfo {
  47515. /**
  47516. * The pixel array for the front face.
  47517. * This is stored in format, left to right, up to down format.
  47518. */
  47519. front: Nullable<ArrayBufferView>;
  47520. /**
  47521. * The pixel array for the back face.
  47522. * This is stored in format, left to right, up to down format.
  47523. */
  47524. back: Nullable<ArrayBufferView>;
  47525. /**
  47526. * The pixel array for the left face.
  47527. * This is stored in format, left to right, up to down format.
  47528. */
  47529. left: Nullable<ArrayBufferView>;
  47530. /**
  47531. * The pixel array for the right face.
  47532. * This is stored in format, left to right, up to down format.
  47533. */
  47534. right: Nullable<ArrayBufferView>;
  47535. /**
  47536. * The pixel array for the up face.
  47537. * This is stored in format, left to right, up to down format.
  47538. */
  47539. up: Nullable<ArrayBufferView>;
  47540. /**
  47541. * The pixel array for the down face.
  47542. * This is stored in format, left to right, up to down format.
  47543. */
  47544. down: Nullable<ArrayBufferView>;
  47545. /**
  47546. * The size of the cubemap stored.
  47547. *
  47548. * Each faces will be size * size pixels.
  47549. */
  47550. size: number;
  47551. /**
  47552. * The format of the texture.
  47553. *
  47554. * RGBA, RGB.
  47555. */
  47556. format: number;
  47557. /**
  47558. * The type of the texture data.
  47559. *
  47560. * UNSIGNED_INT, FLOAT.
  47561. */
  47562. type: number;
  47563. /**
  47564. * Specifies whether the texture is in gamma space.
  47565. */
  47566. gammaSpace: boolean;
  47567. }
  47568. /**
  47569. * Helper class usefull to convert panorama picture to their cubemap representation in 6 faces.
  47570. */
  47571. class PanoramaToCubeMapTools {
  47572. private static FACE_FRONT;
  47573. private static FACE_BACK;
  47574. private static FACE_RIGHT;
  47575. private static FACE_LEFT;
  47576. private static FACE_DOWN;
  47577. private static FACE_UP;
  47578. /**
  47579. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  47580. *
  47581. * @param float32Array The source data.
  47582. * @param inputWidth The width of the input panorama.
  47583. * @param inputHeight The height of the input panorama.
  47584. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  47585. * @return The cubemap data
  47586. */
  47587. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  47588. private static CreateCubemapTexture;
  47589. private static CalcProjectionSpherical;
  47590. }
  47591. }
  47592. declare module BABYLON {
  47593. }
  47594. declare module BABYLON {
  47595. }
  47596. declare module BABYLON {
  47597. }
  47598. declare module BABYLON {
  47599. }
  47600. declare module BABYLON {
  47601. /**
  47602. * Procedural texturing is a way to programmatically create a texture. There are 2 types of procedural textures: code-only, and code that references some classic 2D images, sometimes called 'refMaps' or 'sampler' images.
  47603. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  47604. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  47605. */
  47606. class CustomProceduralTexture extends ProceduralTexture {
  47607. private _animate;
  47608. private _time;
  47609. private _config;
  47610. private _texturePath;
  47611. /**
  47612. * Instantiates a new Custom Procedural Texture.
  47613. * Procedural texturing is a way to programmatically create a texture. There are 2 types of procedural textures: code-only, and code that references some classic 2D images, sometimes called 'refMaps' or 'sampler' images.
  47614. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  47615. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  47616. * @param name Define the name of the texture
  47617. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  47618. * @param size Define the size of the texture to create
  47619. * @param scene Define the scene the texture belongs to
  47620. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  47621. * @param generateMipMaps Define if the texture should creates mip maps or not
  47622. */
  47623. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  47624. private _loadJson;
  47625. /**
  47626. * Is the texture ready to be used ? (rendered at least once)
  47627. * @returns true if ready, otherwise, false.
  47628. */
  47629. isReady(): boolean;
  47630. /**
  47631. * Render the texture to its associated render target.
  47632. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  47633. */
  47634. render(useCameraPostProcess?: boolean): void;
  47635. /**
  47636. * Update the list of dependant textures samplers in the shader.
  47637. */
  47638. updateTextures(): void;
  47639. /**
  47640. * Update the uniform values of the procedural texture in the shader.
  47641. */
  47642. updateShaderUniforms(): void;
  47643. /**
  47644. * Define if the texture animates or not.
  47645. */
  47646. animate: boolean;
  47647. }
  47648. }
  47649. declare module BABYLON {
  47650. /**
  47651. * Class used to generate noise procedural textures
  47652. */
  47653. class NoiseProceduralTexture extends ProceduralTexture {
  47654. private _time;
  47655. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  47656. brightness: number;
  47657. /** Defines the number of octaves to process */
  47658. octaves: number;
  47659. /** Defines the level of persistence (0.8 by default) */
  47660. persistence: number;
  47661. /** Gets or sets animation speed factor (default is 1) */
  47662. animationSpeedFactor: number;
  47663. /**
  47664. * Creates a new NoiseProceduralTexture
  47665. * @param name defines the name fo the texture
  47666. * @param size defines the size of the texture (default is 256)
  47667. * @param scene defines the hosting scene
  47668. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  47669. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  47670. */
  47671. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  47672. private _updateShaderUniforms;
  47673. protected _getDefines(): string;
  47674. /** Generate the current state of the procedural texture */
  47675. render(useCameraPostProcess?: boolean): void;
  47676. /**
  47677. * Serializes this noise procedural texture
  47678. * @returns a serialized noise procedural texture object
  47679. */
  47680. serialize(): any;
  47681. /**
  47682. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  47683. * @param parsedTexture defines parsed texture data
  47684. * @param scene defines the current scene
  47685. * @param rootUrl defines the root URL containing noise procedural texture information
  47686. * @returns a parsed NoiseProceduralTexture
  47687. */
  47688. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): NoiseProceduralTexture;
  47689. }
  47690. }
  47691. declare module BABYLON {
  47692. /**
  47693. * Procedural texturing is a way to programmatically create a texture. There are 2 types of procedural textures: code-only, and code that references some classic 2D images, sometimes called 'refMaps' or 'sampler' images.
  47694. * This is the base class of any Procedural texture and contains most of the shareable code.
  47695. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  47696. */
  47697. class ProceduralTexture extends Texture {
  47698. isCube: boolean;
  47699. /**
  47700. * Define if the texture is enabled or not (disabled texture will not render)
  47701. */
  47702. isEnabled: boolean;
  47703. /**
  47704. * Define if the texture must be cleared before rendering (default is true)
  47705. */
  47706. autoClear: boolean;
  47707. /**
  47708. * Callback called when the texture is generated
  47709. */
  47710. onGenerated: () => void;
  47711. /**
  47712. * Event raised when the texture is generated
  47713. */
  47714. onGeneratedObservable: Observable<ProceduralTexture>;
  47715. /** @hidden */
  47716. /** @hidden **/
  47717. /** @hidden */
  47718. ;
  47719. private _size;
  47720. private _currentRefreshId;
  47721. private _refreshRate;
  47722. private _vertexBuffers;
  47723. private _indexBuffer;
  47724. private _uniforms;
  47725. private _samplers;
  47726. private _fragment;
  47727. private _floats;
  47728. private _ints;
  47729. private _floatsArrays;
  47730. private _colors3;
  47731. private _colors4;
  47732. private _vectors2;
  47733. private _vectors3;
  47734. private _matrices;
  47735. private _fallbackTexture;
  47736. private _fallbackTextureUsed;
  47737. private _engine;
  47738. private _cachedDefines;
  47739. private _contentUpdateId;
  47740. private _contentData;
  47741. /**
  47742. * Instantiates a new procedural texture.
  47743. * Procedural texturing is a way to programmatically create a texture. There are 2 types of procedural textures: code-only, and code that references some classic 2D images, sometimes called 'refMaps' or 'sampler' images.
  47744. * This is the base class of any Procedural texture and contains most of the shareable code.
  47745. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  47746. * @param name Define the name of the texture
  47747. * @param size Define the size of the texture to create
  47748. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  47749. * @param scene Define the scene the texture belongs to
  47750. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  47751. * @param generateMipMaps Define if the texture should creates mip maps or not
  47752. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  47753. */
  47754. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  47755. /**
  47756. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  47757. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  47758. */
  47759. getContent(): Nullable<ArrayBufferView>;
  47760. private _createIndexBuffer;
  47761. /** @hidden */
  47762. /**
  47763. * Resets the texture in order to recreate its associated resources.
  47764. * This can be called in case of context loss
  47765. */
  47766. reset(): void;
  47767. protected _getDefines(): string;
  47768. /**
  47769. * Is the texture ready to be used ? (rendered at least once)
  47770. * @returns true if ready, otherwise, false.
  47771. */
  47772. isReady(): boolean;
  47773. /**
  47774. * Resets the refresh counter of the texture and start bak from scratch.
  47775. * Could be usefull to regenerate the texture if it is setup to render only once.
  47776. */
  47777. resetRefreshCounter(): void;
  47778. /**
  47779. * Set the fragment shader to use in order to render the texture.
  47780. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  47781. */
  47782. setFragment(fragment: any): void;
  47783. /**
  47784. * Define the refresh rate of the texture or the rendering frequency.
  47785. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  47786. */
  47787. refreshRate: number;
  47788. /** @hidden */
  47789. /**
  47790. * Get the size the texture is rendering at.
  47791. * @returns the size (texture is always squared)
  47792. */
  47793. getRenderSize(): number;
  47794. /**
  47795. * Resize the texture to new value.
  47796. * @param size Define the new size the texture should have
  47797. * @param generateMipMaps Define whether the new texture should create mip maps
  47798. */
  47799. resize(size: number, generateMipMaps: boolean): void;
  47800. private _checkUniform;
  47801. /**
  47802. * Set a texture in the shader program used to render.
  47803. * @param name Define the name of the uniform samplers as defined in the shader
  47804. * @param texture Define the texture to bind to this sampler
  47805. * @return the texture itself allowing "fluent" like uniform updates
  47806. */
  47807. setTexture(name: string, texture: Texture): ProceduralTexture;
  47808. /**
  47809. * Set a float in the shader.
  47810. * @param name Define the name of the uniform as defined in the shader
  47811. * @param value Define the value to give to the uniform
  47812. * @return the texture itself allowing "fluent" like uniform updates
  47813. */
  47814. setFloat(name: string, value: number): ProceduralTexture;
  47815. /**
  47816. * Set a int in the shader.
  47817. * @param name Define the name of the uniform as defined in the shader
  47818. * @param value Define the value to give to the uniform
  47819. * @return the texture itself allowing "fluent" like uniform updates
  47820. */
  47821. setInt(name: string, value: number): ProceduralTexture;
  47822. /**
  47823. * Set an array of floats in the shader.
  47824. * @param name Define the name of the uniform as defined in the shader
  47825. * @param value Define the value to give to the uniform
  47826. * @return the texture itself allowing "fluent" like uniform updates
  47827. */
  47828. setFloats(name: string, value: number[]): ProceduralTexture;
  47829. /**
  47830. * Set a vec3 in the shader from a Color3.
  47831. * @param name Define the name of the uniform as defined in the shader
  47832. * @param value Define the value to give to the uniform
  47833. * @return the texture itself allowing "fluent" like uniform updates
  47834. */
  47835. setColor3(name: string, value: Color3): ProceduralTexture;
  47836. /**
  47837. * Set a vec4 in the shader from a Color4.
  47838. * @param name Define the name of the uniform as defined in the shader
  47839. * @param value Define the value to give to the uniform
  47840. * @return the texture itself allowing "fluent" like uniform updates
  47841. */
  47842. setColor4(name: string, value: Color4): ProceduralTexture;
  47843. /**
  47844. * Set a vec2 in the shader from a Vector2.
  47845. * @param name Define the name of the uniform as defined in the shader
  47846. * @param value Define the value to give to the uniform
  47847. * @return the texture itself allowing "fluent" like uniform updates
  47848. */
  47849. setVector2(name: string, value: Vector2): ProceduralTexture;
  47850. /**
  47851. * Set a vec3 in the shader from a Vector3.
  47852. * @param name Define the name of the uniform as defined in the shader
  47853. * @param value Define the value to give to the uniform
  47854. * @return the texture itself allowing "fluent" like uniform updates
  47855. */
  47856. setVector3(name: string, value: Vector3): ProceduralTexture;
  47857. /**
  47858. * Set a mat4 in the shader from a MAtrix.
  47859. * @param name Define the name of the uniform as defined in the shader
  47860. * @param value Define the value to give to the uniform
  47861. * @return the texture itself allowing "fluent" like uniform updates
  47862. */
  47863. setMatrix(name: string, value: Matrix): ProceduralTexture;
  47864. /**
  47865. * Render the texture to its associated render target.
  47866. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  47867. */
  47868. render(useCameraPostProcess?: boolean): void;
  47869. /**
  47870. * Clone the texture.
  47871. * @returns the cloned texture
  47872. */
  47873. clone(): ProceduralTexture;
  47874. /**
  47875. * Dispose the texture and release its asoociated resources.
  47876. */
  47877. dispose(): void;
  47878. }
  47879. }
  47880. declare module BABYLON {
  47881. interface AbstractScene {
  47882. /**
  47883. * The list of procedural textures added to the scene
  47884. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  47885. */
  47886. proceduralTextures: Array<ProceduralTexture>;
  47887. }
  47888. /**
  47889. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  47890. * in a given scene.
  47891. */
  47892. class ProceduralTextureSceneComponent implements ISceneComponent {
  47893. /**
  47894. * The component name helpfull to identify the component in the list of scene components.
  47895. */
  47896. readonly name: string;
  47897. /**
  47898. * The scene the component belongs to.
  47899. */
  47900. scene: Scene;
  47901. /**
  47902. * Creates a new instance of the component for the given scene
  47903. * @param scene Defines the scene to register the component in
  47904. */
  47905. constructor(scene: Scene);
  47906. /**
  47907. * Registers the component in a given scene
  47908. */
  47909. register(): void;
  47910. /**
  47911. * Rebuilds the elements related to this component in case of
  47912. * context lost for instance.
  47913. */
  47914. rebuild(): void;
  47915. /**
  47916. * Disposes the component and the associated ressources.
  47917. */
  47918. dispose(): void;
  47919. private _beforeClear;
  47920. }
  47921. }
  47922. declare module BABYLON {
  47923. /**
  47924. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  47925. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  47926. */
  47927. class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  47928. private _scene;
  47929. private _camerasToBeAttached;
  47930. /**
  47931. * ID of the sharpen post process,
  47932. */
  47933. private readonly SharpenPostProcessId;
  47934. /**
  47935. * @ignore
  47936. * ID of the image processing post process;
  47937. */
  47938. readonly ImageProcessingPostProcessId: string;
  47939. /**
  47940. * @ignore
  47941. * ID of the Fast Approximate Anti-Aliasing post process;
  47942. */
  47943. readonly FxaaPostProcessId: string;
  47944. /**
  47945. * ID of the chromatic aberration post process,
  47946. */
  47947. private readonly ChromaticAberrationPostProcessId;
  47948. /**
  47949. * ID of the grain post process
  47950. */
  47951. private readonly GrainPostProcessId;
  47952. /**
  47953. * Sharpen post process which will apply a sharpen convolution to enhance edges
  47954. */
  47955. sharpen: SharpenPostProcess;
  47956. private _sharpenEffect;
  47957. private bloom;
  47958. /**
  47959. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  47960. */
  47961. depthOfField: DepthOfFieldEffect;
  47962. /**
  47963. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  47964. */
  47965. fxaa: FxaaPostProcess;
  47966. /**
  47967. * Image post processing pass used to perform operations such as tone mapping or color grading.
  47968. */
  47969. imageProcessing: ImageProcessingPostProcess;
  47970. /**
  47971. * Chromatic aberration post process which will shift rgb colors in the image
  47972. */
  47973. chromaticAberration: ChromaticAberrationPostProcess;
  47974. private _chromaticAberrationEffect;
  47975. /**
  47976. * Grain post process which add noise to the image
  47977. */
  47978. grain: GrainPostProcess;
  47979. private _grainEffect;
  47980. /**
  47981. * Glow post process which adds a glow to emmisive areas of the image
  47982. */
  47983. private _glowLayer;
  47984. /**
  47985. * Animations which can be used to tweak settings over a period of time
  47986. */
  47987. animations: Animation[];
  47988. private _imageProcessingConfigurationObserver;
  47989. private _sharpenEnabled;
  47990. private _bloomEnabled;
  47991. private _depthOfFieldEnabled;
  47992. private _depthOfFieldBlurLevel;
  47993. private _fxaaEnabled;
  47994. private _imageProcessingEnabled;
  47995. private _defaultPipelineTextureType;
  47996. private _bloomScale;
  47997. private _chromaticAberrationEnabled;
  47998. private _grainEnabled;
  47999. private _buildAllowed;
  48000. /**
  48001. * Enable or disable the sharpen process from the pipeline
  48002. */
  48003. sharpenEnabled: boolean;
  48004. private _resizeObserver;
  48005. private _hardwareScaleLevel;
  48006. private _bloomKernel;
  48007. /**
  48008. * Specifies the size of the bloom blur kernel, relative to the final output size
  48009. */
  48010. bloomKernel: number;
  48011. /**
  48012. * Specifies the weight of the bloom in the final rendering
  48013. */
  48014. private _bloomWeight;
  48015. /**
  48016. * Specifies the luma threshold for the area that will be blurred by the bloom
  48017. */
  48018. private _bloomThreshold;
  48019. private _hdr;
  48020. /**
  48021. * The strength of the bloom.
  48022. */
  48023. bloomWeight: number;
  48024. /**
  48025. * The strength of the bloom.
  48026. */
  48027. bloomThreshold: number;
  48028. /**
  48029. * The scale of the bloom, lower value will provide better performance.
  48030. */
  48031. bloomScale: number;
  48032. /**
  48033. * Enable or disable the bloom from the pipeline
  48034. */
  48035. bloomEnabled: boolean;
  48036. private _rebuildBloom;
  48037. /**
  48038. * If the depth of field is enabled.
  48039. */
  48040. depthOfFieldEnabled: boolean;
  48041. /**
  48042. * Blur level of the depth of field effect. (Higher blur will effect performance)
  48043. */
  48044. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  48045. /**
  48046. * If the anti aliasing is enabled.
  48047. */
  48048. fxaaEnabled: boolean;
  48049. private _samples;
  48050. /**
  48051. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  48052. */
  48053. samples: number;
  48054. /**
  48055. * If image processing is enabled.
  48056. */
  48057. imageProcessingEnabled: boolean;
  48058. /**
  48059. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  48060. */
  48061. glowLayerEnabled: boolean;
  48062. /**
  48063. * Enable or disable the chromaticAberration process from the pipeline
  48064. */
  48065. chromaticAberrationEnabled: boolean;
  48066. /**
  48067. * Enable or disable the grain process from the pipeline
  48068. */
  48069. grainEnabled: boolean;
  48070. /**
  48071. * @constructor
  48072. * @param name - The rendering pipeline name (default: "")
  48073. * @param hdr - If high dynamic range textures should be used (default: true)
  48074. * @param scene - The scene linked to this pipeline (default: the last created scene)
  48075. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  48076. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  48077. */
  48078. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  48079. /**
  48080. * Force the compilation of the entire pipeline.
  48081. */
  48082. prepare(): void;
  48083. private _hasCleared;
  48084. private _prevPostProcess;
  48085. private _prevPrevPostProcess;
  48086. private _setAutoClearAndTextureSharing;
  48087. private _depthOfFieldSceneObserver;
  48088. private _buildPipeline;
  48089. private _disposePostProcesses;
  48090. /**
  48091. * Adds a camera to the pipeline
  48092. * @param camera the camera to be added
  48093. */
  48094. addCamera(camera: Camera): void;
  48095. /**
  48096. * Removes a camera from the pipeline
  48097. * @param camera the camera to remove
  48098. */
  48099. removeCamera(camera: Camera): void;
  48100. /**
  48101. * Dispose of the pipeline and stop all post processes
  48102. */
  48103. dispose(): void;
  48104. /**
  48105. * Serialize the rendering pipeline (Used when exporting)
  48106. * @returns the serialized object
  48107. */
  48108. serialize(): any;
  48109. /**
  48110. * Parse the serialized pipeline
  48111. * @param source Source pipeline.
  48112. * @param scene The scene to load the pipeline to.
  48113. * @param rootUrl The URL of the serialized pipeline.
  48114. * @returns An instantiated pipeline from the serialized object.
  48115. */
  48116. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  48117. }
  48118. }
  48119. declare module BABYLON {
  48120. /**
  48121. * BABYLON.JS Chromatic Aberration GLSL Shader
  48122. * Author: Olivier Guyot
  48123. * Separates very slightly R, G and B colors on the edges of the screen
  48124. * Inspired by Francois Tarlier & Martins Upitis
  48125. */
  48126. class LensRenderingPipeline extends PostProcessRenderPipeline {
  48127. /**
  48128. * @ignore
  48129. * The chromatic aberration PostProcess id in the pipeline
  48130. */
  48131. LensChromaticAberrationEffect: string;
  48132. /**
  48133. * @ignore
  48134. * The highlights enhancing PostProcess id in the pipeline
  48135. */
  48136. HighlightsEnhancingEffect: string;
  48137. /**
  48138. * @ignore
  48139. * The depth-of-field PostProcess id in the pipeline
  48140. */
  48141. LensDepthOfFieldEffect: string;
  48142. private _scene;
  48143. private _depthTexture;
  48144. private _grainTexture;
  48145. private _chromaticAberrationPostProcess;
  48146. private _highlightsPostProcess;
  48147. private _depthOfFieldPostProcess;
  48148. private _edgeBlur;
  48149. private _grainAmount;
  48150. private _chromaticAberration;
  48151. private _distortion;
  48152. private _highlightsGain;
  48153. private _highlightsThreshold;
  48154. private _dofDistance;
  48155. private _dofAperture;
  48156. private _dofDarken;
  48157. private _dofPentagon;
  48158. private _blurNoise;
  48159. /**
  48160. * @constructor
  48161. *
  48162. * Effect parameters are as follow:
  48163. * {
  48164. * chromatic_aberration: number; // from 0 to x (1 for realism)
  48165. * edge_blur: number; // from 0 to x (1 for realism)
  48166. * distortion: number; // from 0 to x (1 for realism)
  48167. * grain_amount: number; // from 0 to 1
  48168. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  48169. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  48170. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  48171. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  48172. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  48173. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  48174. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  48175. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  48176. * }
  48177. * Note: if an effect parameter is unset, effect is disabled
  48178. *
  48179. * @param name The rendering pipeline name
  48180. * @param parameters - An object containing all parameters (see above)
  48181. * @param scene The scene linked to this pipeline
  48182. * @param ratio The size of the postprocesses (0.5 means that your postprocess will have a width = canvas.width 0.5 and a height = canvas.height 0.5)
  48183. * @param cameras The array of cameras that the rendering pipeline will be attached to
  48184. */
  48185. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  48186. /**
  48187. * Sets the amount of blur at the edges
  48188. * @param amount blur amount
  48189. */
  48190. setEdgeBlur(amount: number): void;
  48191. /**
  48192. * Sets edge blur to 0
  48193. */
  48194. disableEdgeBlur(): void;
  48195. /**
  48196. * Sets the amout of grain
  48197. * @param amount Amount of grain
  48198. */
  48199. setGrainAmount(amount: number): void;
  48200. /**
  48201. * Set grain amount to 0
  48202. */
  48203. disableGrain(): void;
  48204. /**
  48205. * Sets the chromatic aberration amount
  48206. * @param amount amount of chromatic aberration
  48207. */
  48208. setChromaticAberration(amount: number): void;
  48209. /**
  48210. * Sets chromatic aberration amount to 0
  48211. */
  48212. disableChromaticAberration(): void;
  48213. /**
  48214. * Sets the EdgeDistortion amount
  48215. * @param amount amount of EdgeDistortion
  48216. */
  48217. setEdgeDistortion(amount: number): void;
  48218. /**
  48219. * Sets edge distortion to 0
  48220. */
  48221. disableEdgeDistortion(): void;
  48222. /**
  48223. * Sets the FocusDistance amount
  48224. * @param amount amount of FocusDistance
  48225. */
  48226. setFocusDistance(amount: number): void;
  48227. /**
  48228. * Disables depth of field
  48229. */
  48230. disableDepthOfField(): void;
  48231. /**
  48232. * Sets the Aperture amount
  48233. * @param amount amount of Aperture
  48234. */
  48235. setAperture(amount: number): void;
  48236. /**
  48237. * Sets the DarkenOutOfFocus amount
  48238. * @param amount amount of DarkenOutOfFocus
  48239. */
  48240. setDarkenOutOfFocus(amount: number): void;
  48241. /**
  48242. * Creates a pentagon bokeh effect
  48243. */
  48244. enablePentagonBokeh(): void;
  48245. /**
  48246. * Disables the pentagon bokeh effect
  48247. */
  48248. disablePentagonBokeh(): void;
  48249. /**
  48250. * Enables noise blur
  48251. */
  48252. enableNoiseBlur(): void;
  48253. /**
  48254. * Disables noise blur
  48255. */
  48256. disableNoiseBlur(): void;
  48257. /**
  48258. * Sets the HighlightsGain amount
  48259. * @param amount amount of HighlightsGain
  48260. */
  48261. setHighlightsGain(amount: number): void;
  48262. /**
  48263. * Sets the HighlightsThreshold amount
  48264. * @param amount amount of HighlightsThreshold
  48265. */
  48266. setHighlightsThreshold(amount: number): void;
  48267. /**
  48268. * Disables highlights
  48269. */
  48270. disableHighlights(): void;
  48271. /**
  48272. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  48273. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  48274. */
  48275. dispose(disableDepthRender?: boolean): void;
  48276. private _createChromaticAberrationPostProcess;
  48277. private _createHighlightsPostProcess;
  48278. private _createDepthOfFieldPostProcess;
  48279. private _createGrainTexture;
  48280. }
  48281. }
  48282. declare module BABYLON {
  48283. /**
  48284. * Render pipeline to produce ssao effect
  48285. */
  48286. class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  48287. /**
  48288. * @ignore
  48289. * The PassPostProcess id in the pipeline that contains the original scene color
  48290. */
  48291. SSAOOriginalSceneColorEffect: string;
  48292. /**
  48293. * @ignore
  48294. * The SSAO PostProcess id in the pipeline
  48295. */
  48296. SSAORenderEffect: string;
  48297. /**
  48298. * @ignore
  48299. * The horizontal blur PostProcess id in the pipeline
  48300. */
  48301. SSAOBlurHRenderEffect: string;
  48302. /**
  48303. * @ignore
  48304. * The vertical blur PostProcess id in the pipeline
  48305. */
  48306. SSAOBlurVRenderEffect: string;
  48307. /**
  48308. * @ignore
  48309. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  48310. */
  48311. SSAOCombineRenderEffect: string;
  48312. /**
  48313. * The output strength of the SSAO post-process. Default value is 1.0.
  48314. */
  48315. totalStrength: number;
  48316. /**
  48317. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  48318. */
  48319. maxZ: number;
  48320. /**
  48321. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  48322. */
  48323. minZAspect: number;
  48324. private _samples;
  48325. /**
  48326. * Number of samples used for the SSAO calculations. Default value is 8
  48327. */
  48328. samples: number;
  48329. private _textureSamples;
  48330. /**
  48331. * Number of samples to use for antialiasing
  48332. */
  48333. textureSamples: number;
  48334. /**
  48335. * Ratio object used for SSAO ratio and blur ratio
  48336. */
  48337. private _ratio;
  48338. /**
  48339. * Dynamically generated sphere sampler.
  48340. */
  48341. private _sampleSphere;
  48342. /**
  48343. * Blur filter offsets
  48344. */
  48345. private _samplerOffsets;
  48346. private _expensiveBlur;
  48347. /**
  48348. * If bilateral blur should be used
  48349. */
  48350. expensiveBlur: boolean;
  48351. /**
  48352. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  48353. */
  48354. radius: number;
  48355. /**
  48356. * The base color of the SSAO post-process
  48357. * The final result is "base + ssao" between [0, 1]
  48358. */
  48359. base: number;
  48360. /**
  48361. * Support test.
  48362. */
  48363. static readonly IsSupported: boolean;
  48364. private _scene;
  48365. private _depthTexture;
  48366. private _normalTexture;
  48367. private _randomTexture;
  48368. private _originalColorPostProcess;
  48369. private _ssaoPostProcess;
  48370. private _blurHPostProcess;
  48371. private _blurVPostProcess;
  48372. private _ssaoCombinePostProcess;
  48373. private _firstUpdate;
  48374. /**
  48375. * @constructor
  48376. * @param name The rendering pipeline name
  48377. * @param scene The scene linked to this pipeline
  48378. * @param ratio The size of the postprocesses. Can be a number shared between passes or an object for more precision: { ssaoRatio: 0.5, blurRatio: 1.0 }
  48379. * @param cameras The array of cameras that the rendering pipeline will be attached to
  48380. */
  48381. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  48382. /**
  48383. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  48384. */
  48385. dispose(disableGeometryBufferRenderer?: boolean): void;
  48386. private _createBlurPostProcess;
  48387. /** @hidden */
  48388. private _bits;
  48389. private _radicalInverse_VdC;
  48390. private _hammersley;
  48391. private _hemisphereSample_uniform;
  48392. private _generateHemisphere;
  48393. private _createSSAOPostProcess;
  48394. private _createSSAOCombinePostProcess;
  48395. private _createRandomTexture;
  48396. /**
  48397. * Serialize the rendering pipeline (Used when exporting)
  48398. * @returns the serialized object
  48399. */
  48400. serialize(): any;
  48401. /**
  48402. * Parse the serialized pipeline
  48403. * @param source Source pipeline.
  48404. * @param scene The scene to load the pipeline to.
  48405. * @param rootUrl The URL of the serialized pipeline.
  48406. * @returns An instantiated pipeline from the serialized object.
  48407. */
  48408. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  48409. }
  48410. }
  48411. declare module BABYLON {
  48412. /**
  48413. * Render pipeline to produce ssao effect
  48414. */
  48415. class SSAORenderingPipeline extends PostProcessRenderPipeline {
  48416. /**
  48417. * @ignore
  48418. * The PassPostProcess id in the pipeline that contains the original scene color
  48419. */
  48420. SSAOOriginalSceneColorEffect: string;
  48421. /**
  48422. * @ignore
  48423. * The SSAO PostProcess id in the pipeline
  48424. */
  48425. SSAORenderEffect: string;
  48426. /**
  48427. * @ignore
  48428. * The horizontal blur PostProcess id in the pipeline
  48429. */
  48430. SSAOBlurHRenderEffect: string;
  48431. /**
  48432. * @ignore
  48433. * The vertical blur PostProcess id in the pipeline
  48434. */
  48435. SSAOBlurVRenderEffect: string;
  48436. /**
  48437. * @ignore
  48438. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  48439. */
  48440. SSAOCombineRenderEffect: string;
  48441. /**
  48442. * The output strength of the SSAO post-process. Default value is 1.0.
  48443. */
  48444. totalStrength: number;
  48445. /**
  48446. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  48447. */
  48448. radius: number;
  48449. /**
  48450. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  48451. * Must not be equal to fallOff and superior to fallOff.
  48452. * Default value is 0.975
  48453. */
  48454. area: number;
  48455. /**
  48456. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  48457. * Must not be equal to area and inferior to area.
  48458. * Default value is 0.0
  48459. */
  48460. fallOff: number;
  48461. /**
  48462. * The base color of the SSAO post-process
  48463. * The final result is "base + ssao" between [0, 1]
  48464. */
  48465. base: number;
  48466. private _scene;
  48467. private _depthTexture;
  48468. private _randomTexture;
  48469. private _originalColorPostProcess;
  48470. private _ssaoPostProcess;
  48471. private _blurHPostProcess;
  48472. private _blurVPostProcess;
  48473. private _ssaoCombinePostProcess;
  48474. private _firstUpdate;
  48475. /**
  48476. * @constructor
  48477. * @param name - The rendering pipeline name
  48478. * @param scene - The scene linked to this pipeline
  48479. * @param ratio - The size of the postprocesses. Can be a number shared between passes or an object for more precision: { ssaoRatio: 0.5, combineRatio: 1.0 }
  48480. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  48481. */
  48482. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  48483. /**
  48484. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  48485. */
  48486. dispose(disableDepthRender?: boolean): void;
  48487. private _createBlurPostProcess;
  48488. /** @hidden */
  48489. private _createSSAOPostProcess;
  48490. private _createSSAOCombinePostProcess;
  48491. private _createRandomTexture;
  48492. }
  48493. }
  48494. declare module BABYLON {
  48495. /**
  48496. * Standard rendering pipeline
  48497. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  48498. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  48499. */
  48500. class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  48501. /**
  48502. * Public members
  48503. */
  48504. /**
  48505. * Post-process which contains the original scene color before the pipeline applies all the effects
  48506. */
  48507. originalPostProcess: Nullable<PostProcess>;
  48508. /**
  48509. * Post-process used to down scale an image x4
  48510. */
  48511. downSampleX4PostProcess: Nullable<PostProcess>;
  48512. /**
  48513. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  48514. */
  48515. brightPassPostProcess: Nullable<PostProcess>;
  48516. /**
  48517. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  48518. */
  48519. blurHPostProcesses: PostProcess[];
  48520. /**
  48521. * Post-process array storing all the vertical blur post-processes used by the pipeline
  48522. */
  48523. blurVPostProcesses: PostProcess[];
  48524. /**
  48525. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  48526. */
  48527. textureAdderPostProcess: Nullable<PostProcess>;
  48528. /**
  48529. * Post-process used to create volumetric lighting effect
  48530. */
  48531. volumetricLightPostProcess: Nullable<PostProcess>;
  48532. /**
  48533. * Post-process used to smooth the previous volumetric light post-process on the X axis
  48534. */
  48535. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  48536. /**
  48537. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  48538. */
  48539. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  48540. /**
  48541. * Post-process used to merge the volumetric light effect and the real scene color
  48542. */
  48543. volumetricLightMergePostProces: Nullable<PostProcess>;
  48544. /**
  48545. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  48546. */
  48547. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  48548. /**
  48549. * Base post-process used to calculate the average luminance of the final image for HDR
  48550. */
  48551. luminancePostProcess: Nullable<PostProcess>;
  48552. /**
  48553. * Post-processes used to create down sample post-processes in order to get
  48554. * the average luminance of the final image for HDR
  48555. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  48556. */
  48557. luminanceDownSamplePostProcesses: PostProcess[];
  48558. /**
  48559. * Post-process used to create a HDR effect (light adaptation)
  48560. */
  48561. hdrPostProcess: Nullable<PostProcess>;
  48562. /**
  48563. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  48564. */
  48565. textureAdderFinalPostProcess: Nullable<PostProcess>;
  48566. /**
  48567. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  48568. */
  48569. lensFlareFinalPostProcess: Nullable<PostProcess>;
  48570. /**
  48571. * Post-process used to merge the final HDR post-process and the real scene color
  48572. */
  48573. hdrFinalPostProcess: Nullable<PostProcess>;
  48574. /**
  48575. * Post-process used to create a lens flare effect
  48576. */
  48577. lensFlarePostProcess: Nullable<PostProcess>;
  48578. /**
  48579. * Post-process that merges the result of the lens flare post-process and the real scene color
  48580. */
  48581. lensFlareComposePostProcess: Nullable<PostProcess>;
  48582. /**
  48583. * Post-process used to create a motion blur effect
  48584. */
  48585. motionBlurPostProcess: Nullable<PostProcess>;
  48586. /**
  48587. * Post-process used to create a depth of field effect
  48588. */
  48589. depthOfFieldPostProcess: Nullable<PostProcess>;
  48590. /**
  48591. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  48592. */
  48593. fxaaPostProcess: Nullable<FxaaPostProcess>;
  48594. /**
  48595. * Represents the brightness threshold in order to configure the illuminated surfaces
  48596. */
  48597. brightThreshold: number;
  48598. /**
  48599. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  48600. */
  48601. blurWidth: number;
  48602. /**
  48603. * Sets if the blur for highlighted surfaces must be only horizontal
  48604. */
  48605. horizontalBlur: boolean;
  48606. /**
  48607. * Sets the overall exposure used by the pipeline
  48608. */
  48609. exposure: number;
  48610. /**
  48611. * Texture used typically to simulate "dirty" on camera lens
  48612. */
  48613. lensTexture: Nullable<Texture>;
  48614. /**
  48615. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  48616. */
  48617. volumetricLightCoefficient: number;
  48618. /**
  48619. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  48620. */
  48621. volumetricLightPower: number;
  48622. /**
  48623. * Used the set the blur intensity to smooth the volumetric lights
  48624. */
  48625. volumetricLightBlurScale: number;
  48626. /**
  48627. * Light (spot or directional) used to generate the volumetric lights rays
  48628. * The source light must have a shadow generate so the pipeline can get its
  48629. * depth map
  48630. */
  48631. sourceLight: Nullable<SpotLight | DirectionalLight>;
  48632. /**
  48633. * For eye adaptation, represents the minimum luminance the eye can see
  48634. */
  48635. hdrMinimumLuminance: number;
  48636. /**
  48637. * For eye adaptation, represents the decrease luminance speed
  48638. */
  48639. hdrDecreaseRate: number;
  48640. /**
  48641. * For eye adaptation, represents the increase luminance speed
  48642. */
  48643. hdrIncreaseRate: number;
  48644. /**
  48645. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  48646. */
  48647. lensColorTexture: Nullable<Texture>;
  48648. /**
  48649. * The overall strengh for the lens flare effect
  48650. */
  48651. lensFlareStrength: number;
  48652. /**
  48653. * Dispersion coefficient for lens flare ghosts
  48654. */
  48655. lensFlareGhostDispersal: number;
  48656. /**
  48657. * Main lens flare halo width
  48658. */
  48659. lensFlareHaloWidth: number;
  48660. /**
  48661. * Based on the lens distortion effect, defines how much the lens flare result
  48662. * is distorted
  48663. */
  48664. lensFlareDistortionStrength: number;
  48665. /**
  48666. * Lens star texture must be used to simulate rays on the flares and is available
  48667. * in the documentation
  48668. */
  48669. lensStarTexture: Nullable<Texture>;
  48670. /**
  48671. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  48672. * flare effect by taking account of the dirt texture
  48673. */
  48674. lensFlareDirtTexture: Nullable<Texture>;
  48675. /**
  48676. * Represents the focal length for the depth of field effect
  48677. */
  48678. depthOfFieldDistance: number;
  48679. /**
  48680. * Represents the blur intensity for the blurred part of the depth of field effect
  48681. */
  48682. depthOfFieldBlurWidth: number;
  48683. /**
  48684. * For motion blur, defines how much the image is blurred by the movement
  48685. */
  48686. motionStrength: number;
  48687. /**
  48688. * List of animations for the pipeline (IAnimatable implementation)
  48689. */
  48690. animations: Animation[];
  48691. /**
  48692. * Private members
  48693. */
  48694. private _scene;
  48695. private _currentDepthOfFieldSource;
  48696. private _basePostProcess;
  48697. private _hdrCurrentLuminance;
  48698. private _floatTextureType;
  48699. private _ratio;
  48700. private _bloomEnabled;
  48701. private _depthOfFieldEnabled;
  48702. private _vlsEnabled;
  48703. private _lensFlareEnabled;
  48704. private _hdrEnabled;
  48705. private _motionBlurEnabled;
  48706. private _fxaaEnabled;
  48707. private _motionBlurSamples;
  48708. private _volumetricLightStepsCount;
  48709. private _samples;
  48710. /**
  48711. * @ignore
  48712. * Specifies if the bloom pipeline is enabled
  48713. */
  48714. BloomEnabled: boolean;
  48715. /**
  48716. * @ignore
  48717. * Specifies if the depth of field pipeline is enabed
  48718. */
  48719. DepthOfFieldEnabled: boolean;
  48720. /**
  48721. * @ignore
  48722. * Specifies if the lens flare pipeline is enabed
  48723. */
  48724. LensFlareEnabled: boolean;
  48725. /**
  48726. * @ignore
  48727. * Specifies if the HDR pipeline is enabled
  48728. */
  48729. HDREnabled: boolean;
  48730. /**
  48731. * @ignore
  48732. * Specifies if the volumetric lights scattering effect is enabled
  48733. */
  48734. VLSEnabled: boolean;
  48735. /**
  48736. * @ignore
  48737. * Specifies if the motion blur effect is enabled
  48738. */
  48739. MotionBlurEnabled: boolean;
  48740. /**
  48741. * Specifies if anti-aliasing is enabled
  48742. */
  48743. fxaaEnabled: boolean;
  48744. /**
  48745. * Specifies the number of steps used to calculate the volumetric lights
  48746. * Typically in interval [50, 200]
  48747. */
  48748. volumetricLightStepsCount: number;
  48749. /**
  48750. * Specifies the number of samples used for the motion blur effect
  48751. * Typically in interval [16, 64]
  48752. */
  48753. motionBlurSamples: number;
  48754. /**
  48755. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  48756. */
  48757. samples: number;
  48758. /**
  48759. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  48760. * @constructor
  48761. * @param name The rendering pipeline name
  48762. * @param scene The scene linked to this pipeline
  48763. * @param ratio The size of the postprocesses (0.5 means that your postprocess will have a width = canvas.width 0.5 and a height = canvas.height 0.5)
  48764. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  48765. * @param cameras The array of cameras that the rendering pipeline will be attached to
  48766. */
  48767. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  48768. private _buildPipeline;
  48769. private _createDownSampleX4PostProcess;
  48770. private _createBrightPassPostProcess;
  48771. private _createBlurPostProcesses;
  48772. private _createTextureAdderPostProcess;
  48773. private _createVolumetricLightPostProcess;
  48774. private _createLuminancePostProcesses;
  48775. private _createHdrPostProcess;
  48776. private _createLensFlarePostProcess;
  48777. private _createDepthOfFieldPostProcess;
  48778. private _createMotionBlurPostProcess;
  48779. private _getDepthTexture;
  48780. private _disposePostProcesses;
  48781. /**
  48782. * Dispose of the pipeline and stop all post processes
  48783. */
  48784. dispose(): void;
  48785. /**
  48786. * Serialize the rendering pipeline (Used when exporting)
  48787. * @returns the serialized object
  48788. */
  48789. serialize(): any;
  48790. /**
  48791. * Parse the serialized pipeline
  48792. * @param source Source pipeline.
  48793. * @param scene The scene to load the pipeline to.
  48794. * @param rootUrl The URL of the serialized pipeline.
  48795. * @returns An instantiated pipeline from the serialized object.
  48796. */
  48797. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  48798. /**
  48799. * Luminance steps
  48800. */
  48801. static LuminanceSteps: number;
  48802. }
  48803. }
  48804. /*BabylonJS GUI*/
  48805. // Dependencies for this module:
  48806. // ../../../../Tools/Gulp/babylonjs
  48807. declare module BABYLON.GUI {
  48808. }
  48809. declare module BABYLON.GUI {
  48810. }
  48811. declare module BABYLON.GUI {
  48812. }
  48813. declare module BABYLON.GUI {
  48814. }
  48815. declare module BABYLON.GUI {
  48816. /**
  48817. * Interface used to define a control that can receive focus
  48818. */
  48819. export interface IFocusableControl {
  48820. /**
  48821. * Function called when the control receives the focus
  48822. */
  48823. onFocus(): void;
  48824. /**
  48825. * Function called when the control loses the focus
  48826. */
  48827. onBlur(): void;
  48828. /**
  48829. * Function called to let the control handle keyboard events
  48830. * @param evt defines the current keyboard event
  48831. */
  48832. processKeyboard(evt: KeyboardEvent): void;
  48833. /**
  48834. * Function called to get the list of controls that should not steal the focus from this control
  48835. * @returns an array of controls
  48836. */
  48837. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  48838. }
  48839. /**
  48840. * Class used to create texture to support 2D GUI elements
  48841. * @see http://doc.babylonjs.com/how_to/gui
  48842. */
  48843. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  48844. /** @hidden */
  48845. /** @hidden */
  48846. /** @hidden */ ;
  48847. /** @hidden */ ;
  48848. /** @hidden */ ;
  48849. /** @hidden */
  48850. /** @hidden */
  48851. /** @hidden */
  48852. /**
  48853. * Gets or sets a boolean defining if alpha is stored as premultiplied
  48854. */
  48855. premulAlpha: boolean;
  48856. /**
  48857. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  48858. * Useful when you want more antialiasing
  48859. */
  48860. renderScale: number;
  48861. /** Gets or sets the background color */
  48862. background: string;
  48863. /**
  48864. * Gets or sets the ideal width used to design controls.
  48865. * The GUI will then rescale everything accordingly
  48866. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  48867. */
  48868. idealWidth: number;
  48869. /**
  48870. * Gets or sets the ideal height used to design controls.
  48871. * The GUI will then rescale everything accordingly
  48872. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  48873. */
  48874. idealHeight: number;
  48875. /**
  48876. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  48877. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  48878. */
  48879. useSmallestIdeal: boolean;
  48880. /**
  48881. * Gets or sets a boolean indicating if adaptive scaling must be used
  48882. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  48883. */
  48884. renderAtIdealSize: boolean;
  48885. /**
  48886. * Gets the underlying layer used to render the texture when in fullscreen mode
  48887. */
  48888. readonly layer: BABYLON.Nullable<BABYLON.Layer>;
  48889. /**
  48890. * Gets the root container control
  48891. */
  48892. readonly rootContainer: Container;
  48893. /**
  48894. * Gets or sets the current focused control
  48895. */
  48896. focusedControl: BABYLON.Nullable<IFocusableControl>;
  48897. /**
  48898. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  48899. */
  48900. isForeground: boolean;
  48901. /**
  48902. * Creates a new AdvancedDynamicTexture
  48903. * @param name defines the name of the texture
  48904. * @param width defines the width of the texture
  48905. * @param height defines the height of the texture
  48906. * @param scene defines the hosting scene
  48907. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  48908. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  48909. */
  48910. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  48911. /**
  48912. * Function used to execute a function on all controls
  48913. * @param func defines the function to execute
  48914. * @param container defines the container where controls belong. If null the root container will be used
  48915. */
  48916. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  48917. /**
  48918. * Marks the texture as dirty forcing a complete update
  48919. */
  48920. markAsDirty(): void;
  48921. /**
  48922. * Helper function used to create a new style
  48923. * @returns a new style
  48924. * @see http://doc.babylonjs.com/how_to/gui#styles
  48925. */
  48926. createStyle(): Style;
  48927. /**
  48928. * Adds a new control to the root container
  48929. * @param control defines the control to add
  48930. * @returns the current texture
  48931. */
  48932. addControl(control: Control): AdvancedDynamicTexture;
  48933. /**
  48934. * Removes a control from the root container
  48935. * @param control defines the control to remove
  48936. * @returns the current texture
  48937. */
  48938. removeControl(control: Control): AdvancedDynamicTexture;
  48939. /**
  48940. * Release all resources
  48941. */
  48942. dispose(): void;
  48943. /** @hidden */
  48944. /**
  48945. * Get screen coordinates for a vector3
  48946. * @param position defines the position to project
  48947. * @param worldMatrix defines the world matrix to use
  48948. * @returns the projected position
  48949. */
  48950. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  48951. /** @hidden */
  48952. /** @hidden */ , control: Control): void;
  48953. /** @hidden */
  48954. /** Attach to all scene events required to support pointer events */
  48955. attach(): void;
  48956. /**
  48957. * Connect the texture to a hosting mesh to enable interactions
  48958. * @param mesh defines the mesh to attach to
  48959. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  48960. */
  48961. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  48962. /**
  48963. * Move the focus to a specific control
  48964. * @param control defines the control which will receive the focus
  48965. */
  48966. moveFocusToControl(control: IFocusableControl): void;
  48967. /**
  48968. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  48969. * @param mesh defines the mesh which will receive the texture
  48970. * @param width defines the texture width (1024 by default)
  48971. * @param height defines the texture height (1024 by default)
  48972. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  48973. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  48974. * @returns a new AdvancedDynamicTexture
  48975. */
  48976. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  48977. /**
  48978. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  48979. * In this mode the texture will rely on a layer for its rendering.
  48980. * This allows it to be treated like any other layer.
  48981. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  48982. * LayerMask is set through advancedTexture.layer.layerMask
  48983. * @param name defines name for the texture
  48984. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  48985. * @param scene defines the hsoting scene
  48986. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  48987. * @returns a new AdvancedDynamicTexture
  48988. */
  48989. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  48990. }
  48991. }
  48992. declare module BABYLON.GUI {
  48993. /**
  48994. * Class used to transport BABYLON.Vector2 information for pointer events
  48995. */
  48996. export class Vector2WithInfo extends BABYLON.Vector2 {
  48997. /** defines the current mouse button index */
  48998. buttonIndex: number;
  48999. /**
  49000. * Creates a new Vector2WithInfo
  49001. * @param source defines the vector2 data to transport
  49002. * @param buttonIndex defines the current mouse button index
  49003. */
  49004. constructor(source: BABYLON.Vector2,
  49005. /** defines the current mouse button index */
  49006. buttonIndex?: number);
  49007. }
  49008. /** Class used to provide 2D matrix features */
  49009. export class Matrix2D {
  49010. /** Gets the internal array of 6 floats used to store matrix data */
  49011. m: Float32Array;
  49012. /**
  49013. * Creates a new matrix
  49014. * @param m00 defines value for (0, 0)
  49015. * @param m01 defines value for (0, 1)
  49016. * @param m10 defines value for (1, 0)
  49017. * @param m11 defines value for (1, 1)
  49018. * @param m20 defines value for (2, 0)
  49019. * @param m21 defines value for (2, 1)
  49020. */
  49021. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  49022. /**
  49023. * Fills the matrix from direct values
  49024. * @param m00 defines value for (0, 0)
  49025. * @param m01 defines value for (0, 1)
  49026. * @param m10 defines value for (1, 0)
  49027. * @param m11 defines value for (1, 1)
  49028. * @param m20 defines value for (2, 0)
  49029. * @param m21 defines value for (2, 1)
  49030. * @returns the current modified matrix
  49031. */
  49032. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  49033. /**
  49034. * Gets matrix determinant
  49035. * @returns the determinant
  49036. */
  49037. determinant(): number;
  49038. /**
  49039. * Inverses the matrix and stores it in a target matrix
  49040. * @param result defines the target matrix
  49041. * @returns the current matrix
  49042. */
  49043. invertToRef(result: Matrix2D): Matrix2D;
  49044. /**
  49045. * Multiplies the current matrix with another one
  49046. * @param other defines the second operand
  49047. * @param result defines the target matrix
  49048. * @returns the current matrix
  49049. */
  49050. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  49051. /**
  49052. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  49053. * @param x defines the x coordinate to transform
  49054. * @param y defines the x coordinate to transform
  49055. * @param result defines the target vector2
  49056. * @returns the current matrix
  49057. */
  49058. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  49059. /**
  49060. * Creates an identity matrix
  49061. * @returns a new matrix
  49062. */
  49063. static Identity(): Matrix2D;
  49064. /**
  49065. * Creates a translation matrix and stores it in a target matrix
  49066. * @param x defines the x coordinate of the translation
  49067. * @param y defines the y coordinate of the translation
  49068. * @param result defines the target matrix
  49069. */
  49070. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  49071. /**
  49072. * Creates a scaling matrix and stores it in a target matrix
  49073. * @param x defines the x coordinate of the scaling
  49074. * @param y defines the y coordinate of the scaling
  49075. * @param result defines the target matrix
  49076. */
  49077. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  49078. /**
  49079. * Creates a rotation matrix and stores it in a target matrix
  49080. * @param angle defines the rotation angle
  49081. * @param result defines the target matrix
  49082. */
  49083. static RotationToRef(angle: number, result: Matrix2D): void;
  49084. /**
  49085. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  49086. * @param tx defines the x coordinate of the translation
  49087. * @param ty defines the y coordinate of the translation
  49088. * @param angle defines the rotation angle
  49089. * @param scaleX defines the x coordinate of the scaling
  49090. * @param scaleY defines the y coordinate of the scaling
  49091. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  49092. * @param result defines the target matrix
  49093. */
  49094. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  49095. }
  49096. }
  49097. declare module BABYLON.GUI {
  49098. /**
  49099. * Class used to store 2D control sizes
  49100. */
  49101. export class Measure {
  49102. /** defines left coordinate */
  49103. left: number;
  49104. /** defines top coordinate */
  49105. top: number;
  49106. /** defines width dimension */
  49107. width: number;
  49108. /** defines height dimension */
  49109. height: number;
  49110. /**
  49111. * Creates a new measure
  49112. * @param left defines left coordinate
  49113. * @param top defines top coordinate
  49114. * @param width defines width dimension
  49115. * @param height defines height dimension
  49116. */
  49117. constructor(
  49118. /** defines left coordinate */
  49119. left: number,
  49120. /** defines top coordinate */
  49121. top: number,
  49122. /** defines width dimension */
  49123. width: number,
  49124. /** defines height dimension */
  49125. height: number);
  49126. /**
  49127. * Copy from another measure
  49128. * @param other defines the other measure to copy from
  49129. */
  49130. copyFrom(other: Measure): void;
  49131. /**
  49132. * Check equality between this measure and another one
  49133. * @param other defines the other measures
  49134. * @returns true if both measures are equals
  49135. */
  49136. isEqualsTo(other: Measure): boolean;
  49137. /**
  49138. * Creates an empty measure
  49139. * @returns a new measure
  49140. */
  49141. static Empty(): Measure;
  49142. }
  49143. }
  49144. declare module BABYLON.GUI {
  49145. /**
  49146. * Class used to store a point for a MultiLine object.
  49147. * The point can be pure 2D coordinates, a mesh or a control
  49148. */
  49149. export class MultiLinePoint {
  49150. /** @hidden */
  49151. /**
  49152. * Creates a new MultiLinePoint
  49153. * @param multiLine defines the source MultiLine object
  49154. */
  49155. constructor(multiLine: MultiLine);
  49156. /** Gets or sets x coordinate */
  49157. x: string | number;
  49158. /** Gets or sets y coordinate */
  49159. y: string | number;
  49160. /** Gets or sets the control associated with this point */
  49161. control: BABYLON.Nullable<Control>;
  49162. /** Gets or sets the mesh associated with this point */
  49163. mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  49164. /** Resets links */
  49165. resetLinks(): void;
  49166. /**
  49167. * Gets a translation vector
  49168. * @returns the translation vector
  49169. */
  49170. translate(): BABYLON.Vector2;
  49171. /** Release associated resources */
  49172. dispose(): void;
  49173. }
  49174. }
  49175. declare module BABYLON.GUI {
  49176. /**
  49177. * Define a style used by control to automatically setup properties based on a template.
  49178. * Only support font related properties so far
  49179. */
  49180. export class Style implements BABYLON.IDisposable {
  49181. /** @hidden */
  49182. /** @hidden */
  49183. /**
  49184. * BABYLON.Observable raised when the style values are changed
  49185. */
  49186. onChangedObservable: BABYLON.Observable<Style>;
  49187. /**
  49188. * Creates a new style object
  49189. * @param host defines the AdvancedDynamicTexture which hosts this style
  49190. */
  49191. constructor(host: AdvancedDynamicTexture);
  49192. /**
  49193. * Gets or sets the font size
  49194. */
  49195. fontSize: string | number;
  49196. /**
  49197. * Gets or sets the font family
  49198. */
  49199. fontFamily: string;
  49200. /**
  49201. * Gets or sets the font style
  49202. */
  49203. fontStyle: string;
  49204. /** Gets or sets font weight */
  49205. fontWeight: string;
  49206. /** Dispose all associated resources */
  49207. dispose(): void;
  49208. }
  49209. }
  49210. declare module BABYLON.GUI {
  49211. /**
  49212. * Class used to specific a value and its associated unit
  49213. */
  49214. export class ValueAndUnit {
  49215. /** defines the unit to store */
  49216. unit: number;
  49217. /** defines a boolean indicating if the value can be negative */
  49218. negativeValueAllowed: boolean;
  49219. /**
  49220. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  49221. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  49222. */
  49223. ignoreAdaptiveScaling: boolean;
  49224. /**
  49225. * Creates a new ValueAndUnit
  49226. * @param value defines the value to store
  49227. * @param unit defines the unit to store
  49228. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  49229. */
  49230. constructor(value: number,
  49231. /** defines the unit to store */
  49232. unit?: number,
  49233. /** defines a boolean indicating if the value can be negative */
  49234. negativeValueAllowed?: boolean);
  49235. /** Gets a boolean indicating if the value is a percentage */
  49236. readonly isPercentage: boolean;
  49237. /** Gets a boolean indicating if the value is store as pixel */
  49238. readonly isPixel: boolean;
  49239. /** Gets direct internal value */
  49240. readonly internalValue: number;
  49241. /**
  49242. * Gets value as pixel
  49243. * @param host defines the root host
  49244. * @param refValue defines the reference value for percentages
  49245. * @returns the value as pixel
  49246. */
  49247. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  49248. /**
  49249. * Gets the value accordingly to its unit
  49250. * @param host defines the root host
  49251. * @returns the value
  49252. */
  49253. getValue(host: AdvancedDynamicTexture): number;
  49254. /**
  49255. * Gets a string representation of the value
  49256. * @param host defines the root host
  49257. * @returns a string
  49258. */
  49259. toString(host: AdvancedDynamicTexture): string;
  49260. /**
  49261. * Store a value parsed from a string
  49262. * @param source defines the source string
  49263. * @returns true if the value was successfully parsed
  49264. */
  49265. fromString(source: string | number): boolean;
  49266. /** UNITMODE_PERCENTAGE */
  49267. static readonly UNITMODE_PERCENTAGE: number;
  49268. /** UNITMODE_PIXEL */
  49269. static readonly UNITMODE_PIXEL: number;
  49270. }
  49271. }
  49272. declare module BABYLON.GUI {
  49273. }
  49274. declare module BABYLON.GUI {
  49275. }
  49276. declare module BABYLON.GUI {
  49277. /**
  49278. * Class used to manage 3D user interface
  49279. * @see http://doc.babylonjs.com/how_to/gui3d
  49280. */
  49281. export class GUI3DManager implements BABYLON.IDisposable {
  49282. /** @hidden */
  49283. /** @hidden */ ;
  49284. /** @hidden */ ;
  49285. /**
  49286. * BABYLON.Observable raised when the point picked by the pointer events changed
  49287. */
  49288. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  49289. /** @hidden */ ;
  49290. /** Gets the hosting scene */
  49291. readonly scene: BABYLON.Scene;
  49292. /** Gets associated utility layer */
  49293. readonly utilityLayer: BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  49294. /**
  49295. * Creates a new GUI3DManager
  49296. * @param scene
  49297. */
  49298. constructor(scene?: BABYLON.Scene);
  49299. /**
  49300. * Gets the root container
  49301. */
  49302. readonly rootContainer: Container3D;
  49303. /**
  49304. * Gets a boolean indicating if the given control is in the root child list
  49305. * @param control defines the control to check
  49306. * @returns true if the control is in the root child list
  49307. */
  49308. containsControl(control: Control3D): boolean;
  49309. /**
  49310. * Adds a control to the root child list
  49311. * @param control defines the control to add
  49312. * @returns the current manager
  49313. */
  49314. addControl(control: Control3D): GUI3DManager;
  49315. /**
  49316. * Removes a control from the root child list
  49317. * @param control defines the control to remove
  49318. * @returns the current container
  49319. */
  49320. removeControl(control: Control3D): GUI3DManager;
  49321. /**
  49322. * Releases all associated resources
  49323. */
  49324. dispose(): void;
  49325. }
  49326. }
  49327. declare module BABYLON.GUI {
  49328. /**
  49329. * Class used to transport BABYLON.Vector3 information for pointer events
  49330. */
  49331. export class Vector3WithInfo extends BABYLON.Vector3 {
  49332. /** defines the current mouse button index */
  49333. buttonIndex: number;
  49334. /**
  49335. * Creates a new Vector3WithInfo
  49336. * @param source defines the vector3 data to transport
  49337. * @param buttonIndex defines the current mouse button index
  49338. */
  49339. constructor(source: BABYLON.Vector3,
  49340. /** defines the current mouse button index */
  49341. buttonIndex?: number);
  49342. }
  49343. }
  49344. declare module BABYLON.GUI {
  49345. /**
  49346. * Class used to create 2D buttons
  49347. */
  49348. export class Button extends Rectangle {
  49349. name?: string | undefined;
  49350. /**
  49351. * Function called to generate a pointer enter animation
  49352. */
  49353. pointerEnterAnimation: () => void;
  49354. /**
  49355. * Function called to generate a pointer out animation
  49356. */
  49357. pointerOutAnimation: () => void;
  49358. /**
  49359. * Function called to generate a pointer down animation
  49360. */
  49361. pointerDownAnimation: () => void;
  49362. /**
  49363. * Function called to generate a pointer up animation
  49364. */
  49365. pointerUpAnimation: () => void;
  49366. /**
  49367. * Creates a new Button
  49368. * @param name defines the name of the button
  49369. */
  49370. constructor(name?: string | undefined);
  49371. protected _getTypeName(): string;
  49372. /** @hidden */
  49373. /** @hidden */
  49374. /** @hidden */
  49375. /** @hidden */
  49376. /** @hidden */
  49377. /**
  49378. * Creates a new button made with an image and a text
  49379. * @param name defines the name of the button
  49380. * @param text defines the text of the button
  49381. * @param imageUrl defines the url of the image
  49382. * @returns a new Button
  49383. */
  49384. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  49385. /**
  49386. * Creates a new button made with an image
  49387. * @param name defines the name of the button
  49388. * @param imageUrl defines the url of the image
  49389. * @returns a new Button
  49390. */
  49391. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  49392. /**
  49393. * Creates a new button made with a text
  49394. * @param name defines the name of the button
  49395. * @param text defines the text of the button
  49396. * @returns a new Button
  49397. */
  49398. static CreateSimpleButton(name: string, text: string): Button;
  49399. /**
  49400. * Creates a new button made with an image and a centered text
  49401. * @param name defines the name of the button
  49402. * @param text defines the text of the button
  49403. * @param imageUrl defines the url of the image
  49404. * @returns a new Button
  49405. */
  49406. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  49407. }
  49408. }
  49409. declare module BABYLON.GUI {
  49410. /**
  49411. * Class used to represent a 2D checkbox
  49412. */
  49413. export class Checkbox extends Control {
  49414. name?: string | undefined;
  49415. /** Gets or sets border thickness */
  49416. thickness: number;
  49417. /**
  49418. * BABYLON.Observable raised when isChecked property changes
  49419. */
  49420. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  49421. /** Gets or sets a value indicating the ratio between overall size and check size */
  49422. checkSizeRatio: number;
  49423. /** Gets or sets background color */
  49424. background: string;
  49425. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  49426. isChecked: boolean;
  49427. /**
  49428. * Creates a new CheckBox
  49429. * @param name defines the control name
  49430. */
  49431. constructor(name?: string | undefined);
  49432. protected _getTypeName(): string;
  49433. /** @hidden */
  49434. /** @hidden */
  49435. /**
  49436. * Utility function to easily create a checkbox with a header
  49437. * @param title defines the label to use for the header
  49438. * @param onValueChanged defines the callback to call when value changes
  49439. * @returns a StackPanel containing the checkbox and a textBlock
  49440. */
  49441. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  49442. }
  49443. }
  49444. declare module BABYLON.GUI {
  49445. /** Class used to create color pickers */
  49446. export class ColorPicker extends Control {
  49447. name?: string | undefined;
  49448. /**
  49449. * BABYLON.Observable raised when the value changes
  49450. */
  49451. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  49452. /** Gets or sets the color of the color picker */
  49453. value: BABYLON.Color3;
  49454. /** Gets or sets control width */
  49455. width: string | number;
  49456. /** Gets or sets control height */
  49457. height: string | number;
  49458. /** Gets or sets control size */
  49459. size: string | number;
  49460. /**
  49461. * Creates a new ColorPicker
  49462. * @param name defines the control name
  49463. */
  49464. constructor(name?: string | undefined);
  49465. protected _getTypeName(): string;
  49466. /** @hidden */
  49467. }
  49468. }
  49469. declare module BABYLON.GUI {
  49470. /**
  49471. * Root class for 2D containers
  49472. * @see http://doc.babylonjs.com/how_to/gui#containers
  49473. */
  49474. export class Container extends Control {
  49475. name?: string | undefined;
  49476. /** @hidden */
  49477. protected _children: Control[];
  49478. /** @hidden */
  49479. protected _measureForChildren: Measure;
  49480. /** @hidden */
  49481. protected _background: string;
  49482. /** @hidden */
  49483. protected _adaptWidthToChildren: boolean;
  49484. /** @hidden */
  49485. protected _adaptHeightToChildren: boolean;
  49486. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  49487. adaptHeightToChildren: boolean;
  49488. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  49489. adaptWidthToChildren: boolean;
  49490. /** Gets or sets background color */
  49491. background: string;
  49492. /** Gets the list of children */
  49493. readonly children: Control[];
  49494. /**
  49495. * Creates a new Container
  49496. * @param name defines the name of the container
  49497. */
  49498. constructor(name?: string | undefined);
  49499. protected _getTypeName(): string;
  49500. /**
  49501. * Gets a child using its name
  49502. * @param name defines the child name to look for
  49503. * @returns the child control if found
  49504. */
  49505. getChildByName(name: string): BABYLON.Nullable<Control>;
  49506. /**
  49507. * Gets a child using its type and its name
  49508. * @param name defines the child name to look for
  49509. * @param type defines the child type to look for
  49510. * @returns the child control if found
  49511. */
  49512. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  49513. /**
  49514. * Search for a specific control in children
  49515. * @param control defines the control to look for
  49516. * @returns true if the control is in child list
  49517. */
  49518. containsControl(control: Control): boolean;
  49519. /**
  49520. * Adds a new control to the current container
  49521. * @param control defines the control to add
  49522. * @returns the current container
  49523. */
  49524. addControl(control: BABYLON.Nullable<Control>): Container;
  49525. /**
  49526. * Removes all controls from the current container
  49527. * @returns the current container
  49528. */
  49529. clearControls(): Container;
  49530. /**
  49531. * Removes a control from the current container
  49532. * @param control defines the control to remove
  49533. * @returns the current container
  49534. */
  49535. removeControl(control: Control): Container;
  49536. /** @hidden */
  49537. /** @hidden */
  49538. /** @hidden */
  49539. protected _localDraw(context: CanvasRenderingContext2D): void;
  49540. /** @hidden */
  49541. /** @hidden */
  49542. /** @hidden */
  49543. /** @hidden */
  49544. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  49545. /** @hidden */
  49546. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  49547. /** Releases associated resources */
  49548. dispose(): void;
  49549. }
  49550. }
  49551. declare module BABYLON.GUI {
  49552. /**
  49553. * Root class used for all 2D controls
  49554. * @see http://doc.babylonjs.com/how_to/gui#controls
  49555. */
  49556. export class Control {
  49557. /** defines the name of the control */
  49558. name?: string | undefined;
  49559. /** @hidden */
  49560. /** @hidden */
  49561. /** Gets or sets the control parent */
  49562. parent: BABYLON.Nullable<Container>;
  49563. /** @hidden */
  49564. /** @hidden */
  49565. /** @hidden */
  49566. /** @hidden */
  49567. protected _fontOffset: {
  49568. ascent: number;
  49569. height: number;
  49570. descent: number;
  49571. };
  49572. /** @hidden */
  49573. protected _horizontalAlignment: number;
  49574. /** @hidden */
  49575. protected _verticalAlignment: number;
  49576. /** @hidden */
  49577. /** @hidden */
  49578. protected _cachedParentMeasure: Measure;
  49579. /** @hidden */
  49580. /** @hidden */
  49581. /** @hidden */
  49582. protected _invertTransformMatrix: Matrix2D;
  49583. /** @hidden */
  49584. protected _transformedPosition: BABYLON.Vector2;
  49585. /** @hidden */
  49586. protected _isEnabled: boolean;
  49587. protected _disabledColor: string;
  49588. /** @hidden */
  49589. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  49590. isHitTestVisible: boolean;
  49591. /** Gets or sets a boolean indicating if the control can block pointer events */
  49592. isPointerBlocker: boolean;
  49593. /** Gets or sets a boolean indicating if the control can be focusable */
  49594. isFocusInvisible: boolean;
  49595. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  49596. shadowOffsetX: number;
  49597. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  49598. shadowOffsetY: number;
  49599. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  49600. shadowBlur: number;
  49601. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  49602. shadowColor: string;
  49603. /** Gets or sets the cursor to use when the control is hovered */
  49604. hoverCursor: string;
  49605. /** @hidden */
  49606. protected _linkOffsetX: ValueAndUnit;
  49607. /** @hidden */
  49608. protected _linkOffsetY: ValueAndUnit;
  49609. /** Gets the control type name */
  49610. readonly typeName: string;
  49611. /**
  49612. * An event triggered when the pointer move over the control.
  49613. */
  49614. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  49615. /**
  49616. * An event triggered when the pointer move out of the control.
  49617. */
  49618. onPointerOutObservable: BABYLON.Observable<Control>;
  49619. /**
  49620. * An event triggered when the pointer taps the control
  49621. */
  49622. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  49623. /**
  49624. * An event triggered when pointer up
  49625. */
  49626. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  49627. /**
  49628. * An event triggered when a control is clicked on
  49629. */
  49630. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  49631. /**
  49632. * An event triggered when pointer enters the control
  49633. */
  49634. onPointerEnterObservable: BABYLON.Observable<Control>;
  49635. /**
  49636. * An event triggered when the control is marked as dirty
  49637. */
  49638. onDirtyObservable: BABYLON.Observable<Control>;
  49639. /**
  49640. * An event triggered after the control is drawn
  49641. */
  49642. onAfterDrawObservable: BABYLON.Observable<Control>;
  49643. /** Gets or set information about font offsets (used to render and align text) */
  49644. fontOffset: {
  49645. ascent: number;
  49646. height: number;
  49647. descent: number;
  49648. };
  49649. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  49650. alpha: number;
  49651. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  49652. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  49653. */
  49654. scaleX: number;
  49655. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  49656. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  49657. */
  49658. scaleY: number;
  49659. /** Gets or sets the rotation angle (0 by default)
  49660. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  49661. */
  49662. rotation: number;
  49663. /** Gets or sets the transformation center on Y axis (0 by default)
  49664. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  49665. */
  49666. transformCenterY: number;
  49667. /** Gets or sets the transformation center on X axis (0 by default)
  49668. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  49669. */
  49670. transformCenterX: number;
  49671. /**
  49672. * Gets or sets the horizontal alignment
  49673. * @see http://doc.babylonjs.com/how_to/gui#alignments
  49674. */
  49675. horizontalAlignment: number;
  49676. /**
  49677. * Gets or sets the vertical alignment
  49678. * @see http://doc.babylonjs.com/how_to/gui#alignments
  49679. */
  49680. verticalAlignment: number;
  49681. /**
  49682. * Gets or sets control width
  49683. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  49684. */
  49685. width: string | number;
  49686. /**
  49687. * Gets control width in pixel
  49688. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  49689. */
  49690. readonly widthInPixels: number;
  49691. /**
  49692. * Gets or sets control height
  49693. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  49694. */
  49695. height: string | number;
  49696. /**
  49697. * Gets control height in pixel
  49698. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  49699. */
  49700. readonly heightInPixels: number;
  49701. /** Gets or set font family */
  49702. fontFamily: string;
  49703. /** Gets or sets font style */
  49704. fontStyle: string;
  49705. /** Gets or sets font weight */
  49706. fontWeight: string;
  49707. /**
  49708. * Gets or sets style
  49709. * @see http://doc.babylonjs.com/how_to/gui#styles
  49710. */
  49711. style: BABYLON.Nullable<Style>;
  49712. /** @hidden */ protected readonly _isFontSizeInPercentage: boolean;
  49713. /** Gets font size in pixels */
  49714. readonly fontSizeInPixels: number;
  49715. /** Gets or sets font size */
  49716. fontSize: string | number;
  49717. /** Gets or sets foreground color */
  49718. color: string;
  49719. /** Gets or sets z index which is used to reorder controls on the z axis */
  49720. zIndex: number;
  49721. /** Gets or sets a boolean indicating if the control can be rendered */
  49722. notRenderable: boolean;
  49723. /** Gets or sets a boolean indicating if the control is visible */
  49724. isVisible: boolean;
  49725. /** Gets a boolean indicating that the control needs to update its rendering */
  49726. readonly isDirty: boolean;
  49727. /**
  49728. * Gets the current linked mesh (or null if none)
  49729. */
  49730. readonly linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  49731. /**
  49732. * Gets or sets a value indicating the padding to use on the left of the control
  49733. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  49734. */
  49735. paddingLeft: string | number;
  49736. /**
  49737. * Gets a value indicating the padding in pixels to use on the left of the control
  49738. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  49739. */
  49740. readonly paddingLeftInPixels: number;
  49741. /**
  49742. * Gets or sets a value indicating the padding to use on the right of the control
  49743. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  49744. */
  49745. paddingRight: string | number;
  49746. /**
  49747. * Gets a value indicating the padding in pixels to use on the right of the control
  49748. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  49749. */
  49750. readonly paddingRightInPixels: number;
  49751. /**
  49752. * Gets or sets a value indicating the padding to use on the top of the control
  49753. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  49754. */
  49755. paddingTop: string | number;
  49756. /**
  49757. * Gets a value indicating the padding in pixels to use on the top of the control
  49758. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  49759. */
  49760. readonly paddingTopInPixels: number;
  49761. /**
  49762. * Gets or sets a value indicating the padding to use on the bottom of the control
  49763. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  49764. */
  49765. paddingBottom: string | number;
  49766. /**
  49767. * Gets a value indicating the padding in pixels to use on the bottom of the control
  49768. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  49769. */
  49770. readonly paddingBottomInPixels: number;
  49771. /**
  49772. * Gets or sets a value indicating the left coordinate of the control
  49773. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  49774. */
  49775. left: string | number;
  49776. /**
  49777. * Gets a value indicating the left coordinate in pixels of the control
  49778. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  49779. */
  49780. readonly leftInPixels: number;
  49781. /**
  49782. * Gets or sets a value indicating the top coordinate of the control
  49783. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  49784. */
  49785. top: string | number;
  49786. /**
  49787. * Gets a value indicating the top coordinate in pixels of the control
  49788. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  49789. */
  49790. readonly topInPixels: number;
  49791. /**
  49792. * Gets or sets a value indicating the offset on X axis to the linked mesh
  49793. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  49794. */
  49795. linkOffsetX: string | number;
  49796. /**
  49797. * Gets a value indicating the offset in pixels on X axis to the linked mesh
  49798. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  49799. */
  49800. readonly linkOffsetXInPixels: number;
  49801. /**
  49802. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  49803. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  49804. */
  49805. linkOffsetY: string | number;
  49806. /**
  49807. * Gets a value indicating the offset in pixels on Y axis to the linked mesh
  49808. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  49809. */
  49810. readonly linkOffsetYInPixels: number;
  49811. /** Gets the center coordinate on X axis */
  49812. readonly centerX: number;
  49813. /** Gets the center coordinate on Y axis */
  49814. readonly centerY: number;
  49815. /** Gets or sets if control is Enabled*/
  49816. isEnabled: boolean;
  49817. /** Gets or sets background color of control if it's disabled*/
  49818. disabledColor: string;
  49819. /**
  49820. * Creates a new control
  49821. * @param name defines the name of the control
  49822. */
  49823. constructor(
  49824. /** defines the name of the control */
  49825. name?: string | undefined);
  49826. /** @hidden */
  49827. protected _getTypeName(): string;
  49828. /** @hidden */
  49829. /**
  49830. * Determines if a container is an ascendant of the current control
  49831. * @param container defines the container to look for
  49832. * @returns true if the container is one of the ascendant of the control
  49833. */
  49834. isAscendant(container: Control): boolean;
  49835. /**
  49836. * Gets coordinates in local control space
  49837. * @param globalCoordinates defines the coordinates to transform
  49838. * @returns the new coordinates in local space
  49839. */
  49840. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  49841. /**
  49842. * Gets coordinates in local control space
  49843. * @param globalCoordinates defines the coordinates to transform
  49844. * @param result defines the target vector2 where to store the result
  49845. * @returns the current control
  49846. */
  49847. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  49848. /**
  49849. * Gets coordinates in parent local control space
  49850. * @param globalCoordinates defines the coordinates to transform
  49851. * @returns the new coordinates in parent local space
  49852. */
  49853. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  49854. /**
  49855. * Move the current control to a vector3 position projected onto the screen.
  49856. * @param position defines the target position
  49857. * @param scene defines the hosting scene
  49858. */
  49859. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  49860. /**
  49861. * Link current control with a target mesh
  49862. * @param mesh defines the mesh to link with
  49863. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  49864. */
  49865. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  49866. /** @hidden */
  49867. /** @hidden */
  49868. /** @hidden */
  49869. /** @hidden */
  49870. /** @hidden */
  49871. /** @hidden */
  49872. /** @hidden */
  49873. protected _transform(context: CanvasRenderingContext2D): void;
  49874. /** @hidden */
  49875. protected _applyStates(context: CanvasRenderingContext2D): void;
  49876. /** @hidden */
  49877. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  49878. /** @hidden */
  49879. protected _clip(context: CanvasRenderingContext2D): void;
  49880. /** @hidden */
  49881. /** @hidden */
  49882. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  49883. /** @hidden */
  49884. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  49885. /** @hidden */
  49886. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  49887. /** @hidden */
  49888. /**
  49889. * Tests if a given coordinates belong to the current control
  49890. * @param x defines x coordinate to test
  49891. * @param y defines y coordinate to test
  49892. * @returns true if the coordinates are inside the control
  49893. */
  49894. contains(x: number, y: number): boolean;
  49895. /** @hidden */
  49896. /** @hidden */
  49897. /** @hidden */
  49898. /** @hidden */
  49899. /** @hidden */
  49900. /** @hidden */
  49901. /** @hidden */
  49902. /** @hidden */
  49903. /** Releases associated resources */
  49904. dispose(): void;
  49905. /** HORIZONTAL_ALIGNMENT_LEFT */
  49906. static readonly HORIZONTAL_ALIGNMENT_LEFT: number;
  49907. /** HORIZONTAL_ALIGNMENT_RIGHT */
  49908. static readonly HORIZONTAL_ALIGNMENT_RIGHT: number;
  49909. /** HORIZONTAL_ALIGNMENT_CENTER */
  49910. static readonly HORIZONTAL_ALIGNMENT_CENTER: number;
  49911. /** VERTICAL_ALIGNMENT_TOP */
  49912. static readonly VERTICAL_ALIGNMENT_TOP: number;
  49913. /** VERTICAL_ALIGNMENT_BOTTOM */
  49914. static readonly VERTICAL_ALIGNMENT_BOTTOM: number;
  49915. /** VERTICAL_ALIGNMENT_CENTER */
  49916. static readonly VERTICAL_ALIGNMENT_CENTER: number;
  49917. /** @hidden */ private static _GetFontOffset(font: string): {
  49918. ascent: number;
  49919. height: number;
  49920. descent: number;
  49921. };
  49922. /**
  49923. * Creates a stack panel that can be used to render headers
  49924. * @param control defines the control to associate with the header
  49925. * @param text defines the text of the header
  49926. * @param size defines the size of the header
  49927. * @param options defines options used to configure the header
  49928. * @returns a new StackPanel
  49929. * @ignore
  49930. * @hidden
  49931. */
  49932. static AddHeader: (control: Control, text: string, size: string | number, options: {
  49933. isHorizontal: boolean;
  49934. controlFirst: boolean;
  49935. }) => any;
  49936. /** @hidden */
  49937. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  49938. }
  49939. }
  49940. declare module BABYLON.GUI {
  49941. /** Class used to create 2D ellipse containers */
  49942. export class Ellipse extends Container {
  49943. name?: string | undefined;
  49944. /** Gets or sets border thickness */
  49945. thickness: number;
  49946. /**
  49947. * Creates a new Ellipse
  49948. * @param name defines the control name
  49949. */
  49950. constructor(name?: string | undefined);
  49951. protected _getTypeName(): string;
  49952. protected _localDraw(context: CanvasRenderingContext2D): void;
  49953. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  49954. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  49955. }
  49956. }
  49957. declare module BABYLON.GUI {
  49958. /**
  49959. * Class used to create a 2D grid container
  49960. */
  49961. export class Grid extends Container {
  49962. name?: string | undefined;
  49963. /** Gets the list of children */
  49964. readonly children: Control[];
  49965. /**
  49966. * Adds a new row to the grid
  49967. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  49968. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  49969. * @returns the current grid
  49970. */
  49971. addRowDefinition(height: number, isPixel?: boolean): Grid;
  49972. /**
  49973. * Adds a new column to the grid
  49974. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  49975. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  49976. * @returns the current grid
  49977. */
  49978. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  49979. /**
  49980. * Update a row definition
  49981. * @param index defines the index of the row to update
  49982. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  49983. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  49984. * @returns the current grid
  49985. */
  49986. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  49987. /**
  49988. * Update a column definition
  49989. * @param index defines the index of the column to update
  49990. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  49991. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  49992. * @returns the current grid
  49993. */
  49994. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  49995. /**
  49996. * Remove a column definition at specified index
  49997. * @param index defines the index of the column to remove
  49998. * @returns the current grid
  49999. */
  50000. removeColumnDefinition(index: number): Grid;
  50001. /**
  50002. * Remove a row definition at specified index
  50003. * @param index defines the index of the row to remove
  50004. * @returns the current grid
  50005. */
  50006. removeRowDefinition(index: number): Grid;
  50007. /**
  50008. * Adds a new control to the current grid
  50009. * @param control defines the control to add
  50010. * @param row defines the row where to add the control (0 by default)
  50011. * @param column defines the column where to add the control (0 by default)
  50012. * @returns the current grid
  50013. */
  50014. addControl(control: Control, row?: number, column?: number): Grid;
  50015. /**
  50016. * Removes a control from the current container
  50017. * @param control defines the control to remove
  50018. * @returns the current container
  50019. */
  50020. removeControl(control: Control): Container;
  50021. /**
  50022. * Creates a new Grid
  50023. * @param name defines control name
  50024. */
  50025. constructor(name?: string | undefined);
  50026. protected _getTypeName(): string;
  50027. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  50028. /** Releases associated resources */
  50029. dispose(): void;
  50030. }
  50031. }
  50032. declare module BABYLON.GUI {
  50033. /**
  50034. * Class used to create 2D images
  50035. */
  50036. export class Image extends Control {
  50037. name?: string | undefined;
  50038. /**
  50039. * Gets or sets the left coordinate in the source image
  50040. */
  50041. sourceLeft: number;
  50042. /**
  50043. * Gets or sets the top coordinate in the source image
  50044. */
  50045. sourceTop: number;
  50046. /**
  50047. * Gets or sets the width to capture in the source image
  50048. */
  50049. sourceWidth: number;
  50050. /**
  50051. * Gets or sets the height to capture in the source image
  50052. */
  50053. sourceHeight: number;
  50054. /**
  50055. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  50056. * @see http://doc.babylonjs.com/how_to/gui#image
  50057. */
  50058. autoScale: boolean;
  50059. /** Gets or sets the streching mode used by the image */
  50060. stretch: number;
  50061. /**
  50062. * Gets or sets the internal DOM image used to render the control
  50063. */
  50064. domImage: HTMLImageElement;
  50065. /**
  50066. * Gets or sets image source url
  50067. */
  50068. source: BABYLON.Nullable<string>;
  50069. /**
  50070. * Gets or sets the cell width to use when animation sheet is enabled
  50071. * @see http://doc.babylonjs.com/how_to/gui#image
  50072. */
  50073. cellWidth: number;
  50074. /**
  50075. * Gets or sets the cell height to use when animation sheet is enabled
  50076. * @see http://doc.babylonjs.com/how_to/gui#image
  50077. */
  50078. cellHeight: number;
  50079. /**
  50080. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  50081. * @see http://doc.babylonjs.com/how_to/gui#image
  50082. */
  50083. cellId: number;
  50084. /**
  50085. * Creates a new Image
  50086. * @param name defines the control name
  50087. * @param url defines the image url
  50088. */
  50089. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  50090. protected _getTypeName(): string;
  50091. /** Force the control to synchronize with its content */
  50092. synchronizeSizeWithContent(): void;
  50093. /** STRETCH_NONE */
  50094. static readonly STRETCH_NONE: number;
  50095. /** STRETCH_FILL */
  50096. static readonly STRETCH_FILL: number;
  50097. /** STRETCH_UNIFORM */
  50098. static readonly STRETCH_UNIFORM: number;
  50099. /** STRETCH_EXTEND */
  50100. static readonly STRETCH_EXTEND: number;
  50101. }
  50102. }
  50103. declare module BABYLON.GUI {
  50104. /**
  50105. * Class used to create input text control
  50106. */
  50107. export class InputText extends Control implements IFocusableControl {
  50108. name?: string | undefined;
  50109. /** @hidden */
  50110. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  50111. promptMessage: string;
  50112. /** BABYLON.Observable raised when the text changes */
  50113. onTextChangedObservable: BABYLON.Observable<InputText>;
  50114. /** BABYLON.Observable raised just before an entered character is to be added */
  50115. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  50116. /** BABYLON.Observable raised when the control gets the focus */
  50117. onFocusObservable: BABYLON.Observable<InputText>;
  50118. /** BABYLON.Observable raised when the control loses the focus */
  50119. onBlurObservable: BABYLON.Observable<InputText>;
  50120. /** Gets or sets the maximum width allowed by the control */
  50121. maxWidth: string | number;
  50122. /** Gets the maximum width allowed by the control in pixels */
  50123. readonly maxWidthInPixels: number;
  50124. /** Gets or sets control margin */
  50125. margin: string;
  50126. /** Gets control margin in pixels */
  50127. readonly marginInPixels: number;
  50128. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  50129. autoStretchWidth: boolean;
  50130. /** Gets or sets border thickness */
  50131. thickness: number;
  50132. /** Gets or sets the background color when focused */
  50133. focusedBackground: string;
  50134. /** Gets or sets the background color */
  50135. background: string;
  50136. /** Gets or sets the placeholder color */
  50137. placeholderColor: string;
  50138. /** Gets or sets the text displayed when the control is empty */
  50139. placeholderText: string;
  50140. /** Gets or sets the dead key flag */
  50141. deadKey: boolean;
  50142. /** Gets or sets if the current key should be added */
  50143. addKey: boolean;
  50144. /** Gets or sets the value of the current key being entered */
  50145. currentKey: string;
  50146. /** Gets or sets the text displayed in the control */
  50147. text: string;
  50148. /** Gets or sets control width */
  50149. width: string | number;
  50150. /**
  50151. * Creates a new InputText
  50152. * @param name defines the control name
  50153. * @param text defines the text of the control
  50154. */
  50155. constructor(name?: string | undefined, text?: string);
  50156. /** @hidden */
  50157. onBlur(): void;
  50158. /** @hidden */
  50159. onFocus(): void;
  50160. protected _getTypeName(): string;
  50161. /**
  50162. * Function called to get the list of controls that should not steal the focus from this control
  50163. * @returns an array of controls
  50164. */
  50165. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  50166. /** @hidden */
  50167. processKey(keyCode: number, key?: string): void;
  50168. /** @hidden */
  50169. processKeyboard(evt: KeyboardEvent): void;
  50170. protected _beforeRenderText(text: string): string;
  50171. dispose(): void;
  50172. }
  50173. }
  50174. declare module BABYLON.GUI {
  50175. /**
  50176. * Class used to create a password control
  50177. */
  50178. export class InputPassword extends InputText {
  50179. protected _beforeRenderText(text: string): string;
  50180. }
  50181. }
  50182. declare module BABYLON.GUI {
  50183. /** Class used to render 2D lines */
  50184. export class Line extends Control {
  50185. name?: string | undefined;
  50186. /** Gets or sets the dash pattern */
  50187. dash: Array<number>;
  50188. /** Gets or sets the control connected with the line end */
  50189. connectedControl: Control;
  50190. /** Gets or sets start coordinates on X axis */
  50191. x1: string | number;
  50192. /** Gets or sets start coordinates on Y axis */
  50193. y1: string | number;
  50194. /** Gets or sets end coordinates on X axis */
  50195. x2: string | number;
  50196. /** Gets or sets end coordinates on Y axis */
  50197. y2: string | number;
  50198. /** Gets or sets line width */
  50199. lineWidth: number;
  50200. /** Gets or sets horizontal alignment */
  50201. horizontalAlignment: number;
  50202. /** Gets or sets vertical alignment */
  50203. verticalAlignment: number;
  50204. /**
  50205. * Creates a new Line
  50206. * @param name defines the control name
  50207. */
  50208. constructor(name?: string | undefined);
  50209. protected _getTypeName(): string;
  50210. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  50211. /**
  50212. * Move one end of the line given 3D cartesian coordinates.
  50213. * @param position Targeted world position
  50214. * @param scene BABYLON.Scene
  50215. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  50216. */
  50217. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  50218. /**
  50219. * Move one end of the line to a position in screen absolute space.
  50220. * @param projectedPosition Position in screen absolute space (X, Y)
  50221. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  50222. */
  50223. }
  50224. }
  50225. declare module BABYLON.GUI {
  50226. /**
  50227. * Class used to create multi line control
  50228. */
  50229. export class MultiLine extends Control {
  50230. name?: string | undefined;
  50231. /**
  50232. * Creates a new MultiLine
  50233. * @param name defines the control name
  50234. */
  50235. constructor(name?: string | undefined);
  50236. /** Gets or sets dash pattern */
  50237. dash: Array<number>;
  50238. /**
  50239. * Gets point stored at specified index
  50240. * @param index defines the index to look for
  50241. * @returns the requested point if found
  50242. */
  50243. getAt(index: number): MultiLinePoint;
  50244. /** Function called when a point is updated */
  50245. onPointUpdate: () => void;
  50246. /**
  50247. * Adds new points to the point collection
  50248. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  50249. * @returns the list of created MultiLinePoint
  50250. */
  50251. add(...items: (AbstractMesh | Control | {
  50252. x: string | number;
  50253. y: string | number;
  50254. })[]): MultiLinePoint[];
  50255. /**
  50256. * Adds a new point to the point collection
  50257. * @param item defines the item (mesh, control or 2d coordiantes) to add
  50258. * @returns the created MultiLinePoint
  50259. */
  50260. push(item?: (AbstractMesh | Control | {
  50261. x: string | number;
  50262. y: string | number;
  50263. })): MultiLinePoint;
  50264. /**
  50265. * Remove a specific value or point from the active point collection
  50266. * @param value defines the value or point to remove
  50267. */
  50268. remove(value: number | MultiLinePoint): void;
  50269. /**
  50270. * Resets this object to initial state (no point)
  50271. */
  50272. reset(): void;
  50273. /**
  50274. * Resets all links
  50275. */
  50276. resetLinks(): void;
  50277. /** Gets or sets line width */
  50278. lineWidth: number;
  50279. horizontalAlignment: number;
  50280. verticalAlignment: number;
  50281. protected _getTypeName(): string;
  50282. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  50283. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  50284. dispose(): void;
  50285. }
  50286. }
  50287. declare module BABYLON.GUI {
  50288. /**
  50289. * Class used to create radio button controls
  50290. */
  50291. export class RadioButton extends Control {
  50292. name?: string | undefined;
  50293. /** Gets or sets border thickness */
  50294. thickness: number;
  50295. /** Gets or sets group name */
  50296. group: string;
  50297. /** BABYLON.Observable raised when isChecked is changed */
  50298. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  50299. /** Gets or sets a value indicating the ratio between overall size and check size */
  50300. checkSizeRatio: number;
  50301. /** Gets or sets background color */
  50302. background: string;
  50303. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  50304. isChecked: boolean;
  50305. /**
  50306. * Creates a new RadioButton
  50307. * @param name defines the control name
  50308. */
  50309. constructor(name?: string | undefined);
  50310. protected _getTypeName(): string;
  50311. /**
  50312. * Utility function to easily create a radio button with a header
  50313. * @param title defines the label to use for the header
  50314. * @param group defines the group to use for the radio button
  50315. * @param isChecked defines the initial state of the radio button
  50316. * @param onValueChanged defines the callback to call when value changes
  50317. * @returns a StackPanel containing the radio button and a textBlock
  50318. */
  50319. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  50320. }
  50321. }
  50322. declare module BABYLON.GUI {
  50323. /**
  50324. * Class used to create a 2D stack panel container
  50325. */
  50326. export class StackPanel extends Container {
  50327. name?: string | undefined;
  50328. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  50329. isVertical: boolean;
  50330. /** Gets or sets panel width */
  50331. width: string | number;
  50332. /** Gets or sets panel height */
  50333. height: string | number;
  50334. /**
  50335. * Creates a new StackPanel
  50336. * @param name defines control name
  50337. */
  50338. constructor(name?: string | undefined);
  50339. protected _getTypeName(): string;
  50340. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  50341. }
  50342. }
  50343. declare module BABYLON.GUI {
  50344. /** Class used to create a RadioGroup
  50345. * which contains groups of radio buttons
  50346. */
  50347. export class SelectorGroup {
  50348. /** name of SelectorGroup */
  50349. name: string;
  50350. /**
  50351. * Creates a new SelectorGroup
  50352. * @param name of group, used as a group heading
  50353. */
  50354. constructor(
  50355. /** name of SelectorGroup */
  50356. name: string);
  50357. /** Gets the groupPanel of the SelectorGroup */
  50358. readonly groupPanel: StackPanel;
  50359. /** Gets the selectors array */
  50360. readonly selectors: StackPanel[];
  50361. /** Gets and sets the group header */
  50362. header: string;
  50363. /** @hidden*/
  50364. /** Removes the selector at the given position
  50365. * @param selectorNb the position of the selector within the group
  50366. */
  50367. removeSelector(selectorNb: number): void;
  50368. }
  50369. /** Class used to create a CheckboxGroup
  50370. * which contains groups of checkbox buttons
  50371. */
  50372. export class CheckboxGroup extends SelectorGroup {
  50373. /** Adds a checkbox as a control
  50374. * @param text is the label for the selector
  50375. * @param func is the function called when the Selector is checked
  50376. * @param checked is true when Selector is checked
  50377. */
  50378. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  50379. /** @hidden */
  50380. /** @hidden */
  50381. /** @hidden */
  50382. /** @hidden */
  50383. }
  50384. /** Class used to create a RadioGroup
  50385. * which contains groups of radio buttons
  50386. */
  50387. export class RadioGroup extends SelectorGroup {
  50388. /** Adds a radio button as a control
  50389. * @param label is the label for the selector
  50390. * @param func is the function called when the Selector is checked
  50391. * @param checked is true when Selector is checked
  50392. */
  50393. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  50394. /** @hidden */
  50395. /** @hidden */
  50396. /** @hidden */
  50397. /** @hidden */
  50398. }
  50399. /** Class used to create a SliderGroup
  50400. * which contains groups of slider buttons
  50401. */
  50402. export class SliderGroup extends SelectorGroup {
  50403. /**
  50404. * Adds a slider to the SelectorGroup
  50405. * @param label is the label for the SliderBar
  50406. * @param func is the function called when the Slider moves
  50407. * @param unit is a string describing the units used, eg degrees or metres
  50408. * @param min is the minimum value for the Slider
  50409. * @param max is the maximum value for the Slider
  50410. * @param value is the start value for the Slider between min and max
  50411. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  50412. */
  50413. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  50414. /** @hidden */
  50415. /** @hidden */
  50416. /** @hidden */
  50417. /** @hidden */
  50418. }
  50419. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  50420. * @see http://doc.babylonjs.com/how_to/selector
  50421. */
  50422. export class SelectionPanel extends Rectangle {
  50423. /** name of SelectionPanel */
  50424. name: string;
  50425. /** an array of SelectionGroups */
  50426. groups: SelectorGroup[];
  50427. /**
  50428. * Creates a new SelectionPanel
  50429. * @param name of SelectionPanel
  50430. * @param groups is an array of SelectionGroups
  50431. */
  50432. constructor(
  50433. /** name of SelectionPanel */
  50434. name: string,
  50435. /** an array of SelectionGroups */
  50436. groups?: SelectorGroup[]);
  50437. protected _getTypeName(): string;
  50438. /** Gets or sets the headerColor */
  50439. headerColor: string;
  50440. /** Gets or sets the button color */
  50441. buttonColor: string;
  50442. /** Gets or sets the label color */
  50443. labelColor: string;
  50444. /** Gets or sets the button background */
  50445. buttonBackground: string;
  50446. /** Gets or sets the color of separator bar */
  50447. barColor: string;
  50448. /** Gets or sets the height of separator bar */
  50449. barHeight: string;
  50450. /** Gets or sets the height of spacers*/
  50451. spacerHeight: string;
  50452. /** Add a group to the selection panel
  50453. * @param group is the selector group to add
  50454. */
  50455. addGroup(group: SelectorGroup): void;
  50456. /** Remove the group from the given position
  50457. * @param groupNb is the position of the group in the list
  50458. */
  50459. removeGroup(groupNb: number): void;
  50460. /** Change a group header label
  50461. * @param label is the new group header label
  50462. * @param groupNb is the number of the group to relabel
  50463. * */
  50464. setHeaderName(label: string, groupNb: number): void;
  50465. /** Change selector label to the one given
  50466. * @param label is the new selector label
  50467. * @param groupNb is the number of the groupcontaining the selector
  50468. * @param selectorNb is the number of the selector within a group to relabel
  50469. * */
  50470. relabel(label: string, groupNb: number, selectorNb: number): void;
  50471. /** For a given group position remove the selector at the given position
  50472. * @param groupNb is the number of the group to remove the selector from
  50473. * @param selectorNb is the number of the selector within the group
  50474. */
  50475. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  50476. /** For a given group position of correct type add a checkbox button
  50477. * @param groupNb is the number of the group to remove the selector from
  50478. * @param label is the label for the selector
  50479. * @param func is the function called when the Selector is checked
  50480. * @param checked is true when Selector is checked
  50481. */
  50482. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  50483. /** For a given group position of correct type add a radio button
  50484. * @param groupNb is the number of the group to remove the selector from
  50485. * @param label is the label for the selector
  50486. * @param func is the function called when the Selector is checked
  50487. * @param checked is true when Selector is checked
  50488. */
  50489. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  50490. /**
  50491. * For a given slider group add a slider
  50492. * @param groupNb is the number of the group to add the slider to
  50493. * @param label is the label for the Slider
  50494. * @param func is the function called when the Slider moves
  50495. * @param unit is a string describing the units used, eg degrees or metres
  50496. * @param min is the minimum value for the Slider
  50497. * @param max is the maximum value for the Slider
  50498. * @param value is the start value for the Slider between min and max
  50499. * @param onVal is the function used to format the value displayed, eg radians to degrees
  50500. */
  50501. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  50502. }
  50503. }
  50504. declare module BABYLON.GUI {
  50505. /**
  50506. * Enum that determines the text-wrapping mode to use.
  50507. */
  50508. export enum TextWrapping {
  50509. /**
  50510. * Clip the text when it's larger than Control.width; this is the default mode.
  50511. */
  50512. Clip = 0,
  50513. /**
  50514. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  50515. */
  50516. WordWrap = 1,
  50517. /**
  50518. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  50519. */
  50520. Ellipsis = 2
  50521. }
  50522. /**
  50523. * Class used to create text block control
  50524. */
  50525. export class TextBlock extends Control {
  50526. /**
  50527. * Defines the name of the control
  50528. */
  50529. name?: string | undefined;
  50530. /**
  50531. * An event triggered after the text is changed
  50532. */
  50533. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  50534. /**
  50535. * An event triggered after the text was broken up into lines
  50536. */
  50537. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  50538. /**
  50539. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  50540. */
  50541. readonly lines: any[];
  50542. /**
  50543. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  50544. */
  50545. resizeToFit: boolean;
  50546. /**
  50547. * Gets or sets a boolean indicating if text must be wrapped
  50548. */
  50549. textWrapping: TextWrapping | boolean;
  50550. /**
  50551. * Gets or sets text to display
  50552. */
  50553. text: string;
  50554. /**
  50555. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  50556. */
  50557. textHorizontalAlignment: number;
  50558. /**
  50559. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  50560. */
  50561. textVerticalAlignment: number;
  50562. /**
  50563. * Gets or sets line spacing value
  50564. */
  50565. lineSpacing: string | number;
  50566. /**
  50567. * Gets or sets outlineWidth of the text to display
  50568. */
  50569. outlineWidth: number;
  50570. /**
  50571. * Gets or sets outlineColor of the text to display
  50572. */
  50573. outlineColor: string;
  50574. /**
  50575. * Creates a new TextBlock object
  50576. * @param name defines the name of the control
  50577. * @param text defines the text to display (emptry string by default)
  50578. */
  50579. constructor(
  50580. /**
  50581. * Defines the name of the control
  50582. */
  50583. name?: string | undefined, text?: string);
  50584. protected _getTypeName(): string;
  50585. /** @hidden */
  50586. protected _applyStates(context: CanvasRenderingContext2D): void;
  50587. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  50588. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  50589. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  50590. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  50591. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  50592. protected _renderLines(context: CanvasRenderingContext2D): void;
  50593. /**
  50594. * Given a width constraint applied on the text block, find the expected height
  50595. * @returns expected height
  50596. */
  50597. computeExpectedHeight(): number;
  50598. dispose(): void;
  50599. }
  50600. }
  50601. declare module BABYLON.GUI {
  50602. /**
  50603. * Class used to store key control properties
  50604. */
  50605. export class KeyPropertySet {
  50606. /** Width */
  50607. width?: string;
  50608. /** Height */
  50609. height?: string;
  50610. /** Left padding */
  50611. paddingLeft?: string;
  50612. /** Right padding */
  50613. paddingRight?: string;
  50614. /** Top padding */
  50615. paddingTop?: string;
  50616. /** Bottom padding */
  50617. paddingBottom?: string;
  50618. /** Foreground color */
  50619. color?: string;
  50620. /** Background color */
  50621. background?: string;
  50622. }
  50623. /**
  50624. * Class used to create virtual keyboard
  50625. */
  50626. export class VirtualKeyboard extends StackPanel {
  50627. /** BABYLON.Observable raised when a key is pressed */
  50628. onKeyPressObservable: BABYLON.Observable<string>;
  50629. /** Gets or sets default key button width */
  50630. defaultButtonWidth: string;
  50631. /** Gets or sets default key button height */
  50632. defaultButtonHeight: string;
  50633. /** Gets or sets default key button left padding */
  50634. defaultButtonPaddingLeft: string;
  50635. /** Gets or sets default key button right padding */
  50636. defaultButtonPaddingRight: string;
  50637. /** Gets or sets default key button top padding */
  50638. defaultButtonPaddingTop: string;
  50639. /** Gets or sets default key button bottom padding */
  50640. defaultButtonPaddingBottom: string;
  50641. /** Gets or sets default key button foreground color */
  50642. defaultButtonColor: string;
  50643. /** Gets or sets default key button background color */
  50644. defaultButtonBackground: string;
  50645. /** Gets or sets shift button foreground color */
  50646. shiftButtonColor: string;
  50647. /** Gets or sets shift button thickness*/
  50648. selectedShiftThickness: number;
  50649. /** Gets shift key state */
  50650. shiftState: number;
  50651. protected _getTypeName(): string;
  50652. /**
  50653. * Adds a new row of keys
  50654. * @param keys defines the list of keys to add
  50655. * @param propertySets defines the associated property sets
  50656. */
  50657. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  50658. /**
  50659. * Set the shift key to a specific state
  50660. * @param shiftState defines the new shift state
  50661. */
  50662. applyShiftState(shiftState: number): void;
  50663. /** Gets the input text control currently attached to the keyboard */
  50664. readonly connectedInputText: BABYLON.Nullable<InputText>;
  50665. /**
  50666. * Connects the keyboard with an input text control
  50667. *
  50668. * @param input defines the target control
  50669. */
  50670. connect(input: InputText): void;
  50671. /**
  50672. * Disconnects the keyboard from connected InputText controls
  50673. *
  50674. * @param input optionally defines a target control, otherwise all are disconnected
  50675. */
  50676. disconnect(input?: InputText): void;
  50677. /**
  50678. * Release all resources
  50679. */
  50680. dispose(): void;
  50681. /**
  50682. * Creates a new keyboard using a default layout
  50683. *
  50684. * @param name defines control name
  50685. * @returns a new VirtualKeyboard
  50686. */
  50687. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  50688. }
  50689. }
  50690. declare module BABYLON.GUI {
  50691. /**
  50692. * Class used to create slider controls
  50693. */
  50694. export class Slider extends Control {
  50695. name?: string | undefined;
  50696. /** BABYLON.Observable raised when the sldier value changes */
  50697. onValueChangedObservable: BABYLON.Observable<number>;
  50698. /** Gets or sets border color */
  50699. borderColor: string;
  50700. /** Gets or sets background color */
  50701. background: string;
  50702. /** Gets or sets main bar offset */
  50703. barOffset: string | number;
  50704. /** Gets main bar offset in pixels*/
  50705. readonly barOffsetInPixels: number;
  50706. /** Gets or sets thumb width */
  50707. thumbWidth: string | number;
  50708. /** Gets thumb width in pixels */
  50709. readonly thumbWidthInPixels: number;
  50710. /** Gets or sets minimum value */
  50711. minimum: number;
  50712. /** Gets or sets maximum value */
  50713. maximum: number;
  50714. /** Gets or sets current value */
  50715. value: number;
  50716. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  50717. isVertical: boolean;
  50718. /** Gets or sets a boolean indicating if the thumb should be round or square */
  50719. isThumbCircle: boolean;
  50720. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  50721. isThumbClamped: boolean;
  50722. /**
  50723. * Creates a new Slider
  50724. * @param name defines the control name
  50725. */
  50726. constructor(name?: string | undefined);
  50727. protected _getTypeName(): string;
  50728. protected _getThumbThickness(type: string, backgroundLength: number): number;
  50729. }
  50730. }
  50731. declare module BABYLON.GUI {
  50732. /** Class used to create rectangle container */
  50733. export class Rectangle extends Container {
  50734. name?: string | undefined;
  50735. /** Gets or sets border thickness */
  50736. thickness: number;
  50737. /** Gets or sets the corner radius angle */
  50738. cornerRadius: number;
  50739. /**
  50740. * Creates a new Rectangle
  50741. * @param name defines the control name
  50742. */
  50743. constructor(name?: string | undefined);
  50744. protected _getTypeName(): string;
  50745. protected _localDraw(context: CanvasRenderingContext2D): void;
  50746. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  50747. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  50748. }
  50749. }
  50750. declare module BABYLON.GUI {
  50751. /** Class used to render a grid */
  50752. export class DisplayGrid extends Control {
  50753. name?: string | undefined;
  50754. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  50755. displayMinorLines: boolean;
  50756. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  50757. displayMajorLines: boolean;
  50758. /** Gets or sets background color (Black by default) */
  50759. background: string;
  50760. /** Gets or sets the width of each cell (20 by default) */
  50761. cellWidth: number;
  50762. /** Gets or sets the height of each cell (20 by default) */
  50763. cellHeight: number;
  50764. /** Gets or sets the tickness of minor lines (1 by default) */
  50765. minorLineTickness: number;
  50766. /** Gets or sets the color of minor lines (DarkGray by default) */
  50767. minorLineColor: string;
  50768. /** Gets or sets the tickness of major lines (2 by default) */
  50769. majorLineTickness: number;
  50770. /** Gets or sets the color of major lines (White by default) */
  50771. majorLineColor: string;
  50772. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  50773. majorLineFrequency: number;
  50774. /**
  50775. * Creates a new GridDisplayRectangle
  50776. * @param name defines the control name
  50777. */
  50778. constructor(name?: string | undefined);
  50779. protected _getTypeName(): string;
  50780. }
  50781. }
  50782. declare module BABYLON.GUI {
  50783. /**
  50784. * Forcing an export so that this code will execute
  50785. * @hidden
  50786. */
  50787. const name = "Statics";
  50788. }
  50789. declare module BABYLON.GUI {
  50790. /**
  50791. * Class used as a root to all buttons
  50792. */
  50793. export class AbstractButton3D extends Control3D {
  50794. /**
  50795. * Creates a new button
  50796. * @param name defines the control name
  50797. */
  50798. constructor(name?: string);
  50799. protected _getTypeName(): string;
  50800. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  50801. }
  50802. }
  50803. declare module BABYLON.GUI {
  50804. /**
  50805. * Class used to create a button in 3D
  50806. */
  50807. export class Button3D extends AbstractButton3D {
  50808. /** @hidden */
  50809. protected _currentMaterial: BABYLON.Material;
  50810. /**
  50811. * Gets or sets the texture resolution used to render content (512 by default)
  50812. */
  50813. contentResolution: BABYLON.int;
  50814. /**
  50815. * Gets or sets the texture scale ratio used to render content (2 by default)
  50816. */
  50817. contentScaleRatio: number;
  50818. protected _disposeFacadeTexture(): void;
  50819. protected _resetContent(): void;
  50820. /**
  50821. * Creates a new button
  50822. * @param name defines the control name
  50823. */
  50824. constructor(name?: string);
  50825. /**
  50826. * Gets or sets the GUI 2D content used to display the button's facade
  50827. */
  50828. content: Control;
  50829. /**
  50830. * Apply the facade texture (created from the content property).
  50831. * This function can be overloaded by child classes
  50832. * @param facadeTexture defines the AdvancedDynamicTexture to use
  50833. */
  50834. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  50835. protected _getTypeName(): string;
  50836. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  50837. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  50838. /**
  50839. * Releases all associated resources
  50840. */
  50841. dispose(): void;
  50842. }
  50843. }
  50844. declare module BABYLON.GUI {
  50845. /**
  50846. * Class used to create containers for controls
  50847. */
  50848. export class Container3D extends Control3D {
  50849. /**
  50850. * Gets the list of child controls
  50851. */
  50852. protected _children: Control3D[];
  50853. /**
  50854. * Gets the list of child controls
  50855. */
  50856. readonly children: Array<Control3D>;
  50857. /**
  50858. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  50859. * This is helpful to optimize layout operation when adding multiple children in a row
  50860. */
  50861. blockLayout: boolean;
  50862. /**
  50863. * Creates a new container
  50864. * @param name defines the container name
  50865. */
  50866. constructor(name?: string);
  50867. /**
  50868. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  50869. * @returns the current container
  50870. */
  50871. updateLayout(): Container3D;
  50872. /**
  50873. * Gets a boolean indicating if the given control is in the children of this control
  50874. * @param control defines the control to check
  50875. * @returns true if the control is in the child list
  50876. */
  50877. containsControl(control: Control3D): boolean;
  50878. /**
  50879. * Adds a control to the children of this control
  50880. * @param control defines the control to add
  50881. * @returns the current container
  50882. */
  50883. addControl(control: Control3D): Container3D;
  50884. /**
  50885. * This function will be called everytime a new control is added
  50886. */
  50887. protected _arrangeChildren(): void;
  50888. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  50889. /**
  50890. * Removes a control from the children of this control
  50891. * @param control defines the control to remove
  50892. * @returns the current container
  50893. */
  50894. removeControl(control: Control3D): Container3D;
  50895. protected _getTypeName(): string;
  50896. /**
  50897. * Releases all associated resources
  50898. */
  50899. dispose(): void;
  50900. /** Control rotation will remain unchanged */
  50901. static readonly UNSET_ORIENTATION: number;
  50902. /** Control will rotate to make it look at sphere central axis */
  50903. static readonly FACEORIGIN_ORIENTATION: number;
  50904. /** Control will rotate to make it look back at sphere central axis */
  50905. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  50906. /** Control will rotate to look at z axis (0, 0, 1) */
  50907. static readonly FACEFORWARD_ORIENTATION: number;
  50908. /** Control will rotate to look at negative z axis (0, 0, -1) */
  50909. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  50910. }
  50911. }
  50912. declare module BABYLON.GUI {
  50913. /**
  50914. * Class used as base class for controls
  50915. */
  50916. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  50917. /** Defines the control name */
  50918. name?: string | undefined;
  50919. /** @hidden */
  50920. /** Gets or sets the control position in world space */
  50921. position: BABYLON.Vector3;
  50922. /** Gets or sets the control scaling in world space */
  50923. scaling: BABYLON.Vector3;
  50924. /** Callback used to start pointer enter animation */
  50925. pointerEnterAnimation: () => void;
  50926. /** Callback used to start pointer out animation */
  50927. pointerOutAnimation: () => void;
  50928. /** Callback used to start pointer down animation */
  50929. pointerDownAnimation: () => void;
  50930. /** Callback used to start pointer up animation */
  50931. pointerUpAnimation: () => void;
  50932. /**
  50933. * An event triggered when the pointer move over the control
  50934. */
  50935. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  50936. /**
  50937. * An event triggered when the pointer move out of the control
  50938. */
  50939. onPointerOutObservable: BABYLON.Observable<Control3D>;
  50940. /**
  50941. * An event triggered when the pointer taps the control
  50942. */
  50943. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  50944. /**
  50945. * An event triggered when pointer is up
  50946. */
  50947. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  50948. /**
  50949. * An event triggered when a control is clicked on (with a mouse)
  50950. */
  50951. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  50952. /**
  50953. * An event triggered when pointer enters the control
  50954. */
  50955. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  50956. /**
  50957. * Gets or sets the parent container
  50958. */
  50959. parent: BABYLON.Nullable<Container3D>;
  50960. /**
  50961. * Gets the list of attached behaviors
  50962. * @see http://doc.babylonjs.com/features/behaviour
  50963. */
  50964. readonly behaviors: BABYLON.Behavior<Control3D>[];
  50965. /**
  50966. * Attach a behavior to the control
  50967. * @see http://doc.babylonjs.com/features/behaviour
  50968. * @param behavior defines the behavior to attach
  50969. * @returns the current control
  50970. */
  50971. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  50972. /**
  50973. * Remove an attached behavior
  50974. * @see http://doc.babylonjs.com/features/behaviour
  50975. * @param behavior defines the behavior to attach
  50976. * @returns the current control
  50977. */
  50978. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  50979. /**
  50980. * Gets an attached behavior by name
  50981. * @param name defines the name of the behavior to look for
  50982. * @see http://doc.babylonjs.com/features/behaviour
  50983. * @returns null if behavior was not found else the requested behavior
  50984. */
  50985. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  50986. /** Gets or sets a boolean indicating if the control is visible */
  50987. isVisible: boolean;
  50988. /**
  50989. * Creates a new control
  50990. * @param name defines the control name
  50991. */
  50992. constructor(
  50993. /** Defines the control name */
  50994. name?: string | undefined);
  50995. /**
  50996. * Gets a string representing the class name
  50997. */
  50998. readonly typeName: string;
  50999. protected _getTypeName(): string;
  51000. /**
  51001. * Gets the transform node used by this control
  51002. */
  51003. readonly node: BABYLON.Nullable<BABYLON.TransformNode>;
  51004. /**
  51005. * Gets the mesh used to render this control
  51006. */
  51007. readonly mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  51008. /**
  51009. * Link the control as child of the given node
  51010. * @param node defines the node to link to. Use null to unlink the control
  51011. * @returns the current control
  51012. */
  51013. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  51014. /** @hidden **/
  51015. /**
  51016. * Node creation.
  51017. * Can be overriden by children
  51018. * @param scene defines the scene where the node must be attached
  51019. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  51020. */
  51021. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  51022. /**
  51023. * Affect a material to the given mesh
  51024. * @param mesh defines the mesh which will represent the control
  51025. */
  51026. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  51027. /** @hidden */
  51028. /** @hidden */
  51029. /** @hidden */
  51030. /** @hidden */
  51031. /** @hidden */
  51032. /** @hidden */
  51033. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  51034. /** @hidden */
  51035. /** @hidden */
  51036. /**
  51037. * Releases all associated resources
  51038. */
  51039. dispose(): void;
  51040. }
  51041. }
  51042. declare module BABYLON.GUI {
  51043. /**
  51044. * Class used to create a container panel deployed on the surface of a cylinder
  51045. */
  51046. export class CylinderPanel extends VolumeBasedPanel {
  51047. /**
  51048. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  51049. */
  51050. radius: BABYLON.float;
  51051. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  51052. }
  51053. }
  51054. declare module BABYLON.GUI {
  51055. /**
  51056. * Class used to create a holographic button in 3D
  51057. */
  51058. export class HolographicButton extends Button3D {
  51059. /**
  51060. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  51061. */
  51062. tooltipText: BABYLON.Nullable<string>;
  51063. /**
  51064. * Gets or sets text for the button
  51065. */
  51066. text: string;
  51067. /**
  51068. * Gets or sets the image url for the button
  51069. */
  51070. imageUrl: string;
  51071. /**
  51072. * Gets the back material used by this button
  51073. */
  51074. readonly backMaterial: FluentMaterial;
  51075. /**
  51076. * Gets the front material used by this button
  51077. */
  51078. readonly frontMaterial: FluentMaterial;
  51079. /**
  51080. * Gets the plate material used by this button
  51081. */
  51082. readonly plateMaterial: BABYLON.StandardMaterial;
  51083. /**
  51084. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  51085. */
  51086. readonly shareMaterials: boolean;
  51087. /**
  51088. * Creates a new button
  51089. * @param name defines the control name
  51090. */
  51091. constructor(name?: string, shareMaterials?: boolean);
  51092. protected _getTypeName(): string;
  51093. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  51094. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  51095. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  51096. /**
  51097. * Releases all associated resources
  51098. */
  51099. dispose(): void;
  51100. }
  51101. }
  51102. declare module BABYLON.GUI {
  51103. /**
  51104. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  51105. */
  51106. export class MeshButton3D extends Button3D {
  51107. /** @hidden */
  51108. protected _currentMesh: BABYLON.Mesh;
  51109. /**
  51110. * Creates a new 3D button based on a mesh
  51111. * @param mesh mesh to become a 3D button
  51112. * @param name defines the control name
  51113. */
  51114. constructor(mesh: BABYLON.Mesh, name?: string);
  51115. protected _getTypeName(): string;
  51116. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  51117. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  51118. }
  51119. }
  51120. declare module BABYLON.GUI {
  51121. /**
  51122. * Class used to create a container panel deployed on the surface of a plane
  51123. */
  51124. export class PlanePanel extends VolumeBasedPanel {
  51125. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  51126. }
  51127. }
  51128. declare module BABYLON.GUI {
  51129. /**
  51130. * Class used to create a container panel where items get randomized planar mapping
  51131. */
  51132. export class ScatterPanel extends VolumeBasedPanel {
  51133. /**
  51134. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  51135. */
  51136. iteration: BABYLON.float;
  51137. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  51138. protected _finalProcessing(): void;
  51139. }
  51140. }
  51141. declare module BABYLON.GUI {
  51142. /**
  51143. * Class used to create a container panel deployed on the surface of a sphere
  51144. */
  51145. export class SpherePanel extends VolumeBasedPanel {
  51146. /**
  51147. * Gets or sets the radius of the sphere where to project controls (5 by default)
  51148. */
  51149. radius: BABYLON.float;
  51150. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  51151. }
  51152. }
  51153. declare module BABYLON.GUI {
  51154. /**
  51155. * Class used to create a stack panel in 3D on XY plane
  51156. */
  51157. export class StackPanel3D extends Container3D {
  51158. /**
  51159. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  51160. */
  51161. isVertical: boolean;
  51162. /**
  51163. * Gets or sets the distance between elements
  51164. */
  51165. margin: number;
  51166. /**
  51167. * Creates new StackPanel
  51168. * @param isVertical
  51169. */
  51170. constructor(isVertical?: boolean);
  51171. protected _arrangeChildren(): void;
  51172. }
  51173. }
  51174. declare module BABYLON.GUI {
  51175. /**
  51176. * Abstract class used to create a container panel deployed on the surface of a volume
  51177. */
  51178. export abstract class VolumeBasedPanel extends Container3D {
  51179. protected _cellWidth: number;
  51180. protected _cellHeight: number;
  51181. /**
  51182. * Gets or sets the distance between elements
  51183. */
  51184. margin: number;
  51185. /**
  51186. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  51187. * | Value | Type | Description |
  51188. * | ----- | ----------------------------------- | ----------- |
  51189. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  51190. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  51191. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  51192. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  51193. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  51194. */
  51195. orientation: number;
  51196. /**
  51197. * Gets or sets the number of columns requested (10 by default).
  51198. * The panel will automatically compute the number of rows based on number of child controls.
  51199. */
  51200. columns: BABYLON.int;
  51201. /**
  51202. * Gets or sets a the number of rows requested.
  51203. * The panel will automatically compute the number of columns based on number of child controls.
  51204. */
  51205. rows: BABYLON.int;
  51206. /**
  51207. * Creates new VolumeBasedPanel
  51208. */
  51209. constructor();
  51210. protected _arrangeChildren(): void;
  51211. /** Child classes must implement this function to provide correct control positioning */
  51212. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  51213. /** Child classes can implement this function to provide additional processing */
  51214. protected _finalProcessing(): void;
  51215. }
  51216. }
  51217. declare module BABYLON.GUI {
  51218. /** @hidden */
  51219. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  51220. INNERGLOW: boolean;
  51221. BORDER: boolean;
  51222. HOVERLIGHT: boolean;
  51223. TEXTURE: boolean;
  51224. constructor();
  51225. }
  51226. /**
  51227. * Class used to render controls with fluent desgin
  51228. */
  51229. export class FluentMaterial extends BABYLON.PushMaterial {
  51230. /**
  51231. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  51232. */
  51233. innerGlowColorIntensity: number;
  51234. /**
  51235. * Gets or sets the inner glow color (white by default)
  51236. */
  51237. innerGlowColor: BABYLON.Color3;
  51238. /**
  51239. * Gets or sets alpha value (default is 1.0)
  51240. */
  51241. alpha: number;
  51242. /**
  51243. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  51244. */
  51245. albedoColor: BABYLON.Color3;
  51246. /**
  51247. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  51248. */
  51249. renderBorders: boolean;
  51250. /**
  51251. * Gets or sets border width (default is 0.5)
  51252. */
  51253. borderWidth: number;
  51254. /**
  51255. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  51256. */
  51257. edgeSmoothingValue: number;
  51258. /**
  51259. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  51260. */
  51261. borderMinValue: number;
  51262. /**
  51263. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  51264. */
  51265. renderHoverLight: boolean;
  51266. /**
  51267. * Gets or sets the radius used to render the hover light (default is 1.0)
  51268. */
  51269. hoverRadius: number;
  51270. /**
  51271. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  51272. */
  51273. hoverColor: BABYLON.Color4;
  51274. /**
  51275. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  51276. */
  51277. hoverPosition: BABYLON.Vector3;
  51278. /** Gets or sets the texture to use for albedo color */
  51279. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  51280. /**
  51281. * Creates a new Fluent material
  51282. * @param name defines the name of the material
  51283. * @param scene defines the hosting scene
  51284. */
  51285. constructor(name: string, scene: BABYLON.Scene);
  51286. needAlphaBlending(): boolean;
  51287. needAlphaTesting(): boolean;
  51288. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  51289. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  51290. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  51291. getActiveTextures(): BABYLON.BaseTexture[];
  51292. hasTexture(texture: BABYLON.BaseTexture): boolean;
  51293. dispose(forceDisposeEffect?: boolean): void;
  51294. clone(name: string): FluentMaterial;
  51295. serialize(): any;
  51296. getClassName(): string;
  51297. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  51298. }
  51299. }
  51300. declare module BABYLON {
  51301. /**
  51302. * Mode that determines the coordinate system to use.
  51303. */
  51304. enum GLTFLoaderCoordinateSystemMode {
  51305. /**
  51306. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  51307. */
  51308. AUTO = 0,
  51309. /**
  51310. * Sets the useRightHandedSystem flag on the scene.
  51311. */
  51312. FORCE_RIGHT_HANDED = 1
  51313. }
  51314. /**
  51315. * Mode that determines what animations will start.
  51316. */
  51317. enum GLTFLoaderAnimationStartMode {
  51318. /**
  51319. * No animation will start.
  51320. */
  51321. NONE = 0,
  51322. /**
  51323. * The first animation will start.
  51324. */
  51325. FIRST = 1,
  51326. /**
  51327. * All animations will start.
  51328. */
  51329. ALL = 2
  51330. }
  51331. /**
  51332. * Interface that contains the data for the glTF asset.
  51333. */
  51334. interface IGLTFLoaderData {
  51335. /**
  51336. * Object that represents the glTF JSON.
  51337. */
  51338. json: Object;
  51339. /**
  51340. * The BIN chunk of a binary glTF.
  51341. */
  51342. bin: Nullable<ArrayBufferView>;
  51343. }
  51344. /**
  51345. * Interface for extending the loader.
  51346. */
  51347. interface IGLTFLoaderExtension {
  51348. /**
  51349. * The name of this extension.
  51350. */
  51351. readonly name: string;
  51352. /**
  51353. * Defines whether this extension is enabled.
  51354. */
  51355. enabled: boolean;
  51356. }
  51357. /**
  51358. * Loader state.
  51359. */
  51360. enum GLTFLoaderState {
  51361. /**
  51362. * The asset is loading.
  51363. */
  51364. LOADING = 0,
  51365. /**
  51366. * The asset is ready for rendering.
  51367. */
  51368. READY = 1,
  51369. /**
  51370. * The asset is completely loaded.
  51371. */
  51372. COMPLETE = 2
  51373. }
  51374. /** @hidden */
  51375. interface IGLTFLoader extends IDisposable {
  51376. readonly state: Nullable<GLTFLoaderState>;
  51377. importMeshAsync: (meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<{
  51378. meshes: AbstractMesh[];
  51379. particleSystems: IParticleSystem[];
  51380. skeletons: Skeleton[];
  51381. animationGroups: AnimationGroup[];
  51382. }>;
  51383. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  51384. }
  51385. /**
  51386. * File loader for loading glTF files into a scene.
  51387. */
  51388. class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  51389. /** @hidden */
  51390. private static _CreateGLTFLoaderV1: (parent: GLTFFileLoader) => IGLTFLoader;
  51391. /** @hidden */
  51392. private static _CreateGLTFLoaderV2: (parent: GLTFFileLoader) => IGLTFLoader;
  51393. /**
  51394. * Raised when the asset has been parsed
  51395. */
  51396. onParsedObservable: Observable<IGLTFLoaderData>;
  51397. private _onParsedObserver;
  51398. /**
  51399. * Raised when the asset has been parsed
  51400. */
  51401. onParsed: (loaderData: IGLTFLoaderData) => void;
  51402. /**
  51403. * 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.
  51404. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  51405. * Defaults to true.
  51406. * @hidden
  51407. */
  51408. static IncrementalLoading: boolean;
  51409. /**
  51410. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  51411. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  51412. * @hidden
  51413. */
  51414. static HomogeneousCoordinates: boolean;
  51415. /**
  51416. * The coordinate system mode. Defaults to AUTO.
  51417. */
  51418. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  51419. /**
  51420. * The animation start mode. Defaults to FIRST.
  51421. */
  51422. animationStartMode: GLTFLoaderAnimationStartMode;
  51423. /**
  51424. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  51425. */
  51426. compileMaterials: boolean;
  51427. /**
  51428. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  51429. */
  51430. useClipPlane: boolean;
  51431. /**
  51432. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  51433. */
  51434. compileShadowGenerators: boolean;
  51435. /**
  51436. * Defines if the Alpha blended materials are only applied as coverage.
  51437. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  51438. * If true, no extra effects are applied to transparent pixels.
  51439. */
  51440. transparencyAsCoverage: boolean;
  51441. /**
  51442. * Function called before loading a url referenced by the asset.
  51443. */
  51444. preprocessUrlAsync: (url: string) => Promise<string>;
  51445. /**
  51446. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  51447. */
  51448. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  51449. private _onMeshLoadedObserver;
  51450. /**
  51451. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  51452. */
  51453. onMeshLoaded: (mesh: AbstractMesh) => void;
  51454. /**
  51455. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  51456. */
  51457. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  51458. private _onTextureLoadedObserver;
  51459. /**
  51460. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  51461. */
  51462. onTextureLoaded: (texture: BaseTexture) => void;
  51463. /**
  51464. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  51465. */
  51466. readonly onMaterialLoadedObservable: Observable<Material>;
  51467. private _onMaterialLoadedObserver;
  51468. /**
  51469. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  51470. */
  51471. onMaterialLoaded: (material: Material) => void;
  51472. /**
  51473. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  51474. */
  51475. readonly onCameraLoadedObservable: Observable<Camera>;
  51476. private _onCameraLoadedObserver;
  51477. /**
  51478. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  51479. */
  51480. onCameraLoaded: (camera: Camera) => void;
  51481. /**
  51482. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  51483. * For assets with LODs, raised when all of the LODs are complete.
  51484. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  51485. */
  51486. readonly onCompleteObservable: Observable<void>;
  51487. private _onCompleteObserver;
  51488. /**
  51489. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  51490. * For assets with LODs, raised when all of the LODs are complete.
  51491. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  51492. */
  51493. onComplete: () => void;
  51494. /**
  51495. * Observable raised when an error occurs.
  51496. */
  51497. readonly onErrorObservable: Observable<any>;
  51498. private _onErrorObserver;
  51499. /**
  51500. * Callback raised when an error occurs.
  51501. */
  51502. onError: (reason: any) => void;
  51503. /**
  51504. * Observable raised after the loader is disposed.
  51505. */
  51506. readonly onDisposeObservable: Observable<void>;
  51507. private _onDisposeObserver;
  51508. /**
  51509. * Callback raised after the loader is disposed.
  51510. */
  51511. onDispose: () => void;
  51512. /**
  51513. * Observable raised after a loader extension is created.
  51514. * Set additional options for a loader extension in this event.
  51515. */
  51516. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  51517. private _onExtensionLoadedObserver;
  51518. /**
  51519. * Callback raised after a loader extension is created.
  51520. */
  51521. onExtensionLoaded: (extension: IGLTFLoaderExtension) => void;
  51522. /**
  51523. * Defines if the loader logging is enabled.
  51524. */
  51525. loggingEnabled: boolean;
  51526. /**
  51527. * Defines if the loader should capture performance counters.
  51528. */
  51529. capturePerformanceCounters: boolean;
  51530. /**
  51531. * Defines if the loader should validate the asset.
  51532. */
  51533. validate: boolean;
  51534. /**
  51535. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  51536. */
  51537. readonly onValidatedObservable: Observable<IGLTFValidationResults>;
  51538. private _onValidatedObserver;
  51539. /**
  51540. * Callback raised after a loader extension is created.
  51541. */
  51542. onValidated: (results: IGLTFValidationResults) => void;
  51543. private _loader;
  51544. /**
  51545. * Name of the loader ("gltf")
  51546. */
  51547. name: string;
  51548. /**
  51549. * Supported file extensions of the loader (.gltf, .glb)
  51550. */
  51551. extensions: ISceneLoaderPluginExtensions;
  51552. /**
  51553. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  51554. */
  51555. dispose(): void;
  51556. /** @hidden */
  51557. /**
  51558. * Imports one or more meshes from the loaded glTF data and adds them to the scene
  51559. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  51560. * @param scene the scene the meshes should be added to
  51561. * @param data the glTF data to load
  51562. * @param rootUrl root url to load from
  51563. * @param onProgress event that fires when loading progress has occured
  51564. * @param fileName Defines the name of the file to load
  51565. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  51566. */
  51567. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  51568. meshes: AbstractMesh[];
  51569. particleSystems: IParticleSystem[];
  51570. skeletons: Skeleton[];
  51571. animationGroups: AnimationGroup[];
  51572. }>;
  51573. /**
  51574. * Imports all objects from the loaded glTF data and adds them to the scene
  51575. * @param scene the scene the objects should be added to
  51576. * @param data the glTF data to load
  51577. * @param rootUrl root url to load from
  51578. * @param onProgress event that fires when loading progress has occured
  51579. * @param fileName Defines the name of the file to load
  51580. * @returns a promise which completes when objects have been loaded to the scene
  51581. */
  51582. loadAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  51583. /**
  51584. * Load into an asset container.
  51585. * @param scene The scene to load into
  51586. * @param data The data to import
  51587. * @param rootUrl The root url for scene and resources
  51588. * @param onProgress The callback when the load progresses
  51589. * @param fileName Defines the name of the file to load
  51590. * @returns The loaded asset container
  51591. */
  51592. loadAssetContainerAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  51593. /**
  51594. * If the data string can be loaded directly.
  51595. * @param data string contianing the file data
  51596. * @returns if the data can be loaded directly
  51597. */
  51598. canDirectLoad(data: string): boolean;
  51599. /**
  51600. * Rewrites a url by combining a root url and response url.
  51601. */
  51602. rewriteRootURL: (rootUrl: string, responseURL?: string) => string;
  51603. /**
  51604. * Instantiates a glTF file loader plugin.
  51605. * @returns the created plugin
  51606. */
  51607. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  51608. /**
  51609. * The loader state or null if the loader is not active.
  51610. */
  51611. readonly loaderState: Nullable<GLTFLoaderState>;
  51612. /**
  51613. * Returns a promise that resolves when the asset is completely loaded.
  51614. * @returns a promise that resolves when the asset is completely loaded.
  51615. */
  51616. whenCompleteAsync(): Promise<void>;
  51617. private _parseAsync;
  51618. private _validateAsync;
  51619. private _getLoader;
  51620. private _unpackBinary;
  51621. private _unpackBinaryV1;
  51622. private _unpackBinaryV2;
  51623. private static _parseVersion;
  51624. private static _compareVersion;
  51625. private static _decodeBufferToText;
  51626. private static readonly _logSpaces;
  51627. private _logIndentLevel;
  51628. private _loggingEnabled;
  51629. /** @hidden */
  51630. /** @hidden */
  51631. /** @hidden */
  51632. private _logEnabled;
  51633. private _logDisabled;
  51634. private _capturePerformanceCounters;
  51635. /** @hidden */
  51636. /** @hidden */
  51637. private _startPerformanceCounterEnabled;
  51638. private _startPerformanceCounterDisabled;
  51639. private _endPerformanceCounterEnabled;
  51640. private _endPerformanceCounterDisabled;
  51641. }
  51642. }
  51643. declare module BABYLON.GLTF2.Loader {
  51644. /**
  51645. * Loader interface with an index field.
  51646. */
  51647. interface IArrayItem {
  51648. /**
  51649. * The index of this item in the array.
  51650. */
  51651. index: number;
  51652. }
  51653. /**
  51654. * Loader interface with additional members.
  51655. */
  51656. interface IAccessor extends GLTF2.IAccessor, IArrayItem {
  51657. /** @hidden */
  51658. /** @hidden */
  51659. }
  51660. /**
  51661. * Loader interface with additional members.
  51662. */
  51663. interface IAnimationChannel extends GLTF2.IAnimationChannel, IArrayItem {
  51664. }
  51665. /** @hidden */
  51666. interface _IAnimationSamplerData {
  51667. input: Float32Array;
  51668. interpolation: AnimationSamplerInterpolation;
  51669. output: Float32Array;
  51670. }
  51671. /**
  51672. * Loader interface with additional members.
  51673. */
  51674. interface IAnimationSampler extends GLTF2.IAnimationSampler, IArrayItem {
  51675. /** @hidden */
  51676. }
  51677. /**
  51678. * Loader interface with additional members.
  51679. */
  51680. interface IAnimation extends GLTF2.IAnimation, IArrayItem {
  51681. channels: IAnimationChannel[];
  51682. samplers: IAnimationSampler[];
  51683. /** @hidden */
  51684. }
  51685. /**
  51686. * Loader interface with additional members.
  51687. */
  51688. interface IBuffer extends GLTF2.IBuffer, IArrayItem {
  51689. /** @hidden */
  51690. }
  51691. /**
  51692. * Loader interface with additional members.
  51693. */
  51694. interface IBufferView extends GLTF2.IBufferView, IArrayItem {
  51695. /** @hidden */
  51696. /** @hidden */
  51697. }
  51698. /**
  51699. * Loader interface with additional members.
  51700. */
  51701. interface ICamera extends GLTF2.ICamera, IArrayItem {
  51702. }
  51703. /**
  51704. * Loader interface with additional members.
  51705. */
  51706. interface IImage extends GLTF2.IImage, IArrayItem {
  51707. /** @hidden */
  51708. }
  51709. /**
  51710. * Loader interface with additional members.
  51711. */
  51712. interface IMaterialNormalTextureInfo extends GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  51713. }
  51714. /**
  51715. * Loader interface with additional members.
  51716. */
  51717. interface IMaterialOcclusionTextureInfo extends GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  51718. }
  51719. /**
  51720. * Loader interface with additional members.
  51721. */
  51722. interface IMaterialPbrMetallicRoughness extends GLTF2.IMaterialPbrMetallicRoughness {
  51723. baseColorTexture?: ITextureInfo;
  51724. metallicRoughnessTexture?: ITextureInfo;
  51725. }
  51726. /**
  51727. * Loader interface with additional members.
  51728. */
  51729. interface IMaterial extends GLTF2.IMaterial, IArrayItem {
  51730. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  51731. normalTexture?: IMaterialNormalTextureInfo;
  51732. occlusionTexture?: IMaterialOcclusionTextureInfo;
  51733. emissiveTexture?: ITextureInfo;
  51734. /** @hidden */
  51735. ;
  51736. };
  51737. }
  51738. /**
  51739. * Loader interface with additional members.
  51740. */
  51741. interface IMesh extends GLTF2.IMesh, IArrayItem {
  51742. primitives: IMeshPrimitive[];
  51743. }
  51744. /**
  51745. * Loader interface with additional members.
  51746. */
  51747. interface IMeshPrimitive extends GLTF2.IMeshPrimitive, IArrayItem {
  51748. }
  51749. /**
  51750. * Loader interface with additional members.
  51751. */
  51752. interface INode extends GLTF2.INode, IArrayItem {
  51753. /**
  51754. * The parent glTF node.
  51755. */
  51756. parent?: INode;
  51757. /** @hidden */
  51758. /** @hidden */
  51759. /** @hidden */
  51760. /** @hidden */
  51761. }
  51762. /** @hidden */
  51763. interface _ISamplerData {
  51764. noMipMaps: boolean;
  51765. samplingMode: number;
  51766. wrapU: number;
  51767. wrapV: number;
  51768. }
  51769. /**
  51770. * Loader interface with additional members.
  51771. */
  51772. interface ISampler extends GLTF2.ISampler, IArrayItem {
  51773. /** @hidden */
  51774. }
  51775. /**
  51776. * Loader interface with additional members.
  51777. */
  51778. interface IScene extends GLTF2.IScene, IArrayItem {
  51779. }
  51780. /**
  51781. * Loader interface with additional members.
  51782. */
  51783. interface ISkin extends GLTF2.ISkin, IArrayItem {
  51784. /** @hidden */
  51785. /** @hidden */
  51786. }
  51787. /**
  51788. * Loader interface with additional members.
  51789. */
  51790. interface ITexture extends GLTF2.ITexture, IArrayItem {
  51791. }
  51792. /**
  51793. * Loader interface with additional members.
  51794. */
  51795. interface ITextureInfo extends GLTF2.ITextureInfo {
  51796. }
  51797. /**
  51798. * Loader interface with additional members.
  51799. */
  51800. interface IGLTF extends GLTF2.IGLTF {
  51801. accessors?: IAccessor[];
  51802. animations?: IAnimation[];
  51803. buffers?: IBuffer[];
  51804. bufferViews?: IBufferView[];
  51805. cameras?: ICamera[];
  51806. images?: IImage[];
  51807. materials?: IMaterial[];
  51808. meshes?: IMesh[];
  51809. nodes?: INode[];
  51810. samplers?: ISampler[];
  51811. scenes?: IScene[];
  51812. skins?: ISkin[];
  51813. textures?: ITexture[];
  51814. }
  51815. }
  51816. /**
  51817. * Defines the module for importing and exporting glTF 2.0 assets
  51818. */
  51819. declare module BABYLON.GLTF2 {
  51820. /**
  51821. * Helper class for working with arrays when loading the glTF asset
  51822. */
  51823. class ArrayItem {
  51824. /**
  51825. * Gets an item from the given array.
  51826. * @param context The context when loading the asset
  51827. * @param array The array to get the item from
  51828. * @param index The index to the array
  51829. * @returns The array item
  51830. */
  51831. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  51832. /**
  51833. * Assign an `index` field to each item of the given array.
  51834. * @param array The array of items
  51835. */
  51836. static Assign(array?: Loader.IArrayItem[]): void;
  51837. }
  51838. /**
  51839. * The glTF 2.0 loader
  51840. */
  51841. class GLTFLoader implements IGLTFLoader {
  51842. /** The glTF object parsed from the JSON. */
  51843. gltf: Loader.IGLTF;
  51844. /** The Babylon scene when loading the asset. */
  51845. babylonScene: Scene;
  51846. /** @hidden */
  51847. private _disposed;
  51848. private _parent;
  51849. private _state;
  51850. private _extensions;
  51851. private _rootUrl;
  51852. private _fileName;
  51853. private _uniqueRootUrl;
  51854. private _rootBabylonMesh;
  51855. private _defaultBabylonMaterialData;
  51856. private _progressCallback?;
  51857. private _requests;
  51858. private static readonly _DefaultSampler;
  51859. private static _ExtensionNames;
  51860. private static _ExtensionFactories;
  51861. /**
  51862. * Registers a loader extension.
  51863. * @param name The name of the loader extension.
  51864. * @param factory The factory function that creates the loader extension.
  51865. */
  51866. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  51867. /**
  51868. * Unregisters a loader extension.
  51869. * @param name The name of the loader extenion.
  51870. * @returns A boolean indicating whether the extension has been unregistered
  51871. */
  51872. static UnregisterExtension(name: string): boolean;
  51873. /**
  51874. * Gets the loader state.
  51875. */
  51876. readonly state: Nullable<GLTFLoaderState>;
  51877. /** @hidden */
  51878. constructor(parent: GLTFFileLoader);
  51879. /** @hidden */
  51880. dispose(): void;
  51881. /** @hidden */
  51882. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  51883. meshes: AbstractMesh[];
  51884. particleSystems: IParticleSystem[];
  51885. skeletons: Skeleton[];
  51886. animationGroups: AnimationGroup[];
  51887. }>;
  51888. /** @hidden */
  51889. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  51890. private _loadAsync;
  51891. private _loadData;
  51892. private _setupData;
  51893. private _loadExtensions;
  51894. private _checkExtensions;
  51895. private _setState;
  51896. private _createRootNode;
  51897. /**
  51898. * Loads a glTF scene.
  51899. * @param context The context when loading the asset
  51900. * @param scene The glTF scene property
  51901. * @returns A promise that resolves when the load is complete
  51902. */
  51903. loadSceneAsync(context: string, scene: Loader.IScene): Promise<void>;
  51904. private _forEachPrimitive;
  51905. private _getMeshes;
  51906. private _getSkeletons;
  51907. private _getAnimationGroups;
  51908. private _startAnimations;
  51909. /**
  51910. * Loads a glTF node.
  51911. * @param context The context when loading the asset
  51912. * @param node The glTF node property
  51913. * @param assign A function called synchronously after parsing the glTF properties
  51914. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  51915. */
  51916. loadNodeAsync(context: string, node: Loader.INode, assign?: (babylonMesh: Mesh) => void): Promise<Mesh>;
  51917. private _loadMeshAsync;
  51918. private _loadMeshPrimitiveAsync;
  51919. private _loadVertexDataAsync;
  51920. private _createMorphTargets;
  51921. private _loadMorphTargetsAsync;
  51922. private _loadMorphTargetVertexDataAsync;
  51923. private static _LoadTransform;
  51924. private _loadSkinAsync;
  51925. private _loadBones;
  51926. private _loadBone;
  51927. private _loadSkinInverseBindMatricesDataAsync;
  51928. private _updateBoneMatrices;
  51929. private _getNodeMatrix;
  51930. /**
  51931. * Loads a glTF camera.
  51932. * @param context The context when loading the asset
  51933. * @param camera The glTF camera property
  51934. * @param assign A function called synchronously after parsing the glTF properties
  51935. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  51936. */
  51937. loadCameraAsync(context: string, camera: Loader.ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  51938. private _loadAnimationsAsync;
  51939. /**
  51940. * Loads a glTF animation.
  51941. * @param context The context when loading the asset
  51942. * @param animation The glTF animation property
  51943. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  51944. */
  51945. loadAnimationAsync(context: string, animation: Loader.IAnimation): Promise<AnimationGroup>;
  51946. private _loadAnimationChannelAsync;
  51947. private _loadAnimationSamplerAsync;
  51948. private _loadBufferAsync;
  51949. /**
  51950. * Loads a glTF buffer view.
  51951. * @param context The context when loading the asset
  51952. * @param bufferView The glTF buffer view property
  51953. * @returns A promise that resolves with the loaded data when the load is complete
  51954. */
  51955. loadBufferViewAsync(context: string, bufferView: Loader.IBufferView): Promise<ArrayBufferView>;
  51956. private _loadIndicesAccessorAsync;
  51957. private _loadFloatAccessorAsync;
  51958. private _loadVertexBufferViewAsync;
  51959. private _loadVertexAccessorAsync;
  51960. private _loadMaterialMetallicRoughnessPropertiesAsync;
  51961. /** @hidden */
  51962. private _createDefaultMaterial;
  51963. /**
  51964. * Creates a Babylon material from a glTF material.
  51965. * @param context The context when loading the asset
  51966. * @param material The glTF material property
  51967. * @param babylonDrawMode The draw mode for the Babylon material
  51968. * @returns The Babylon material
  51969. */
  51970. createMaterial(context: string, material: Loader.IMaterial, babylonDrawMode: number): Material;
  51971. /**
  51972. * Loads properties from a glTF material into a Babylon material.
  51973. * @param context The context when loading the asset
  51974. * @param material The glTF material property
  51975. * @param babylonMaterial The Babylon material
  51976. * @returns A promise that resolves when the load is complete
  51977. */
  51978. loadMaterialPropertiesAsync(context: string, material: Loader.IMaterial, babylonMaterial: Material): Promise<void>;
  51979. /**
  51980. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  51981. * @param context The context when loading the asset
  51982. * @param material The glTF material property
  51983. * @param babylonMaterial The Babylon material
  51984. * @returns A promise that resolves when the load is complete
  51985. */
  51986. loadMaterialBasePropertiesAsync(context: string, material: Loader.IMaterial, babylonMaterial: Material): Promise<void>;
  51987. /**
  51988. * Loads the alpha properties from a glTF material into a Babylon material.
  51989. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  51990. * @param context The context when loading the asset
  51991. * @param material The glTF material property
  51992. * @param babylonMaterial The Babylon material
  51993. */
  51994. loadMaterialAlphaProperties(context: string, material: Loader.IMaterial, babylonMaterial: Material): void;
  51995. /**
  51996. * Loads a glTF texture info.
  51997. * @param context The context when loading the asset
  51998. * @param textureInfo The glTF texture info property
  51999. * @param assign A function called synchronously after parsing the glTF properties
  52000. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  52001. */
  52002. loadTextureInfoAsync(context: string, textureInfo: Loader.ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  52003. private _loadTextureAsync;
  52004. private _loadSampler;
  52005. /**
  52006. * Loads a glTF image.
  52007. * @param context The context when loading the asset
  52008. * @param image The glTF image property
  52009. * @returns A promise that resolves with the loaded data when the load is complete
  52010. */
  52011. loadImageAsync(context: string, image: Loader.IImage): Promise<ArrayBufferView>;
  52012. /**
  52013. * Loads a glTF uri.
  52014. * @param context The context when loading the asset
  52015. * @param uri The base64 or relative uri
  52016. * @returns A promise that resolves with the loaded data when the load is complete
  52017. */
  52018. loadUriAsync(context: string, uri: string): Promise<ArrayBufferView>;
  52019. private _onProgress;
  52020. private static _GetTextureWrapMode;
  52021. private static _GetTextureSamplingMode;
  52022. private static _GetTypedArray;
  52023. private static _GetNumComponents;
  52024. private static _ValidateUri;
  52025. private static _GetDrawMode;
  52026. private _compileMaterialsAsync;
  52027. private _compileShadowGeneratorsAsync;
  52028. private _forEachExtensions;
  52029. private _applyExtensions;
  52030. private _extensionsOnLoading;
  52031. private _extensionsOnReady;
  52032. private _extensionsLoadSceneAsync;
  52033. private _extensionsLoadNodeAsync;
  52034. private _extensionsLoadCameraAsync;
  52035. private _extensionsLoadVertexDataAsync;
  52036. private _extensionsLoadMaterialAsync;
  52037. private _extensionsCreateMaterial;
  52038. private _extensionsLoadMaterialPropertiesAsync;
  52039. private _extensionsLoadTextureInfoAsync;
  52040. private _extensionsLoadAnimationAsync;
  52041. private _extensionsLoadUriAsync;
  52042. /**
  52043. * Helper method called by a loader extension to load an glTF extension.
  52044. * @param context The context when loading the asset
  52045. * @param property The glTF property to load the extension from
  52046. * @param extensionName The name of the extension to load
  52047. * @param actionAsync The action to run
  52048. * @returns The promise returned by actionAsync or null if the extension does not exist
  52049. */
  52050. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  52051. /**
  52052. * Helper method called by a loader extension to load a glTF extra.
  52053. * @param context The context when loading the asset
  52054. * @param property The glTF property to load the extra from
  52055. * @param extensionName The name of the extension to load
  52056. * @param actionAsync The action to run
  52057. * @returns The promise returned by actionAsync or null if the extra does not exist
  52058. */
  52059. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  52060. /**
  52061. * Increments the indentation level and logs a message.
  52062. * @param message The message to log
  52063. */
  52064. logOpen(message: string): void;
  52065. /**
  52066. * Decrements the indentation level.
  52067. */
  52068. logClose(): void;
  52069. /**
  52070. * Logs a message
  52071. * @param message The message to log
  52072. */
  52073. log(message: string): void;
  52074. /**
  52075. * Starts a performance counter.
  52076. * @param counterName The name of the performance counter
  52077. */
  52078. startPerformanceCounter(counterName: string): void;
  52079. /**
  52080. * Ends a performance counter.
  52081. * @param counterName The name of the performance counter
  52082. */
  52083. endPerformanceCounter(counterName: string): void;
  52084. }
  52085. }
  52086. declare module BABYLON.GLTF2 {
  52087. /**
  52088. * Interface for a glTF loader extension.
  52089. */
  52090. interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  52091. /**
  52092. * Called after the loader state changes to LOADING.
  52093. */
  52094. onLoading?(): void;
  52095. /**
  52096. * Called after the loader state changes to READY.
  52097. */
  52098. onReady?(): void;
  52099. /**
  52100. * Define this method to modify the default behavior when loading scenes.
  52101. * @param context The context when loading the asset
  52102. * @param scene The glTF scene property
  52103. * @returns A promise that resolves when the load is complete or null if not handled
  52104. */
  52105. loadSceneAsync?(context: string, scene: Loader.IScene): Nullable<Promise<void>>;
  52106. /**
  52107. * Define this method to modify the default behavior when loading nodes.
  52108. * @param context The context when loading the asset
  52109. * @param node The glTF node property
  52110. * @param assign A function called synchronously after parsing the glTF properties
  52111. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete or null if not handled
  52112. */
  52113. loadNodeAsync?(context: string, node: Loader.INode, assign: (babylonMesh: Mesh) => void): Nullable<Promise<Mesh>>;
  52114. /**
  52115. * Define this method to modify the default behavior when loading cameras.
  52116. * @param context The context when loading the asset
  52117. * @param camera The glTF camera property
  52118. * @param assign A function called synchronously after parsing the glTF properties
  52119. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  52120. */
  52121. loadCameraAsync?(context: string, camera: Loader.ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  52122. /**
  52123. * @hidden Define this method to modify the default behavior when loading vertex data for mesh primitives.
  52124. * @param context The context when loading the asset
  52125. * @param primitive The glTF mesh primitive property
  52126. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  52127. */
  52128. /**
  52129. * @hidden Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  52130. * @param context The context when loading the asset
  52131. * @param material The glTF material property
  52132. * @param assign A function called synchronously after parsing the glTF properties
  52133. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  52134. */
  52135. /**
  52136. * Define this method to modify the default behavior when creating materials.
  52137. * @param context The context when loading the asset
  52138. * @param material The glTF material property
  52139. * @param babylonDrawMode The draw mode for the Babylon material
  52140. * @returns The Babylon material or null if not handled
  52141. */
  52142. createMaterial?(context: string, material: Loader.IMaterial, babylonDrawMode: number): Nullable<Material>;
  52143. /**
  52144. * Define this method to modify the default behavior when loading material properties.
  52145. * @param context The context when loading the asset
  52146. * @param material The glTF material property
  52147. * @param babylonMaterial The Babylon material
  52148. * @returns A promise that resolves when the load is complete or null if not handled
  52149. */
  52150. loadMaterialPropertiesAsync?(context: string, material: Loader.IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  52151. /**
  52152. * Define this method to modify the default behavior when loading texture infos.
  52153. * @param context The context when loading the asset
  52154. * @param textureInfo The glTF texture info property
  52155. * @param assign A function called synchronously after parsing the glTF properties
  52156. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  52157. */
  52158. loadTextureInfoAsync?(context: string, textureInfo: Loader.ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  52159. /**
  52160. * Define this method to modify the default behavior when loading animations.
  52161. * @param context The context when loading the asset
  52162. * @param animation The glTF animation property
  52163. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  52164. */
  52165. loadAnimationAsync?(context: string, animation: Loader.IAnimation): Nullable<Promise<AnimationGroup>>;
  52166. /**
  52167. * Define this method to modify the default behavior when loading uris.
  52168. * @param context The context when loading the asset
  52169. * @param uri The uri to load
  52170. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  52171. */
  52172. }
  52173. }
  52174. /**
  52175. * Defines the module for the built-in glTF 2.0 loader extensions.
  52176. */
  52177. declare module BABYLON.GLTF2.Loader.Extensions {
  52178. }
  52179. declare module BABYLON.GLTF2.Loader.Extensions {
  52180. /**
  52181. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  52182. */
  52183. class MSFT_lod implements IGLTFLoaderExtension {
  52184. /** The name of this extension. */
  52185. readonly name: string;
  52186. /** Defines whether this extension is enabled. */
  52187. enabled: boolean;
  52188. /**
  52189. * Maximum number of LODs to load, starting from the lowest LOD.
  52190. */
  52191. maxLODsToLoad: number;
  52192. /**
  52193. * Observable raised when all node LODs of one level are loaded.
  52194. * The event data is the index of the loaded LOD starting from zero.
  52195. * Dispose the loader to cancel the loading of the next level of LODs.
  52196. */
  52197. onNodeLODsLoadedObservable: Observable<number>;
  52198. /**
  52199. * Observable raised when all material LODs of one level are loaded.
  52200. * The event data is the index of the loaded LOD starting from zero.
  52201. * Dispose the loader to cancel the loading of the next level of LODs.
  52202. */
  52203. onMaterialLODsLoadedObservable: Observable<number>;
  52204. private _loader;
  52205. private _nodeIndexLOD;
  52206. private _nodeSignalLODs;
  52207. private _nodePromiseLODs;
  52208. private _materialIndexLOD;
  52209. private _materialSignalLODs;
  52210. private _materialPromiseLODs;
  52211. /** @hidden */
  52212. constructor(loader: GLTFLoader);
  52213. /** @hidden */
  52214. dispose(): void;
  52215. /** @hidden */
  52216. onReady(): void;
  52217. /** @hidden */
  52218. loadNodeAsync(context: string, node: INode, assign: (babylonMesh: Mesh) => void): Nullable<Promise<Mesh>>;
  52219. /** @hidden */
  52220. /** @hidden */
  52221. /**
  52222. * Gets an array of LOD properties from lowest to highest.
  52223. */
  52224. private _getLODs;
  52225. private _disposeUnusedMaterials;
  52226. }
  52227. }
  52228. declare module BABYLON.GLTF2.Loader.Extensions {
  52229. /** @hidden */
  52230. class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  52231. readonly name: string;
  52232. enabled: boolean;
  52233. private _loader;
  52234. constructor(loader: GLTFLoader);
  52235. dispose(): void;
  52236. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  52237. }
  52238. }
  52239. declare module BABYLON.GLTF2.Loader.Extensions {
  52240. /** @hidden */
  52241. class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  52242. readonly name: string;
  52243. enabled: boolean;
  52244. private _loader;
  52245. constructor(loader: GLTFLoader);
  52246. dispose(): void;
  52247. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  52248. }
  52249. }
  52250. declare module BABYLON.GLTF2.Loader.Extensions {
  52251. /**
  52252. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  52253. */
  52254. class MSFT_audio_emitter implements IGLTFLoaderExtension {
  52255. /** The name of this extension. */
  52256. readonly name: string;
  52257. /** Defines whether this extension is enabled. */
  52258. enabled: boolean;
  52259. private _loader;
  52260. private _clips;
  52261. private _emitters;
  52262. /** @hidden */
  52263. constructor(loader: GLTFLoader);
  52264. /** @hidden */
  52265. dispose(): void;
  52266. /** @hidden */
  52267. onLoading(): void;
  52268. /** @hidden */
  52269. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  52270. /** @hidden */
  52271. loadNodeAsync(context: string, node: INode, assign: (babylonMesh: Mesh) => void): Nullable<Promise<Mesh>>;
  52272. /** @hidden */
  52273. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  52274. private _loadClipAsync;
  52275. private _loadEmitterAsync;
  52276. private _getEventAction;
  52277. private _loadAnimationEventAsync;
  52278. }
  52279. }
  52280. declare module BABYLON.GLTF2.Loader.Extensions {
  52281. /**
  52282. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  52283. */
  52284. class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  52285. /** The name of this extension. */
  52286. readonly name: string;
  52287. /** Defines whether this extension is enabled. */
  52288. enabled: boolean;
  52289. private _loader;
  52290. private _dracoCompression?;
  52291. /** @hidden */
  52292. constructor(loader: GLTFLoader);
  52293. /** @hidden */
  52294. dispose(): void;
  52295. /** @hidden */
  52296. }
  52297. }
  52298. declare module BABYLON.GLTF2.Loader.Extensions {
  52299. /**
  52300. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  52301. */
  52302. class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  52303. /** The name of this extension. */
  52304. readonly name: string;
  52305. /** Defines whether this extension is enabled. */
  52306. enabled: boolean;
  52307. private _loader;
  52308. /** @hidden */
  52309. constructor(loader: GLTFLoader);
  52310. /** @hidden */
  52311. dispose(): void;
  52312. /** @hidden */
  52313. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  52314. private _loadSpecularGlossinessPropertiesAsync;
  52315. }
  52316. }
  52317. declare module BABYLON.GLTF2.Loader.Extensions {
  52318. /**
  52319. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  52320. */
  52321. class KHR_materials_unlit implements IGLTFLoaderExtension {
  52322. /** The name of this extension. */
  52323. readonly name: string;
  52324. /** Defines whether this extension is enabled. */
  52325. enabled: boolean;
  52326. private _loader;
  52327. /** @hidden */
  52328. constructor(loader: GLTFLoader);
  52329. /** @hidden */
  52330. dispose(): void;
  52331. /** @hidden */
  52332. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  52333. private _loadUnlitPropertiesAsync;
  52334. }
  52335. }
  52336. declare module BABYLON.GLTF2.Loader.Extensions {
  52337. /**
  52338. * [Specification](https://github.com/KhronosGroup/glTF/blob/1048d162a44dbcb05aefc1874bfd423cf60135a6/extensions/2.0/Khronos/KHR_lights_punctual/README.md) (Experimental)
  52339. */
  52340. class KHR_lights implements IGLTFLoaderExtension {
  52341. /** The name of this extension. */
  52342. readonly name: string;
  52343. /** Defines whether this extension is enabled. */
  52344. enabled: boolean;
  52345. private _loader;
  52346. private _lights?;
  52347. /** @hidden */
  52348. constructor(loader: GLTFLoader);
  52349. /** @hidden */
  52350. dispose(): void;
  52351. /** @hidden */
  52352. onLoading(): void;
  52353. /** @hidden */
  52354. loadNodeAsync(context: string, node: INode, assign: (babylonMesh: Mesh) => void): Nullable<Promise<Mesh>>;
  52355. }
  52356. }
  52357. declare module BABYLON.GLTF2.Loader.Extensions {
  52358. /**
  52359. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform/README.md)
  52360. */
  52361. class KHR_texture_transform implements IGLTFLoaderExtension {
  52362. /** The name of this extension. */
  52363. readonly name: string;
  52364. /** Defines whether this extension is enabled. */
  52365. enabled: boolean;
  52366. private _loader;
  52367. /** @hidden */
  52368. constructor(loader: GLTFLoader);
  52369. /** @hidden */
  52370. dispose(): void;
  52371. /** @hidden */
  52372. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  52373. }
  52374. }
  52375. declare module BABYLON.GLTF2.Loader.Extensions {
  52376. /**
  52377. * [Specification](https://github.com/KhronosGroup/glTF/blob/eb3e32332042e04691a5f35103f8c261e50d8f1e/extensions/2.0/Khronos/EXT_lights_image_based/README.md) (Experimental)
  52378. */
  52379. class EXT_lights_image_based implements IGLTFLoaderExtension {
  52380. /** The name of this extension. */
  52381. readonly name: string;
  52382. /** Defines whether this extension is enabled. */
  52383. enabled: boolean;
  52384. private _loader;
  52385. private _lights?;
  52386. /** @hidden */
  52387. constructor(loader: GLTFLoader);
  52388. /** @hidden */
  52389. dispose(): void;
  52390. /** @hidden */
  52391. onLoading(): void;
  52392. /** @hidden */
  52393. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  52394. private _loadLightAsync;
  52395. }
  52396. }
  52397. declare module BABYLON {
  52398. /**
  52399. * Holds a collection of exporter options and parameters
  52400. */
  52401. interface IExportOptions {
  52402. /**
  52403. * Function which indicates whether a babylon mesh should be exported or not
  52404. * @param transformNode source Babylon transform node. It is used to check whether it should be exported to glTF or not
  52405. * @returns boolean, which indicates whether the mesh should be exported (true) or not (false)
  52406. */
  52407. shouldExportTransformNode?(transformNode: TransformNode): boolean;
  52408. /**
  52409. * The sample rate to bake animation curves
  52410. */
  52411. animationSampleRate?: number;
  52412. /**
  52413. * Begin serialization without waiting for the scene to be ready
  52414. */
  52415. exportWithoutWaitingForScene?: boolean;
  52416. }
  52417. /**
  52418. * Class for generating glTF data from a Babylon scene.
  52419. */
  52420. class GLTF2Export {
  52421. /**
  52422. * Exports the geometry of the scene to .gltf file format asynchronously
  52423. * @param scene Babylon scene with scene hierarchy information
  52424. * @param filePrefix File prefix to use when generating the glTF file
  52425. * @param options Exporter options
  52426. * @returns Returns an object with a .gltf file and associates texture names
  52427. * as keys and their data and paths as values
  52428. */
  52429. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  52430. private static _PreExportAsync;
  52431. private static _PostExportAsync;
  52432. /**
  52433. * Exports the geometry of the scene to .glb file format asychronously
  52434. * @param scene Babylon scene with scene hierarchy information
  52435. * @param filePrefix File prefix to use when generating glb file
  52436. * @param options Exporter options
  52437. * @returns Returns an object with a .glb filename as key and data as value
  52438. */
  52439. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  52440. }
  52441. }
  52442. /**
  52443. * @hidden
  52444. */
  52445. declare module BABYLON.GLTF2.Exporter {
  52446. /**
  52447. * Converts Babylon Scene into glTF 2.0.
  52448. * @hidden
  52449. */
  52450. class _Exporter {
  52451. /**
  52452. * Stores all generated buffer views, which represents views into the main glTF buffer data
  52453. */
  52454. /**
  52455. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  52456. */
  52457. /**
  52458. * Stores all the generated nodes, which contains transform and/or mesh information per node
  52459. */
  52460. private _nodes;
  52461. /**
  52462. * Stores the glTF asset information, which represents the glTF version and this file generator
  52463. */
  52464. private _asset;
  52465. /**
  52466. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  52467. */
  52468. private _scenes;
  52469. /**
  52470. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  52471. */
  52472. private _meshes;
  52473. /**
  52474. * Stores all the generated material information, which represents the appearance of each primitive
  52475. */
  52476. ;
  52477. /**
  52478. * Stores all the generated texture information, which is referenced by glTF materials
  52479. */
  52480. /**
  52481. * Stores all the generated image information, which is referenced by glTF textures
  52482. */
  52483. /**
  52484. * Stores all the texture samplers
  52485. */
  52486. /**
  52487. * Stores all the generated animation samplers, which is referenced by glTF animations
  52488. */
  52489. /**
  52490. * Stores the animations for glTF models
  52491. */
  52492. private _animations;
  52493. /**
  52494. * Stores the total amount of bytes stored in the glTF buffer
  52495. */
  52496. private _totalByteLength;
  52497. /**
  52498. * Stores a reference to the Babylon scene containing the source geometry and material information
  52499. */
  52500. private _babylonScene;
  52501. /**
  52502. * Stores a map of the image data, where the key is the file name and the value
  52503. * is the image data
  52504. */
  52505. ;
  52506. };
  52507. /**
  52508. * Stores a map of the unique id of a node to its index in the node array
  52509. */
  52510. private _nodeMap;
  52511. /**
  52512. * Specifies if the Babylon scene should be converted to right-handed on export
  52513. */
  52514. private _convertToRightHandedSystem;
  52515. /**
  52516. * Baked animation sample rate
  52517. */
  52518. private _animationSampleRate;
  52519. /**
  52520. * Callback which specifies if a transform node should be exported or not
  52521. */
  52522. private _shouldExportTransformNode;
  52523. private _localEngine;
  52524. private _extensions;
  52525. private _extensionsUsed;
  52526. private _extensionsRequired;
  52527. private static _ExtensionNames;
  52528. private static _ExtensionFactories;
  52529. private _applyExtensions;
  52530. /**
  52531. * Load glTF serializer extensions
  52532. */
  52533. private _loadExtensions;
  52534. /**
  52535. * Creates a glTF Exporter instance, which can accept optional exporter options
  52536. * @param babylonScene Babylon scene object
  52537. * @param options Options to modify the behavior of the exporter
  52538. */
  52539. constructor(babylonScene: Scene, options?: IExportOptions);
  52540. /**
  52541. * Registers a glTF exporter extension
  52542. * @param name Name of the extension to export
  52543. * @param factory The factory function that creates the exporter extension
  52544. */
  52545. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtension): void;
  52546. /**
  52547. * Un-registers an exporter extension
  52548. * @param name The name fo the exporter extension
  52549. * @returns A boolean indicating whether the extension has been un-registered
  52550. */
  52551. static UnregisterExtension(name: string): boolean;
  52552. /**
  52553. * Lazy load a local engine with premultiplied alpha set to false
  52554. */
  52555. private reorderIndicesBasedOnPrimitiveMode;
  52556. /**
  52557. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  52558. * clock-wise during export to glTF
  52559. * @param submesh BabylonJS submesh
  52560. * @param primitiveMode Primitive mode of the mesh
  52561. * @param sideOrientation the winding order of the submesh
  52562. * @param vertexBufferKind The type of vertex attribute
  52563. * @param meshAttributeArray The vertex attribute data
  52564. * @param byteOffset The offset to the binary data
  52565. * @param binaryWriter The binary data for the glTF file
  52566. */
  52567. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  52568. /**
  52569. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  52570. * clock-wise during export to glTF
  52571. * @param submesh BabylonJS submesh
  52572. * @param primitiveMode Primitive mode of the mesh
  52573. * @param sideOrientation the winding order of the submesh
  52574. * @param vertexBufferKind The type of vertex attribute
  52575. * @param meshAttributeArray The vertex attribute data
  52576. * @param byteOffset The offset to the binary data
  52577. * @param binaryWriter The binary data for the glTF file
  52578. */
  52579. private reorderTriangleFillMode;
  52580. /**
  52581. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  52582. * clock-wise during export to glTF
  52583. * @param submesh BabylonJS submesh
  52584. * @param primitiveMode Primitive mode of the mesh
  52585. * @param sideOrientation the winding order of the submesh
  52586. * @param vertexBufferKind The type of vertex attribute
  52587. * @param meshAttributeArray The vertex attribute data
  52588. * @param byteOffset The offset to the binary data
  52589. * @param binaryWriter The binary data for the glTF file
  52590. */
  52591. private reorderTriangleStripDrawMode;
  52592. /**
  52593. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  52594. * clock-wise during export to glTF
  52595. * @param submesh BabylonJS submesh
  52596. * @param primitiveMode Primitive mode of the mesh
  52597. * @param sideOrientation the winding order of the submesh
  52598. * @param vertexBufferKind The type of vertex attribute
  52599. * @param meshAttributeArray The vertex attribute data
  52600. * @param byteOffset The offset to the binary data
  52601. * @param binaryWriter The binary data for the glTF file
  52602. */
  52603. private reorderTriangleFanMode;
  52604. /**
  52605. * Writes the vertex attribute data to binary
  52606. * @param vertices The vertices to write to the binary writer
  52607. * @param byteOffset The offset into the binary writer to overwrite binary data
  52608. * @param vertexAttributeKind The vertex attribute type
  52609. * @param meshAttributeArray The vertex attribute data
  52610. * @param binaryWriter The writer containing the binary data
  52611. */
  52612. private writeVertexAttributeData;
  52613. /**
  52614. * Writes mesh attribute data to a data buffer
  52615. * Returns the bytelength of the data
  52616. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  52617. * @param meshAttributeArray Array containing the attribute data
  52618. * @param binaryWriter The buffer to write the binary data to
  52619. * @param indices Used to specify the order of the vertex data
  52620. */
  52621. writeAttributeData(vertexBufferKind: string, meshAttributeArray: FloatArray, byteStride: number, binaryWriter: _BinaryWriter): void;
  52622. /**
  52623. * Generates glTF json data
  52624. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  52625. * @param glTFPrefix Text to use when prefixing a glTF file
  52626. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  52627. * @returns json data as string
  52628. */
  52629. private generateJSON;
  52630. /**
  52631. * Generates data for .gltf and .bin files based on the glTF prefix string
  52632. * @param glTFPrefix Text to use when prefixing a glTF file
  52633. * @returns GLTFData with glTF file data
  52634. */
  52635. /**
  52636. * Creates a binary buffer for glTF
  52637. * @returns array buffer for binary data
  52638. */
  52639. private _generateBinaryAsync;
  52640. /**
  52641. * Pads the number to a multiple of 4
  52642. * @param num number to pad
  52643. * @returns padded number
  52644. */
  52645. private _getPadding;
  52646. /**
  52647. * Generates a glb file from the json and binary data
  52648. * Returns an object with the glb file name as the key and data as the value
  52649. * @param glTFPrefix
  52650. * @returns object with glb filename as key and data as value
  52651. */
  52652. /**
  52653. * Sets the TRS for each node
  52654. * @param node glTF Node for storing the transformation data
  52655. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  52656. */
  52657. private setNodeTransformation;
  52658. private getVertexBufferFromMesh;
  52659. /**
  52660. * Creates a bufferview based on the vertices type for the Babylon mesh
  52661. * @param kind Indicates the type of vertices data
  52662. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  52663. * @param binaryWriter The buffer to write the bufferview data to
  52664. */
  52665. private createBufferViewKind;
  52666. /**
  52667. * The primitive mode of the Babylon mesh
  52668. * @param babylonMesh The BabylonJS mesh
  52669. */
  52670. private getMeshPrimitiveMode;
  52671. /**
  52672. * Sets the primitive mode of the glTF mesh primitive
  52673. * @param meshPrimitive glTF mesh primitive
  52674. * @param primitiveMode The primitive mode
  52675. */
  52676. private setPrimitiveMode;
  52677. /**
  52678. * Sets the vertex attribute accessor based of the glTF mesh primitive
  52679. * @param meshPrimitive glTF mesh primitive
  52680. * @param attributeKind vertex attribute
  52681. * @returns boolean specifying if uv coordinates are present
  52682. */
  52683. private setAttributeKind;
  52684. /**
  52685. * Sets data for the primitive attributes of each submesh
  52686. * @param mesh glTF Mesh object to store the primitive attribute information
  52687. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  52688. * @param binaryWriter Buffer to write the attribute data to
  52689. */
  52690. private setPrimitiveAttributesAsync;
  52691. /**
  52692. * Creates a glTF scene based on the array of meshes
  52693. * Returns the the total byte offset
  52694. * @param babylonScene Babylon scene to get the mesh data from
  52695. * @param binaryWriter Buffer to write binary data to
  52696. */
  52697. private createSceneAsync;
  52698. /**
  52699. * Creates a mapping of Node unique id to node index and handles animations
  52700. * @param babylonScene Babylon Scene
  52701. * @param nodes Babylon transform nodes
  52702. * @param shouldExportTransformNode Callback specifying if a transform node should be exported
  52703. * @param binaryWriter Buffer to write binary data to
  52704. * @returns Node mapping of unique id to index
  52705. */
  52706. private createNodeMapAndAnimationsAsync;
  52707. /**
  52708. * Creates a glTF node from a Babylon mesh
  52709. * @param babylonMesh Source Babylon mesh
  52710. * @param binaryWriter Buffer for storing geometry data
  52711. * @returns glTF node
  52712. */
  52713. private createNodeAsync;
  52714. }
  52715. /**
  52716. * @hidden
  52717. *
  52718. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  52719. */
  52720. class _BinaryWriter {
  52721. /**
  52722. * Array buffer which stores all binary data
  52723. */
  52724. private _arrayBuffer;
  52725. /**
  52726. * View of the array buffer
  52727. */
  52728. private _dataView;
  52729. /**
  52730. * byte offset of data in array buffer
  52731. */
  52732. private _byteOffset;
  52733. /**
  52734. * Initialize binary writer with an initial byte length
  52735. * @param byteLength Initial byte length of the array buffer
  52736. */
  52737. constructor(byteLength: number);
  52738. /**
  52739. * Resize the array buffer to the specified byte length
  52740. * @param byteLength
  52741. */
  52742. private resizeBuffer;
  52743. /**
  52744. * Get an array buffer with the length of the byte offset
  52745. * @returns ArrayBuffer resized to the byte offset
  52746. */
  52747. getArrayBuffer(): ArrayBuffer;
  52748. /**
  52749. * Get the byte offset of the array buffer
  52750. * @returns byte offset
  52751. */
  52752. getByteOffset(): number;
  52753. /**
  52754. * Stores an UInt8 in the array buffer
  52755. * @param entry
  52756. * @param byteOffset If defined, specifies where to set the value as an offset.
  52757. */
  52758. setUInt8(entry: number, byteOffset?: number): void;
  52759. /**
  52760. * Gets an UInt32 in the array buffer
  52761. * @param entry
  52762. * @param byteOffset If defined, specifies where to set the value as an offset.
  52763. */
  52764. getUInt32(byteOffset: number): number;
  52765. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  52766. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  52767. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  52768. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  52769. /**
  52770. * Stores a Float32 in the array buffer
  52771. * @param entry
  52772. */
  52773. setFloat32(entry: number, byteOffset?: number): void;
  52774. /**
  52775. * Stores an UInt32 in the array buffer
  52776. * @param entry
  52777. * @param byteOffset If defined, specifies where to set the value as an offset.
  52778. */
  52779. setUInt32(entry: number, byteOffset?: number): void;
  52780. }
  52781. }
  52782. declare module BABYLON {
  52783. /**
  52784. * Class for holding and downloading glTF file data
  52785. */
  52786. class GLTFData {
  52787. /**
  52788. * Object which contains the file name as the key and its data as the value
  52789. */
  52790. glTFFiles: {
  52791. [fileName: string]: string | Blob;
  52792. };
  52793. /**
  52794. * Initializes the glTF file object
  52795. */
  52796. constructor();
  52797. /**
  52798. * Downloads the glTF data as files based on their names and data
  52799. */
  52800. downloadFiles(): void;
  52801. }
  52802. }
  52803. declare module BABYLON.GLTF2.Exporter {
  52804. /**
  52805. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  52806. * @hidden
  52807. */
  52808. class _GLTFMaterialExporter {
  52809. /**
  52810. * Represents the dielectric specular values for R, G and B
  52811. */
  52812. private static readonly _DielectricSpecular;
  52813. /**
  52814. * Allows the maximum specular power to be defined for material calculations
  52815. */
  52816. private static readonly _MaxSpecularPower;
  52817. /**
  52818. * Mapping to store textures
  52819. */
  52820. private _textureMap;
  52821. /**
  52822. * Numeric tolerance value
  52823. */
  52824. private static readonly _Epsilon;
  52825. /**
  52826. * Reference to the glTF Exporter
  52827. */
  52828. private _exporter;
  52829. constructor(exporter: _Exporter);
  52830. /**
  52831. * Specifies if two colors are approximately equal in value
  52832. * @param color1 first color to compare to
  52833. * @param color2 second color to compare to
  52834. * @param epsilon threshold value
  52835. */
  52836. private static FuzzyEquals;
  52837. /**
  52838. * Gets the materials from a Babylon scene and converts them to glTF materials
  52839. * @param scene babylonjs scene
  52840. * @param mimeType texture mime type
  52841. * @param images array of images
  52842. * @param textures array of textures
  52843. * @param materials array of materials
  52844. * @param imageData mapping of texture names to base64 textures
  52845. * @param hasTextureCoords specifies if texture coordinates are present on the material
  52846. */
  52847. /**
  52848. * Makes a copy of the glTF material without the texture parameters
  52849. * @param originalMaterial original glTF material
  52850. * @returns glTF material without texture parameters
  52851. */
  52852. /**
  52853. * Specifies if the material has any texture parameters present
  52854. * @param material glTF Material
  52855. * @returns boolean specifying if texture parameters are present
  52856. */
  52857. /**
  52858. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  52859. * @param babylonStandardMaterial
  52860. * @returns glTF Metallic Roughness Material representation
  52861. */
  52862. /**
  52863. * Computes the metallic factor
  52864. * @param diffuse diffused value
  52865. * @param specular specular value
  52866. * @param oneMinusSpecularStrength one minus the specular strength
  52867. * @returns metallic value
  52868. */
  52869. private static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  52870. /**
  52871. * Gets the glTF alpha mode from the Babylon Material
  52872. * @param babylonMaterial Babylon Material
  52873. * @returns The Babylon alpha mode value
  52874. */
  52875. /**
  52876. * Converts a Babylon Standard Material to a glTF Material
  52877. * @param babylonStandardMaterial BJS Standard Material
  52878. * @param mimeType mime type to use for the textures
  52879. * @param images array of glTF image interfaces
  52880. * @param textures array of glTF texture interfaces
  52881. * @param materials array of glTF material interfaces
  52882. * @param imageData map of image file name to data
  52883. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  52884. */
  52885. /**
  52886. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  52887. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  52888. * @param mimeType mime type to use for the textures
  52889. * @param images array of glTF image interfaces
  52890. * @param textures array of glTF texture interfaces
  52891. * @param materials array of glTF material interfaces
  52892. * @param imageData map of image file name to data
  52893. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  52894. */
  52895. /**
  52896. * Converts an image typed array buffer to a base64 image
  52897. * @param buffer typed array buffer
  52898. * @param width width of the image
  52899. * @param height height of the image
  52900. * @param mimeType mimetype of the image
  52901. * @returns base64 image string
  52902. */
  52903. private _createBase64FromCanvasAsync;
  52904. /**
  52905. * Generates a white texture based on the specified width and height
  52906. * @param width width of the texture in pixels
  52907. * @param height height of the texture in pixels
  52908. * @param scene babylonjs scene
  52909. * @returns white texture
  52910. */
  52911. private _createWhiteTexture;
  52912. /**
  52913. * 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
  52914. * @param texture1 first texture to resize
  52915. * @param texture2 second texture to resize
  52916. * @param scene babylonjs scene
  52917. * @returns resized textures or null
  52918. */
  52919. private _resizeTexturesToSameDimensions;
  52920. /**
  52921. * Converts an array of pixels to a Float32Array
  52922. * Throws an error if the pixel format is not supported
  52923. * @param pixels - array buffer containing pixel values
  52924. * @returns Float32 of pixels
  52925. */
  52926. private _convertPixelArrayToFloat32;
  52927. /**
  52928. * Convert Specular Glossiness Textures to Metallic Roughness
  52929. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  52930. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  52931. * @param diffuseTexture texture used to store diffuse information
  52932. * @param specularGlossinessTexture texture used to store specular and glossiness information
  52933. * @param factors specular glossiness material factors
  52934. * @param mimeType the mime type to use for the texture
  52935. * @returns pbr metallic roughness interface or null
  52936. */
  52937. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  52938. /**
  52939. * Converts specular glossiness material properties to metallic roughness
  52940. * @param specularGlossiness interface with specular glossiness material properties
  52941. * @returns interface with metallic roughness material properties
  52942. */
  52943. private _convertSpecularGlossinessToMetallicRoughness;
  52944. /**
  52945. * Calculates the surface reflectance, independent of lighting conditions
  52946. * @param color Color source to calculate brightness from
  52947. * @returns number representing the perceived brightness, or zero if color is undefined
  52948. */
  52949. private _getPerceivedBrightness;
  52950. /**
  52951. * Returns the maximum color component value
  52952. * @param color
  52953. * @returns maximum color component value, or zero if color is null or undefined
  52954. */
  52955. private _getMaxComponent;
  52956. /**
  52957. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  52958. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  52959. * @param mimeType mime type to use for the textures
  52960. * @param images array of glTF image interfaces
  52961. * @param textures array of glTF texture interfaces
  52962. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  52963. * @param imageData map of image file name to data
  52964. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  52965. * @returns glTF PBR Metallic Roughness factors
  52966. */
  52967. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  52968. private _getGLTFTextureSampler;
  52969. private _getGLTFTextureWrapMode;
  52970. private _getGLTFTextureWrapModesSampler;
  52971. /**
  52972. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  52973. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  52974. * @param mimeType mime type to use for the textures
  52975. * @param images array of glTF image interfaces
  52976. * @param textures array of glTF texture interfaces
  52977. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  52978. * @param imageData map of image file name to data
  52979. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  52980. * @returns glTF PBR Metallic Roughness factors
  52981. */
  52982. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  52983. /**
  52984. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  52985. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  52986. * @param mimeType mime type to use for the textures
  52987. * @param images array of glTF image interfaces
  52988. * @param textures array of glTF texture interfaces
  52989. * @param materials array of glTF material interfaces
  52990. * @param imageData map of image file name to data
  52991. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  52992. */
  52993. private setMetallicRoughnessPbrMaterial;
  52994. private getPixelsFromTexture;
  52995. /**
  52996. * Extracts a texture from a Babylon texture into file data and glTF data
  52997. * @param babylonTexture Babylon texture to extract
  52998. * @param mimeType Mime Type of the babylonTexture
  52999. * @return glTF texture info, or null if the texture format is not supported
  53000. */
  53001. /**
  53002. * Builds a texture from base64 string
  53003. * @param base64Texture base64 texture string
  53004. * @param baseTextureName Name to use for the texture
  53005. * @param mimeType image mime type for the texture
  53006. * @param images array of images
  53007. * @param textures array of textures
  53008. * @param imageData map of image data
  53009. * @returns glTF texture info, or null if the texture format is not supported
  53010. */
  53011. private _getTextureInfoFromBase64;
  53012. }
  53013. }
  53014. declare module BABYLON.GLTF2.Exporter {
  53015. /**
  53016. * @hidden
  53017. * Interface to store animation data.
  53018. */
  53019. interface _IAnimationData {
  53020. /**
  53021. * Keyframe data.
  53022. */
  53023. inputs: number[];
  53024. /**
  53025. * Value data.
  53026. */
  53027. outputs: number[][];
  53028. /**
  53029. * Animation interpolation data.
  53030. */
  53031. samplerInterpolation: AnimationSamplerInterpolation;
  53032. /**
  53033. * Minimum keyframe value.
  53034. */
  53035. inputsMin: number;
  53036. /**
  53037. * Maximum keyframe value.
  53038. */
  53039. inputsMax: number;
  53040. }
  53041. /**
  53042. * @hidden
  53043. */
  53044. interface _IAnimationInfo {
  53045. /**
  53046. * The target channel for the animation
  53047. */
  53048. animationChannelTargetPath: AnimationChannelTargetPath;
  53049. /**
  53050. * The glTF accessor type for the data.
  53051. */
  53052. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4;
  53053. /**
  53054. * Specifies if quaternions should be used.
  53055. */
  53056. useQuaternion: boolean;
  53057. }
  53058. /**
  53059. * @hidden
  53060. * Utility class for generating glTF animation data from BabylonJS.
  53061. */
  53062. class _GLTFAnimation {
  53063. /**
  53064. * @ignore
  53065. *
  53066. * Creates glTF channel animation from BabylonJS animation.
  53067. * @param babylonTransformNode - BabylonJS mesh.
  53068. * @param animation - animation.
  53069. * @param animationChannelTargetPath - The target animation channel.
  53070. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  53071. * @param useQuaternion - Specifies if quaternions are used.
  53072. * @returns nullable IAnimationData
  53073. */
  53074. private static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  53075. private static _DeduceAnimationInfo;
  53076. /**
  53077. * @ignore
  53078. * Create node animations from the transform node animations
  53079. * @param babylonTransformNode
  53080. * @param runtimeGLTFAnimation
  53081. * @param idleGLTFAnimations
  53082. * @param nodeMap
  53083. * @param nodes
  53084. * @param binaryWriter
  53085. * @param bufferViews
  53086. * @param accessors
  53087. * @param convertToRightHandedSystem
  53088. */
  53089. private static _CreateNodeAnimationFromTransformNodeAnimations(babylonTransformNode: TransformNode, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  53090. [key: number]: number;
  53091. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  53092. /**
  53093. * @ignore
  53094. * Create node animations from the animation groups
  53095. * @param babylonScene
  53096. * @param glTFAnimations
  53097. * @param nodeMap
  53098. * @param nodes
  53099. * @param binaryWriter
  53100. * @param bufferViews
  53101. * @param accessors
  53102. * @param convertToRightHandedSystem
  53103. */
  53104. private static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  53105. [key: number]: number;
  53106. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  53107. private static AddAnimation;
  53108. /**
  53109. * Create a baked animation
  53110. * @param babylonTransformNode BabylonJS mesh
  53111. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  53112. * @param animationChannelTargetPath animation target channel
  53113. * @param minFrame minimum animation frame
  53114. * @param maxFrame maximum animation frame
  53115. * @param fps frames per second of the animation
  53116. * @param inputs input key frames of the animation
  53117. * @param outputs output key frame data of the animation
  53118. * @param convertToRightHandedSystem converts the values to right-handed
  53119. * @param useQuaternion specifies if quaternions should be used
  53120. */
  53121. private static _CreateBakedAnimation;
  53122. private static _ConvertFactorToVector3OrQuaternion;
  53123. private static _SetInterpolatedValue;
  53124. /**
  53125. * Creates linear animation from the animation key frames
  53126. * @param babylonTransformNode BabylonJS mesh
  53127. * @param animation BabylonJS animation
  53128. * @param animationChannelTargetPath The target animation channel
  53129. * @param frameDelta The difference between the last and first frame of the animation
  53130. * @param inputs Array to store the key frame times
  53131. * @param outputs Array to store the key frame data
  53132. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  53133. * @param useQuaternion Specifies if quaternions are used in the animation
  53134. */
  53135. private static _CreateLinearOrStepAnimation;
  53136. /**
  53137. * Creates cubic spline animation from the animation key frames
  53138. * @param babylonTransformNode BabylonJS mesh
  53139. * @param animation BabylonJS animation
  53140. * @param animationChannelTargetPath The target animation channel
  53141. * @param frameDelta The difference between the last and first frame of the animation
  53142. * @param inputs Array to store the key frame times
  53143. * @param outputs Array to store the key frame data
  53144. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  53145. * @param useQuaternion Specifies if quaternions are used in the animation
  53146. */
  53147. private static _CreateCubicSplineAnimation;
  53148. private static _GetBasePositionRotationOrScale;
  53149. /**
  53150. * Adds a key frame value
  53151. * @param keyFrame
  53152. * @param animation
  53153. * @param outputs
  53154. * @param animationChannelTargetPath
  53155. * @param basePositionRotationOrScale
  53156. * @param convertToRightHandedSystem
  53157. * @param useQuaternion
  53158. */
  53159. private static _AddKeyframeValue;
  53160. /**
  53161. * Determine the interpolation based on the key frames
  53162. * @param keyFrames
  53163. * @param animationChannelTargetPath
  53164. * @param useQuaternion
  53165. */
  53166. private static _DeduceInterpolation;
  53167. /**
  53168. * Adds an input tangent or output tangent to the output data
  53169. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  53170. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  53171. * @param outputs The animation data by keyframe
  53172. * @param animationChannelTargetPath The target animation channel
  53173. * @param interpolation The interpolation type
  53174. * @param keyFrame The key frame with the animation data
  53175. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  53176. * @param useQuaternion Specifies if quaternions are used
  53177. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  53178. */
  53179. private static AddSplineTangent;
  53180. /**
  53181. * Get the minimum and maximum key frames' frame values
  53182. * @param keyFrames animation key frames
  53183. * @returns the minimum and maximum key frame value
  53184. */
  53185. private static calculateMinMaxKeyFrames;
  53186. }
  53187. }
  53188. declare module BABYLON.GLTF2.Exporter {
  53189. /**
  53190. * @hidden
  53191. */
  53192. class _GLTFUtilities {
  53193. /**
  53194. * Creates a buffer view based on the supplied arguments
  53195. * @param bufferIndex index value of the specified buffer
  53196. * @param byteOffset byte offset value
  53197. * @param byteLength byte length of the bufferView
  53198. * @param byteStride byte distance between conequential elements
  53199. * @param name name of the buffer view
  53200. * @returns bufferView for glTF
  53201. */
  53202. private static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  53203. /**
  53204. * Creates an accessor based on the supplied arguments
  53205. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  53206. * @param name The name of the accessor
  53207. * @param type The type of the accessor
  53208. * @param componentType The datatype of components in the attribute
  53209. * @param count The number of attributes referenced by this accessor
  53210. * @param byteOffset The offset relative to the start of the bufferView in bytes
  53211. * @param min Minimum value of each component in this attribute
  53212. * @param max Maximum value of each component in this attribute
  53213. * @returns accessor for glTF
  53214. */
  53215. private static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  53216. /**
  53217. * Calculates the minimum and maximum values of an array of position floats
  53218. * @param positions Positions array of a mesh
  53219. * @param vertexStart Starting vertex offset to calculate min and max values
  53220. * @param vertexCount Number of vertices to check for min and max values
  53221. * @returns min number array and max number array
  53222. */
  53223. private static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  53224. min: number[];
  53225. max: number[];
  53226. };
  53227. /**
  53228. * Converts a new right-handed Vector3
  53229. * @param vector vector3 array
  53230. * @returns right-handed Vector3
  53231. */
  53232. private static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  53233. /**
  53234. * Converts a Vector3 to right-handed
  53235. * @param vector Vector3 to convert to right-handed
  53236. */
  53237. private static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  53238. /**
  53239. * Converts a three element number array to right-handed
  53240. * @param vector number array to convert to right-handed
  53241. */
  53242. private static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  53243. /**
  53244. * Converts a new right-handed Vector3
  53245. * @param vector vector3 array
  53246. * @returns right-handed Vector3
  53247. */
  53248. private static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  53249. /**
  53250. * Converts a Vector3 to right-handed
  53251. * @param vector Vector3 to convert to right-handed
  53252. */
  53253. private static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  53254. /**
  53255. * Converts a three element number array to right-handed
  53256. * @param vector number array to convert to right-handed
  53257. */
  53258. private static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  53259. /**
  53260. * Converts a Vector4 to right-handed
  53261. * @param vector Vector4 to convert to right-handed
  53262. */
  53263. private static _GetRightHandedVector4FromRef(vector: Vector4): void;
  53264. /**
  53265. * Converts a Vector4 to right-handed
  53266. * @param vector Vector4 to convert to right-handed
  53267. */
  53268. private static _GetRightHandedArray4FromRef(vector: number[]): void;
  53269. /**
  53270. * Converts a Quaternion to right-handed
  53271. * @param quaternion Source quaternion to convert to right-handed
  53272. */
  53273. private static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  53274. /**
  53275. * Converts a Quaternion to right-handed
  53276. * @param quaternion Source quaternion to convert to right-handed
  53277. */
  53278. private static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  53279. private static _NormalizeTangentFromRef(tangent: Vector4): void;
  53280. }
  53281. }
  53282. declare module BABYLON.GLTF2.Exporter {
  53283. /**
  53284. * Interface for a glTF exporter extension
  53285. * @hidden
  53286. */
  53287. interface IGLTFExporterExtension extends BABYLON.IGLTFExporterExtension, IDisposable {
  53288. /**
  53289. * Define this method to modify the default behavior before exporting a texture
  53290. * @param context The context when loading the asset
  53291. * @param babylonTexture The glTF texture info property
  53292. * @param mimeType The mime-type of the generated image
  53293. * @returns A promise that resolves with the exported glTF texture info when the export is complete, or null if not handled
  53294. */
  53295. preExportTextureAsync?(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<Texture>>;
  53296. /**
  53297. * Define this method to modify the default behavior when exporting texture info
  53298. * @param context The context when loading the asset
  53299. * @param meshPrimitive glTF mesh primitive
  53300. * @param babylonSubMesh Babylon submesh
  53301. * @param binaryWriter glTF serializer binary writer instance
  53302. */
  53303. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Nullable<Promise<IMeshPrimitive>>;
  53304. }
  53305. }
  53306. declare module BABYLON {
  53307. /**
  53308. * Interface for extending the exporter
  53309. * @hidden
  53310. */
  53311. interface IGLTFExporterExtension {
  53312. /**
  53313. * The name of this extension
  53314. */
  53315. readonly name: string;
  53316. /**
  53317. * Defines whether this extension is enabled
  53318. */
  53319. enabled: boolean;
  53320. /**
  53321. * Defines whether this extension is required
  53322. */
  53323. required: boolean;
  53324. }
  53325. }
  53326. /**
  53327. * @hidden
  53328. */
  53329. declare module BABYLON.GLTF2.Exporter.Extensions {
  53330. /**
  53331. * @hidden
  53332. */
  53333. class KHR_texture_transform implements IGLTFExporterExtension {
  53334. /** Name of this extension */
  53335. readonly name: string;
  53336. /** Defines whether this extension is enabled */
  53337. enabled: boolean;
  53338. /** Defines whether this extension is required */
  53339. required: boolean;
  53340. /** Reference to the glTF exporter */
  53341. private _exporter;
  53342. constructor(exporter: _Exporter);
  53343. dispose(): void;
  53344. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<Texture>>;
  53345. /**
  53346. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  53347. * @param babylonTexture
  53348. * @param offset
  53349. * @param rotation
  53350. * @param scale
  53351. * @param scene
  53352. */
  53353. textureTransformTextureAsync(babylonTexture: Texture, offset: Vector2, rotation: number, scale: Vector2, scene: Scene): Promise<BaseTexture>;
  53354. }
  53355. }
  53356. /**
  53357. * @ignoreChildren
  53358. * @ignore
  53359. */
  53360. declare module "babylonjs-gltf2interface" {
  53361. export = BABYLON.GLTF2;
  53362. }
  53363. /**
  53364. * Module for glTF 2.0 Interface
  53365. */
  53366. declare module BABYLON.GLTF2 {
  53367. /**
  53368. * The datatype of the components in the attribute
  53369. */
  53370. const enum AccessorComponentType {
  53371. /**
  53372. * Byte
  53373. */
  53374. BYTE = 5120,
  53375. /**
  53376. * Unsigned Byte
  53377. */
  53378. UNSIGNED_BYTE = 5121,
  53379. /**
  53380. * Short
  53381. */
  53382. SHORT = 5122,
  53383. /**
  53384. * Unsigned Short
  53385. */
  53386. UNSIGNED_SHORT = 5123,
  53387. /**
  53388. * Unsigned Int
  53389. */
  53390. UNSIGNED_INT = 5125,
  53391. /**
  53392. * Float
  53393. */
  53394. FLOAT = 5126,
  53395. }
  53396. /**
  53397. * Specifies if the attirbute is a scalar, vector, or matrix
  53398. */
  53399. const enum AccessorType {
  53400. /**
  53401. * Scalar
  53402. */
  53403. SCALAR = "SCALAR",
  53404. /**
  53405. * Vector2
  53406. */
  53407. VEC2 = "VEC2",
  53408. /**
  53409. * Vector3
  53410. */
  53411. VEC3 = "VEC3",
  53412. /**
  53413. * Vector4
  53414. */
  53415. VEC4 = "VEC4",
  53416. /**
  53417. * Matrix2x2
  53418. */
  53419. MAT2 = "MAT2",
  53420. /**
  53421. * Matrix3x3
  53422. */
  53423. MAT3 = "MAT3",
  53424. /**
  53425. * Matrix4x4
  53426. */
  53427. MAT4 = "MAT4",
  53428. }
  53429. /**
  53430. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  53431. */
  53432. const enum AnimationChannelTargetPath {
  53433. /**
  53434. * Translation
  53435. */
  53436. TRANSLATION = "translation",
  53437. /**
  53438. * Rotation
  53439. */
  53440. ROTATION = "rotation",
  53441. /**
  53442. * Scale
  53443. */
  53444. SCALE = "scale",
  53445. /**
  53446. * Weights
  53447. */
  53448. WEIGHTS = "weights",
  53449. }
  53450. /**
  53451. * Interpolation algorithm
  53452. */
  53453. const enum AnimationSamplerInterpolation {
  53454. /**
  53455. * The animated values are linearly interpolated between keyframes
  53456. */
  53457. LINEAR = "LINEAR",
  53458. /**
  53459. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  53460. */
  53461. STEP = "STEP",
  53462. /**
  53463. * The animation's interpolation is computed using a cubic spline with specified tangents
  53464. */
  53465. CUBICSPLINE = "CUBICSPLINE",
  53466. }
  53467. /**
  53468. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  53469. */
  53470. const enum CameraType {
  53471. /**
  53472. * A perspective camera containing properties to create a perspective projection matrix
  53473. */
  53474. PERSPECTIVE = "perspective",
  53475. /**
  53476. * An orthographic camera containing properties to create an orthographic projection matrix
  53477. */
  53478. ORTHOGRAPHIC = "orthographic",
  53479. }
  53480. /**
  53481. * The mime-type of the image
  53482. */
  53483. const enum ImageMimeType {
  53484. /**
  53485. * JPEG Mime-type
  53486. */
  53487. JPEG = "image/jpeg",
  53488. /**
  53489. * PNG Mime-type
  53490. */
  53491. PNG = "image/png",
  53492. }
  53493. /**
  53494. * The alpha rendering mode of the material
  53495. */
  53496. const enum MaterialAlphaMode {
  53497. /**
  53498. * The alpha value is ignored and the rendered output is fully opaque
  53499. */
  53500. OPAQUE = "OPAQUE",
  53501. /**
  53502. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  53503. */
  53504. MASK = "MASK",
  53505. /**
  53506. * 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)
  53507. */
  53508. BLEND = "BLEND",
  53509. }
  53510. /**
  53511. * The type of the primitives to render
  53512. */
  53513. const enum MeshPrimitiveMode {
  53514. /**
  53515. * Points
  53516. */
  53517. POINTS = 0,
  53518. /**
  53519. * Lines
  53520. */
  53521. LINES = 1,
  53522. /**
  53523. * Line Loop
  53524. */
  53525. LINE_LOOP = 2,
  53526. /**
  53527. * Line Strip
  53528. */
  53529. LINE_STRIP = 3,
  53530. /**
  53531. * Triangles
  53532. */
  53533. TRIANGLES = 4,
  53534. /**
  53535. * Triangle Strip
  53536. */
  53537. TRIANGLE_STRIP = 5,
  53538. /**
  53539. * Triangle Fan
  53540. */
  53541. TRIANGLE_FAN = 6,
  53542. }
  53543. /**
  53544. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  53545. */
  53546. const enum TextureMagFilter {
  53547. /**
  53548. * Nearest
  53549. */
  53550. NEAREST = 9728,
  53551. /**
  53552. * Linear
  53553. */
  53554. LINEAR = 9729,
  53555. }
  53556. /**
  53557. * Minification filter. All valid values correspond to WebGL enums
  53558. */
  53559. const enum TextureMinFilter {
  53560. /**
  53561. * Nearest
  53562. */
  53563. NEAREST = 9728,
  53564. /**
  53565. * Linear
  53566. */
  53567. LINEAR = 9729,
  53568. /**
  53569. * Nearest Mip-Map Nearest
  53570. */
  53571. NEAREST_MIPMAP_NEAREST = 9984,
  53572. /**
  53573. * Linear Mipmap Nearest
  53574. */
  53575. LINEAR_MIPMAP_NEAREST = 9985,
  53576. /**
  53577. * Nearest Mipmap Linear
  53578. */
  53579. NEAREST_MIPMAP_LINEAR = 9986,
  53580. /**
  53581. * Linear Mipmap Linear
  53582. */
  53583. LINEAR_MIPMAP_LINEAR = 9987,
  53584. }
  53585. /**
  53586. * S (U) wrapping mode. All valid values correspond to WebGL enums
  53587. */
  53588. const enum TextureWrapMode {
  53589. /**
  53590. * Clamp to Edge
  53591. */
  53592. CLAMP_TO_EDGE = 33071,
  53593. /**
  53594. * Mirrored Repeat
  53595. */
  53596. MIRRORED_REPEAT = 33648,
  53597. /**
  53598. * Repeat
  53599. */
  53600. REPEAT = 10497,
  53601. }
  53602. /**
  53603. * glTF Property
  53604. */
  53605. interface IProperty {
  53606. /**
  53607. * Dictionary object with extension-specific objects
  53608. */
  53609. extensions?: {
  53610. [key: string]: any;
  53611. };
  53612. /**
  53613. * Application-Specific data
  53614. */
  53615. extras?: any;
  53616. }
  53617. /**
  53618. * glTF Child of Root Property
  53619. */
  53620. interface IChildRootProperty extends IProperty {
  53621. /**
  53622. * The user-defined name of this object
  53623. */
  53624. name?: string;
  53625. }
  53626. /**
  53627. * Indices of those attributes that deviate from their initialization value
  53628. */
  53629. interface IAccessorSparseIndices extends IProperty {
  53630. /**
  53631. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  53632. */
  53633. bufferView: number;
  53634. /**
  53635. * The offset relative to the start of the bufferView in bytes. Must be aligned
  53636. */
  53637. byteOffset?: number;
  53638. /**
  53639. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  53640. */
  53641. componentType: AccessorComponentType;
  53642. }
  53643. /**
  53644. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  53645. */
  53646. interface IAccessorSparseValues extends IProperty {
  53647. /**
  53648. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  53649. */
  53650. bufferView: number;
  53651. /**
  53652. * The offset relative to the start of the bufferView in bytes. Must be aligned
  53653. */
  53654. byteOffset?: number;
  53655. }
  53656. /**
  53657. * Sparse storage of attributes that deviate from their initialization value
  53658. */
  53659. interface IAccessorSparse extends IProperty {
  53660. /**
  53661. * The number of attributes encoded in this sparse accessor
  53662. */
  53663. count: number;
  53664. /**
  53665. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  53666. */
  53667. indices: IAccessorSparseIndices;
  53668. /**
  53669. * 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
  53670. */
  53671. values: IAccessorSparseValues;
  53672. }
  53673. /**
  53674. * 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
  53675. */
  53676. interface IAccessor extends IChildRootProperty {
  53677. /**
  53678. * The index of the bufferview
  53679. */
  53680. bufferView?: number;
  53681. /**
  53682. * The offset relative to the start of the bufferView in bytes
  53683. */
  53684. byteOffset?: number;
  53685. /**
  53686. * The datatype of components in the attribute
  53687. */
  53688. componentType: AccessorComponentType;
  53689. /**
  53690. * Specifies whether integer data values should be normalized
  53691. */
  53692. normalized?: boolean;
  53693. /**
  53694. * The number of attributes referenced by this accessor
  53695. */
  53696. count: number;
  53697. /**
  53698. * Specifies if the attribute is a scalar, vector, or matrix
  53699. */
  53700. type: AccessorType;
  53701. /**
  53702. * Maximum value of each component in this attribute
  53703. */
  53704. max?: number[];
  53705. /**
  53706. * Minimum value of each component in this attribute
  53707. */
  53708. min?: number[];
  53709. /**
  53710. * Sparse storage of attributes that deviate from their initialization value
  53711. */
  53712. sparse?: IAccessorSparse;
  53713. }
  53714. /**
  53715. * Targets an animation's sampler at a node's property
  53716. */
  53717. interface IAnimationChannel extends IProperty {
  53718. /**
  53719. * The index of a sampler in this animation used to compute the value for the target
  53720. */
  53721. sampler: number;
  53722. /**
  53723. * The index of the node and TRS property to target
  53724. */
  53725. target: IAnimationChannelTarget;
  53726. }
  53727. /**
  53728. * The index of the node and TRS property that an animation channel targets
  53729. */
  53730. interface IAnimationChannelTarget extends IProperty {
  53731. /**
  53732. * The index of the node to target
  53733. */
  53734. node: number;
  53735. /**
  53736. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  53737. */
  53738. path: AnimationChannelTargetPath;
  53739. }
  53740. /**
  53741. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  53742. */
  53743. interface IAnimationSampler extends IProperty {
  53744. /**
  53745. * The index of an accessor containing keyframe input values, e.g., time
  53746. */
  53747. input: number;
  53748. /**
  53749. * Interpolation algorithm
  53750. */
  53751. interpolation?: AnimationSamplerInterpolation;
  53752. /**
  53753. * The index of an accessor, containing keyframe output values
  53754. */
  53755. output: number;
  53756. }
  53757. /**
  53758. * A keyframe animation
  53759. */
  53760. interface IAnimation extends IChildRootProperty {
  53761. /**
  53762. * An array of channels, each of which targets an animation's sampler at a node's property
  53763. */
  53764. channels: IAnimationChannel[];
  53765. /**
  53766. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  53767. */
  53768. samplers: IAnimationSampler[];
  53769. }
  53770. /**
  53771. * Metadata about the glTF asset
  53772. */
  53773. interface IAsset extends IChildRootProperty {
  53774. /**
  53775. * A copyright message suitable for display to credit the content creator
  53776. */
  53777. copyright?: string;
  53778. /**
  53779. * Tool that generated this glTF model. Useful for debugging
  53780. */
  53781. generator?: string;
  53782. /**
  53783. * The glTF version that this asset targets
  53784. */
  53785. version: string;
  53786. /**
  53787. * The minimum glTF version that this asset targets
  53788. */
  53789. minVersion?: string;
  53790. }
  53791. /**
  53792. * A buffer points to binary geometry, animation, or skins
  53793. */
  53794. interface IBuffer extends IChildRootProperty {
  53795. /**
  53796. * 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
  53797. */
  53798. uri?: string;
  53799. /**
  53800. * The length of the buffer in bytes
  53801. */
  53802. byteLength: number;
  53803. }
  53804. /**
  53805. * A view into a buffer generally representing a subset of the buffer
  53806. */
  53807. interface IBufferView extends IChildRootProperty {
  53808. /**
  53809. * The index of the buffer
  53810. */
  53811. buffer: number;
  53812. /**
  53813. * The offset into the buffer in bytes
  53814. */
  53815. byteOffset?: number;
  53816. /**
  53817. * The lenth of the bufferView in bytes
  53818. */
  53819. byteLength: number;
  53820. /**
  53821. * The stride, in bytes
  53822. */
  53823. byteStride?: number;
  53824. }
  53825. /**
  53826. * An orthographic camera containing properties to create an orthographic projection matrix
  53827. */
  53828. interface ICameraOrthographic extends IProperty {
  53829. /**
  53830. * The floating-point horizontal magnification of the view. Must not be zero
  53831. */
  53832. xmag: number;
  53833. /**
  53834. * The floating-point vertical magnification of the view. Must not be zero
  53835. */
  53836. ymag: number;
  53837. /**
  53838. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  53839. */
  53840. zfar: number;
  53841. /**
  53842. * The floating-point distance to the near clipping plane
  53843. */
  53844. znear: number;
  53845. }
  53846. /**
  53847. * A perspective camera containing properties to create a perspective projection matrix
  53848. */
  53849. interface ICameraPerspective extends IProperty {
  53850. /**
  53851. * The floating-point aspect ratio of the field of view
  53852. */
  53853. aspectRatio?: number;
  53854. /**
  53855. * The floating-point vertical field of view in radians
  53856. */
  53857. yfov: number;
  53858. /**
  53859. * The floating-point distance to the far clipping plane
  53860. */
  53861. zfar?: number;
  53862. /**
  53863. * The floating-point distance to the near clipping plane
  53864. */
  53865. znear: number;
  53866. }
  53867. /**
  53868. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  53869. */
  53870. interface ICamera extends IChildRootProperty {
  53871. /**
  53872. * An orthographic camera containing properties to create an orthographic projection matrix
  53873. */
  53874. orthographic?: ICameraOrthographic;
  53875. /**
  53876. * A perspective camera containing properties to create a perspective projection matrix
  53877. */
  53878. perspective?: ICameraPerspective;
  53879. /**
  53880. * Specifies if the camera uses a perspective or orthographic projection
  53881. */
  53882. type: CameraType;
  53883. }
  53884. /**
  53885. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  53886. */
  53887. interface IImage extends IChildRootProperty {
  53888. /**
  53889. * 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
  53890. */
  53891. uri?: string;
  53892. /**
  53893. * The image's MIME type
  53894. */
  53895. mimeType?: ImageMimeType;
  53896. /**
  53897. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  53898. */
  53899. bufferView?: number;
  53900. }
  53901. /**
  53902. * Material Normal Texture Info
  53903. */
  53904. interface IMaterialNormalTextureInfo extends ITextureInfo {
  53905. /**
  53906. * The scalar multiplier applied to each normal vector of the normal texture
  53907. */
  53908. scale?: number;
  53909. }
  53910. /**
  53911. * Material Occlusion Texture Info
  53912. */
  53913. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  53914. /**
  53915. * A scalar multiplier controlling the amount of occlusion applied
  53916. */
  53917. strength?: number;
  53918. }
  53919. /**
  53920. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  53921. */
  53922. interface IMaterialPbrMetallicRoughness {
  53923. /**
  53924. * The material's base color factor
  53925. */
  53926. baseColorFactor?: number[];
  53927. /**
  53928. * The base color texture
  53929. */
  53930. baseColorTexture?: ITextureInfo;
  53931. /**
  53932. * The metalness of the material
  53933. */
  53934. metallicFactor?: number;
  53935. /**
  53936. * The roughness of the material
  53937. */
  53938. roughnessFactor?: number;
  53939. /**
  53940. * The metallic-roughness texture
  53941. */
  53942. metallicRoughnessTexture?: ITextureInfo;
  53943. }
  53944. /**
  53945. * The material appearance of a primitive
  53946. */
  53947. interface IMaterial extends IChildRootProperty {
  53948. /**
  53949. * 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
  53950. */
  53951. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  53952. /**
  53953. * The normal map texture
  53954. */
  53955. normalTexture?: IMaterialNormalTextureInfo;
  53956. /**
  53957. * The occlusion map texture
  53958. */
  53959. occlusionTexture?: IMaterialOcclusionTextureInfo;
  53960. /**
  53961. * The emissive map texture
  53962. */
  53963. emissiveTexture?: ITextureInfo;
  53964. /**
  53965. * 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
  53966. */
  53967. emissiveFactor?: number[];
  53968. /**
  53969. * The alpha rendering mode of the material
  53970. */
  53971. alphaMode?: MaterialAlphaMode;
  53972. /**
  53973. * The alpha cutoff value of the material
  53974. */
  53975. alphaCutoff?: number;
  53976. /**
  53977. * Specifies whether the material is double sided
  53978. */
  53979. doubleSided?: boolean;
  53980. }
  53981. /**
  53982. * Geometry to be rendered with the given material
  53983. */
  53984. interface IMeshPrimitive extends IProperty {
  53985. /**
  53986. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  53987. */
  53988. attributes: {
  53989. [name: string]: number;
  53990. };
  53991. /**
  53992. * The index of the accessor that contains the indices
  53993. */
  53994. indices?: number;
  53995. /**
  53996. * The index of the material to apply to this primitive when rendering
  53997. */
  53998. material?: number;
  53999. /**
  54000. * The type of primitives to render. All valid values correspond to WebGL enums
  54001. */
  54002. mode?: MeshPrimitiveMode;
  54003. /**
  54004. * 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
  54005. */
  54006. targets?: {
  54007. [name: string]: number;
  54008. }[];
  54009. }
  54010. /**
  54011. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  54012. */
  54013. interface IMesh extends IChildRootProperty {
  54014. /**
  54015. * An array of primitives, each defining geometry to be rendered with a material
  54016. */
  54017. primitives: IMeshPrimitive[];
  54018. /**
  54019. * Array of weights to be applied to the Morph Targets
  54020. */
  54021. weights?: number[];
  54022. }
  54023. /**
  54024. * A node in the node hierarchy
  54025. */
  54026. interface INode extends IChildRootProperty {
  54027. /**
  54028. * The index of the camera referenced by this node
  54029. */
  54030. camera?: number;
  54031. /**
  54032. * The indices of this node's children
  54033. */
  54034. children?: number[];
  54035. /**
  54036. * The index of the skin referenced by this node
  54037. */
  54038. skin?: number;
  54039. /**
  54040. * A floating-point 4x4 transformation matrix stored in column-major order
  54041. */
  54042. matrix?: number[];
  54043. /**
  54044. * The index of the mesh in this node
  54045. */
  54046. mesh?: number;
  54047. /**
  54048. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  54049. */
  54050. rotation?: number[];
  54051. /**
  54052. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  54053. */
  54054. scale?: number[];
  54055. /**
  54056. * The node's translation along the x, y, and z axes
  54057. */
  54058. translation?: number[];
  54059. /**
  54060. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  54061. */
  54062. weights?: number[];
  54063. }
  54064. /**
  54065. * Texture sampler properties for filtering and wrapping modes
  54066. */
  54067. interface ISampler extends IChildRootProperty {
  54068. /**
  54069. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  54070. */
  54071. magFilter?: TextureMagFilter;
  54072. /**
  54073. * Minification filter. All valid values correspond to WebGL enums
  54074. */
  54075. minFilter?: TextureMinFilter;
  54076. /**
  54077. * S (U) wrapping mode. All valid values correspond to WebGL enums
  54078. */
  54079. wrapS?: TextureWrapMode;
  54080. /**
  54081. * T (V) wrapping mode. All valid values correspond to WebGL enums
  54082. */
  54083. wrapT?: TextureWrapMode;
  54084. }
  54085. /**
  54086. * The root nodes of a scene
  54087. */
  54088. interface IScene extends IChildRootProperty {
  54089. /**
  54090. * The indices of each root node
  54091. */
  54092. nodes: number[];
  54093. }
  54094. /**
  54095. * Joints and matrices defining a skin
  54096. */
  54097. interface ISkin extends IChildRootProperty {
  54098. /**
  54099. * 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
  54100. */
  54101. inverseBindMatrices?: number;
  54102. /**
  54103. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  54104. */
  54105. skeleton?: number;
  54106. /**
  54107. * 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)
  54108. */
  54109. joints: number[];
  54110. }
  54111. /**
  54112. * A texture and its sampler
  54113. */
  54114. interface ITexture extends IChildRootProperty {
  54115. /**
  54116. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  54117. */
  54118. sampler?: number;
  54119. /**
  54120. * The index of the image used by this texture
  54121. */
  54122. source: number;
  54123. }
  54124. /**
  54125. * Reference to a texture
  54126. */
  54127. interface ITextureInfo extends IProperty {
  54128. /**
  54129. * The index of the texture
  54130. */
  54131. index: number;
  54132. /**
  54133. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  54134. */
  54135. texCoord?: number;
  54136. }
  54137. /**
  54138. * The root object for a glTF asset
  54139. */
  54140. interface IGLTF extends IProperty {
  54141. /**
  54142. * An array of accessors. An accessor is a typed view into a bufferView
  54143. */
  54144. accessors?: IAccessor[];
  54145. /**
  54146. * An array of keyframe animations
  54147. */
  54148. animations?: IAnimation[];
  54149. /**
  54150. * Metadata about the glTF asset
  54151. */
  54152. asset: IAsset;
  54153. /**
  54154. * An array of buffers. A buffer points to binary geometry, animation, or skins
  54155. */
  54156. buffers?: IBuffer[];
  54157. /**
  54158. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  54159. */
  54160. bufferViews?: IBufferView[];
  54161. /**
  54162. * An array of cameras
  54163. */
  54164. cameras?: ICamera[];
  54165. /**
  54166. * Names of glTF extensions used somewhere in this asset
  54167. */
  54168. extensionsUsed?: string[];
  54169. /**
  54170. * Names of glTF extensions required to properly load this asset
  54171. */
  54172. extensionsRequired?: string[];
  54173. /**
  54174. * An array of images. An image defines data used to create a texture
  54175. */
  54176. images?: IImage[];
  54177. /**
  54178. * An array of materials. A material defines the appearance of a primitive
  54179. */
  54180. materials?: IMaterial[];
  54181. /**
  54182. * An array of meshes. A mesh is a set of primitives to be rendered
  54183. */
  54184. meshes?: IMesh[];
  54185. /**
  54186. * An array of nodes
  54187. */
  54188. nodes?: INode[];
  54189. /**
  54190. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  54191. */
  54192. samplers?: ISampler[];
  54193. /**
  54194. * The index of the default scene
  54195. */
  54196. scene?: number;
  54197. /**
  54198. * An array of scenes
  54199. */
  54200. scenes?: IScene[];
  54201. /**
  54202. * An array of skins. A skin is defined by joints and matrices
  54203. */
  54204. skins?: ISkin[];
  54205. /**
  54206. * An array of textures
  54207. */
  54208. textures?: ITexture[];
  54209. }
  54210. }
  54211. /**
  54212. * Interface for glTF validation results
  54213. */
  54214. interface IGLTFValidationResults {
  54215. info: {
  54216. generator: string;
  54217. hasAnimations: boolean;
  54218. hasDefaultScene: boolean;
  54219. hasMaterials: boolean;
  54220. hasMorphTargets: boolean;
  54221. hasSkins: boolean;
  54222. hasTextures: boolean;
  54223. maxAttributesUsed: number;
  54224. primitivesCount: number
  54225. };
  54226. issues: {
  54227. messages: Array<string>;
  54228. numErrors: number;
  54229. numHints: number;
  54230. numInfos: number;
  54231. numWarnings: number;
  54232. truncated: boolean
  54233. };
  54234. mimeType: string;
  54235. uri: string;
  54236. validatedAt: string;
  54237. validatorVersion: string;
  54238. }
  54239. /**
  54240. * Interface for glTF validation options
  54241. */
  54242. interface IGLTFValidationOptions {
  54243. uri?: string;
  54244. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  54245. validateAccessorData?: boolean;
  54246. maxIssues?: number;
  54247. ignoredIssues?: Array<string>;
  54248. severityOverrides?: Object;
  54249. }
  54250. /**
  54251. * glTF validator object
  54252. */
  54253. declare var GLTFValidator: {
  54254. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  54255. };