babylon.d.txt 1.7 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968
  1. declare module 'babylonjs' {
  2. export = BABYLON;
  3. }
  4. declare module BABYLON {
  5. /**
  6. * Set of assets to keep when moving a scene into an asset container.
  7. */
  8. class KeepAssets {
  9. /**
  10. * Cameras to keep.
  11. */
  12. cameras: Camera[];
  13. /**
  14. * Lights to keep.
  15. */
  16. lights: Light[];
  17. /**
  18. * Meshes to keep.
  19. */
  20. meshes: AbstractMesh[];
  21. /**
  22. * Skeletons to keep.
  23. */
  24. skeletons: Skeleton[];
  25. /**
  26. * ParticleSystems to keep.
  27. */
  28. particleSystems: IParticleSystem[];
  29. /**
  30. * Animations to keep.
  31. */
  32. animations: Animation[];
  33. /**
  34. * AnimationGroups to keep.
  35. */
  36. animationGroups: AnimationGroup[];
  37. /**
  38. * MultiMaterials to keep.
  39. */
  40. multiMaterials: MultiMaterial[];
  41. /**
  42. * Materials to keep.
  43. */
  44. materials: Material[];
  45. /**
  46. * MorphTargetManagers to keep.
  47. */
  48. morphTargetManagers: MorphTargetManager[];
  49. /**
  50. * Geometries to keep.
  51. */
  52. geometries: Geometry[];
  53. /**
  54. * TransformNodes to keep.
  55. */
  56. transformNodes: TransformNode[];
  57. /**
  58. * LensFlareSystems to keep.
  59. */
  60. lensFlareSystems: LensFlareSystem[];
  61. /**
  62. * ShadowGenerators to keep.
  63. */
  64. shadowGenerators: ShadowGenerator[];
  65. /**
  66. * ActionManagers to keep.
  67. */
  68. actionManagers: ActionManager[];
  69. /**
  70. * Sounds to keep.
  71. */
  72. sounds: Sound[];
  73. /**
  74. * Textures to keep.
  75. */
  76. textures: Texture[];
  77. /**
  78. * Effect layers to keep.
  79. */
  80. effectLayers: EffectLayer[];
  81. }
  82. /**
  83. * Container with a set of assets that can be added or removed from a scene.
  84. */
  85. class AssetContainer {
  86. /**
  87. * The scene the AssetContainer belongs to.
  88. */
  89. scene: Scene;
  90. /**
  91. * Cameras populated in the container.
  92. */
  93. cameras: Camera[];
  94. /**
  95. * Lights populated in the container.
  96. */
  97. lights: Light[];
  98. /**
  99. * Meshes populated in the container.
  100. */
  101. meshes: AbstractMesh[];
  102. /**
  103. * Skeletons populated in the container.
  104. */
  105. skeletons: Skeleton[];
  106. /**
  107. * ParticleSystems populated in the container.
  108. */
  109. particleSystems: IParticleSystem[];
  110. /**
  111. * Animations populated in the container.
  112. */
  113. animations: Animation[];
  114. /**
  115. * AnimationGroups populated in the container.
  116. */
  117. animationGroups: AnimationGroup[];
  118. /**
  119. * MultiMaterials populated in the container.
  120. */
  121. multiMaterials: MultiMaterial[];
  122. /**
  123. * Materials populated in the container.
  124. */
  125. materials: Material[];
  126. /**
  127. * MorphTargetManagers populated in the container.
  128. */
  129. morphTargetManagers: MorphTargetManager[];
  130. /**
  131. * Geometries populated in the container.
  132. */
  133. geometries: Geometry[];
  134. /**
  135. * TransformNodes populated in the container.
  136. */
  137. transformNodes: TransformNode[];
  138. /**
  139. * LensFlareSystems populated in the container.
  140. */
  141. lensFlareSystems: LensFlareSystem[];
  142. /**
  143. * ShadowGenerators populated in the container.
  144. */
  145. shadowGenerators: ShadowGenerator[];
  146. /**
  147. * ActionManagers populated in the container.
  148. */
  149. actionManagers: ActionManager[];
  150. /**
  151. * Sounds populated in the container.
  152. */
  153. sounds: Sound[];
  154. /**
  155. * Textures populated in the container.
  156. */
  157. textures: Texture[];
  158. /**
  159. * Effect layers populated in the container.
  160. */
  161. effectLayers: EffectLayer[];
  162. /**
  163. * Instantiates an AssetContainer.
  164. * @param scene The scene the AssetContainer belongs to.
  165. */
  166. constructor(scene: Scene);
  167. /**
  168. * Adds all the assets from the container to the scene.
  169. */
  170. addAllToScene(): void;
  171. /**
  172. * Removes all the assets in the container from the scene
  173. */
  174. removeAllFromScene(): void;
  175. private _moveAssets<T>(sourceAssets, targetAssets, keepAssets);
  176. /**
  177. * Removes all the assets contained in the scene and adds them to the container.
  178. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  179. */
  180. moveAllFromScene(keepAssets?: KeepAssets): void;
  181. /**
  182. * 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.
  183. * @returns the root mesh
  184. */
  185. createRootMesh(): Mesh;
  186. }
  187. }
  188. interface Window {
  189. mozIndexedDB: IDBFactory;
  190. webkitIndexedDB: IDBFactory;
  191. msIndexedDB: IDBFactory;
  192. webkitURL: typeof URL;
  193. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  194. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  195. WebGLRenderingContext: WebGLRenderingContext;
  196. MSGesture: MSGesture;
  197. CANNON: any;
  198. AudioContext: AudioContext;
  199. webkitAudioContext: AudioContext;
  200. PointerEvent: any;
  201. Math: Math;
  202. Uint8Array: Uint8ArrayConstructor;
  203. Float32Array: Float32ArrayConstructor;
  204. mozURL: typeof URL;
  205. msURL: typeof URL;
  206. VRFrameData: any;
  207. DracoDecoderModule: any;
  208. }
  209. interface WebGLRenderingContext {
  210. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  211. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  212. vertexAttribDivisor(index: number, divisor: number): void;
  213. createVertexArray(): any;
  214. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  215. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  216. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  217. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  218. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  219. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  220. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  221. createQuery(): WebGLQuery;
  222. deleteQuery(query: WebGLQuery): void;
  223. beginQuery(target: number, query: WebGLQuery): void;
  224. endQuery(target: number): void;
  225. getQueryParameter(query: WebGLQuery, pname: number): any;
  226. getQuery(target: number, pname: number): any;
  227. MAX_SAMPLES: number;
  228. RGBA8: number;
  229. READ_FRAMEBUFFER: number;
  230. DRAW_FRAMEBUFFER: number;
  231. UNIFORM_BUFFER: number;
  232. HALF_FLOAT_OES: number;
  233. RGBA16F: number;
  234. RGBA32F: number;
  235. R32F: number;
  236. RG32F: number;
  237. RGB32F: number;
  238. R16F: number;
  239. RG16F: number;
  240. RGB16F: number;
  241. RED: number;
  242. RG: number;
  243. R8: number;
  244. RG8: number;
  245. UNSIGNED_INT_24_8: number;
  246. DEPTH24_STENCIL8: number;
  247. drawBuffers(buffers: number[]): void;
  248. readBuffer(src: number): void;
  249. readonly COLOR_ATTACHMENT0: number;
  250. readonly COLOR_ATTACHMENT1: number;
  251. readonly COLOR_ATTACHMENT2: number;
  252. readonly COLOR_ATTACHMENT3: number;
  253. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  254. ANY_SAMPLES_PASSED: number;
  255. QUERY_RESULT_AVAILABLE: number;
  256. QUERY_RESULT: number;
  257. }
  258. interface Document {
  259. mozCancelFullScreen(): void;
  260. msCancelFullScreen(): void;
  261. mozFullScreen: boolean;
  262. msIsFullScreen: boolean;
  263. fullscreen: boolean;
  264. mozPointerLockElement: HTMLElement;
  265. msPointerLockElement: HTMLElement;
  266. webkitPointerLockElement: HTMLElement;
  267. }
  268. interface HTMLCanvasElement {
  269. msRequestPointerLock?(): void;
  270. mozRequestPointerLock?(): void;
  271. webkitRequestPointerLock?(): void;
  272. }
  273. interface CanvasRenderingContext2D {
  274. msImageSmoothingEnabled: boolean;
  275. }
  276. interface WebGLBuffer {
  277. references: number;
  278. capacity: number;
  279. is32Bits: boolean;
  280. }
  281. interface WebGLProgram {
  282. transformFeedback?: WebGLTransformFeedback | null;
  283. }
  284. interface MouseEvent {
  285. mozMovementX: number;
  286. mozMovementY: number;
  287. webkitMovementX: number;
  288. webkitMovementY: number;
  289. msMovementX: number;
  290. msMovementY: number;
  291. }
  292. interface Navigator {
  293. mozGetVRDevices: (any: any) => any;
  294. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  295. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  296. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  297. webkitGetGamepads(): Gamepad[];
  298. msGetGamepads(): Gamepad[];
  299. webkitGamepads(): Gamepad[];
  300. }
  301. interface HTMLVideoElement {
  302. mozSrcObject: any;
  303. }
  304. interface Screen {
  305. orientation: string;
  306. 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. * Node is the basic class for all scene objects (Mesh, Light Camera).
  331. */
  332. class Node implements IBehaviorAware<Node> {
  333. /**
  334. * Gets or sets the name of the node
  335. */
  336. name: string;
  337. /**
  338. * Gets or sets the id of the node
  339. */
  340. id: string;
  341. /**
  342. * Gets or sets the unique id of the node
  343. */
  344. uniqueId: number;
  345. /**
  346. * Gets or sets a string used to store user defined state for the node
  347. */
  348. state: string;
  349. /**
  350. * Gets or sets an object used to store user defined information for the node
  351. */
  352. metadata: any;
  353. /**
  354. * Gets or sets a boolean used to define if the node must be serialized
  355. */
  356. doNotSerialize: boolean;
  357. /** @hidden */
  358. /**
  359. * Gets a list of Animations associated with the node
  360. */
  361. animations: Animation[];
  362. private _ranges;
  363. /**
  364. * Callback raised when the node is ready to be used
  365. */
  366. onReady: (node: Node) => void;
  367. private _isEnabled;
  368. private _isReady;
  369. /** @hidden */
  370. private _parentRenderId;
  371. protected _childRenderId: number;
  372. /** @hidden */
  373. private _scene;
  374. /** @hidden */
  375. private _parentNode;
  376. private _children;
  377. /**
  378. * Gets a boolean indicating if the node has been disposed
  379. * @returns true if the node was disposed
  380. */
  381. isDisposed(): boolean;
  382. /**
  383. * Gets or sets the parent of the node
  384. */
  385. parent: Nullable<Node>;
  386. private _animationPropertiesOverride;
  387. /**
  388. * Gets or sets the animation properties override
  389. */
  390. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  391. /**
  392. * Gets a string idenfifying the name of the class
  393. * @returns "Node" string
  394. */
  395. getClassName(): string;
  396. /**
  397. * An event triggered when the mesh is disposed
  398. */
  399. onDisposeObservable: Observable<Node>;
  400. private _onDisposeObserver;
  401. /**
  402. * Sets a callback that will be raised when the node will be disposed
  403. */
  404. onDispose: () => void;
  405. /**
  406. * Creates a new Node
  407. * @param {string} name - the name and id to be given to this node
  408. * @param {BABYLON.Scene} the scene this node will be added to
  409. */
  410. constructor(name: string, scene?: Nullable<Scene>);
  411. /**
  412. * Gets the scene of the node
  413. * @returns a {BABYLON.Scene}
  414. */
  415. getScene(): Scene;
  416. /**
  417. * Gets the engine of the node
  418. * @returns a {BABYLON.Engine}
  419. */
  420. getEngine(): Engine;
  421. private _behaviors;
  422. /**
  423. * Attach a behavior to the node
  424. * @see http://doc.babylonjs.com/features/behaviour
  425. * @param behavior defines the behavior to attach
  426. * @returns the current Node
  427. */
  428. addBehavior(behavior: Behavior<Node>): Node;
  429. /**
  430. * Remove an attached behavior
  431. * @see http://doc.babylonjs.com/features/behaviour
  432. * @param behavior defines the behavior to attach
  433. * @returns the current Node
  434. */
  435. removeBehavior(behavior: Behavior<Node>): Node;
  436. /**
  437. * Gets the list of attached behaviors
  438. * @see http://doc.babylonjs.com/features/behaviour
  439. */
  440. readonly behaviors: Behavior<Node>[];
  441. /**
  442. * Gets an attached behavior by name
  443. * @param name defines the name of the behavior to look for
  444. * @see http://doc.babylonjs.com/features/behaviour
  445. * @returns null if behavior was not found else the requested behavior
  446. */
  447. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  448. /**
  449. * Returns the world matrix of the node
  450. * @returns a matrix containing the node's world matrix
  451. */
  452. getWorldMatrix(): Matrix;
  453. /** @hidden */
  454. /** @hidden */
  455. /** @hidden */
  456. updateCache(force?: boolean): void;
  457. /** @hidden */
  458. /** @hidden */
  459. /** @hidden */
  460. /** @hidden */
  461. isSynchronizedWithParent(): boolean;
  462. /** @hidden */
  463. isSynchronized(updateCache?: boolean): boolean;
  464. /** @hidden */
  465. hasNewParent(update?: boolean): boolean;
  466. /**
  467. * Is this node ready to be used/rendered
  468. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  469. * @return true if the node is ready
  470. */
  471. isReady(completeCheck?: boolean): boolean;
  472. /**
  473. * Is this node enabled?
  474. * 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
  475. * @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
  476. * @return whether this node (and its parent) is enabled
  477. */
  478. isEnabled(checkAncestors?: boolean): boolean;
  479. /**
  480. * Set the enabled state of this node
  481. * @param value defines the new enabled state
  482. */
  483. setEnabled(value: boolean): void;
  484. /**
  485. * Is this node a descendant of the given node?
  486. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  487. * @param ancestor defines the parent node to inspect
  488. * @returns a boolean indicating if this node is a descendant of the given node
  489. */
  490. isDescendantOf(ancestor: Node): boolean;
  491. /** @hidden */
  492. /**
  493. * Will return all nodes that have this node as ascendant
  494. * @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
  495. * @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
  496. * @return all children nodes of all types
  497. */
  498. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  499. /**
  500. * Get all child-meshes of this node
  501. * @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
  502. * @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
  503. * @returns an array of {BABYLON.AbstractMesh}
  504. */
  505. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  506. /**
  507. * Get all child-transformNodes of this node
  508. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered
  509. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  510. * @returns an array of {BABYLON.TransformNode}
  511. */
  512. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  513. /**
  514. * Get all direct children of this node
  515. * @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
  516. * @returns an array of {BABYLON.Node}
  517. */
  518. getChildren(predicate?: (node: Node) => boolean): Node[];
  519. /** @hidden */
  520. /**
  521. * Get an animation by name
  522. * @param name defines the name of the animation to look for
  523. * @returns null if not found else the requested animation
  524. */
  525. getAnimationByName(name: string): Nullable<Animation>;
  526. /**
  527. * Creates an animation range for this node
  528. * @param name defines the name of the range
  529. * @param from defines the starting key
  530. * @param to defines the end key
  531. */
  532. createAnimationRange(name: string, from: number, to: number): void;
  533. /**
  534. * Delete a specific animation range
  535. * @param name defines the name of the range to delete
  536. * @param deleteFrames defines if animation frames from the range must be deleted as well
  537. */
  538. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  539. /**
  540. * Get an animation range by name
  541. * @param name defines the name of the animation range to look for
  542. * @returns null if not found else the requested animation range
  543. */
  544. getAnimationRange(name: string): Nullable<AnimationRange>;
  545. /**
  546. * Will start the animation sequence
  547. * @param name defines the range frames for animation sequence
  548. * @param loop defines if the animation should loop (false by default)
  549. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  550. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  551. * @returns the object created for this animation. If range does not exist, it will return null
  552. */
  553. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  554. /**
  555. * Serialize animation ranges into a JSON compatible object
  556. * @returns serialization object
  557. */
  558. serializeAnimationRanges(): any;
  559. /**
  560. * Computes the world matrix of the node
  561. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  562. * @returns the world matrix
  563. */
  564. computeWorldMatrix(force?: boolean): Matrix;
  565. /**
  566. * Releases resources associated with this node.
  567. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  568. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  569. */
  570. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  571. /**
  572. * Parse animation range data from a serialization object and store them into a given node
  573. * @param node defines where to store the animation ranges
  574. * @param parsedNode defines the serialization object to read data from
  575. * @param scene defines the hosting scene
  576. */
  577. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  578. }
  579. }
  580. declare module BABYLON {
  581. /**
  582. * Define an interface for all classes that will hold resources
  583. */
  584. interface IDisposable {
  585. /**
  586. * Releases all held resources
  587. */
  588. dispose(): void;
  589. }
  590. /**
  591. * Interface used to let developers provide their own mesh selection mechanism
  592. */
  593. interface IActiveMeshCandidateProvider {
  594. /**
  595. * Return the list of active meshes
  596. * @param scene defines the current scene
  597. * @returns the list of active meshes
  598. */
  599. getMeshes(scene: Scene): AbstractMesh[];
  600. /**
  601. * Indicates if the meshes have been checked to make sure they are isEnabled()
  602. */
  603. readonly checksIsEnabled: boolean;
  604. }
  605. /**
  606. * This class is used by the onRenderingGroupObservable
  607. */
  608. class RenderingGroupInfo {
  609. /**
  610. * The Scene that being rendered
  611. */
  612. scene: Scene;
  613. /**
  614. * The camera currently used for the rendering pass
  615. */
  616. camera: Nullable<Camera>;
  617. /**
  618. * The ID of the renderingGroup being processed
  619. */
  620. renderingGroupId: number;
  621. /**
  622. * The rendering stage, can be either STAGE_PRECLEAR, STAGE_PREOPAQUE, STAGE_PRETRANSPARENT, STAGE_POSTTRANSPARENT
  623. */
  624. renderStage: number;
  625. /**
  626. * Stage corresponding to the very first hook in the renderingGroup phase: before the render buffer may be cleared
  627. * This stage will be fired no matter what
  628. */
  629. static STAGE_PRECLEAR: number;
  630. /**
  631. * Called before opaque object are rendered.
  632. * This stage will be fired only if there's 3D Opaque content to render
  633. */
  634. static STAGE_PREOPAQUE: number;
  635. /**
  636. * Called after the opaque objects are rendered and before the transparent ones
  637. * This stage will be fired only if there's 3D transparent content to render
  638. */
  639. static STAGE_PRETRANSPARENT: number;
  640. /**
  641. * Called after the transparent object are rendered, last hook of the renderingGroup phase
  642. * This stage will be fired no matter what
  643. */
  644. static STAGE_POSTTRANSPARENT: number;
  645. }
  646. /**
  647. * Represents a scene to be rendered by the engine.
  648. * @see http://doc.babylonjs.com/features/scene
  649. */
  650. class Scene implements IAnimatable {
  651. private static _FOGMODE_NONE;
  652. private static _FOGMODE_EXP;
  653. private static _FOGMODE_EXP2;
  654. private static _FOGMODE_LINEAR;
  655. private static _uniqueIdCounter;
  656. /**
  657. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  658. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  659. */
  660. static MinDeltaTime: number;
  661. /**
  662. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  663. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  664. */
  665. static MaxDeltaTime: number;
  666. /** The fog is deactivated */
  667. static readonly FOGMODE_NONE: number;
  668. /** The fog density is following an exponential function */
  669. static readonly FOGMODE_EXP: number;
  670. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  671. static readonly FOGMODE_EXP2: number;
  672. /** The fog density is following a linear function. */
  673. static readonly FOGMODE_LINEAR: 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 a boolean indicating if all bounding boxes must be rendered
  727. */
  728. forceShowBoundingBoxes: boolean;
  729. /**
  730. * Gets or sets the active clipplane
  731. */
  732. clipPlane: Nullable<Plane>;
  733. /**
  734. * Gets or sets a boolean indicating if animations are enabled
  735. */
  736. animationsEnabled: boolean;
  737. private _animationPropertiesOverride;
  738. /**
  739. * Gets or sets the animation properties override
  740. */
  741. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  742. /**
  743. * Gets or sets a boolean indicating if a constant deltatime has to be used
  744. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  745. */
  746. useConstantAnimationDeltaTime: boolean;
  747. /**
  748. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  749. * Please note that it requires to run a ray cast through the scene on every frame
  750. */
  751. constantlyUpdateMeshUnderPointer: boolean;
  752. /**
  753. * Defines the HTML cursor to use when hovering over interactive elements
  754. */
  755. hoverCursor: string;
  756. /**
  757. * Defines the HTML default cursor to use (empty by default)
  758. */
  759. defaultCursor: string;
  760. /**
  761. * This is used to call preventDefault() on pointer down
  762. * in order to block unwanted artifacts like system double clicks
  763. */
  764. preventDefaultOnPointerDown: boolean;
  765. /**
  766. * Gets or sets user defined metadata
  767. */
  768. metadata: any;
  769. /**
  770. * Gets the name of the plugin used to load this scene (null by default)
  771. */
  772. loadingPluginName: string;
  773. /**
  774. * Use this array to add regular expressions used to disable offline support for specific urls
  775. */
  776. disableOfflineSupportExceptionRules: RegExp[];
  777. private _spritePredicate;
  778. /**
  779. * An event triggered when the scene is disposed.
  780. */
  781. onDisposeObservable: Observable<Scene>;
  782. private _onDisposeObserver;
  783. /** Sets a function to be executed when this scene is disposed. */
  784. onDispose: () => void;
  785. /**
  786. * An event triggered before rendering the scene (right after animations and physics)
  787. */
  788. onBeforeRenderObservable: Observable<Scene>;
  789. private _onBeforeRenderObserver;
  790. /** Sets a function to be executed before rendering this scene */
  791. beforeRender: Nullable<() => void>;
  792. /**
  793. * An event triggered after rendering the scene
  794. */
  795. onAfterRenderObservable: Observable<Scene>;
  796. private _onAfterRenderObserver;
  797. /** Sets a function to be executed after rendering this scene */
  798. afterRender: Nullable<() => void>;
  799. /**
  800. * An event triggered before animating the scene
  801. */
  802. onBeforeAnimationsObservable: Observable<Scene>;
  803. /**
  804. * An event triggered after animations processing
  805. */
  806. onAfterAnimationsObservable: Observable<Scene>;
  807. /**
  808. * An event triggered before draw calls are ready to be sent
  809. */
  810. onBeforeDrawPhaseObservable: Observable<Scene>;
  811. /**
  812. * An event triggered after draw calls have been sent
  813. */
  814. onAfterDrawPhaseObservable: Observable<Scene>;
  815. /**
  816. * An event triggered when physic simulation is about to be run
  817. */
  818. onBeforePhysicsObservable: Observable<Scene>;
  819. /**
  820. * An event triggered when physic simulation has been done
  821. */
  822. onAfterPhysicsObservable: Observable<Scene>;
  823. /**
  824. * An event triggered when the scene is ready
  825. */
  826. onReadyObservable: Observable<Scene>;
  827. /**
  828. * An event triggered before rendering a camera
  829. */
  830. onBeforeCameraRenderObservable: Observable<Camera>;
  831. private _onBeforeCameraRenderObserver;
  832. /** Sets a function to be executed before rendering a camera*/
  833. beforeCameraRender: () => void;
  834. /**
  835. * An event triggered after rendering a camera
  836. */
  837. onAfterCameraRenderObservable: Observable<Camera>;
  838. private _onAfterCameraRenderObserver;
  839. /** Sets a function to be executed after rendering a camera*/
  840. afterCameraRender: () => void;
  841. /**
  842. * An event triggered when active meshes evaluation is about to start
  843. */
  844. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  845. /**
  846. * An event triggered when active meshes evaluation is done
  847. */
  848. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  849. /**
  850. * An event triggered when particles rendering is about to start
  851. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  852. */
  853. onBeforeParticlesRenderingObservable: Observable<Scene>;
  854. /**
  855. * An event triggered when particles rendering is done
  856. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  857. */
  858. onAfterParticlesRenderingObservable: Observable<Scene>;
  859. /**
  860. * An event triggered when sprites rendering is about to start
  861. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  862. */
  863. onBeforeSpritesRenderingObservable: Observable<Scene>;
  864. /**
  865. * An event triggered when sprites rendering is done
  866. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  867. */
  868. onAfterSpritesRenderingObservable: Observable<Scene>;
  869. /**
  870. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  871. */
  872. onDataLoadedObservable: Observable<Scene>;
  873. /**
  874. * An event triggered when a camera is created
  875. */
  876. onNewCameraAddedObservable: Observable<Camera>;
  877. /**
  878. * An event triggered when a camera is removed
  879. */
  880. onCameraRemovedObservable: Observable<Camera>;
  881. /**
  882. * An event triggered when a light is created
  883. */
  884. onNewLightAddedObservable: Observable<Light>;
  885. /**
  886. * An event triggered when a light is removed
  887. */
  888. onLightRemovedObservable: Observable<Light>;
  889. /**
  890. * An event triggered when a geometry is created
  891. */
  892. onNewGeometryAddedObservable: Observable<Geometry>;
  893. /**
  894. * An event triggered when a geometry is removed
  895. */
  896. onGeometryRemovedObservable: Observable<Geometry>;
  897. /**
  898. * An event triggered when a transform node is created
  899. */
  900. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  901. /**
  902. * An event triggered when a transform node is removed
  903. */
  904. onTransformNodeRemovedObservable: Observable<TransformNode>;
  905. /**
  906. * An event triggered when a mesh is created
  907. */
  908. onNewMeshAddedObservable: Observable<AbstractMesh>;
  909. /**
  910. * An event triggered when a mesh is removed
  911. */
  912. onMeshRemovedObservable: Observable<AbstractMesh>;
  913. /**
  914. * An event triggered when render targets are about to be rendered
  915. * Can happen multiple times per frame.
  916. */
  917. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  918. /**
  919. * An event triggered when render targets were rendered.
  920. * Can happen multiple times per frame.
  921. */
  922. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  923. /**
  924. * An event triggered before calculating deterministic simulation step
  925. */
  926. onBeforeStepObservable: Observable<Scene>;
  927. /**
  928. * An event triggered after calculating deterministic simulation step
  929. */
  930. onAfterStepObservable: Observable<Scene>;
  931. /**
  932. * This Observable will be triggered for each stage of each renderingGroup of each rendered camera.
  933. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  934. * 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)
  935. */
  936. onRenderingGroupObservable: Observable<RenderingGroupInfo>;
  937. /**
  938. * Gets a list of Animations associated with the scene
  939. */
  940. animations: Animation[];
  941. private _registeredForLateAnimationBindings;
  942. /**
  943. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  944. */
  945. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  946. /**
  947. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  948. */
  949. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  950. /**
  951. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  952. */
  953. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  954. private _onPointerMove;
  955. private _onPointerDown;
  956. private _onPointerUp;
  957. /** Deprecated. Use onPointerObservable instead */
  958. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  959. /** Deprecated. Use onPointerObservable instead */
  960. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  961. /** Deprecated. Use onPointerObservable instead */
  962. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  963. /** Deprecated. Use onPointerObservable instead */
  964. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  965. private _gamepadManager;
  966. /**
  967. * Gets the gamepad manager associated with the scene
  968. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  969. */
  970. readonly gamepadManager: GamepadManager;
  971. /**
  972. * 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).
  973. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  974. */
  975. onPrePointerObservable: Observable<PointerInfoPre>;
  976. /**
  977. * Observable event triggered each time an input event is received from the rendering canvas
  978. */
  979. onPointerObservable: Observable<PointerInfo>;
  980. /**
  981. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  982. */
  983. readonly unTranslatedPointer: Vector2;
  984. /** The distance in pixel that you have to move to prevent some events */
  985. static DragMovementThreshold: number;
  986. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  987. static LongPressDelay: number;
  988. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  989. static DoubleClickDelay: number;
  990. /** If you need to check double click without raising a single click at first click, enable this flag */
  991. static ExclusiveDoubleClickMode: boolean;
  992. private _initClickEvent;
  993. private _initActionManager;
  994. private _delayedSimpleClick;
  995. private _delayedSimpleClickTimeout;
  996. private _previousDelayedSimpleClickTimeout;
  997. private _meshPickProceed;
  998. private _previousButtonPressed;
  999. private _currentPickResult;
  1000. private _previousPickResult;
  1001. private _totalPointersPressed;
  1002. private _doubleClickOccured;
  1003. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  1004. cameraToUseForPointers: Nullable<Camera>;
  1005. private _pointerX;
  1006. private _pointerY;
  1007. private _unTranslatedPointerX;
  1008. private _unTranslatedPointerY;
  1009. private _startingPointerPosition;
  1010. private _previousStartingPointerPosition;
  1011. private _startingPointerTime;
  1012. private _previousStartingPointerTime;
  1013. private _pointerCaptures;
  1014. private _timeAccumulator;
  1015. private _currentStepId;
  1016. private _currentInternalStep;
  1017. /** @hidden */
  1018. /**
  1019. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  1020. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  1021. */
  1022. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  1023. /**
  1024. * Observable event triggered each time an keyboard event is received from the hosting window
  1025. */
  1026. onKeyboardObservable: Observable<KeyboardInfo>;
  1027. private _onKeyDown;
  1028. private _onKeyUp;
  1029. private _onCanvasFocusObserver;
  1030. private _onCanvasBlurObserver;
  1031. private _useRightHandedSystem;
  1032. /**
  1033. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  1034. */
  1035. useRightHandedSystem: boolean;
  1036. /**
  1037. * Sets the step Id used by deterministic lock step
  1038. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  1039. * @param newStepId defines the step Id
  1040. */
  1041. setStepId(newStepId: number): void;
  1042. /**
  1043. * Gets the step Id used by deterministic lock step
  1044. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  1045. * @returns the step Id
  1046. */
  1047. getStepId(): number;
  1048. /**
  1049. * Gets the internal step used by deterministic lock step
  1050. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  1051. * @returns the internal step
  1052. */
  1053. getInternalStep(): number;
  1054. private _fogEnabled;
  1055. /**
  1056. * Gets or sets a boolean indicating if fog is enabled on this scene
  1057. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1058. */
  1059. fogEnabled: boolean;
  1060. private _fogMode;
  1061. /**
  1062. * Gets or sets the fog mode to use
  1063. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1064. */
  1065. fogMode: number;
  1066. /**
  1067. * Gets or sets the fog color to use
  1068. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1069. */
  1070. fogColor: Color3;
  1071. /**
  1072. * Gets or sets the fog density to use
  1073. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1074. */
  1075. fogDensity: number;
  1076. /**
  1077. * Gets or sets the fog start distance to use
  1078. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1079. */
  1080. fogStart: number;
  1081. /**
  1082. * Gets or sets the fog end distance to use
  1083. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1084. */
  1085. fogEnd: number;
  1086. private _shadowsEnabled;
  1087. /**
  1088. * Gets or sets a boolean indicating if shadows are enabled on this scene
  1089. */
  1090. shadowsEnabled: boolean;
  1091. private _lightsEnabled;
  1092. /**
  1093. * Gets or sets a boolean indicating if lights are enabled on this scene
  1094. */
  1095. lightsEnabled: boolean;
  1096. /**
  1097. * All of the lights added to this scene
  1098. * @see http://doc.babylonjs.com/babylon101/lights
  1099. */
  1100. lights: Light[];
  1101. /** All of the cameras added to this scene.
  1102. * @see http://doc.babylonjs.com/babylon101/cameras
  1103. */
  1104. cameras: Camera[];
  1105. /** All of the active cameras added to this scene. */
  1106. activeCameras: Camera[];
  1107. /** The current active camera */
  1108. activeCamera: Nullable<Camera>;
  1109. /**
  1110. * All of the tranform nodes added to this scene
  1111. * @see http://doc.babylonjs.com/how_to/transformnode
  1112. */
  1113. transformNodes: TransformNode[];
  1114. /**
  1115. * All of the (abstract) meshes added to this scene
  1116. */
  1117. meshes: AbstractMesh[];
  1118. /**
  1119. * All of the animation groups added to this scene
  1120. * @see http://doc.babylonjs.com/how_to/group
  1121. */
  1122. animationGroups: AnimationGroup[];
  1123. private _geometries;
  1124. /**
  1125. * All of the materials added to this scene
  1126. * @see http://doc.babylonjs.com/babylon101/materials
  1127. */
  1128. materials: Material[];
  1129. /**
  1130. * All of the multi-materials added to this scene
  1131. * @see http://doc.babylonjs.com/how_to/multi_materials
  1132. */
  1133. multiMaterials: MultiMaterial[];
  1134. private _defaultMaterial;
  1135. /** The default material used on meshes when no material is affected */
  1136. /** The default material used on meshes when no material is affected */
  1137. defaultMaterial: Material;
  1138. private _texturesEnabled;
  1139. /**
  1140. * Gets or sets a boolean indicating if textures are enabled on this scene
  1141. */
  1142. texturesEnabled: boolean;
  1143. /**
  1144. * All of the textures added to this scene
  1145. */
  1146. textures: BaseTexture[];
  1147. /**
  1148. * Gets or sets a boolean indicating if particles are enabled on this scene
  1149. */
  1150. particlesEnabled: boolean;
  1151. /**
  1152. * All of the particle systems added to this scene
  1153. * @see http://doc.babylonjs.com/babylon101/particles
  1154. */
  1155. particleSystems: IParticleSystem[];
  1156. /**
  1157. * Gets or sets a boolean indicating if sprites are enabled on this scene
  1158. */
  1159. spritesEnabled: boolean;
  1160. /**
  1161. * All of the sprite managers added to this scene
  1162. * @see http://doc.babylonjs.com/babylon101/sprites
  1163. */
  1164. spriteManagers: SpriteManager[];
  1165. /**
  1166. * The list of layers (background and foreground) of the scene
  1167. */
  1168. layers: Layer[];
  1169. /**
  1170. * The list of effect layers (highlights/glow) added to the scene
  1171. * @see http://doc.babylonjs.com/how_to/highlight_layer
  1172. * @see http://doc.babylonjs.com/how_to/glow_layer
  1173. */
  1174. effectLayers: EffectLayer[];
  1175. private _skeletonsEnabled;
  1176. /**
  1177. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  1178. */
  1179. skeletonsEnabled: boolean;
  1180. /**
  1181. * The list of skeletons added to the scene
  1182. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  1183. */
  1184. skeletons: Skeleton[];
  1185. /**
  1186. * The list of morph target managers added to the scene
  1187. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  1188. */
  1189. morphTargetManagers: MorphTargetManager[];
  1190. /**
  1191. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  1192. */
  1193. lensFlaresEnabled: boolean;
  1194. /**
  1195. * The list of lens flare system added to the scene
  1196. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  1197. */
  1198. lensFlareSystems: LensFlareSystem[];
  1199. /**
  1200. * Gets or sets a boolean indicating if collisions are enabled on this scene
  1201. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  1202. */
  1203. collisionsEnabled: boolean;
  1204. private _workerCollisions;
  1205. /** @hidden */
  1206. collisionCoordinator: ICollisionCoordinator;
  1207. /**
  1208. * Defines the gravity applied to this scene (used only for collisions)
  1209. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  1210. */
  1211. gravity: Vector3;
  1212. /**
  1213. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  1214. */
  1215. postProcessesEnabled: boolean;
  1216. /**
  1217. * The list of postprocesses added to the scene
  1218. */
  1219. postProcesses: PostProcess[];
  1220. /**
  1221. * Gets the current postprocess manager
  1222. */
  1223. postProcessManager: PostProcessManager;
  1224. private _postProcessRenderPipelineManager;
  1225. /**
  1226. * Gets the postprocess render pipeline manager
  1227. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  1228. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  1229. */
  1230. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  1231. /**
  1232. * Gets or sets a boolean indicating if render targets are enabled on this scene
  1233. */
  1234. renderTargetsEnabled: boolean;
  1235. /**
  1236. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  1237. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  1238. */
  1239. dumpNextRenderTargets: boolean;
  1240. /**
  1241. * The list of user defined render targets added to the scene
  1242. */
  1243. customRenderTargets: RenderTargetTexture[];
  1244. /**
  1245. * Defines if texture loading must be delayed
  1246. * If true, textures will only be loaded when they need to be rendered
  1247. */
  1248. useDelayedTextureLoading: boolean;
  1249. /**
  1250. * Gets the list of meshes imported to the scene through SceneLoader
  1251. */
  1252. importedMeshesFiles: String[];
  1253. /**
  1254. * Gets or sets a boolean indicating if probes are enabled on this scene
  1255. */
  1256. probesEnabled: boolean;
  1257. /**
  1258. * The list of reflection probes added to the scene
  1259. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  1260. */
  1261. reflectionProbes: ReflectionProbe[];
  1262. /**
  1263. * @hidden
  1264. */
  1265. database: Database;
  1266. /**
  1267. * Gets or sets the action manager associated with the scene
  1268. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1269. */
  1270. actionManager: ActionManager;
  1271. /** @hidden */
  1272. private _meshesForIntersections;
  1273. /**
  1274. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  1275. */
  1276. proceduralTexturesEnabled: boolean;
  1277. /**
  1278. * The list of procedural textures added to the scene
  1279. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  1280. */
  1281. proceduralTextures: ProceduralTexture[];
  1282. private _mainSoundTrack;
  1283. /**
  1284. * The list of sound tracks added to the scene
  1285. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  1286. */
  1287. soundTracks: SoundTrack[];
  1288. private _audioEnabled;
  1289. private _headphone;
  1290. /**
  1291. * Gets the main soundtrack associated with the scene
  1292. */
  1293. readonly mainSoundTrack: SoundTrack;
  1294. /**
  1295. * Gets or sets the VRExperienceHelper attached to the scene
  1296. * @see http://doc.babylonjs.com/how_to/webvr_helper
  1297. * @ignorenaming
  1298. */
  1299. VRHelper: VRExperienceHelper;
  1300. /**
  1301. * Gets or sets the simplification queue attached to the scene
  1302. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  1303. */
  1304. simplificationQueue: SimplificationQueue;
  1305. private _engine;
  1306. private _totalVertices;
  1307. /** @hidden */
  1308. /** @hidden */
  1309. /** @hidden */
  1310. private _animationRatio;
  1311. private _animationTimeLast;
  1312. private _animationTime;
  1313. /**
  1314. * Gets or sets a general scale for animation speed
  1315. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  1316. */
  1317. animationTimeScale: number;
  1318. /** @hidden */
  1319. /** @hidden */
  1320. /** @hidden */
  1321. private _renderId;
  1322. private _executeWhenReadyTimeoutId;
  1323. private _intermediateRendering;
  1324. private _viewUpdateFlag;
  1325. private _projectionUpdateFlag;
  1326. private _alternateViewUpdateFlag;
  1327. private _alternateProjectionUpdateFlag;
  1328. /** @hidden */
  1329. private _activeRequests;
  1330. private _pendingData;
  1331. private _isDisposed;
  1332. /**
  1333. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  1334. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  1335. */
  1336. dispatchAllSubMeshesOfActiveMeshes: boolean;
  1337. private _activeMeshes;
  1338. private _processedMaterials;
  1339. private _renderTargets;
  1340. /** @hidden */
  1341. private _activeSkeletons;
  1342. private _softwareSkinnedMeshes;
  1343. private _renderingManager;
  1344. private _physicsEngine;
  1345. /** @hidden */
  1346. private _transformMatrix;
  1347. private _sceneUbo;
  1348. private _alternateSceneUbo;
  1349. private _pickWithRayInverseMatrix;
  1350. private _boundingBoxRenderer;
  1351. private _outlineRenderer;
  1352. private _viewMatrix;
  1353. private _projectionMatrix;
  1354. private _alternateViewMatrix;
  1355. private _alternateProjectionMatrix;
  1356. private _alternateTransformMatrix;
  1357. private _useAlternateCameraConfiguration;
  1358. private _alternateRendering;
  1359. /** @hidden */
  1360. /** @hidden */
  1361. protected readonly _isAlternateRenderingEnabled: boolean;
  1362. private _frustumPlanes;
  1363. /**
  1364. * Gets the list of frustum planes (built from the active camera)
  1365. */
  1366. readonly frustumPlanes: Plane[];
  1367. /**
  1368. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  1369. * This is useful if there are more lights that the maximum simulteanous authorized
  1370. */
  1371. requireLightSorting: boolean;
  1372. private _selectionOctree;
  1373. private _pointerOverMesh;
  1374. private _pointerOverSprite;
  1375. private _debugLayer;
  1376. private _depthRenderer;
  1377. private _geometryBufferRenderer;
  1378. /**
  1379. * Gets the current geometry buffer associated to the scene.
  1380. */
  1381. /**
  1382. * Sets the current geometry buffer for the scene.
  1383. */
  1384. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  1385. private _pickedDownMesh;
  1386. private _pickedUpMesh;
  1387. private _pickedDownSprite;
  1388. private _externalData;
  1389. private _uid;
  1390. /**
  1391. * Creates a new Scene
  1392. * @param engine defines the engine to use to render this scene
  1393. */
  1394. constructor(engine: Engine);
  1395. /**
  1396. * Gets the debug layer (aka Inspector) associated with the scene
  1397. * @see http://doc.babylonjs.com/features/playground_debuglayer
  1398. */
  1399. readonly debugLayer: DebugLayer;
  1400. /**
  1401. * Gets a boolean indicating if collisions are processed on a web worker
  1402. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#web-worker-based-collision-system-since-21
  1403. */
  1404. workerCollisions: boolean;
  1405. /**
  1406. * Gets the octree used to boost mesh selection (picking)
  1407. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  1408. */
  1409. readonly selectionOctree: Octree<AbstractMesh>;
  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 bounding box renderer associated with the scene
  1447. * @returns a BoundingBoxRenderer
  1448. */
  1449. getBoundingBoxRenderer(): BoundingBoxRenderer;
  1450. /**
  1451. * Gets the outline renderer associated with the scene
  1452. * @returns a OutlineRenderer
  1453. */
  1454. getOutlineRenderer(): OutlineRenderer;
  1455. /**
  1456. * Gets the engine associated with the scene
  1457. * @returns an Engine
  1458. */
  1459. getEngine(): Engine;
  1460. /**
  1461. * Gets the total number of vertices rendered per frame
  1462. * @returns the total number of vertices rendered per frame
  1463. */
  1464. getTotalVertices(): number;
  1465. /**
  1466. * Gets the performance counter for total vertices
  1467. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1468. */
  1469. readonly totalVerticesPerfCounter: PerfCounter;
  1470. /**
  1471. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  1472. * @returns the total number of active indices rendered per frame
  1473. */
  1474. getActiveIndices(): number;
  1475. /**
  1476. * Gets the performance counter for active indices
  1477. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1478. */
  1479. readonly totalActiveIndicesPerfCounter: PerfCounter;
  1480. /**
  1481. * Gets the total number of active particles rendered per frame
  1482. * @returns the total number of active particles rendered per frame
  1483. */
  1484. getActiveParticles(): number;
  1485. /**
  1486. * Gets the performance counter for active particles
  1487. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1488. */
  1489. readonly activeParticlesPerfCounter: PerfCounter;
  1490. /**
  1491. * Gets the total number of active bones rendered per frame
  1492. * @returns the total number of active bones rendered per frame
  1493. */
  1494. getActiveBones(): number;
  1495. /**
  1496. * Gets the performance counter for active bones
  1497. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1498. */
  1499. readonly activeBonesPerfCounter: PerfCounter;
  1500. /** @hidden */
  1501. getInterFramePerfCounter(): number;
  1502. /** @hidden */
  1503. readonly interFramePerfCounter: Nullable<PerfCounter>;
  1504. /** @hidden */
  1505. getLastFrameDuration(): number;
  1506. /** @hidden */
  1507. readonly lastFramePerfCounter: Nullable<PerfCounter>;
  1508. /** @hidden */
  1509. getEvaluateActiveMeshesDuration(): number;
  1510. /** @hidden */
  1511. readonly evaluateActiveMeshesDurationPerfCounter: Nullable<PerfCounter>;
  1512. /**
  1513. * Gets the array of active meshes
  1514. * @returns an array of AbstractMesh
  1515. */
  1516. getActiveMeshes(): SmartArray<AbstractMesh>;
  1517. /** @hidden */
  1518. getRenderTargetsDuration(): number;
  1519. /** @hidden */
  1520. getRenderDuration(): number;
  1521. /** @hidden */
  1522. readonly renderDurationPerfCounter: Nullable<PerfCounter>;
  1523. /** @hidden */
  1524. getParticlesDuration(): number;
  1525. /** @hidden */
  1526. readonly particlesDurationPerfCounter: Nullable<PerfCounter>;
  1527. /** @hidden */
  1528. getSpritesDuration(): number;
  1529. /** @hidden */
  1530. readonly spriteDuractionPerfCounter: Nullable<PerfCounter>;
  1531. /**
  1532. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  1533. * @returns a number
  1534. */
  1535. getAnimationRatio(): number;
  1536. /**
  1537. * Gets an unique Id for the current frame
  1538. * @returns a number
  1539. */
  1540. getRenderId(): number;
  1541. /** Call this function if you want to manually increment the render Id*/
  1542. incrementRenderId(): void;
  1543. private _updatePointerPosition(evt);
  1544. private _createUbo();
  1545. private _createAlternateUbo();
  1546. private _pickSpriteButKeepRay(originalPointerInfo, x, y, predicate?, fastCheck?, camera?);
  1547. private _setRayOnPointerInfo(pointerInfo);
  1548. /**
  1549. * Use this method to simulate a pointer move on a mesh
  1550. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1551. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  1552. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  1553. * @returns the current scene
  1554. */
  1555. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  1556. private _processPointerMove(pickResult, evt);
  1557. private _checkPrePointerObservable(pickResult, evt, type);
  1558. /**
  1559. * Use this method to simulate a pointer down on a mesh
  1560. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1561. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  1562. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  1563. * @returns the current scene
  1564. */
  1565. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  1566. private _processPointerDown(pickResult, evt);
  1567. /**
  1568. * Use this method to simulate a pointer up on a mesh
  1569. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1570. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  1571. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  1572. * @returns the current scene
  1573. */
  1574. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  1575. private _processPointerUp(pickResult, evt, clickInfo);
  1576. /**
  1577. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  1578. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  1579. * @returns true if the pointer was captured
  1580. */
  1581. isPointerCaptured(pointerId?: number): boolean;
  1582. /**
  1583. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  1584. * @param attachUp defines if you want to attach events to pointerup
  1585. * @param attachDown defines if you want to attach events to pointerdown
  1586. * @param attachMove defines if you want to attach events to pointermove
  1587. */
  1588. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  1589. /** Detaches all event handlers*/
  1590. detachControl(): void;
  1591. /**
  1592. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  1593. * Delay loaded resources are not taking in account
  1594. * @return true if all required resources are ready
  1595. */
  1596. isReady(): boolean;
  1597. /** Resets all cached information relative to material (including effect and visibility) */
  1598. resetCachedMaterial(): void;
  1599. /**
  1600. * Registers a function to be called before every frame render
  1601. * @param func defines the function to register
  1602. */
  1603. registerBeforeRender(func: () => void): void;
  1604. /**
  1605. * Unregisters a function called before every frame render
  1606. * @param func defines the function to unregister
  1607. */
  1608. unregisterBeforeRender(func: () => void): void;
  1609. /**
  1610. * Registers a function to be called after every frame render
  1611. * @param func defines the function to register
  1612. */
  1613. registerAfterRender(func: () => void): void;
  1614. /**
  1615. * Unregisters a function called after every frame render
  1616. * @param func defines the function to unregister
  1617. */
  1618. unregisterAfterRender(func: () => void): void;
  1619. private _executeOnceBeforeRender(func);
  1620. /**
  1621. * The provided function will run before render once and will be disposed afterwards.
  1622. * A timeout delay can be provided so that the function will be executed in N ms.
  1623. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  1624. * @param func The function to be executed.
  1625. * @param timeout optional delay in ms
  1626. */
  1627. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  1628. /** @hidden */
  1629. /** @hidden */
  1630. /**
  1631. * Returns the number of items waiting to be loaded
  1632. * @returns the number of items waiting to be loaded
  1633. */
  1634. getWaitingItemsCount(): number;
  1635. /**
  1636. * Returns a boolean indicating if the scene is still loading data
  1637. */
  1638. readonly isLoading: boolean;
  1639. /**
  1640. * Registers a function to be executed when the scene is ready
  1641. * @param {Function} func - the function to be executed
  1642. */
  1643. executeWhenReady(func: () => void): void;
  1644. /**
  1645. * Returns a promise that resolves when the scene is ready
  1646. * @returns A promise that resolves when the scene is ready
  1647. */
  1648. whenReadyAsync(): Promise<void>;
  1649. /** @hidden */
  1650. /**
  1651. * Will start the animation sequence of a given target
  1652. * @param target defines the target
  1653. * @param from defines from which frame should animation start
  1654. * @param to defines until which frame should animation run.
  1655. * @param weight defines the weight to apply to the animation (1.0 by default)
  1656. * @param loop defines if the animation loops
  1657. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  1658. * @param onAnimationEnd defines the function to be executed when the animation ends
  1659. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  1660. * @returns the animatable object created for this animation
  1661. */
  1662. beginWeightedAnimation(target: any, from: number, to: number, weight?: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable): Animatable;
  1663. /**
  1664. * Will start the animation sequence of a given target
  1665. * @param target defines the target
  1666. * @param from defines from which frame should animation start
  1667. * @param to defines until which frame should animation run.
  1668. * @param loop defines if the animation loops
  1669. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  1670. * @param onAnimationEnd defines the function to be executed when the animation ends
  1671. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  1672. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  1673. * @returns the animatable object created for this animation
  1674. */
  1675. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean): Animatable;
  1676. /**
  1677. * Begin a new animation on a given node
  1678. * @param target defines the target where the animation will take place
  1679. * @param animations defines the list of animations to start
  1680. * @param from defines the initial value
  1681. * @param to defines the final value
  1682. * @param loop defines if you want animation to loop (off by default)
  1683. * @param speedRatio defines the speed ratio to apply to all animations
  1684. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  1685. * @returns the list of created animatables
  1686. */
  1687. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Animatable;
  1688. /**
  1689. * Begin a new animation on a given node and its hierarchy
  1690. * @param target defines the root node where the animation will take place
  1691. * @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.
  1692. * @param animations defines the list of animations to start
  1693. * @param from defines the initial value
  1694. * @param to defines the final value
  1695. * @param loop defines if you want animation to loop (off by default)
  1696. * @param speedRatio defines the speed ratio to apply to all animations
  1697. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  1698. * @returns the list of animatables created for all nodes
  1699. */
  1700. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Animatable[];
  1701. /**
  1702. * Gets the animatable associated with a specific target
  1703. * @param target defines the target of the animatable
  1704. * @returns the required animatable if found
  1705. */
  1706. getAnimatableByTarget(target: any): Nullable<Animatable>;
  1707. /**
  1708. * Gets all animatables associated with a given target
  1709. * @param target defines the target to look animatables for
  1710. * @returns an array of Animatables
  1711. */
  1712. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  1713. /**
  1714. * Gets all animatable attached to the scene
  1715. */
  1716. readonly animatables: Animatable[];
  1717. /**
  1718. * Will stop the animation of the given target
  1719. * @param target - the target
  1720. * @param animationName - the name of the animation to stop (all animations will be stopped if empty)
  1721. */
  1722. stopAnimation(target: any, animationName?: string): void;
  1723. /**
  1724. * Stops and removes all animations that have been applied to the scene
  1725. */
  1726. stopAllAnimations(): void;
  1727. private _animate();
  1728. /** @hidden */
  1729. private _processLateAnimationBindingsForMatrices(holder);
  1730. private _processLateAnimationBindingsForQuaternions(holder);
  1731. private _processLateAnimationBindings();
  1732. /** @hidden */
  1733. /**
  1734. * Gets the current view matrix
  1735. * @returns a Matrix
  1736. */
  1737. getViewMatrix(): Matrix;
  1738. /**
  1739. * Gets the current projection matrix
  1740. * @returns a Matrix
  1741. */
  1742. getProjectionMatrix(): Matrix;
  1743. /**
  1744. * Gets the current transform matrix
  1745. * @returns a Matrix made of View * Projection
  1746. */
  1747. getTransformMatrix(): Matrix;
  1748. /**
  1749. * Sets the current transform matrix
  1750. * @param view defines the View matrix to use
  1751. * @param projection defines the Projection matrix to use
  1752. */
  1753. setTransformMatrix(view: Matrix, projection: Matrix): void;
  1754. /** @hidden */
  1755. /**
  1756. * Gets the uniform buffer used to store scene data
  1757. * @returns a UniformBuffer
  1758. */
  1759. getSceneUniformBuffer(): UniformBuffer;
  1760. /**
  1761. * Gets an unique (relatively to the current scene) Id
  1762. * @returns an unique number for the scene
  1763. */
  1764. getUniqueId(): number;
  1765. /**
  1766. * Add a mesh to the list of scene's meshes
  1767. * @param newMesh defines the mesh to add
  1768. * @param recursive if all child meshes should also be added to the scene
  1769. */
  1770. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  1771. /**
  1772. * Remove a mesh for the list of scene's meshes
  1773. * @param toRemove defines the mesh to remove
  1774. * @param recursive if all child meshes should also be removed from the scene
  1775. * @returns the index where the mesh was in the mesh list
  1776. */
  1777. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  1778. /**
  1779. * Add a transform node to the list of scene's transform nodes
  1780. * @param newTransformNode defines the transform node to add
  1781. */
  1782. addTransformNode(newTransformNode: TransformNode): void;
  1783. /**
  1784. * Remove a transform node for the list of scene's transform nodes
  1785. * @param toRemove defines the transform node to remove
  1786. * @returns the index where the transform node was in the transform node list
  1787. */
  1788. removeTransformNode(toRemove: TransformNode): number;
  1789. /**
  1790. * Remove a skeleton for the list of scene's skeletons
  1791. * @param toRemove defines the skeleton to remove
  1792. * @returns the index where the skeleton was in the skeleton list
  1793. */
  1794. removeSkeleton(toRemove: Skeleton): number;
  1795. /**
  1796. * Remove a morph target for the list of scene's morph targets
  1797. * @param toRemove defines the morph target to remove
  1798. * @returns the index where the morph target was in the morph target list
  1799. */
  1800. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  1801. /**
  1802. * Remove a light for the list of scene's lights
  1803. * @param toRemove defines the light to remove
  1804. * @returns the index where the light was in the light list
  1805. */
  1806. removeLight(toRemove: Light): number;
  1807. /**
  1808. * Remove a camera for the list of scene's cameras
  1809. * @param toRemove defines the camera to remove
  1810. * @returns the index where the camera was in the camera list
  1811. */
  1812. removeCamera(toRemove: Camera): number;
  1813. /**
  1814. * Remove a particle system for the list of scene's particle systems
  1815. * @param toRemove defines the particle system to remove
  1816. * @returns the index where the particle system was in the particle system list
  1817. */
  1818. removeParticleSystem(toRemove: IParticleSystem): number;
  1819. /**
  1820. * Remove a animation for the list of scene's animations
  1821. * @param toRemove defines the animation to remove
  1822. * @returns the index where the animation was in the animation list
  1823. */
  1824. removeAnimation(toRemove: Animation): number;
  1825. /**
  1826. * Removes the given animation group from this scene.
  1827. * @param toRemove The animation group to remove
  1828. * @returns The index of the removed animation group
  1829. */
  1830. removeAnimationGroup(toRemove: AnimationGroup): number;
  1831. /**
  1832. * Removes the given multi-material from this scene.
  1833. * @param toRemove The multi-material to remove
  1834. * @returns The index of the removed multi-material
  1835. */
  1836. removeMultiMaterial(toRemove: MultiMaterial): number;
  1837. /**
  1838. * Removes the given material from this scene.
  1839. * @param toRemove The material to remove
  1840. * @returns The index of the removed material
  1841. */
  1842. removeMaterial(toRemove: Material): number;
  1843. /**
  1844. * Removes the given lens flare system from this scene.
  1845. * @param toRemove The lens flare system to remove
  1846. * @returns The index of the removed lens flare system
  1847. */
  1848. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  1849. /**
  1850. * Removes the given action manager from this scene.
  1851. * @param toRemove The action manager to remove
  1852. * @returns The index of the removed action manager
  1853. */
  1854. removeActionManager(toRemove: ActionManager): number;
  1855. /**
  1856. * Removes the given effect layer from this scene.
  1857. * @param toRemove defines the effect layer to remove
  1858. * @returns the index of the removed effect layer
  1859. */
  1860. removeEffectLayer(toRemove: EffectLayer): number;
  1861. /**
  1862. * Removes the given texture from this scene.
  1863. * @param toRemove The texture to remove
  1864. * @returns The index of the removed texture
  1865. */
  1866. removeTexture(toRemove: BaseTexture): number;
  1867. /**
  1868. * Adds the given light to this scene
  1869. * @param newLight The light to add
  1870. */
  1871. addLight(newLight: Light): void;
  1872. /**
  1873. * Sorts the list list based on light priorities
  1874. */
  1875. sortLightsByPriority(): void;
  1876. /**
  1877. * Adds the given camera to this scene
  1878. * @param newCamera The camera to add
  1879. */
  1880. addCamera(newCamera: Camera): void;
  1881. /**
  1882. * Adds the given skeleton to this scene
  1883. * @param newSkeleton The skeleton to add
  1884. */
  1885. addSkeleton(newSkeleton: Skeleton): void;
  1886. /**
  1887. * Adds the given particle system to this scene
  1888. * @param newParticleSystem The particle system to add
  1889. */
  1890. addParticleSystem(newParticleSystem: IParticleSystem): void;
  1891. /**
  1892. * Adds the given animation to this scene
  1893. * @param newAnimation The animation to add
  1894. */
  1895. addAnimation(newAnimation: Animation): void;
  1896. /**
  1897. * Adds the given animation group to this scene.
  1898. * @param newAnimationGroup The animation group to add
  1899. */
  1900. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  1901. /**
  1902. * Adds the given multi-material to this scene
  1903. * @param newMultiMaterial The multi-material to add
  1904. */
  1905. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  1906. /**
  1907. * Adds the given material to this scene
  1908. * @param newMaterial The material to add
  1909. */
  1910. addMaterial(newMaterial: Material): void;
  1911. /**
  1912. * Adds the given morph target to this scene
  1913. * @param newMorphTargetManager The morph target to add
  1914. */
  1915. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  1916. /**
  1917. * Adds the given geometry to this scene
  1918. * @param newGeometry The geometry to add
  1919. */
  1920. addGeometry(newGeometry: Geometry): void;
  1921. /**
  1922. * Adds the given lens flare system to this scene
  1923. * @param newLensFlareSystem The lens flare system to add
  1924. */
  1925. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  1926. /**
  1927. * Adds the given effect layer to this scene
  1928. * @param newEffectLayer defines the effect layer to add
  1929. */
  1930. addEffectLayer(newEffectLayer: EffectLayer): void;
  1931. /**
  1932. * Adds the given action manager to this scene
  1933. * @param newActionManager The action manager to add
  1934. */
  1935. addActionManager(newActionManager: ActionManager): void;
  1936. /**
  1937. * Adds the given texture to this scene.
  1938. * @param newTexture The texture to add
  1939. */
  1940. addTexture(newTexture: BaseTexture): void;
  1941. /**
  1942. * Switch active camera
  1943. * @param newCamera defines the new active camera
  1944. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  1945. */
  1946. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  1947. /**
  1948. * sets the active camera of the scene using its ID
  1949. * @param id defines the camera's ID
  1950. * @return the new active camera or null if none found.
  1951. */
  1952. setActiveCameraByID(id: string): Nullable<Camera>;
  1953. /**
  1954. * sets the active camera of the scene using its name
  1955. * @param name defines the camera's name
  1956. * @returns the new active camera or null if none found.
  1957. */
  1958. setActiveCameraByName(name: string): Nullable<Camera>;
  1959. /**
  1960. * get an animation group using its name
  1961. * @param name defines the material's name
  1962. * @return the animation group or null if none found.
  1963. */
  1964. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  1965. /**
  1966. * get a material using its id
  1967. * @param id defines the material's ID
  1968. * @return the material or null if none found.
  1969. */
  1970. getMaterialByID(id: string): Nullable<Material>;
  1971. /**
  1972. * Gets a material using its name
  1973. * @param name defines the material's name
  1974. * @return the material or null if none found.
  1975. */
  1976. getMaterialByName(name: string): Nullable<Material>;
  1977. /**
  1978. * Gets a lens flare system using its name
  1979. * @param name defines the name to look for
  1980. * @returns the lens flare system or null if not found
  1981. */
  1982. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  1983. /**
  1984. * Gets a lens flare system using its id
  1985. * @param id defines the id to look for
  1986. * @returns the lens flare system or null if not found
  1987. */
  1988. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  1989. /**
  1990. * Gets a camera using its id
  1991. * @param id defines the id to look for
  1992. * @returns the camera or null if not found
  1993. */
  1994. getCameraByID(id: string): Nullable<Camera>;
  1995. /**
  1996. * Gets a camera using its unique id
  1997. * @param uniqueId defines the unique id to look for
  1998. * @returns the camera or null if not found
  1999. */
  2000. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  2001. /**
  2002. * Gets a camera using its name
  2003. * @param name defines the camera's name
  2004. * @return the camera or null if none found.
  2005. */
  2006. getCameraByName(name: string): Nullable<Camera>;
  2007. /**
  2008. * Gets a bone using its id
  2009. * @param id defines the bone's id
  2010. * @return the bone or null if not found
  2011. */
  2012. getBoneByID(id: string): Nullable<Bone>;
  2013. /**
  2014. * Gets a bone using its id
  2015. * @param name defines the bone's name
  2016. * @return the bone or null if not found
  2017. */
  2018. getBoneByName(name: string): Nullable<Bone>;
  2019. /**
  2020. * Gets a light node using its name
  2021. * @param name defines the the light's name
  2022. * @return the light or null if none found.
  2023. */
  2024. getLightByName(name: string): Nullable<Light>;
  2025. /**
  2026. * Gets a light node using its id
  2027. * @param id defines the light's id
  2028. * @return the light or null if none found.
  2029. */
  2030. getLightByID(id: string): Nullable<Light>;
  2031. /**
  2032. * Gets a light node using its scene-generated unique ID
  2033. * @param uniqueId defines the light's unique id
  2034. * @return the light or null if none found.
  2035. */
  2036. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  2037. /**
  2038. * Gets a particle system by id
  2039. * @param id defines the particle system id
  2040. * @return the corresponding system or null if none found
  2041. */
  2042. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  2043. /**
  2044. * Gets a geometry using its ID
  2045. * @param id defines the geometry's id
  2046. * @return the geometry or null if none found.
  2047. */
  2048. getGeometryByID(id: string): Nullable<Geometry>;
  2049. /**
  2050. * Add a new geometry to this scene
  2051. * @param geometry defines the geometry to be added to the scene.
  2052. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  2053. * @return a boolean defining if the geometry was added or not
  2054. */
  2055. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  2056. /**
  2057. * Removes an existing geometry
  2058. * @param geometry defines the geometry to be removed from the scene
  2059. * @return a boolean defining if the geometry was removed or not
  2060. */
  2061. removeGeometry(geometry: Geometry): boolean;
  2062. /**
  2063. * Gets the list of geometries attached to the scene
  2064. * @returns an array of Geometry
  2065. */
  2066. getGeometries(): Geometry[];
  2067. /**
  2068. * Gets the first added mesh found of a given ID
  2069. * @param id defines the id to search for
  2070. * @return the mesh found or null if not found at all
  2071. */
  2072. getMeshByID(id: string): Nullable<AbstractMesh>;
  2073. /**
  2074. * Gets a list of meshes using their id
  2075. * @param id defines the id to search for
  2076. * @returns a list of meshes
  2077. */
  2078. getMeshesByID(id: string): Array<AbstractMesh>;
  2079. /**
  2080. * Gets the first added transform node found of a given ID
  2081. * @param id defines the id to search for
  2082. * @return the found transform node or null if not found at all.
  2083. */
  2084. getTransformNodeByID(id: string): Nullable<TransformNode>;
  2085. /**
  2086. * Gets a list of transform nodes using their id
  2087. * @param id defines the id to search for
  2088. * @returns a list of transform nodes
  2089. */
  2090. getTransformNodesByID(id: string): Array<TransformNode>;
  2091. /**
  2092. * Gets a mesh with its auto-generated unique id
  2093. * @param uniqueId defines the unique id to search for
  2094. * @return the found mesh or null if not found at all.
  2095. */
  2096. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  2097. /**
  2098. * Gets a the last added mesh using a given id
  2099. * @param id defines the id to search for
  2100. * @return the found mesh or null if not found at all.
  2101. */
  2102. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  2103. /**
  2104. * Gets a the last added node (Mesh, Camera, Light) using a given id
  2105. * @param id defines the id to search for
  2106. * @return the found node or null if not found at all
  2107. */
  2108. getLastEntryByID(id: string): Nullable<Node>;
  2109. /**
  2110. * Gets a node (Mesh, Camera, Light) using a given id
  2111. * @param id defines the id to search for
  2112. * @return the found node or null if not found at all
  2113. */
  2114. getNodeByID(id: string): Nullable<Node>;
  2115. /**
  2116. * Gets a node (Mesh, Camera, Light) using a given name
  2117. * @param name defines the name to search for
  2118. * @return the found node or null if not found at all.
  2119. */
  2120. getNodeByName(name: string): Nullable<Node>;
  2121. /**
  2122. * Gets a mesh using a given name
  2123. * @param name defines the name to search for
  2124. * @return the found mesh or null if not found at all.
  2125. */
  2126. getMeshByName(name: string): Nullable<AbstractMesh>;
  2127. /**
  2128. * Gets a transform node using a given name
  2129. * @param name defines the name to search for
  2130. * @return the found transform node or null if not found at all.
  2131. */
  2132. getTransformNodeByName(name: string): Nullable<TransformNode>;
  2133. /**
  2134. * Gets a sound using a given name
  2135. * @param name defines the name to search for
  2136. * @return the found sound or null if not found at all.
  2137. */
  2138. getSoundByName(name: string): Nullable<Sound>;
  2139. /**
  2140. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  2141. * @param id defines the id to search for
  2142. * @return the found skeleton or null if not found at all.
  2143. */
  2144. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  2145. /**
  2146. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  2147. * @param id defines the id to search for
  2148. * @return the found skeleton or null if not found at all.
  2149. */
  2150. getSkeletonById(id: string): Nullable<Skeleton>;
  2151. /**
  2152. * Gets a skeleton using a given name
  2153. * @param name defines the name to search for
  2154. * @return the found skeleton or null if not found at all.
  2155. */
  2156. getSkeletonByName(name: string): Nullable<Skeleton>;
  2157. /**
  2158. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  2159. * @param id defines the id to search for
  2160. * @return the found morph target manager or null if not found at all.
  2161. */
  2162. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  2163. /**
  2164. * Gets a boolean indicating if the given mesh is active
  2165. * @param mesh defines the mesh to look for
  2166. * @returns true if the mesh is in the active list
  2167. */
  2168. isActiveMesh(mesh: AbstractMesh): boolean;
  2169. /**
  2170. * Return a the first highlight layer of the scene with a given name.
  2171. * @param name The name of the highlight layer to look for.
  2172. * @return The highlight layer if found otherwise null.
  2173. */
  2174. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  2175. /**
  2176. * Return a the first highlight layer of the scene with a given name.
  2177. * @param name The name of the highlight layer to look for.
  2178. * @return The highlight layer if found otherwise null.
  2179. */
  2180. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  2181. /**
  2182. * Return a unique id as a string which can serve as an identifier for the scene
  2183. */
  2184. readonly uid: string;
  2185. /**
  2186. * Add an externaly attached data from its key.
  2187. * This method call will fail and return false, if such key already exists.
  2188. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  2189. * @param key the unique key that identifies the data
  2190. * @param data the data object to associate to the key for this Engine instance
  2191. * @return true if no such key were already present and the data was added successfully, false otherwise
  2192. */
  2193. addExternalData<T>(key: string, data: T): boolean;
  2194. /**
  2195. * Get an externaly attached data from its key
  2196. * @param key the unique key that identifies the data
  2197. * @return the associated data, if present (can be null), or undefined if not present
  2198. */
  2199. getExternalData<T>(key: string): Nullable<T>;
  2200. /**
  2201. * Get an externaly attached data from its key, create it using a factory if it's not already present
  2202. * @param key the unique key that identifies the data
  2203. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  2204. * @return the associated data, can be null if the factory returned null.
  2205. */
  2206. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  2207. /**
  2208. * Remove an externaly attached data from the Engine instance
  2209. * @param key the unique key that identifies the data
  2210. * @return true if the data was successfully removed, false if it doesn't exist
  2211. */
  2212. removeExternalData(key: string): boolean;
  2213. private _evaluateSubMesh(subMesh, mesh);
  2214. /**
  2215. * Clear the processed materials smart array preventing retention point in material dispose.
  2216. */
  2217. freeProcessedMaterials(): void;
  2218. /**
  2219. * Clear the active meshes smart array preventing retention point in mesh dispose.
  2220. */
  2221. freeActiveMeshes(): void;
  2222. /**
  2223. * Clear the info related to rendering groups preventing retention points during dispose.
  2224. */
  2225. freeRenderingGroups(): void;
  2226. /** @hidden */
  2227. private _activeMeshCandidateProvider;
  2228. /**
  2229. * Defines the current active mesh candidate provider
  2230. * @param provider defines the provider to use
  2231. */
  2232. setActiveMeshCandidateProvider(provider: IActiveMeshCandidateProvider): void;
  2233. /**
  2234. * Gets the current active mesh candidate provider
  2235. * @returns the current active mesh candidate provider
  2236. */
  2237. getActiveMeshCandidateProvider(): IActiveMeshCandidateProvider;
  2238. private _activeMeshesFrozen;
  2239. /**
  2240. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  2241. * @returns the current scene
  2242. */
  2243. freezeActiveMeshes(): Scene;
  2244. /**
  2245. * Use this function to restart evaluating active meshes on every frame
  2246. * @returns the current scene
  2247. */
  2248. unfreezeActiveMeshes(): Scene;
  2249. private _evaluateActiveMeshes();
  2250. private _activeMesh(sourceMesh, mesh);
  2251. /**
  2252. * Update the transform matrix to update from the current active camera
  2253. * @param force defines a boolean used to force the update even if cache is up to date
  2254. */
  2255. updateTransformMatrix(force?: boolean): void;
  2256. /**
  2257. * 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)
  2258. * @param alternateCamera defines the camera to use
  2259. */
  2260. updateAlternateTransformMatrix(alternateCamera: Camera): void;
  2261. private _renderForCamera(camera, rigParent?);
  2262. private _processSubCameras(camera);
  2263. private _checkIntersections();
  2264. /**
  2265. * Render the scene
  2266. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  2267. */
  2268. render(updateCameras?: boolean): void;
  2269. private _updateAudioParameters();
  2270. /**
  2271. * Gets or sets if audio support is enabled
  2272. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  2273. */
  2274. audioEnabled: boolean;
  2275. private _disableAudio();
  2276. private _enableAudio();
  2277. /**
  2278. * Gets or sets if audio will be output to headphones
  2279. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  2280. */
  2281. headphone: boolean;
  2282. private _switchAudioModeForHeadphones();
  2283. private _switchAudioModeForNormalSpeakers();
  2284. /**
  2285. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  2286. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  2287. * @returns the created depth renderer
  2288. */
  2289. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  2290. /**
  2291. * Disables a depth renderer for a given camera
  2292. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  2293. */
  2294. disableDepthRenderer(camera?: Nullable<Camera>): void;
  2295. /**
  2296. * Enables a GeometryBufferRender and associates it with the scene
  2297. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  2298. * @returns the GeometryBufferRenderer
  2299. */
  2300. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  2301. /**
  2302. * Disables the GeometryBufferRender associated with the scene
  2303. */
  2304. disableGeometryBufferRenderer(): void;
  2305. /**
  2306. * Freeze all materials
  2307. * A frozen material will not be updatable but should be faster to render
  2308. */
  2309. freezeMaterials(): void;
  2310. /**
  2311. * Unfreeze all materials
  2312. * A frozen material will not be updatable but should be faster to render
  2313. */
  2314. unfreezeMaterials(): void;
  2315. /**
  2316. * Releases all held ressources
  2317. */
  2318. dispose(): void;
  2319. /**
  2320. * Gets if the scene is already disposed
  2321. */
  2322. readonly isDisposed: boolean;
  2323. /**
  2324. * Releases sounds & soundtracks
  2325. */
  2326. disposeSounds(): void;
  2327. /**
  2328. * Call this function to reduce memory footprint of the scene.
  2329. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  2330. */
  2331. clearCachedVertexData(): void;
  2332. /**
  2333. * This function will remove the local cached buffer data from texture.
  2334. * It will save memory but will prevent the texture from being rebuilt
  2335. */
  2336. cleanCachedTextureBuffer(): void;
  2337. /**
  2338. * Get the world extend vectors with an optional filter
  2339. *
  2340. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  2341. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  2342. */
  2343. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  2344. min: Vector3;
  2345. max: Vector3;
  2346. };
  2347. /**
  2348. * Creates or updates the octree used to boost selection (picking)
  2349. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  2350. * @param maxCapacity defines the maximum capacity per leaf
  2351. * @param maxDepth defines the maximum depth of the octree
  2352. * @returns an octree of AbstractMesh
  2353. */
  2354. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  2355. /**
  2356. * Creates a ray that can be used to pick in the scene
  2357. * @param x defines the x coordinate of the origin (on-screen)
  2358. * @param y defines the y coordinate of the origin (on-screen)
  2359. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  2360. * @param camera defines the camera to use for the picking
  2361. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  2362. * @returns a Ray
  2363. */
  2364. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  2365. /**
  2366. * Creates a ray that can be used to pick in the scene
  2367. * @param x defines the x coordinate of the origin (on-screen)
  2368. * @param y defines the y coordinate of the origin (on-screen)
  2369. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  2370. * @param result defines the ray where to store the picking ray
  2371. * @param camera defines the camera to use for the picking
  2372. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  2373. * @returns the current scene
  2374. */
  2375. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  2376. /**
  2377. * Creates a ray that can be used to pick in the scene
  2378. * @param x defines the x coordinate of the origin (on-screen)
  2379. * @param y defines the y coordinate of the origin (on-screen)
  2380. * @param camera defines the camera to use for the picking
  2381. * @returns a Ray
  2382. */
  2383. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  2384. /**
  2385. * Creates a ray that can be used to pick in the scene
  2386. * @param x defines the x coordinate of the origin (on-screen)
  2387. * @param y defines the y coordinate of the origin (on-screen)
  2388. * @param result defines the ray where to store the picking ray
  2389. * @param camera defines the camera to use for the picking
  2390. * @returns the current scene
  2391. */
  2392. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  2393. private _internalPick(rayFunction, predicate?, fastCheck?);
  2394. private _internalMultiPick(rayFunction, predicate?);
  2395. private _internalPickSprites(ray, predicate?, fastCheck?, camera?);
  2396. private _tempPickingRay;
  2397. /** Launch a ray to try to pick a mesh in the scene
  2398. * @param x position on screen
  2399. * @param y position on screen
  2400. * @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
  2401. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  2402. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  2403. * @returns a PickingInfo
  2404. */
  2405. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  2406. /** Launch a ray to try to pick a sprite in the scene
  2407. * @param x position on screen
  2408. * @param y position on screen
  2409. * @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
  2410. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  2411. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  2412. * @returns a PickingInfo
  2413. */
  2414. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  2415. private _cachedRayForTransform;
  2416. /** Use the given ray to pick a mesh in the scene
  2417. * @param ray The ray to use to pick meshes
  2418. * @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
  2419. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  2420. * @returns a PickingInfo
  2421. */
  2422. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  2423. /**
  2424. * Launch a ray to try to pick a mesh in the scene
  2425. * @param x X position on screen
  2426. * @param y Y position on screen
  2427. * @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
  2428. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  2429. * @returns an array of PickingInfo
  2430. */
  2431. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  2432. /**
  2433. * Launch a ray to try to pick a mesh in the scene
  2434. * @param ray Ray to use
  2435. * @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
  2436. * @returns an array of PickingInfo
  2437. */
  2438. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean): Nullable<PickingInfo[]>;
  2439. /**
  2440. * Force the value of meshUnderPointer
  2441. * @param mesh defines the mesh to use
  2442. */
  2443. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  2444. /**
  2445. * Gets the mesh under the pointer
  2446. * @returns a Mesh or null if no mesh is under the pointer
  2447. */
  2448. getPointerOverMesh(): Nullable<AbstractMesh>;
  2449. /**
  2450. * Force the sprite under the pointer
  2451. * @param sprite defines the sprite to use
  2452. */
  2453. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  2454. /**
  2455. * Gets the sprite under the pointer
  2456. * @returns a Sprite or null if no sprite is under the pointer
  2457. */
  2458. getPointerOverSprite(): Nullable<Sprite>;
  2459. /**
  2460. * Gets the current physics engine
  2461. * @returns a PhysicsEngine or null if none attached
  2462. */
  2463. getPhysicsEngine(): Nullable<PhysicsEngine>;
  2464. /**
  2465. * Enables physics to the current scene
  2466. * @param gravity defines the scene's gravity for the physics engine
  2467. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  2468. * @return a boolean indicating if the physics engine was initialized
  2469. */
  2470. enablePhysics(gravity?: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  2471. /**
  2472. * Disables and disposes the physics engine associated with the scene
  2473. */
  2474. disablePhysicsEngine(): void;
  2475. /**
  2476. * Gets a boolean indicating if there is an active physics engine
  2477. * @returns a boolean indicating if there is an active physics engine
  2478. */
  2479. isPhysicsEnabled(): boolean;
  2480. /**
  2481. * Deletes a physics compound impostor
  2482. * @param compound defines the compound to delete
  2483. */
  2484. deleteCompoundImpostor(compound: any): void;
  2485. /** @hidden */
  2486. /** @hidden */
  2487. /**
  2488. * Creates a default light for the scene.
  2489. * @param replace Whether to replace the existing lights in the scene.
  2490. */
  2491. createDefaultLight(replace?: boolean): void;
  2492. /**
  2493. * Creates a default camera for the scene.
  2494. * @param createArcRotateCamera Whether to create an arc rotate or a free camera.
  2495. * @param replace Whether to replace the existing active camera in the scene.
  2496. * @param attachCameraControls Whether to attach camera controls to the canvas.
  2497. */
  2498. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  2499. /**
  2500. * Creates a default camera and a default light
  2501. * @param createArcRotateCamera defines that the camera will be an ArcRotateCamera
  2502. * @param replace defines if the camera and/or light will replace the existing ones
  2503. * @param attachCameraControls defines if attachControl will be called on the new camera
  2504. */
  2505. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  2506. /**
  2507. * Creates a new sky box
  2508. * @see http://doc.babylonjs.com/babylon101/environment#skybox
  2509. * @param environmentTexture defines the texture to use as environment texture
  2510. * @param pbr defines if PBRMaterial must be used instead of StandardMaterial
  2511. * @param scale defines the overall scale of the skybox
  2512. * @param blur defines if blurring must be applied to the environment texture (works only with pbr === true)
  2513. * @param setGlobalEnvTexture defines a boolean indicating that scene.environmentTexture must match the current skybox texture (true by default)
  2514. * @returns a new mesh holding the sky box
  2515. */
  2516. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  2517. /**
  2518. * Creates a new environment
  2519. * @see http://doc.babylonjs.com/babylon101/environment#skybox
  2520. * @param options defines the options you can use to configure the environment
  2521. * @returns the new EnvironmentHelper
  2522. */
  2523. createDefaultEnvironment(options: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  2524. /**
  2525. * Creates a new VREXperienceHelper
  2526. * @see http://doc.babylonjs.com/how_to/webvr_helper
  2527. * @param webVROptions defines the options used to create the new VREXperienceHelper
  2528. * @returns a new VREXperienceHelper
  2529. */
  2530. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  2531. private _getByTags(list, tagsQuery, forEach?);
  2532. /**
  2533. * Get a list of meshes by tags
  2534. * @param tagsQuery defines the tags query to use
  2535. * @param forEach defines a predicate used to filter results
  2536. * @returns an array of Mesh
  2537. */
  2538. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  2539. /**
  2540. * Get a list of cameras by tags
  2541. * @param tagsQuery defines the tags query to use
  2542. * @param forEach defines a predicate used to filter results
  2543. * @returns an array of Camera
  2544. */
  2545. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  2546. /**
  2547. * Get a list of lights by tags
  2548. * @param tagsQuery defines the tags query to use
  2549. * @param forEach defines a predicate used to filter results
  2550. * @returns an array of Light
  2551. */
  2552. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  2553. /**
  2554. * Get a list of materials by tags
  2555. * @param tagsQuery defines the tags query to use
  2556. * @param forEach defines a predicate used to filter results
  2557. * @returns an array of Material
  2558. */
  2559. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  2560. /**
  2561. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  2562. * This allowed control for front to back rendering or reversly depending of the special needs.
  2563. *
  2564. * @param renderingGroupId The rendering group id corresponding to its index
  2565. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  2566. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  2567. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  2568. */
  2569. 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;
  2570. /**
  2571. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  2572. *
  2573. * @param renderingGroupId The rendering group id corresponding to its index
  2574. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  2575. * @param depth Automatically clears depth between groups if true and autoClear is true.
  2576. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  2577. */
  2578. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  2579. /**
  2580. * Will flag all materials as dirty to trigger new shader compilation
  2581. * @param flag defines the flag used to specify which material part must be marked as dirty
  2582. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  2583. */
  2584. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  2585. /** @hidden */
  2586. /** @hidden */
  2587. }
  2588. }
  2589. declare module BABYLON {
  2590. type Nullable<T> = T | null;
  2591. type float = number;
  2592. type double = number;
  2593. type int = number;
  2594. type FloatArray = number[] | Float32Array;
  2595. type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  2596. /**
  2597. * Alias for types that can be used by a Buffer or VertexBuffer.
  2598. */
  2599. type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  2600. }
  2601. declare module BABYLON {
  2602. /**
  2603. * The action to be carried out following a trigger
  2604. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  2605. */
  2606. class Action {
  2607. /** the trigger, with or without parameters, for the action */
  2608. triggerOptions: any;
  2609. /**
  2610. * Trigger for the action
  2611. */
  2612. trigger: number;
  2613. /**
  2614. * Internal only - manager for action
  2615. * @hidden
  2616. */
  2617. private _nextActiveAction;
  2618. private _child;
  2619. private _condition?;
  2620. private _triggerParameter;
  2621. /**
  2622. * An event triggered prior to action being executed.
  2623. */
  2624. onBeforeExecuteObservable: Observable<Action>;
  2625. /**
  2626. * Creates a new Action
  2627. * @param triggerOptions the trigger, with or without parameters, for the action
  2628. * @param condition an optional determinant of action
  2629. */
  2630. constructor(
  2631. /** the trigger, with or without parameters, for the action */
  2632. triggerOptions: any, condition?: Condition);
  2633. /**
  2634. * Internal only
  2635. * @hidden
  2636. */
  2637. /**
  2638. * Gets the trigger parameters
  2639. * @returns the trigger parameters
  2640. */
  2641. getTriggerParameter(): any;
  2642. /**
  2643. * Internal only - executes current action event
  2644. * @hidden
  2645. */
  2646. /**
  2647. * Execute placeholder for child classes
  2648. * @param evt optional action event
  2649. */
  2650. execute(evt?: ActionEvent): void;
  2651. /**
  2652. * Skips to next active action
  2653. */
  2654. skipToNextActiveAction(): void;
  2655. /**
  2656. * Adds action to chain of actions, may be a DoNothingAction
  2657. * @param action defines the next action to execute
  2658. * @returns The action passed in
  2659. * @see https://www.babylonjs-playground.com/#1T30HR#0
  2660. */
  2661. then(action: Action): Action;
  2662. /**
  2663. * Internal only
  2664. * @hidden
  2665. */
  2666. /**
  2667. * Internal only
  2668. * @hidden
  2669. */
  2670. /**
  2671. * Serialize placeholder for child classes
  2672. * @param parent of child
  2673. * @returns the serialized object
  2674. */
  2675. serialize(parent: any): any;
  2676. /**
  2677. * Internal only called by serialize
  2678. * @hidden
  2679. */
  2680. protected _serialize(serializedAction: any, parent?: any): any;
  2681. /**
  2682. * Internal only
  2683. * @hidden
  2684. */
  2685. private static _SerializeValueAsString: (value: any) => string;
  2686. /**
  2687. * Internal only
  2688. * @hidden
  2689. */
  2690. private static _GetTargetProperty: (target: Scene | Node) => {
  2691. name: string;
  2692. targetType: string;
  2693. value: string;
  2694. };
  2695. }
  2696. }
  2697. declare module BABYLON {
  2698. /**
  2699. * ActionEvent is the event being sent when an action is triggered.
  2700. */
  2701. class ActionEvent {
  2702. /** The mesh or sprite that triggered the action */
  2703. source: any;
  2704. /** The X mouse cursor position at the time of the event */
  2705. pointerX: number;
  2706. /** The Y mouse cursor position at the time of the event */
  2707. pointerY: number;
  2708. /** The mesh that is currently pointed at (can be null) */
  2709. meshUnderPointer: Nullable<AbstractMesh>;
  2710. /** the original (browser) event that triggered the ActionEvent */
  2711. sourceEvent: any;
  2712. /** additional data for the event */
  2713. additionalData: any;
  2714. /**
  2715. * Creates a new ActionEvent
  2716. * @param source The mesh or sprite that triggered the action
  2717. * @param pointerX The X mouse cursor position at the time of the event
  2718. * @param pointerY The Y mouse cursor position at the time of the event
  2719. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  2720. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  2721. * @param additionalData additional data for the event
  2722. */
  2723. constructor(
  2724. /** The mesh or sprite that triggered the action */
  2725. source: any,
  2726. /** The X mouse cursor position at the time of the event */
  2727. pointerX: number,
  2728. /** The Y mouse cursor position at the time of the event */
  2729. pointerY: number,
  2730. /** The mesh that is currently pointed at (can be null) */
  2731. meshUnderPointer: Nullable<AbstractMesh>,
  2732. /** the original (browser) event that triggered the ActionEvent */
  2733. sourceEvent?: any,
  2734. /** additional data for the event */
  2735. additionalData?: any);
  2736. /**
  2737. * Helper function to auto-create an ActionEvent from a source mesh.
  2738. * @param source The source mesh that triggered the event
  2739. * @param evt The original (browser) event
  2740. * @param additionalData additional data for the event
  2741. * @returns the new ActionEvent
  2742. */
  2743. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  2744. /**
  2745. * Helper function to auto-create an ActionEvent from a source sprite
  2746. * @param source The source sprite that triggered the event
  2747. * @param scene Scene associated with the sprite
  2748. * @param evt The original (browser) event
  2749. * @param additionalData additional data for the event
  2750. * @returns the new ActionEvent
  2751. */
  2752. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  2753. /**
  2754. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  2755. * @param scene the scene where the event occurred
  2756. * @param evt The original (browser) event
  2757. * @returns the new ActionEvent
  2758. */
  2759. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  2760. /**
  2761. * Helper function to auto-create an ActionEvent from a primitive
  2762. * @param prim defines the target primitive
  2763. * @param pointerPos defines the pointer position
  2764. * @param evt The original (browser) event
  2765. * @param additionalData additional data for the event
  2766. * @returns the new ActionEvent
  2767. */
  2768. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  2769. }
  2770. /**
  2771. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  2772. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  2773. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  2774. */
  2775. class ActionManager {
  2776. private static _NothingTrigger;
  2777. private static _OnPickTrigger;
  2778. private static _OnLeftPickTrigger;
  2779. private static _OnRightPickTrigger;
  2780. private static _OnCenterPickTrigger;
  2781. private static _OnPickDownTrigger;
  2782. private static _OnDoublePickTrigger;
  2783. private static _OnPickUpTrigger;
  2784. private static _OnLongPressTrigger;
  2785. private static _OnPointerOverTrigger;
  2786. private static _OnPointerOutTrigger;
  2787. private static _OnEveryFrameTrigger;
  2788. private static _OnIntersectionEnterTrigger;
  2789. private static _OnIntersectionExitTrigger;
  2790. private static _OnKeyDownTrigger;
  2791. private static _OnKeyUpTrigger;
  2792. private static _OnPickOutTrigger;
  2793. /**
  2794. * Nothing
  2795. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2796. */
  2797. static readonly NothingTrigger: number;
  2798. /**
  2799. * On pick
  2800. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2801. */
  2802. static readonly OnPickTrigger: number;
  2803. /**
  2804. * On left pick
  2805. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2806. */
  2807. static readonly OnLeftPickTrigger: number;
  2808. /**
  2809. * On right pick
  2810. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2811. */
  2812. static readonly OnRightPickTrigger: number;
  2813. /**
  2814. * On center pick
  2815. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2816. */
  2817. static readonly OnCenterPickTrigger: number;
  2818. /**
  2819. * On pick down
  2820. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2821. */
  2822. static readonly OnPickDownTrigger: number;
  2823. /**
  2824. * On double pick
  2825. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2826. */
  2827. static readonly OnDoublePickTrigger: number;
  2828. /**
  2829. * On pick up
  2830. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2831. */
  2832. static readonly OnPickUpTrigger: number;
  2833. /**
  2834. * On pick out.
  2835. * This trigger will only be raised if you also declared a OnPickDown
  2836. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2837. */
  2838. static readonly OnPickOutTrigger: number;
  2839. /**
  2840. * On long press
  2841. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2842. */
  2843. static readonly OnLongPressTrigger: number;
  2844. /**
  2845. * On pointer over
  2846. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2847. */
  2848. static readonly OnPointerOverTrigger: number;
  2849. /**
  2850. * On pointer out
  2851. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2852. */
  2853. static readonly OnPointerOutTrigger: number;
  2854. /**
  2855. * On every frame
  2856. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2857. */
  2858. static readonly OnEveryFrameTrigger: number;
  2859. /**
  2860. * On intersection enter
  2861. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2862. */
  2863. static readonly OnIntersectionEnterTrigger: number;
  2864. /**
  2865. * On intersection exit
  2866. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2867. */
  2868. static readonly OnIntersectionExitTrigger: number;
  2869. /**
  2870. * On key down
  2871. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2872. */
  2873. static readonly OnKeyDownTrigger: number;
  2874. /**
  2875. * On key up
  2876. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2877. */
  2878. static readonly OnKeyUpTrigger: number;
  2879. /** Gets the list of active triggers */
  2880. static Triggers: {
  2881. [key: string]: number;
  2882. };
  2883. /** Gets the list of actions */
  2884. actions: Action[];
  2885. /** Gets the cursor to use when hovering items */
  2886. hoverCursor: string;
  2887. private _scene;
  2888. /**
  2889. * Creates a new action manager
  2890. * @param scene defines the hosting scene
  2891. */
  2892. constructor(scene: Scene);
  2893. /**
  2894. * Releases all associated resources
  2895. */
  2896. dispose(): void;
  2897. /**
  2898. * Gets hosting scene
  2899. * @returns the hosting scene
  2900. */
  2901. getScene(): Scene;
  2902. /**
  2903. * Does this action manager handles actions of any of the given triggers
  2904. * @param triggers defines the triggers to be tested
  2905. * @return a boolean indicating whether one (or more) of the triggers is handled
  2906. */
  2907. hasSpecificTriggers(triggers: number[]): boolean;
  2908. /**
  2909. * Does this action manager handles actions of a given trigger
  2910. * @param trigger defines the trigger to be tested
  2911. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  2912. * @return whether the trigger is handled
  2913. */
  2914. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  2915. /**
  2916. * Does this action manager has pointer triggers
  2917. */
  2918. readonly hasPointerTriggers: boolean;
  2919. /**
  2920. * Does this action manager has pick triggers
  2921. */
  2922. readonly hasPickTriggers: boolean;
  2923. /**
  2924. * Does exist one action manager with at least one trigger
  2925. **/
  2926. static readonly HasTriggers: boolean;
  2927. /**
  2928. * Does exist one action manager with at least one pick trigger
  2929. **/
  2930. static readonly HasPickTriggers: boolean;
  2931. /**
  2932. * Does exist one action manager that handles actions of a given trigger
  2933. * @param trigger defines the trigger to be tested
  2934. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  2935. **/
  2936. static HasSpecificTrigger(trigger: number): boolean;
  2937. /**
  2938. * Registers an action to this action manager
  2939. * @param action defines the action to be registered
  2940. * @return the action amended (prepared) after registration
  2941. */
  2942. registerAction(action: Action): Nullable<Action>;
  2943. /**
  2944. * Unregisters an action to this action manager
  2945. * @param action defines the action to be unregistered
  2946. * @return a boolean indicating whether the action has been unregistered
  2947. */
  2948. unregisterAction(action: Action): Boolean;
  2949. /**
  2950. * Process a specific trigger
  2951. * @param trigger defines the trigger to process
  2952. * @param evt defines the event details to be processed
  2953. */
  2954. processTrigger(trigger: number, evt?: ActionEvent): void;
  2955. /** @hidden */
  2956. /** @hidden */
  2957. /**
  2958. * Serialize this manager to a JSON object
  2959. * @param name defines the property name to store this manager
  2960. * @returns a JSON representation of this manager
  2961. */
  2962. serialize(name: string): any;
  2963. /**
  2964. * Creates a new ActionManager from a JSON data
  2965. * @param parsedActions defines the JSON data to read from
  2966. * @param object defines the hosting mesh
  2967. * @param scene defines the hosting scene
  2968. */
  2969. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  2970. /**
  2971. * Get a trigger name by index
  2972. * @param trigger defines the trigger index
  2973. * @returns a trigger name
  2974. */
  2975. static GetTriggerName(trigger: number): string;
  2976. }
  2977. }
  2978. declare module BABYLON {
  2979. /**
  2980. * A Condition applied to an Action
  2981. */
  2982. class Condition {
  2983. /**
  2984. * Internal only - manager for action
  2985. * @hidden
  2986. */
  2987. /**
  2988. * Internal only
  2989. * @hidden
  2990. */
  2991. /**
  2992. * Internal only
  2993. * @hidden
  2994. */
  2995. /**
  2996. * Creates a new Condition
  2997. * @param actionManager the manager of the action the condition is applied to
  2998. */
  2999. constructor(actionManager: ActionManager);
  3000. /**
  3001. * Check if the current condition is valid
  3002. * @returns a boolean
  3003. */
  3004. isValid(): boolean;
  3005. /**
  3006. * Internal only
  3007. * @hidden
  3008. */
  3009. /**
  3010. * Internal only
  3011. * @hidden
  3012. */
  3013. /**
  3014. * Serialize placeholder for child classes
  3015. * @returns the serialized object
  3016. */
  3017. serialize(): any;
  3018. /**
  3019. * Internal only
  3020. * @hidden
  3021. */
  3022. protected _serialize(serializedCondition: any): any;
  3023. }
  3024. /**
  3025. * Defines specific conditional operators as extensions of Condition
  3026. */
  3027. class ValueCondition extends Condition {
  3028. /** path to specify the property of the target the conditional operator uses */
  3029. propertyPath: string;
  3030. /** the value compared by the conditional operator against the current value of the property */
  3031. value: any;
  3032. /** the conditional operator, default ValueCondition.IsEqual */
  3033. operator: number;
  3034. /**
  3035. * Internal only
  3036. * @hidden
  3037. */
  3038. private static _IsEqual;
  3039. /**
  3040. * Internal only
  3041. * @hidden
  3042. */
  3043. private static _IsDifferent;
  3044. /**
  3045. * Internal only
  3046. * @hidden
  3047. */
  3048. private static _IsGreater;
  3049. /**
  3050. * Internal only
  3051. * @hidden
  3052. */
  3053. private static _IsLesser;
  3054. /**
  3055. * returns the number for IsEqual
  3056. */
  3057. static readonly IsEqual: number;
  3058. /**
  3059. * Returns the number for IsDifferent
  3060. */
  3061. static readonly IsDifferent: number;
  3062. /**
  3063. * Returns the number for IsGreater
  3064. */
  3065. static readonly IsGreater: number;
  3066. /**
  3067. * Returns the number for IsLesser
  3068. */
  3069. static readonly IsLesser: number;
  3070. /**
  3071. * Internal only The action manager for the condition
  3072. * @hidden
  3073. */
  3074. /**
  3075. * Internal only
  3076. * @hidden
  3077. */
  3078. private _target;
  3079. /**
  3080. * Internal only
  3081. * @hidden
  3082. */
  3083. private _effectiveTarget;
  3084. /**
  3085. * Internal only
  3086. * @hidden
  3087. */
  3088. private _property;
  3089. /**
  3090. * Creates a new ValueCondition
  3091. * @param actionManager manager for the action the condition applies to
  3092. * @param target for the action
  3093. * @param propertyPath path to specify the property of the target the conditional operator uses
  3094. * @param value the value compared by the conditional operator against the current value of the property
  3095. * @param operator the conditional operator, default ValueCondition.IsEqual
  3096. */
  3097. constructor(actionManager: ActionManager, target: any,
  3098. /** path to specify the property of the target the conditional operator uses */
  3099. propertyPath: string,
  3100. /** the value compared by the conditional operator against the current value of the property */
  3101. value: any,
  3102. /** the conditional operator, default ValueCondition.IsEqual */
  3103. operator?: number);
  3104. /**
  3105. * Compares the given value with the property value for the specified conditional operator
  3106. * @returns the result of the comparison
  3107. */
  3108. isValid(): boolean;
  3109. /**
  3110. * Serialize the ValueCondition into a JSON compatible object
  3111. * @returns serialization object
  3112. */
  3113. serialize(): any;
  3114. /**
  3115. * Gets the name of the conditional operator for the ValueCondition
  3116. * @param operator the conditional operator
  3117. * @returns the name
  3118. */
  3119. static GetOperatorName(operator: number): string;
  3120. }
  3121. /**
  3122. * Defines a predicate condition as an extension of Condition
  3123. */
  3124. class PredicateCondition extends Condition {
  3125. /** defines the predicate function used to validate the condition */
  3126. predicate: () => boolean;
  3127. /**
  3128. * Internal only - manager for action
  3129. * @hidden
  3130. */
  3131. /**
  3132. * Creates a new PredicateCondition
  3133. * @param actionManager manager for the action the condition applies to
  3134. * @param predicate defines the predicate function used to validate the condition
  3135. */
  3136. constructor(actionManager: ActionManager,
  3137. /** defines the predicate function used to validate the condition */
  3138. predicate: () => boolean);
  3139. /**
  3140. * @returns the validity of the predicate condition
  3141. */
  3142. isValid(): boolean;
  3143. }
  3144. /**
  3145. * Defines a state condition as an extension of Condition
  3146. */
  3147. class StateCondition extends Condition {
  3148. value: string;
  3149. /**
  3150. * Internal only - manager for action
  3151. * @hidden
  3152. */
  3153. /**
  3154. * Internal only
  3155. * @hidden
  3156. */
  3157. private _target;
  3158. /**
  3159. * Creates a new StateCondition
  3160. * @param actionManager manager for the action the condition applies to
  3161. * @param target of the condition
  3162. * @param value to compare with target state
  3163. */
  3164. constructor(actionManager: ActionManager, target: any, value: string);
  3165. /**
  3166. * @returns the validity of the state
  3167. */
  3168. isValid(): boolean;
  3169. /**
  3170. * Serialize the StateCondition into a JSON compatible object
  3171. * @returns serialization object
  3172. */
  3173. serialize(): any;
  3174. }
  3175. }
  3176. declare module BABYLON {
  3177. class SwitchBooleanAction extends Action {
  3178. propertyPath: string;
  3179. private _target;
  3180. private _effectiveTarget;
  3181. private _property;
  3182. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  3183. execute(): void;
  3184. serialize(parent: any): any;
  3185. }
  3186. class SetStateAction extends Action {
  3187. value: string;
  3188. private _target;
  3189. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  3190. execute(): void;
  3191. serialize(parent: any): any;
  3192. }
  3193. class SetValueAction extends Action {
  3194. propertyPath: string;
  3195. value: any;
  3196. private _target;
  3197. private _effectiveTarget;
  3198. private _property;
  3199. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  3200. execute(): void;
  3201. serialize(parent: any): any;
  3202. }
  3203. class IncrementValueAction extends Action {
  3204. propertyPath: string;
  3205. value: any;
  3206. private _target;
  3207. private _effectiveTarget;
  3208. private _property;
  3209. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  3210. execute(): void;
  3211. serialize(parent: any): any;
  3212. }
  3213. class PlayAnimationAction extends Action {
  3214. from: number;
  3215. to: number;
  3216. loop: boolean | undefined;
  3217. private _target;
  3218. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean | undefined, condition?: Condition);
  3219. execute(): void;
  3220. serialize(parent: any): any;
  3221. }
  3222. class StopAnimationAction extends Action {
  3223. private _target;
  3224. constructor(triggerOptions: any, target: any, condition?: Condition);
  3225. execute(): void;
  3226. serialize(parent: any): any;
  3227. }
  3228. class DoNothingAction extends Action {
  3229. constructor(triggerOptions?: any, condition?: Condition);
  3230. execute(): void;
  3231. serialize(parent: any): any;
  3232. }
  3233. class CombineAction extends Action {
  3234. children: Action[];
  3235. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  3236. execute(evt: ActionEvent): void;
  3237. serialize(parent: any): any;
  3238. }
  3239. class ExecuteCodeAction extends Action {
  3240. func: (evt: ActionEvent) => void;
  3241. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  3242. execute(evt: ActionEvent): void;
  3243. }
  3244. class SetParentAction extends Action {
  3245. private _parent;
  3246. private _target;
  3247. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  3248. execute(): void;
  3249. serialize(parent: any): any;
  3250. }
  3251. class PlaySoundAction extends Action {
  3252. private _sound;
  3253. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  3254. execute(): void;
  3255. serialize(parent: any): any;
  3256. }
  3257. class StopSoundAction extends Action {
  3258. private _sound;
  3259. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  3260. execute(): void;
  3261. serialize(parent: any): any;
  3262. }
  3263. }
  3264. declare module BABYLON {
  3265. class InterpolateValueAction extends Action {
  3266. propertyPath: string;
  3267. value: any;
  3268. duration: number;
  3269. stopOtherAnimations: boolean | undefined;
  3270. onInterpolationDone: (() => void) | undefined;
  3271. private _target;
  3272. private _effectiveTarget;
  3273. private _property;
  3274. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  3275. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean | undefined, onInterpolationDone?: (() => void) | undefined);
  3276. execute(): void;
  3277. serialize(parent: any): any;
  3278. }
  3279. }
  3280. declare module BABYLON {
  3281. class Animatable {
  3282. target: any;
  3283. fromFrame: number;
  3284. toFrame: number;
  3285. loopAnimation: boolean;
  3286. onAnimationEnd: (() => void) | null | undefined;
  3287. private _localDelayOffset;
  3288. private _pausedDelay;
  3289. private _runtimeAnimations;
  3290. private _paused;
  3291. private _scene;
  3292. private _speedRatio;
  3293. private _weight;
  3294. private _syncRoot;
  3295. animationStarted: boolean;
  3296. /**
  3297. * Observer raised when the animation ends
  3298. */
  3299. onAnimationEndObservable: Observable<Animatable>;
  3300. /**
  3301. * Gets the root Animatable used to synchronize and normalize animations
  3302. */
  3303. readonly syncRoot: Animatable;
  3304. /**
  3305. * Gets the current frame of the first RuntimeAnimation
  3306. * Used to synchronize Animatables
  3307. */
  3308. readonly masterFrame: number;
  3309. /**
  3310. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  3311. */
  3312. weight: number;
  3313. /**
  3314. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  3315. */
  3316. speedRatio: number;
  3317. constructor(scene: Scene, target: any, fromFrame?: number, toFrame?: number, loopAnimation?: boolean, speedRatio?: number, onAnimationEnd?: (() => void) | null | undefined, animations?: any);
  3318. /**
  3319. * Synchronize and normalize current Animatable with a source Animatable
  3320. * This is useful when using animation weights and when animations are not of the same length
  3321. * @param root defines the root Animatable to synchronize with
  3322. * @returns the current Animatable
  3323. */
  3324. syncWith(root: Animatable): Animatable;
  3325. getAnimations(): RuntimeAnimation[];
  3326. appendAnimations(target: any, animations: Animation[]): void;
  3327. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  3328. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  3329. reset(): void;
  3330. enableBlending(blendingSpeed: number): void;
  3331. disableBlending(): void;
  3332. goToFrame(frame: number): void;
  3333. pause(): void;
  3334. restart(): void;
  3335. private _raiseOnAnimationEnd();
  3336. stop(animationName?: string): void;
  3337. /**
  3338. * Wait asynchronously for the animation to end
  3339. * @returns a promise which will be fullfilled when the animation ends
  3340. */
  3341. waitAsync(): Promise<Animatable>;
  3342. /** @hidden */
  3343. }
  3344. }
  3345. declare module BABYLON {
  3346. /**
  3347. * Represents the range of an animation
  3348. */
  3349. class AnimationRange {
  3350. /**The name of the animation range**/
  3351. name: string;
  3352. /**The starting frame of the animation */
  3353. from: number;
  3354. /**The ending frame of the animation*/
  3355. to: number;
  3356. /**
  3357. * Initializes the range of an animation
  3358. * @param name The name of the animation range
  3359. * @param from The starting frame of the animation
  3360. * @param to The ending frame of the animation
  3361. */
  3362. constructor(
  3363. /**The name of the animation range**/
  3364. name: string,
  3365. /**The starting frame of the animation */
  3366. from: number,
  3367. /**The ending frame of the animation*/
  3368. to: number);
  3369. /**
  3370. * Makes a copy of the animation range
  3371. * @returns A copy of the animation range
  3372. */
  3373. clone(): AnimationRange;
  3374. }
  3375. /**
  3376. * Composed of a frame, and an action function
  3377. */
  3378. class AnimationEvent {
  3379. /** The frame for which the event is triggered **/
  3380. frame: number;
  3381. /** The event to perform when triggered **/
  3382. action: () => void;
  3383. /** Specifies if the event should be triggered only once**/
  3384. onlyOnce: boolean | undefined;
  3385. /**
  3386. * Specifies if the animation event is done
  3387. */
  3388. isDone: boolean;
  3389. /**
  3390. * Initializes the animation event
  3391. * @param frame The frame for which the event is triggered
  3392. * @param action The event to perform when triggered
  3393. * @param onlyOnce Specifies if the event should be triggered only once
  3394. */
  3395. constructor(
  3396. /** The frame for which the event is triggered **/
  3397. frame: number,
  3398. /** The event to perform when triggered **/
  3399. action: () => void,
  3400. /** Specifies if the event should be triggered only once**/
  3401. onlyOnce?: boolean | undefined);
  3402. /** @hidden */
  3403. }
  3404. /**
  3405. * A cursor which tracks a point on a path
  3406. */
  3407. class PathCursor {
  3408. private path;
  3409. /**
  3410. * Stores path cursor callbacks for when an onchange event is triggered
  3411. */
  3412. private _onchange;
  3413. /**
  3414. * The value of the path cursor
  3415. */
  3416. value: number;
  3417. /**
  3418. * The animation array of the path cursor
  3419. */
  3420. animations: Animation[];
  3421. /**
  3422. * Initializes the path cursor
  3423. * @param path The path to track
  3424. */
  3425. constructor(path: Path2);
  3426. /**
  3427. * Gets the cursor point on the path
  3428. * @returns A point on the path cursor at the cursor location
  3429. */
  3430. getPoint(): Vector3;
  3431. /**
  3432. * Moves the cursor ahead by the step amount
  3433. * @param step The amount to move the cursor forward
  3434. * @returns This path cursor
  3435. */
  3436. moveAhead(step?: number): PathCursor;
  3437. /**
  3438. * Moves the cursor behind by the step amount
  3439. * @param step The amount to move the cursor back
  3440. * @returns This path cursor
  3441. */
  3442. moveBack(step?: number): PathCursor;
  3443. /**
  3444. * Moves the cursor by the step amount
  3445. * If the step amount is greater than one, an exception is thrown
  3446. * @param step The amount to move the cursor
  3447. * @returns This path cursor
  3448. */
  3449. move(step: number): PathCursor;
  3450. /**
  3451. * Ensures that the value is limited between zero and one
  3452. * @returns This path cursor
  3453. */
  3454. private ensureLimits();
  3455. /**
  3456. * Runs onchange callbacks on change (used by the animation engine)
  3457. * @returns This path cursor
  3458. */
  3459. private raiseOnChange();
  3460. /**
  3461. * Executes a function on change
  3462. * @param f A path cursor onchange callback
  3463. * @returns This path cursor
  3464. */
  3465. onchange(f: (cursor: PathCursor) => void): PathCursor;
  3466. }
  3467. /**
  3468. * Defines an interface which represents an animation key frame
  3469. */
  3470. interface IAnimationKey {
  3471. /**
  3472. * Frame of the key frame
  3473. */
  3474. frame: number;
  3475. /**
  3476. * Value at the specifies key frame
  3477. */
  3478. value: any;
  3479. /**
  3480. * The input tangent for the cubic hermite spline
  3481. */
  3482. inTangent?: any;
  3483. /**
  3484. * The output tangent for the cubic hermite spline
  3485. */
  3486. outTangent?: any;
  3487. /**
  3488. * The animation interpolation type
  3489. */
  3490. interpolation?: AnimationKeyInterpolation;
  3491. }
  3492. /**
  3493. * Enum for the animation key frame interpolation type
  3494. */
  3495. enum AnimationKeyInterpolation {
  3496. /**
  3497. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  3498. */
  3499. STEP = 1,
  3500. }
  3501. /**
  3502. * Class used to store any kind of animation
  3503. */
  3504. class Animation {
  3505. /**Name of the animation */
  3506. name: string;
  3507. /**Property to animate */
  3508. targetProperty: string;
  3509. /**The frames per second of the animation */
  3510. framePerSecond: number;
  3511. /**The data type of the animation */
  3512. dataType: number;
  3513. /**The loop mode of the animation */
  3514. loopMode: number | undefined;
  3515. /**Specifies if blending should be enabled */
  3516. enableBlending: boolean | undefined;
  3517. /**
  3518. * Use matrix interpolation instead of using direct key value when animating matrices
  3519. */
  3520. static AllowMatricesInterpolation: boolean;
  3521. /**
  3522. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  3523. */
  3524. static AllowMatrixDecomposeForInterpolation: boolean;
  3525. /**
  3526. * Stores the key frames of the animation
  3527. */
  3528. private _keys;
  3529. /**
  3530. * Stores the easing function of the animation
  3531. */
  3532. private _easingFunction;
  3533. /**
  3534. * @hidden Internal use only
  3535. */
  3536. /**
  3537. * The set of event that will be linked to this animation
  3538. */
  3539. private _events;
  3540. /**
  3541. * Stores an array of target property paths
  3542. */
  3543. targetPropertyPath: string[];
  3544. /**
  3545. * Stores the blending speed of the animation
  3546. */
  3547. blendingSpeed: number;
  3548. /**
  3549. * Stores the animation ranges for the animation
  3550. */
  3551. private _ranges;
  3552. /**
  3553. * @hidden Internal use
  3554. */
  3555. private static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  3556. /**
  3557. * Sets up an animation
  3558. * @param property The property to animate
  3559. * @param animationType The animation type to apply
  3560. * @param framePerSecond The frames per second of the animation
  3561. * @param easingFunction The easing function used in the animation
  3562. * @returns The created animation
  3563. */
  3564. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  3565. /**
  3566. * Create and start an animation on a node
  3567. * @param name defines the name of the global animation that will be run on all nodes
  3568. * @param node defines the root node where the animation will take place
  3569. * @param targetProperty defines property to animate
  3570. * @param framePerSecond defines the number of frame per second yo use
  3571. * @param totalFrame defines the number of frames in total
  3572. * @param from defines the initial value
  3573. * @param to defines the final value
  3574. * @param loopMode defines which loop mode you want to use (off by default)
  3575. * @param easingFunction defines the easing function to use (linear by default)
  3576. * @param onAnimationEnd defines the callback to call when animation end
  3577. * @returns the animatable created for this animation
  3578. */
  3579. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  3580. /**
  3581. * Create and start an animation on a node and its descendants
  3582. * @param name defines the name of the global animation that will be run on all nodes
  3583. * @param node defines the root node where the animation will take place
  3584. * @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
  3585. * @param targetProperty defines property to animate
  3586. * @param framePerSecond defines the number of frame per second to use
  3587. * @param totalFrame defines the number of frames in total
  3588. * @param from defines the initial value
  3589. * @param to defines the final value
  3590. * @param loopMode defines which loop mode you want to use (off by default)
  3591. * @param easingFunction defines the easing function to use (linear by default)
  3592. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  3593. * @returns the list of animatables created for all nodes
  3594. * @example https://www.babylonjs-playground.com/#MH0VLI
  3595. */
  3596. 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[]>;
  3597. /**
  3598. * Creates a new animation, merges it with the existing animations and starts it
  3599. * @param name Name of the animation
  3600. * @param node Node which contains the scene that begins the animations
  3601. * @param targetProperty Specifies which property to animate
  3602. * @param framePerSecond The frames per second of the animation
  3603. * @param totalFrame The total number of frames
  3604. * @param from The frame at the beginning of the animation
  3605. * @param to The frame at the end of the animation
  3606. * @param loopMode Specifies the loop mode of the animation
  3607. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  3608. * @param onAnimationEnd Callback to run once the animation is complete
  3609. * @returns Nullable animation
  3610. */
  3611. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  3612. /**
  3613. * Transition property of an host to the target Value
  3614. * @param property The property to transition
  3615. * @param targetValue The target Value of the property
  3616. * @param host The object where the property to animate belongs
  3617. * @param scene Scene used to run the animation
  3618. * @param frameRate Framerate (in frame/s) to use
  3619. * @param transition The transition type we want to use
  3620. * @param duration The duration of the animation, in milliseconds
  3621. * @param onAnimationEnd Callback trigger at the end of the animation
  3622. * @returns Nullable animation
  3623. */
  3624. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  3625. /**
  3626. * Return the array of runtime animations currently using this animation
  3627. */
  3628. readonly runtimeAnimations: RuntimeAnimation[];
  3629. /**
  3630. * Specifies if any of the runtime animations are currently running
  3631. */
  3632. readonly hasRunningRuntimeAnimations: boolean;
  3633. /**
  3634. * Initializes the animation
  3635. * @param name Name of the animation
  3636. * @param targetProperty Property to animate
  3637. * @param framePerSecond The frames per second of the animation
  3638. * @param dataType The data type of the animation
  3639. * @param loopMode The loop mode of the animation
  3640. * @param enableBlendings Specifies if blending should be enabled
  3641. */
  3642. constructor(
  3643. /**Name of the animation */
  3644. name: string,
  3645. /**Property to animate */
  3646. targetProperty: string,
  3647. /**The frames per second of the animation */
  3648. framePerSecond: number,
  3649. /**The data type of the animation */
  3650. dataType: number,
  3651. /**The loop mode of the animation */
  3652. loopMode?: number | undefined,
  3653. /**Specifies if blending should be enabled */
  3654. enableBlending?: boolean | undefined);
  3655. /**
  3656. * Converts the animation to a string
  3657. * @param fullDetails support for multiple levels of logging within scene loading
  3658. * @returns String form of the animation
  3659. */
  3660. toString(fullDetails?: boolean): string;
  3661. /**
  3662. * Add an event to this animation
  3663. * @param event Event to add
  3664. */
  3665. addEvent(event: AnimationEvent): void;
  3666. /**
  3667. * Remove all events found at the given frame
  3668. * @param frame The frame to remove events from
  3669. */
  3670. removeEvents(frame: number): void;
  3671. /**
  3672. * Retrieves all the events from the animation
  3673. * @returns Events from the animation
  3674. */
  3675. getEvents(): AnimationEvent[];
  3676. /**
  3677. * Creates an animation range
  3678. * @param name Name of the animation range
  3679. * @param from Starting frame of the animation range
  3680. * @param to Ending frame of the animation
  3681. */
  3682. createRange(name: string, from: number, to: number): void;
  3683. /**
  3684. * Deletes an animation range by name
  3685. * @param name Name of the animation range to delete
  3686. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  3687. */
  3688. deleteRange(name: string, deleteFrames?: boolean): void;
  3689. /**
  3690. * Gets the animation range by name, or null if not defined
  3691. * @param name Name of the animation range
  3692. * @returns Nullable animation range
  3693. */
  3694. getRange(name: string): Nullable<AnimationRange>;
  3695. /**
  3696. * Gets the key frames from the animation
  3697. * @returns The key frames of the animation
  3698. */
  3699. getKeys(): Array<IAnimationKey>;
  3700. /**
  3701. * Gets the highest frame rate of the animation
  3702. * @returns Highest frame rate of the animation
  3703. */
  3704. getHighestFrame(): number;
  3705. /**
  3706. * Gets the easing function of the animation
  3707. * @returns Easing function of the animation
  3708. */
  3709. getEasingFunction(): IEasingFunction;
  3710. /**
  3711. * Sets the easing function of the animation
  3712. * @param easingFunction A custom mathematical formula for animation
  3713. */
  3714. setEasingFunction(easingFunction: EasingFunction): void;
  3715. /**
  3716. * Interpolates a scalar linearly
  3717. * @param startValue Start value of the animation curve
  3718. * @param endValue End value of the animation curve
  3719. * @param gradient Scalar amount to interpolate
  3720. * @returns Interpolated scalar value
  3721. */
  3722. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  3723. /**
  3724. * Interpolates a scalar cubically
  3725. * @param startValue Start value of the animation curve
  3726. * @param outTangent End tangent of the animation
  3727. * @param endValue End value of the animation curve
  3728. * @param inTangent Start tangent of the animation curve
  3729. * @param gradient Scalar amount to interpolate
  3730. * @returns Interpolated scalar value
  3731. */
  3732. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  3733. /**
  3734. * Interpolates a quaternion using a spherical linear interpolation
  3735. * @param startValue Start value of the animation curve
  3736. * @param endValue End value of the animation curve
  3737. * @param gradient Scalar amount to interpolate
  3738. * @returns Interpolated quaternion value
  3739. */
  3740. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  3741. /**
  3742. * Interpolates a quaternion cubically
  3743. * @param startValue Start value of the animation curve
  3744. * @param outTangent End tangent of the animation curve
  3745. * @param endValue End value of the animation curve
  3746. * @param inTangent Start tangent of the animation curve
  3747. * @param gradient Scalar amount to interpolate
  3748. * @returns Interpolated quaternion value
  3749. */
  3750. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  3751. /**
  3752. * Interpolates a Vector3 linearl
  3753. * @param startValue Start value of the animation curve
  3754. * @param endValue End value of the animation curve
  3755. * @param gradient Scalar amount to interpolate
  3756. * @returns Interpolated scalar value
  3757. */
  3758. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  3759. /**
  3760. * Interpolates a Vector3 cubically
  3761. * @param startValue Start value of the animation curve
  3762. * @param outTangent End tangent of the animation
  3763. * @param endValue End value of the animation curve
  3764. * @param inTangent Start tangent of the animation curve
  3765. * @param gradient Scalar amount to interpolate
  3766. * @returns InterpolatedVector3 value
  3767. */
  3768. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  3769. /**
  3770. * Interpolates a Vector2 linearly
  3771. * @param startValue Start value of the animation curve
  3772. * @param endValue End value of the animation curve
  3773. * @param gradient Scalar amount to interpolate
  3774. * @returns Interpolated Vector2 value
  3775. */
  3776. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  3777. /**
  3778. * Interpolates a Vector2 cubically
  3779. * @param startValue Start value of the animation curve
  3780. * @param outTangent End tangent of the animation
  3781. * @param endValue End value of the animation curve
  3782. * @param inTangent Start tangent of the animation curve
  3783. * @param gradient Scalar amount to interpolate
  3784. * @returns Interpolated Vector2 value
  3785. */
  3786. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  3787. /**
  3788. * Interpolates a size linearly
  3789. * @param startValue Start value of the animation curve
  3790. * @param endValue End value of the animation curve
  3791. * @param gradient Scalar amount to interpolate
  3792. * @returns Interpolated Size value
  3793. */
  3794. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  3795. /**
  3796. * Interpolates a Color3 linearly
  3797. * @param startValue Start value of the animation curve
  3798. * @param endValue End value of the animation curve
  3799. * @param gradient Scalar amount to interpolate
  3800. * @returns Interpolated Color3 value
  3801. */
  3802. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  3803. /**
  3804. * @hidden Internal use only
  3805. */
  3806. /**
  3807. * @hidden Internal use only
  3808. */
  3809. /**
  3810. * Defines the function to use to interpolate matrices
  3811. * @param startValue defines the start matrix
  3812. * @param endValue defines the end matrix
  3813. * @param gradient defines the gradient between both matrices
  3814. * @param result defines an optional target matrix where to store the interpolation
  3815. * @returns the interpolated matrix
  3816. */
  3817. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  3818. /**
  3819. * Makes a copy of the animation
  3820. * @returns Cloned animation
  3821. */
  3822. clone(): Animation;
  3823. /**
  3824. * Sets the key frames of the animation
  3825. * @param values The animation key frames to set
  3826. */
  3827. setKeys(values: Array<IAnimationKey>): void;
  3828. /**
  3829. * Serializes the animation to an object
  3830. * @returns Serialized object
  3831. */
  3832. serialize(): any;
  3833. /**
  3834. * Float animation type
  3835. */
  3836. private static _ANIMATIONTYPE_FLOAT;
  3837. /**
  3838. * Vector3 animation type
  3839. */
  3840. private static _ANIMATIONTYPE_VECTOR3;
  3841. /**
  3842. * Quaternion animation type
  3843. */
  3844. private static _ANIMATIONTYPE_QUATERNION;
  3845. /**
  3846. * Matrix animation type
  3847. */
  3848. private static _ANIMATIONTYPE_MATRIX;
  3849. /**
  3850. * Color3 animation type
  3851. */
  3852. private static _ANIMATIONTYPE_COLOR3;
  3853. /**
  3854. * Vector2 animation type
  3855. */
  3856. private static _ANIMATIONTYPE_VECTOR2;
  3857. /**
  3858. * Size animation type
  3859. */
  3860. private static _ANIMATIONTYPE_SIZE;
  3861. /**
  3862. * Relative Loop Mode
  3863. */
  3864. private static _ANIMATIONLOOPMODE_RELATIVE;
  3865. /**
  3866. * Cycle Loop Mode
  3867. */
  3868. private static _ANIMATIONLOOPMODE_CYCLE;
  3869. /**
  3870. * Constant Loop Mode
  3871. */
  3872. private static _ANIMATIONLOOPMODE_CONSTANT;
  3873. /**
  3874. * Get the float animation type
  3875. */
  3876. static readonly ANIMATIONTYPE_FLOAT: number;
  3877. /**
  3878. * Get the Vector3 animation type
  3879. */
  3880. static readonly ANIMATIONTYPE_VECTOR3: number;
  3881. /**
  3882. * Get the Vectpr2 animation type
  3883. */
  3884. static readonly ANIMATIONTYPE_VECTOR2: number;
  3885. /**
  3886. * Get the Size animation type
  3887. */
  3888. static readonly ANIMATIONTYPE_SIZE: number;
  3889. /**
  3890. * Get the Quaternion animation type
  3891. */
  3892. static readonly ANIMATIONTYPE_QUATERNION: number;
  3893. /**
  3894. * Get the Matrix animation type
  3895. */
  3896. static readonly ANIMATIONTYPE_MATRIX: number;
  3897. /**
  3898. * Get the Color3 animation type
  3899. */
  3900. static readonly ANIMATIONTYPE_COLOR3: number;
  3901. /**
  3902. * Get the Relative Loop Mode
  3903. */
  3904. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  3905. /**
  3906. * Get the Cycle Loop Mode
  3907. */
  3908. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  3909. /**
  3910. * Get the Constant Loop Mode
  3911. */
  3912. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  3913. /** @hidden */
  3914. private static _UniversalLerp(left: any, right: any, amount: number): any;
  3915. /**
  3916. * Parses an animation object and creates an animation
  3917. * @param parsedAnimation Parsed animation object
  3918. * @returns Animation object
  3919. */
  3920. static Parse(parsedAnimation: any): Animation;
  3921. /**
  3922. * Appends the serialized animations from the source animations
  3923. * @param source Source containing the animations
  3924. * @param destination Target to store the animations
  3925. */
  3926. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  3927. }
  3928. }
  3929. declare module BABYLON {
  3930. /**
  3931. * This class defines the direct association between an animation and a target
  3932. */
  3933. class TargetedAnimation {
  3934. animation: Animation;
  3935. target: any;
  3936. }
  3937. /**
  3938. * Use this class to create coordinated animations on multiple targets
  3939. */
  3940. class AnimationGroup implements IDisposable {
  3941. name: string;
  3942. private _scene;
  3943. private _targetedAnimations;
  3944. private _animatables;
  3945. private _from;
  3946. private _to;
  3947. private _isStarted;
  3948. private _speedRatio;
  3949. onAnimationEndObservable: Observable<TargetedAnimation>;
  3950. /**
  3951. * This observable will notify when all animations have ended.
  3952. */
  3953. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  3954. /**
  3955. * Gets the first frame
  3956. */
  3957. readonly from: number;
  3958. /**
  3959. * Gets the last frame
  3960. */
  3961. readonly to: number;
  3962. /**
  3963. * Define if the animations are started
  3964. */
  3965. readonly isStarted: boolean;
  3966. /**
  3967. * Gets or sets the speed ratio to use for all animations
  3968. */
  3969. /**
  3970. * Gets or sets the speed ratio to use for all animations
  3971. */
  3972. speedRatio: number;
  3973. /**
  3974. * Gets the targeted animations for this animation group
  3975. */
  3976. readonly targetedAnimations: Array<TargetedAnimation>;
  3977. /**
  3978. * returning the list of animatables controlled by this animation group.
  3979. */
  3980. readonly animatables: Array<Animatable>;
  3981. constructor(name: string, scene?: Nullable<Scene>);
  3982. /**
  3983. * Add an animation (with its target) in the group
  3984. * @param animation defines the animation we want to add
  3985. * @param target defines the target of the animation
  3986. * @returns the {BABYLON.TargetedAnimation} object
  3987. */
  3988. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  3989. /**
  3990. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  3991. * It can add constant keys at begin or end
  3992. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  3993. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  3994. */
  3995. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  3996. /**
  3997. * Start all animations on given targets
  3998. * @param loop defines if animations must loop
  3999. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  4000. * @param from defines the from key (optional)
  4001. * @param to defines the to key (optional)
  4002. * @returns the current animation group
  4003. */
  4004. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  4005. /**
  4006. * Pause all animations
  4007. */
  4008. pause(): AnimationGroup;
  4009. /**
  4010. * Play all animations to initial state
  4011. * This function will start() the animations if they were not started or will restart() them if they were paused
  4012. * @param loop defines if animations must loop
  4013. */
  4014. play(loop?: boolean): AnimationGroup;
  4015. /**
  4016. * Reset all animations to initial state
  4017. */
  4018. reset(): AnimationGroup;
  4019. /**
  4020. * Restart animations from key 0
  4021. */
  4022. restart(): AnimationGroup;
  4023. /**
  4024. * Stop all animations
  4025. */
  4026. stop(): AnimationGroup;
  4027. /**
  4028. * Set animation weight for all animatables
  4029. * @param weight defines the weight to use
  4030. * @return the animationGroup
  4031. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  4032. */
  4033. setWeightForAllAnimatables(weight: number): AnimationGroup;
  4034. /**
  4035. * Synchronize and normalize all animatables with a source animatable
  4036. * @param root defines the root animatable to synchronize with
  4037. * @return the animationGroup
  4038. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  4039. */
  4040. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  4041. /**
  4042. * Goes to a specific frame in this animation group
  4043. * @param frame the frame number to go to
  4044. * @return the animationGroup
  4045. */
  4046. goToFrame(frame: number): AnimationGroup;
  4047. /**
  4048. * Dispose all associated resources
  4049. */
  4050. dispose(): void;
  4051. private _checkAnimationGroupEnded(animatable);
  4052. }
  4053. }
  4054. declare module BABYLON {
  4055. /**
  4056. * Class used to override all child animations of a given target
  4057. */
  4058. class AnimationPropertiesOverride {
  4059. /**
  4060. * Gets or sets a value indicating if animation blending must be used
  4061. */
  4062. enableBlending: boolean;
  4063. /**
  4064. * Gets or sets the blending speed to use when enableBlending is true
  4065. */
  4066. blendingSpeed: number;
  4067. /**
  4068. * Gets or sets the default loop mode to use
  4069. */
  4070. loopMode: number;
  4071. }
  4072. }
  4073. declare module BABYLON {
  4074. interface IEasingFunction {
  4075. ease(gradient: number): number;
  4076. }
  4077. class EasingFunction implements IEasingFunction {
  4078. private static _EASINGMODE_EASEIN;
  4079. private static _EASINGMODE_EASEOUT;
  4080. private static _EASINGMODE_EASEINOUT;
  4081. static readonly EASINGMODE_EASEIN: number;
  4082. static readonly EASINGMODE_EASEOUT: number;
  4083. static readonly EASINGMODE_EASEINOUT: number;
  4084. private _easingMode;
  4085. setEasingMode(easingMode: number): void;
  4086. getEasingMode(): number;
  4087. easeInCore(gradient: number): number;
  4088. ease(gradient: number): number;
  4089. }
  4090. class CircleEase extends EasingFunction implements IEasingFunction {
  4091. easeInCore(gradient: number): number;
  4092. }
  4093. class BackEase extends EasingFunction implements IEasingFunction {
  4094. amplitude: number;
  4095. constructor(amplitude?: number);
  4096. easeInCore(gradient: number): number;
  4097. }
  4098. class BounceEase extends EasingFunction implements IEasingFunction {
  4099. bounces: number;
  4100. bounciness: number;
  4101. constructor(bounces?: number, bounciness?: number);
  4102. easeInCore(gradient: number): number;
  4103. }
  4104. class CubicEase extends EasingFunction implements IEasingFunction {
  4105. easeInCore(gradient: number): number;
  4106. }
  4107. class ElasticEase extends EasingFunction implements IEasingFunction {
  4108. oscillations: number;
  4109. springiness: number;
  4110. constructor(oscillations?: number, springiness?: number);
  4111. easeInCore(gradient: number): number;
  4112. }
  4113. class ExponentialEase extends EasingFunction implements IEasingFunction {
  4114. exponent: number;
  4115. constructor(exponent?: number);
  4116. easeInCore(gradient: number): number;
  4117. }
  4118. class PowerEase extends EasingFunction implements IEasingFunction {
  4119. power: number;
  4120. constructor(power?: number);
  4121. easeInCore(gradient: number): number;
  4122. }
  4123. class QuadraticEase extends EasingFunction implements IEasingFunction {
  4124. easeInCore(gradient: number): number;
  4125. }
  4126. class QuarticEase extends EasingFunction implements IEasingFunction {
  4127. easeInCore(gradient: number): number;
  4128. }
  4129. class QuinticEase extends EasingFunction implements IEasingFunction {
  4130. easeInCore(gradient: number): number;
  4131. }
  4132. class SineEase extends EasingFunction implements IEasingFunction {
  4133. easeInCore(gradient: number): number;
  4134. }
  4135. class BezierCurveEase extends EasingFunction implements IEasingFunction {
  4136. x1: number;
  4137. y1: number;
  4138. x2: number;
  4139. y2: number;
  4140. constructor(x1?: number, y1?: number, x2?: number, y2?: number);
  4141. easeInCore(gradient: number): number;
  4142. }
  4143. }
  4144. declare module BABYLON {
  4145. /**
  4146. * Defines a runtime animation
  4147. */
  4148. class RuntimeAnimation {
  4149. private _events;
  4150. /**
  4151. * The current frame of the runtime animation
  4152. */
  4153. private _currentFrame;
  4154. /**
  4155. * The animation used by the runtime animation
  4156. */
  4157. private _animation;
  4158. /**
  4159. * The target of the runtime animation
  4160. */
  4161. private _target;
  4162. /**
  4163. * The initiating animatable
  4164. */
  4165. private _host;
  4166. /**
  4167. * The original value of the runtime animation
  4168. */
  4169. private _originalValue;
  4170. /**
  4171. * The original blend value of the runtime animation
  4172. */
  4173. private _originalBlendValue;
  4174. /**
  4175. * The offsets cache of the runtime animation
  4176. */
  4177. private _offsetsCache;
  4178. /**
  4179. * The high limits cache of the runtime animation
  4180. */
  4181. private _highLimitsCache;
  4182. /**
  4183. * Specifies if the runtime animation has been stopped
  4184. */
  4185. private _stopped;
  4186. /**
  4187. * The blending factor of the runtime animation
  4188. */
  4189. private _blendingFactor;
  4190. /**
  4191. * The BabylonJS scene
  4192. */
  4193. private _scene;
  4194. /**
  4195. * The current value of the runtime animation
  4196. */
  4197. private _currentValue;
  4198. /** @hidden */
  4199. /**
  4200. * The active target of the runtime animation
  4201. */
  4202. private _activeTarget;
  4203. /**
  4204. * The target path of the runtime animation
  4205. */
  4206. private _targetPath;
  4207. /**
  4208. * The weight of the runtime animation
  4209. */
  4210. private _weight;
  4211. /**
  4212. * The ratio offset of the runtime animation
  4213. */
  4214. private _ratioOffset;
  4215. /**
  4216. * The previous delay of the runtime animation
  4217. */
  4218. private _previousDelay;
  4219. /**
  4220. * The previous ratio of the runtime animation
  4221. */
  4222. private _previousRatio;
  4223. /**
  4224. * Gets the current frame of the runtime animation
  4225. */
  4226. readonly currentFrame: number;
  4227. /**
  4228. * Gets the weight of the runtime animation
  4229. */
  4230. readonly weight: number;
  4231. /**
  4232. * Gets the current value of the runtime animation
  4233. */
  4234. readonly currentValue: any;
  4235. /**
  4236. * Gets the target path of the runtime animation
  4237. */
  4238. readonly targetPath: string;
  4239. /**
  4240. * Gets the actual target of the runtime animation
  4241. */
  4242. readonly target: any;
  4243. /**
  4244. * Create a new RuntimeAnimation object
  4245. * @param target defines the target of the animation
  4246. * @param animation defines the source animation object
  4247. * @param scene defines the hosting scene
  4248. * @param host defines the initiating Animatable
  4249. */
  4250. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  4251. /**
  4252. * Gets the animation from the runtime animation
  4253. */
  4254. readonly animation: Animation;
  4255. /**
  4256. * Resets the runtime animation to the beginning
  4257. * @param restoreOriginal defines whether to restore the target property to the original value
  4258. */
  4259. reset(restoreOriginal?: boolean): void;
  4260. /**
  4261. * Specifies if the runtime animation is stopped
  4262. * @returns Boolean specifying if the runtime animation is stopped
  4263. */
  4264. isStopped(): boolean;
  4265. /**
  4266. * Disposes of the runtime animation
  4267. */
  4268. dispose(): void;
  4269. /**
  4270. * Interpolates the animation from the current frame
  4271. * @param currentFrame The frame to interpolate the animation to
  4272. * @param repeatCount The number of times that the animation should loop
  4273. * @param loopMode The type of looping mode to use
  4274. * @param offsetValue Animation offset value
  4275. * @param highLimitValue The high limit value
  4276. * @returns The interpolated value
  4277. */
  4278. private _interpolate(currentFrame, repeatCount, loopMode?, offsetValue?, highLimitValue?);
  4279. /**
  4280. * Apply the interpolated value to the target
  4281. * @param currentValue defines the value computed by the animation
  4282. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  4283. */
  4284. setValue(currentValue: any, weight?: number): void;
  4285. private _setValue(target, currentValue, weight, targetIndex?);
  4286. /**
  4287. * Gets the loop pmode of the runtime animation
  4288. * @returns Loop Mode
  4289. */
  4290. private _getCorrectLoopMode();
  4291. /**
  4292. * Move the current animation to a given frame
  4293. * @param frame defines the frame to move to
  4294. */
  4295. goToFrame(frame: number): void;
  4296. /**
  4297. * @hidden Internal use only
  4298. */
  4299. /**
  4300. * Execute the current animation
  4301. * @param delay defines the delay to add to the current frame
  4302. * @param from defines the lower bound of the animation range
  4303. * @param to defines the upper bound of the animation range
  4304. * @param loop defines if the current animation must loop
  4305. * @param speedRatio defines the current speed ratio
  4306. * @param weight defines the weight of the animation (default is -1 so no weight)
  4307. * @returns a boolean indicating if the animation has ended
  4308. */
  4309. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  4310. }
  4311. }
  4312. declare module BABYLON {
  4313. /**
  4314. * Class used to work with sound analyzer using fast fourier transform (FFT)
  4315. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  4316. */
  4317. class Analyser {
  4318. /**
  4319. * Gets or sets the smoothing
  4320. * @ignorenaming
  4321. */
  4322. SMOOTHING: number;
  4323. /**
  4324. * Gets or sets the FFT table size
  4325. * @ignorenaming
  4326. */
  4327. FFT_SIZE: number;
  4328. /**
  4329. * Gets or sets the bar graph amplitude
  4330. * @ignorenaming
  4331. */
  4332. BARGRAPHAMPLITUDE: number;
  4333. /**
  4334. * Gets or sets the position of the debug canvas
  4335. * @ignorenaming
  4336. */
  4337. DEBUGCANVASPOS: {
  4338. x: number;
  4339. y: number;
  4340. };
  4341. /**
  4342. * Gets or sets the debug canvas size
  4343. * @ignorenaming
  4344. */
  4345. DEBUGCANVASSIZE: {
  4346. width: number;
  4347. height: number;
  4348. };
  4349. private _byteFreqs;
  4350. private _byteTime;
  4351. private _floatFreqs;
  4352. private _webAudioAnalyser;
  4353. private _debugCanvas;
  4354. private _debugCanvasContext;
  4355. private _scene;
  4356. private _registerFunc;
  4357. private _audioEngine;
  4358. /**
  4359. * Creates a new analyser
  4360. * @param scene defines hosting scene
  4361. */
  4362. constructor(scene: Scene);
  4363. /**
  4364. * Get the number of data values you will have to play with for the visualization
  4365. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  4366. * @returns a number
  4367. */
  4368. getFrequencyBinCount(): number;
  4369. /**
  4370. * Gets the current frequency data as a byte array
  4371. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  4372. * @returns a Uint8Array
  4373. */
  4374. getByteFrequencyData(): Uint8Array;
  4375. /**
  4376. * Gets the current waveform as a byte array
  4377. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  4378. * @returns a Uint8Array
  4379. */
  4380. getByteTimeDomainData(): Uint8Array;
  4381. /**
  4382. * Gets the current frequency data as a float array
  4383. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  4384. * @returns a Float32Array
  4385. */
  4386. getFloatFrequencyData(): Float32Array;
  4387. /**
  4388. * Renders the debug canvas
  4389. */
  4390. drawDebugCanvas(): void;
  4391. /**
  4392. * Stops rendering the debug canvas and removes it
  4393. */
  4394. stopDebugCanvas(): void;
  4395. /**
  4396. * Connects two audio nodes
  4397. * @param inputAudioNode defines first node to connect
  4398. * @param outputAudioNode defines second node to connect
  4399. */
  4400. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  4401. /**
  4402. * Releases all associated resources
  4403. */
  4404. dispose(): void;
  4405. }
  4406. }
  4407. declare module BABYLON {
  4408. class AudioEngine {
  4409. private _audioContext;
  4410. private _audioContextInitialized;
  4411. canUseWebAudio: boolean;
  4412. masterGain: GainNode;
  4413. private _connectedAnalyser;
  4414. WarnedWebAudioUnsupported: boolean;
  4415. unlocked: boolean;
  4416. onAudioUnlocked: () => any;
  4417. isMP3supported: boolean;
  4418. isOGGsupported: boolean;
  4419. readonly audioContext: Nullable<AudioContext>;
  4420. constructor();
  4421. private _unlockiOSaudio();
  4422. private _initializeAudioContext();
  4423. dispose(): void;
  4424. getGlobalVolume(): number;
  4425. setGlobalVolume(newVolume: number): void;
  4426. connectToAnalyser(analyser: Analyser): void;
  4427. }
  4428. }
  4429. declare module BABYLON {
  4430. class Sound {
  4431. name: string;
  4432. autoplay: boolean;
  4433. loop: boolean;
  4434. useCustomAttenuation: boolean;
  4435. soundTrackId: number;
  4436. spatialSound: boolean;
  4437. refDistance: number;
  4438. rolloffFactor: number;
  4439. maxDistance: number;
  4440. distanceModel: string;
  4441. private _panningModel;
  4442. onended: () => any;
  4443. private _playbackRate;
  4444. private _streaming;
  4445. private _startTime;
  4446. private _startOffset;
  4447. private _position;
  4448. private _localDirection;
  4449. private _volume;
  4450. private _isReadyToPlay;
  4451. isPlaying: boolean;
  4452. isPaused: boolean;
  4453. private _isDirectional;
  4454. private _readyToPlayCallback;
  4455. private _audioBuffer;
  4456. private _soundSource;
  4457. private _streamingSource;
  4458. private _soundPanner;
  4459. private _soundGain;
  4460. private _inputAudioNode;
  4461. private _ouputAudioNode;
  4462. private _coneInnerAngle;
  4463. private _coneOuterAngle;
  4464. private _coneOuterGain;
  4465. private _scene;
  4466. private _connectedMesh;
  4467. private _customAttenuationFunction;
  4468. private _registerFunc;
  4469. private _isOutputConnected;
  4470. private _htmlAudioElement;
  4471. private _urlType;
  4472. /**
  4473. * Create a sound and attach it to a scene
  4474. * @param name Name of your sound
  4475. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  4476. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  4477. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  4478. */
  4479. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  4480. dispose(): void;
  4481. isReady(): boolean;
  4482. private _soundLoaded(audioData);
  4483. setAudioBuffer(audioBuffer: AudioBuffer): void;
  4484. updateOptions(options: any): void;
  4485. private _createSpatialParameters();
  4486. private _updateSpatialParameters();
  4487. switchPanningModelToHRTF(): void;
  4488. switchPanningModelToEqualPower(): void;
  4489. private _switchPanningModel();
  4490. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  4491. /**
  4492. * Transform this sound into a directional source
  4493. * @param coneInnerAngle Size of the inner cone in degree
  4494. * @param coneOuterAngle Size of the outer cone in degree
  4495. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  4496. */
  4497. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  4498. setPosition(newPosition: Vector3): void;
  4499. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  4500. private _updateDirection();
  4501. updateDistanceFromListener(): void;
  4502. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  4503. /**
  4504. * Play the sound
  4505. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  4506. * @param offset (optional) Start the sound setting it at a specific time
  4507. */
  4508. play(time?: number, offset?: number): void;
  4509. private _onended();
  4510. /**
  4511. * Stop the sound
  4512. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  4513. */
  4514. stop(time?: number): void;
  4515. pause(): void;
  4516. setVolume(newVolume: number, time?: number): void;
  4517. setPlaybackRate(newPlaybackRate: number): void;
  4518. getVolume(): number;
  4519. attachToMesh(meshToConnectTo: AbstractMesh): void;
  4520. detachFromMesh(): void;
  4521. private _onRegisterAfterWorldMatrixUpdate(node);
  4522. clone(): Nullable<Sound>;
  4523. getAudioBuffer(): AudioBuffer | null;
  4524. serialize(): any;
  4525. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  4526. }
  4527. }
  4528. declare module BABYLON {
  4529. class SoundTrack {
  4530. private _outputAudioNode;
  4531. private _scene;
  4532. id: number;
  4533. soundCollection: Array<Sound>;
  4534. private _isMainTrack;
  4535. private _connectedAnalyser;
  4536. private _options;
  4537. private _isInitialized;
  4538. constructor(scene: Scene, options?: any);
  4539. private _initializeSoundTrackAudioGraph();
  4540. dispose(): void;
  4541. AddSound(sound: Sound): void;
  4542. RemoveSound(sound: Sound): void;
  4543. setVolume(newVolume: number): void;
  4544. switchPanningModelToHRTF(): void;
  4545. switchPanningModelToEqualPower(): void;
  4546. connectToAnalyser(analyser: Analyser): void;
  4547. }
  4548. }
  4549. declare module BABYLON {
  4550. /**
  4551. * Class used to store bone information
  4552. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  4553. */
  4554. class Bone extends Node {
  4555. /**
  4556. * defines the bone name
  4557. */
  4558. name: string;
  4559. private static _tmpVecs;
  4560. private static _tmpQuat;
  4561. private static _tmpMats;
  4562. /**
  4563. * Gets the list of child bones
  4564. */
  4565. children: Bone[];
  4566. /** Gets the animations associated with this bone */
  4567. animations: Animation[];
  4568. /**
  4569. * Gets or sets bone length
  4570. */
  4571. length: number;
  4572. /**
  4573. * @hidden Internal only
  4574. * Set this value to map this bone to a different index in the transform matrices
  4575. * Set this value to -1 to exclude the bone from the transform matrices
  4576. */
  4577. private _skeleton;
  4578. private _localMatrix;
  4579. private _restPose;
  4580. private _baseMatrix;
  4581. private _absoluteTransform;
  4582. private _invertedAbsoluteTransform;
  4583. private _parent;
  4584. private _scalingDeterminant;
  4585. private _worldTransform;
  4586. private _localScaling;
  4587. private _localRotation;
  4588. private _localPosition;
  4589. private _needToDecompose;
  4590. private _needToCompose;
  4591. /** @hidden */
  4592. /** @hidden */
  4593. /**
  4594. * Create a new bone
  4595. * @param name defines the bone name
  4596. * @param skeleton defines the parent skeleton
  4597. * @param parentBone defines the parent (can be null if the bone is the root)
  4598. * @param localMatrix defines the local matrix
  4599. * @param restPose defines the rest pose matrix
  4600. * @param baseMatrix defines the base matrix
  4601. * @param index defines index of the bone in the hiearchy
  4602. */
  4603. constructor(
  4604. /**
  4605. * defines the bone name
  4606. */
  4607. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  4608. /**
  4609. * Gets the parent skeleton
  4610. * @returns a skeleton
  4611. */
  4612. getSkeleton(): Skeleton;
  4613. /**
  4614. * Gets parent bone
  4615. * @returns a bone or null if the bone is the root of the bone hierarchy
  4616. */
  4617. getParent(): Nullable<Bone>;
  4618. /**
  4619. * Sets the parent bone
  4620. * @param parent defines the parent (can be null if the bone is the root)
  4621. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  4622. */
  4623. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  4624. /**
  4625. * Gets the local matrix
  4626. * @returns a matrix
  4627. */
  4628. getLocalMatrix(): Matrix;
  4629. /**
  4630. * Gets the base matrix (initial matrix which remains unchanged)
  4631. * @returns a matrix
  4632. */
  4633. getBaseMatrix(): Matrix;
  4634. /**
  4635. * Gets the rest pose matrix
  4636. * @returns a matrix
  4637. */
  4638. getRestPose(): Matrix;
  4639. /**
  4640. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  4641. */
  4642. getWorldMatrix(): Matrix;
  4643. /**
  4644. * Sets the local matrix to rest pose matrix
  4645. */
  4646. returnToRest(): void;
  4647. /**
  4648. * Gets the inverse of the absolute transform matrix.
  4649. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  4650. * @returns a matrix
  4651. */
  4652. getInvertedAbsoluteTransform(): Matrix;
  4653. /**
  4654. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  4655. * @returns a matrix
  4656. */
  4657. getAbsoluteTransform(): Matrix;
  4658. /** Gets or sets current position (in local space) */
  4659. position: Vector3;
  4660. /** Gets or sets current rotation (in local space) */
  4661. rotation: Vector3;
  4662. /** Gets or sets current rotation quaternion (in local space) */
  4663. rotationQuaternion: Quaternion;
  4664. /** Gets or sets current scaling (in local space) */
  4665. scaling: Vector3;
  4666. /**
  4667. * Gets the animation properties override
  4668. */
  4669. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  4670. private _decompose();
  4671. private _compose();
  4672. /**
  4673. * Update the base and local matrices
  4674. * @param matrix defines the new base or local matrix
  4675. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  4676. * @param updateLocalMatrix defines if the local matrix should be updated
  4677. */
  4678. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  4679. /** @hidden */
  4680. /**
  4681. * Flag the bone as dirty (Forcing it to update everything)
  4682. */
  4683. markAsDirty(): void;
  4684. private _markAsDirtyAndCompose();
  4685. private _markAsDirtyAndDecompose();
  4686. /**
  4687. * Copy an animation range from another bone
  4688. * @param source defines the source bone
  4689. * @param rangeName defines the range name to copy
  4690. * @param frameOffset defines the frame offset
  4691. * @param rescaleAsRequired defines if rescaling must be applied if required
  4692. * @param skelDimensionsRatio defines the scaling ratio
  4693. * @returns true if operation was successful
  4694. */
  4695. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired?: boolean, skelDimensionsRatio?: Nullable<Vector3>): boolean;
  4696. /**
  4697. * Translate the bone in local or world space
  4698. * @param vec The amount to translate the bone
  4699. * @param space The space that the translation is in
  4700. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4701. */
  4702. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  4703. /**
  4704. * Set the postion of the bone in local or world space
  4705. * @param position The position to set the bone
  4706. * @param space The space that the position is in
  4707. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4708. */
  4709. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  4710. /**
  4711. * Set the absolute position of the bone (world space)
  4712. * @param position The position to set the bone
  4713. * @param mesh The mesh that this bone is attached to
  4714. */
  4715. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  4716. /**
  4717. * Scale the bone on the x, y and z axes (in local space)
  4718. * @param x The amount to scale the bone on the x axis
  4719. * @param y The amount to scale the bone on the y axis
  4720. * @param z The amount to scale the bone on the z axis
  4721. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  4722. */
  4723. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  4724. /**
  4725. * Set the bone scaling in local space
  4726. * @param scale defines the scaling vector
  4727. */
  4728. setScale(scale: Vector3): void;
  4729. /**
  4730. * Gets the current scaling in local space
  4731. * @returns the current scaling vector
  4732. */
  4733. getScale(): Vector3;
  4734. /**
  4735. * Gets the current scaling in local space and stores it in a target vector
  4736. * @param result defines the target vector
  4737. */
  4738. getScaleToRef(result: Vector3): void;
  4739. /**
  4740. * Set the yaw, pitch, and roll of the bone in local or world space
  4741. * @param yaw The rotation of the bone on the y axis
  4742. * @param pitch The rotation of the bone on the x axis
  4743. * @param roll The rotation of the bone on the z axis
  4744. * @param space The space that the axes of rotation are in
  4745. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4746. */
  4747. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  4748. /**
  4749. * Add a rotation to the bone on an axis in local or world space
  4750. * @param axis The axis to rotate the bone on
  4751. * @param amount The amount to rotate the bone
  4752. * @param space The space that the axis is in
  4753. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4754. */
  4755. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  4756. /**
  4757. * Set the rotation of the bone to a particular axis angle in local or world space
  4758. * @param axis The axis to rotate the bone on
  4759. * @param angle The angle that the bone should be rotated to
  4760. * @param space The space that the axis is in
  4761. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4762. */
  4763. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  4764. /**
  4765. * Set the euler rotation of the bone in local of world space
  4766. * @param rotation The euler rotation that the bone should be set to
  4767. * @param space The space that the rotation is in
  4768. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4769. */
  4770. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  4771. /**
  4772. * Set the quaternion rotation of the bone in local of world space
  4773. * @param quat The quaternion rotation that the bone should be set to
  4774. * @param space The space that the rotation is in
  4775. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4776. */
  4777. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  4778. /**
  4779. * Set the rotation matrix of the bone in local of world space
  4780. * @param rotMat The rotation matrix that the bone should be set to
  4781. * @param space The space that the rotation is in
  4782. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4783. */
  4784. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  4785. private _rotateWithMatrix(rmat, space?, mesh?);
  4786. private _getNegativeRotationToRef(rotMatInv, mesh?);
  4787. /**
  4788. * Get the position of the bone in local or world space
  4789. * @param space The space that the returned position is in
  4790. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4791. * @returns The position of the bone
  4792. */
  4793. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  4794. /**
  4795. * Copy the position of the bone to a vector3 in local or world space
  4796. * @param space The space that the returned position is in
  4797. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4798. * @param result The vector3 to copy the position to
  4799. */
  4800. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  4801. /**
  4802. * Get the absolute position of the bone (world space)
  4803. * @param mesh The mesh that this bone is attached to
  4804. * @returns The absolute position of the bone
  4805. */
  4806. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  4807. /**
  4808. * Copy the absolute position of the bone (world space) to the result param
  4809. * @param mesh The mesh that this bone is attached to
  4810. * @param result The vector3 to copy the absolute position to
  4811. */
  4812. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  4813. /**
  4814. * Compute the absolute transforms of this bone and its children
  4815. */
  4816. computeAbsoluteTransforms(): void;
  4817. /**
  4818. * Get the world direction from an axis that is in the local space of the bone
  4819. * @param localAxis The local direction that is used to compute the world direction
  4820. * @param mesh The mesh that this bone is attached to
  4821. * @returns The world direction
  4822. */
  4823. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  4824. /**
  4825. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  4826. * @param localAxis The local direction that is used to compute the world direction
  4827. * @param mesh The mesh that this bone is attached to
  4828. * @param result The vector3 that the world direction will be copied to
  4829. */
  4830. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  4831. /**
  4832. * Get the euler rotation of the bone in local or world space
  4833. * @param space The space that the rotation should be in
  4834. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4835. * @returns The euler rotation
  4836. */
  4837. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  4838. /**
  4839. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  4840. * @param space The space that the rotation should be in
  4841. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4842. * @param result The vector3 that the rotation should be copied to
  4843. */
  4844. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  4845. /**
  4846. * Get the quaternion rotation of the bone in either local or world space
  4847. * @param space The space that the rotation should be in
  4848. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4849. * @returns The quaternion rotation
  4850. */
  4851. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  4852. /**
  4853. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  4854. * @param space The space that the rotation should be in
  4855. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4856. * @param result The quaternion that the rotation should be copied to
  4857. */
  4858. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  4859. /**
  4860. * Get the rotation matrix of the bone in local or world space
  4861. * @param space The space that the rotation should be in
  4862. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4863. * @returns The rotation matrix
  4864. */
  4865. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  4866. /**
  4867. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  4868. * @param space The space that the rotation should be in
  4869. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4870. * @param result The quaternion that the rotation should be copied to
  4871. */
  4872. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  4873. /**
  4874. * Get the world position of a point that is in the local space of the bone
  4875. * @param position The local position
  4876. * @param mesh The mesh that this bone is attached to
  4877. * @returns The world position
  4878. */
  4879. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  4880. /**
  4881. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  4882. * @param position The local position
  4883. * @param mesh The mesh that this bone is attached to
  4884. * @param result The vector3 that the world position should be copied to
  4885. */
  4886. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  4887. /**
  4888. * Get the local position of a point that is in world space
  4889. * @param position The world position
  4890. * @param mesh The mesh that this bone is attached to
  4891. * @returns The local position
  4892. */
  4893. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  4894. /**
  4895. * Get the local position of a point that is in world space and copy it to the result param
  4896. * @param position The world position
  4897. * @param mesh The mesh that this bone is attached to
  4898. * @param result The vector3 that the local position should be copied to
  4899. */
  4900. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  4901. }
  4902. }
  4903. declare module BABYLON {
  4904. /**
  4905. * Class used to apply inverse kinematics to bones
  4906. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  4907. */
  4908. class BoneIKController {
  4909. private static _tmpVecs;
  4910. private static _tmpQuat;
  4911. private static _tmpMats;
  4912. /**
  4913. * Gets or sets the target mesh
  4914. */
  4915. targetMesh: AbstractMesh;
  4916. /** Gets or sets the mesh used as pole */
  4917. poleTargetMesh: AbstractMesh;
  4918. /**
  4919. * Gets or sets the bone used as pole
  4920. */
  4921. poleTargetBone: Nullable<Bone>;
  4922. /**
  4923. * Gets or sets the target position
  4924. */
  4925. targetPosition: Vector3;
  4926. /**
  4927. * Gets or sets the pole target position
  4928. */
  4929. poleTargetPosition: Vector3;
  4930. /**
  4931. * Gets or sets the pole target local offset
  4932. */
  4933. poleTargetLocalOffset: Vector3;
  4934. /**
  4935. * Gets or sets the pole angle
  4936. */
  4937. poleAngle: number;
  4938. /**
  4939. * Gets or sets the mesh associated with the controller
  4940. */
  4941. mesh: AbstractMesh;
  4942. /**
  4943. * 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)
  4944. */
  4945. slerpAmount: number;
  4946. private _bone1Quat;
  4947. private _bone1Mat;
  4948. private _bone2Ang;
  4949. private _bone1;
  4950. private _bone2;
  4951. private _bone1Length;
  4952. private _bone2Length;
  4953. private _maxAngle;
  4954. private _maxReach;
  4955. private _rightHandedSystem;
  4956. private _bendAxis;
  4957. private _slerping;
  4958. private _adjustRoll;
  4959. /**
  4960. * Gets or sets maximum allowed angle
  4961. */
  4962. maxAngle: number;
  4963. /**
  4964. * Creates a new BoneIKController
  4965. * @param mesh defines the mesh to control
  4966. * @param bone defines the bone to control
  4967. * @param options defines options to set up the controller
  4968. */
  4969. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  4970. targetMesh?: AbstractMesh;
  4971. poleTargetMesh?: AbstractMesh;
  4972. poleTargetBone?: Bone;
  4973. poleTargetLocalOffset?: Vector3;
  4974. poleAngle?: number;
  4975. bendAxis?: Vector3;
  4976. maxAngle?: number;
  4977. slerpAmount?: number;
  4978. });
  4979. private _setMaxAngle(ang);
  4980. /**
  4981. * Force the controller to update the bones
  4982. */
  4983. update(): void;
  4984. }
  4985. }
  4986. declare module BABYLON {
  4987. /**
  4988. * Class used to make a bone look toward a point in space
  4989. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  4990. */
  4991. class BoneLookController {
  4992. private static _tmpVecs;
  4993. private static _tmpQuat;
  4994. private static _tmpMats;
  4995. /**
  4996. * The target Vector3 that the bone will look at
  4997. */
  4998. target: Vector3;
  4999. /**
  5000. * The mesh that the bone is attached to
  5001. */
  5002. mesh: AbstractMesh;
  5003. /**
  5004. * The bone that will be looking to the target
  5005. */
  5006. bone: Bone;
  5007. /**
  5008. * The up axis of the coordinate system that is used when the bone is rotated
  5009. */
  5010. upAxis: Vector3;
  5011. /**
  5012. * The space that the up axis is in - BABYLON.Space.BONE, BABYLON.Space.LOCAL (default), or BABYLON.Space.WORLD
  5013. */
  5014. upAxisSpace: Space;
  5015. /**
  5016. * Used to make an adjustment to the yaw of the bone
  5017. */
  5018. adjustYaw: number;
  5019. /**
  5020. * Used to make an adjustment to the pitch of the bone
  5021. */
  5022. adjustPitch: number;
  5023. /**
  5024. * Used to make an adjustment to the roll of the bone
  5025. */
  5026. adjustRoll: number;
  5027. /**
  5028. * 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)
  5029. */
  5030. slerpAmount: number;
  5031. private _minYaw;
  5032. private _maxYaw;
  5033. private _minPitch;
  5034. private _maxPitch;
  5035. private _minYawSin;
  5036. private _minYawCos;
  5037. private _maxYawSin;
  5038. private _maxYawCos;
  5039. private _midYawConstraint;
  5040. private _minPitchTan;
  5041. private _maxPitchTan;
  5042. private _boneQuat;
  5043. private _slerping;
  5044. private _transformYawPitch;
  5045. private _transformYawPitchInv;
  5046. private _firstFrameSkipped;
  5047. private _yawRange;
  5048. private _fowardAxis;
  5049. /**
  5050. * Gets or sets the minimum yaw angle that the bone can look to
  5051. */
  5052. minYaw: number;
  5053. /**
  5054. * Gets or sets the maximum yaw angle that the bone can look to
  5055. */
  5056. maxYaw: number;
  5057. /**
  5058. * Gets or sets the minimum pitch angle that the bone can look to
  5059. */
  5060. minPitch: number;
  5061. /**
  5062. * Gets or sets the maximum pitch angle that the bone can look to
  5063. */
  5064. maxPitch: number;
  5065. /**
  5066. * Create a BoneLookController
  5067. * @param mesh the mesh that the bone belongs to
  5068. * @param bone the bone that will be looking to the target
  5069. * @param target the target Vector3 to look at
  5070. * @param settings optional settings:
  5071. * * maxYaw: the maximum angle the bone will yaw to
  5072. * * minYaw: the minimum angle the bone will yaw to
  5073. * * maxPitch: the maximum angle the bone will pitch to
  5074. * * minPitch: the minimum angle the bone will yaw to
  5075. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  5076. * * upAxis: the up axis of the coordinate system
  5077. * * upAxisSpace: the space that the up axis is in - BABYLON.Space.BONE, BABYLON.Space.LOCAL (default), or BABYLON.Space.WORLD.
  5078. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  5079. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  5080. * * adjustYaw: used to make an adjustment to the yaw of the bone
  5081. * * adjustPitch: used to make an adjustment to the pitch of the bone
  5082. * * adjustRoll: used to make an adjustment to the roll of the bone
  5083. **/
  5084. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  5085. maxYaw?: number;
  5086. minYaw?: number;
  5087. maxPitch?: number;
  5088. minPitch?: number;
  5089. slerpAmount?: number;
  5090. upAxis?: Vector3;
  5091. upAxisSpace?: Space;
  5092. yawAxis?: Vector3;
  5093. pitchAxis?: Vector3;
  5094. adjustYaw?: number;
  5095. adjustPitch?: number;
  5096. adjustRoll?: number;
  5097. });
  5098. /**
  5099. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  5100. */
  5101. update(): void;
  5102. private _getAngleDiff(ang1, ang2);
  5103. private _getAngleBetween(ang1, ang2);
  5104. private _isAngleBetween(ang, ang1, ang2);
  5105. }
  5106. }
  5107. declare module BABYLON {
  5108. /**
  5109. * Class used to handle skinning animations
  5110. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  5111. */
  5112. class Skeleton implements IAnimatable {
  5113. /** defines the skeleton name */
  5114. name: string;
  5115. /** defines the skeleton Id */
  5116. id: string;
  5117. /**
  5118. * Gets the list of child bones
  5119. */
  5120. bones: Bone[];
  5121. /**
  5122. * Gets an estimate of the dimension of the skeleton at rest
  5123. */
  5124. dimensionsAtRest: Vector3;
  5125. /**
  5126. * Gets a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  5127. */
  5128. needInitialSkinMatrix: boolean;
  5129. /**
  5130. * Gets the list of animations attached to this skeleton
  5131. */
  5132. animations: Array<Animation>;
  5133. private _scene;
  5134. private _isDirty;
  5135. private _transformMatrices;
  5136. private _meshesWithPoseMatrix;
  5137. private _animatables;
  5138. private _identity;
  5139. private _synchronizedWithMesh;
  5140. private _ranges;
  5141. private _lastAbsoluteTransformsUpdateId;
  5142. /**
  5143. * Specifies if the skeleton should be serialized
  5144. */
  5145. doNotSerialize: boolean;
  5146. private _animationPropertiesOverride;
  5147. /**
  5148. * Gets or sets the animation properties override
  5149. */
  5150. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  5151. /**
  5152. * An observable triggered before computing the skeleton's matrices
  5153. */
  5154. onBeforeComputeObservable: Observable<Skeleton>;
  5155. /**
  5156. * Creates a new skeleton
  5157. * @param name defines the skeleton name
  5158. * @param id defines the skeleton Id
  5159. * @param scene defines the hosting scene
  5160. */
  5161. constructor(
  5162. /** defines the skeleton name */
  5163. name: string,
  5164. /** defines the skeleton Id */
  5165. id: string, scene: Scene);
  5166. /**
  5167. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  5168. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  5169. * @returns a Float32Array containing matrices data
  5170. */
  5171. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  5172. /**
  5173. * Gets the current hosting scene
  5174. * @returns a scene object
  5175. */
  5176. getScene(): Scene;
  5177. /**
  5178. * Gets a string representing the current skeleton data
  5179. * @param fullDetails defines a boolean indicating if we want a verbose version
  5180. * @returns a string representing the current skeleton data
  5181. */
  5182. toString(fullDetails?: boolean): string;
  5183. /**
  5184. * Get bone's index searching by name
  5185. * @param name defines bone's name to search for
  5186. * @return the indice of the bone. Returns -1 if not found
  5187. */
  5188. getBoneIndexByName(name: string): number;
  5189. /**
  5190. * Creater a new animation range
  5191. * @param name defines the name of the range
  5192. * @param from defines the start key
  5193. * @param to defines the end key
  5194. */
  5195. createAnimationRange(name: string, from: number, to: number): void;
  5196. /**
  5197. * Delete a specific animation range
  5198. * @param name defines the name of the range
  5199. * @param deleteFrames defines if frames must be removed as well
  5200. */
  5201. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  5202. /**
  5203. * Gets a specific animation range
  5204. * @param name defines the name of the range to look for
  5205. * @returns the requested animation range or null if not found
  5206. */
  5207. getAnimationRange(name: string): Nullable<AnimationRange>;
  5208. /**
  5209. * Gets the list of all animation ranges defined on this skeleton
  5210. * @returns an array
  5211. */
  5212. getAnimationRanges(): Nullable<AnimationRange>[];
  5213. /**
  5214. * Copy animation range from a source skeleton.
  5215. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  5216. * @param source defines the source skeleton
  5217. * @param name defines the name of the range to copy
  5218. * @param rescaleAsRequired defines if rescaling must be applied if required
  5219. * @returns true if operation was successful
  5220. */
  5221. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  5222. /**
  5223. * Forces the skeleton to go to rest pose
  5224. */
  5225. returnToRest(): void;
  5226. private _getHighestAnimationFrame();
  5227. /**
  5228. * Begin a specific animation range
  5229. * @param name defines the name of the range to start
  5230. * @param loop defines if looping must be turned on (false by default)
  5231. * @param speedRatio defines the speed ratio to apply (1 by default)
  5232. * @param onAnimationEnd defines a callback which will be called when animation will end
  5233. * @returns a new animatable
  5234. */
  5235. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  5236. /** @hidden */
  5237. /** @hidden */
  5238. /** @hidden */
  5239. /** @hidden */
  5240. /**
  5241. * Build all resources required to render a skeleton
  5242. */
  5243. prepare(): void;
  5244. /**
  5245. * Gets the list of animatables currently running for this skeleton
  5246. * @returns an array of animatables
  5247. */
  5248. getAnimatables(): IAnimatable[];
  5249. /**
  5250. * Clone the current skeleton
  5251. * @param name defines the name of the new skeleton
  5252. * @param id defines the id of the enw skeleton
  5253. * @returns the new skeleton
  5254. */
  5255. clone(name: string, id: string): Skeleton;
  5256. /**
  5257. * Enable animation blending for this skeleton
  5258. * @param blendingSpeed defines the blending speed to apply
  5259. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  5260. */
  5261. enableBlending(blendingSpeed?: number): void;
  5262. /**
  5263. * Releases all resources associated with the current skeleton
  5264. */
  5265. dispose(): void;
  5266. /**
  5267. * Serialize the skeleton in a JSON object
  5268. * @returns a JSON object
  5269. */
  5270. serialize(): any;
  5271. /**
  5272. * Creates a new skeleton from serialized data
  5273. * @param parsedSkeleton defines the serialized data
  5274. * @param scene defines the hosting scene
  5275. * @returns a new skeleton
  5276. */
  5277. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  5278. /**
  5279. * Compute all node absolute transforms
  5280. * @param forceUpdate defines if computation must be done even if cache is up to date
  5281. */
  5282. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  5283. /**
  5284. * Gets the root pose matrix
  5285. * @returns a matrix
  5286. */
  5287. getPoseMatrix(): Nullable<Matrix>;
  5288. /**
  5289. * Sorts bones per internal index
  5290. */
  5291. sortBones(): void;
  5292. private _sortBones(index, bones, visited);
  5293. }
  5294. }
  5295. declare module BABYLON {
  5296. /**
  5297. * Interface used to define a behavior
  5298. */
  5299. interface Behavior<T> {
  5300. /** gets or sets behavior's name */
  5301. name: string;
  5302. /**
  5303. * Function called when the behavior needs to be initialized (after attaching it to a target)
  5304. */
  5305. init(): void;
  5306. /**
  5307. * Called when the behavior is attached to a target
  5308. * @param target defines the target where the behavior is attached to
  5309. */
  5310. attach(target: T): void;
  5311. /**
  5312. * Called when the behavior is detached from its target
  5313. */
  5314. detach(): void;
  5315. }
  5316. /**
  5317. * Interface implemented by classes supporting behaviors
  5318. */
  5319. interface IBehaviorAware<T> {
  5320. /**
  5321. * Attach a behavior
  5322. * @param behavior defines the behavior to attach
  5323. * @returns the current host
  5324. */
  5325. addBehavior(behavior: Behavior<T>): T;
  5326. /**
  5327. * Remove a behavior from the current object
  5328. * @param behavior defines the behavior to detach
  5329. * @returns the current host
  5330. */
  5331. removeBehavior(behavior: Behavior<T>): T;
  5332. /**
  5333. * Gets a behavior using its name to search
  5334. * @param name defines the name to search
  5335. * @returns the behavior or null if not found
  5336. */
  5337. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  5338. }
  5339. }
  5340. declare module BABYLON {
  5341. class Collider {
  5342. /** Define if a collision was found */
  5343. collisionFound: boolean;
  5344. /**
  5345. * Define last intersection point in local space
  5346. */
  5347. intersectionPoint: Vector3;
  5348. /**
  5349. * Define last collided mesh
  5350. */
  5351. collidedMesh: Nullable<AbstractMesh>;
  5352. private _collisionPoint;
  5353. private _planeIntersectionPoint;
  5354. private _tempVector;
  5355. private _tempVector2;
  5356. private _tempVector3;
  5357. private _tempVector4;
  5358. private _edge;
  5359. private _baseToVertex;
  5360. private _destinationPoint;
  5361. private _slidePlaneNormal;
  5362. private _displacementVector;
  5363. private _velocity;
  5364. private _basePoint;
  5365. private _epsilon;
  5366. private _velocityWorld;
  5367. private _normalizedVelocity;
  5368. private _nearestDistance;
  5369. private _collisionMask;
  5370. collisionMask: number;
  5371. /**
  5372. * Gets the plane normal used to compute the sliding response (in local space)
  5373. */
  5374. readonly slidePlaneNormal: Vector3;
  5375. }
  5376. }
  5377. declare module BABYLON {
  5378. var CollisionWorker: string;
  5379. interface ICollisionCoordinator {
  5380. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  5381. init(scene: Scene): void;
  5382. destroy(): void;
  5383. onMeshAdded(mesh: AbstractMesh): void;
  5384. onMeshUpdated(mesh: AbstractMesh): void;
  5385. onMeshRemoved(mesh: AbstractMesh): void;
  5386. onGeometryAdded(geometry: Geometry): void;
  5387. onGeometryUpdated(geometry: Geometry): void;
  5388. onGeometryDeleted(geometry: Geometry): void;
  5389. }
  5390. interface SerializedMesh {
  5391. id: string;
  5392. name: string;
  5393. uniqueId: number;
  5394. geometryId: Nullable<string>;
  5395. sphereCenter: Array<number>;
  5396. sphereRadius: number;
  5397. boxMinimum: Array<number>;
  5398. boxMaximum: Array<number>;
  5399. worldMatrixFromCache: any;
  5400. subMeshes: Array<SerializedSubMesh>;
  5401. checkCollisions: boolean;
  5402. }
  5403. interface SerializedSubMesh {
  5404. position: number;
  5405. verticesStart: number;
  5406. verticesCount: number;
  5407. indexStart: number;
  5408. indexCount: number;
  5409. hasMaterial: boolean;
  5410. sphereCenter: Array<number>;
  5411. sphereRadius: number;
  5412. boxMinimum: Array<number>;
  5413. boxMaximum: Array<number>;
  5414. }
  5415. /**
  5416. * Interface describing the value associated with a geometry
  5417. */
  5418. interface SerializedGeometry {
  5419. /**
  5420. * Defines the unique ID of the geometry
  5421. */
  5422. id: string;
  5423. /**
  5424. * Defines the array containing the positions
  5425. */
  5426. positions: Float32Array;
  5427. /**
  5428. * Defines the array containing the indices
  5429. */
  5430. indices: Uint32Array;
  5431. /**
  5432. * Defines the array containing the normals
  5433. */
  5434. normals: Float32Array;
  5435. }
  5436. interface BabylonMessage {
  5437. taskType: WorkerTaskType;
  5438. payload: InitPayload | CollidePayload | UpdatePayload;
  5439. }
  5440. interface SerializedColliderToWorker {
  5441. position: Array<number>;
  5442. velocity: Array<number>;
  5443. radius: Array<number>;
  5444. }
  5445. /** Defines supported task for worker process */
  5446. enum WorkerTaskType {
  5447. /** Initialization */
  5448. INIT = 0,
  5449. /** Update of geometry */
  5450. UPDATE = 1,
  5451. /** Evaluate collision */
  5452. COLLIDE = 2,
  5453. }
  5454. interface WorkerReply {
  5455. error: WorkerReplyType;
  5456. taskType: WorkerTaskType;
  5457. payload?: any;
  5458. }
  5459. interface CollisionReplyPayload {
  5460. newPosition: Array<number>;
  5461. collisionId: number;
  5462. collidedMeshUniqueId: number;
  5463. }
  5464. interface InitPayload {
  5465. }
  5466. interface CollidePayload {
  5467. collisionId: number;
  5468. collider: SerializedColliderToWorker;
  5469. maximumRetry: number;
  5470. excludedMeshUniqueId: Nullable<number>;
  5471. }
  5472. interface UpdatePayload {
  5473. updatedMeshes: {
  5474. [n: number]: SerializedMesh;
  5475. };
  5476. updatedGeometries: {
  5477. [s: string]: SerializedGeometry;
  5478. };
  5479. removedMeshes: Array<number>;
  5480. removedGeometries: Array<string>;
  5481. }
  5482. /** Defines kind of replies returned by worker */
  5483. enum WorkerReplyType {
  5484. /** Success */
  5485. SUCCESS = 0,
  5486. /** Unkown error */
  5487. UNKNOWN_ERROR = 1,
  5488. }
  5489. class CollisionCoordinatorWorker implements ICollisionCoordinator {
  5490. private _scene;
  5491. private _scaledPosition;
  5492. private _scaledVelocity;
  5493. private _collisionsCallbackArray;
  5494. private _init;
  5495. private _runningUpdated;
  5496. private _worker;
  5497. private _addUpdateMeshesList;
  5498. private _addUpdateGeometriesList;
  5499. private _toRemoveMeshesArray;
  5500. private _toRemoveGeometryArray;
  5501. constructor();
  5502. static SerializeMesh: (mesh: AbstractMesh) => SerializedMesh;
  5503. static SerializeGeometry: (geometry: Geometry) => SerializedGeometry;
  5504. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  5505. init(scene: Scene): void;
  5506. destroy(): void;
  5507. onMeshAdded(mesh: AbstractMesh): void;
  5508. onMeshUpdated: (transformNode: TransformNode) => void;
  5509. onMeshRemoved(mesh: AbstractMesh): void;
  5510. onGeometryAdded(geometry: Geometry): void;
  5511. onGeometryUpdated: (geometry: Geometry) => void;
  5512. onGeometryDeleted(geometry: Geometry): void;
  5513. private _afterRender;
  5514. private _onMessageFromWorker;
  5515. }
  5516. class CollisionCoordinatorLegacy implements ICollisionCoordinator {
  5517. private _scene;
  5518. private _scaledPosition;
  5519. private _scaledVelocity;
  5520. private _finalPosition;
  5521. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  5522. init(scene: Scene): void;
  5523. destroy(): void;
  5524. onMeshAdded(mesh: AbstractMesh): void;
  5525. onMeshUpdated(mesh: AbstractMesh): void;
  5526. onMeshRemoved(mesh: AbstractMesh): void;
  5527. onGeometryAdded(geometry: Geometry): void;
  5528. onGeometryUpdated(geometry: Geometry): void;
  5529. onGeometryDeleted(geometry: Geometry): void;
  5530. private _collideWithWorld(position, velocity, collider, maximumRetry, finalPosition, excludedMesh?);
  5531. }
  5532. }
  5533. declare function importScripts(...urls: string[]): void;
  5534. declare const safePostMessage: any;
  5535. declare module BABYLON {
  5536. var WorkerIncluded: boolean;
  5537. class CollisionCache {
  5538. private _meshes;
  5539. private _geometries;
  5540. getMeshes(): {
  5541. [n: number]: SerializedMesh;
  5542. };
  5543. getGeometries(): {
  5544. [s: number]: SerializedGeometry;
  5545. };
  5546. getMesh(id: any): SerializedMesh;
  5547. addMesh(mesh: SerializedMesh): void;
  5548. removeMesh(uniqueId: number): void;
  5549. getGeometry(id: string): SerializedGeometry;
  5550. addGeometry(geometry: SerializedGeometry): void;
  5551. removeGeometry(id: string): void;
  5552. }
  5553. class CollideWorker {
  5554. collider: Collider;
  5555. private _collisionCache;
  5556. private finalPosition;
  5557. private collisionsScalingMatrix;
  5558. private collisionTranformationMatrix;
  5559. constructor(collider: Collider, _collisionCache: CollisionCache, finalPosition: Vector3);
  5560. collideWithWorld(position: Vector3, velocity: Vector3, maximumRetry: number, excludedMeshUniqueId: Nullable<number>): void;
  5561. private checkCollision(mesh);
  5562. private processCollisionsForSubMeshes(transformMatrix, mesh);
  5563. private collideForSubMesh(subMesh, transformMatrix, meshGeometry);
  5564. private checkSubmeshCollision(subMesh);
  5565. }
  5566. interface ICollisionDetector {
  5567. onInit(payload: InitPayload): void;
  5568. onUpdate(payload: UpdatePayload): void;
  5569. onCollision(payload: CollidePayload): void;
  5570. }
  5571. class CollisionDetectorTransferable implements ICollisionDetector {
  5572. private _collisionCache;
  5573. onInit(payload: InitPayload): void;
  5574. onUpdate(payload: UpdatePayload): void;
  5575. onCollision(payload: CollidePayload): void;
  5576. }
  5577. }
  5578. declare module BABYLON {
  5579. class IntersectionInfo {
  5580. bu: Nullable<number>;
  5581. bv: Nullable<number>;
  5582. distance: number;
  5583. faceId: number;
  5584. subMeshId: number;
  5585. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  5586. }
  5587. /**
  5588. * Information about the result of picking within a scene
  5589. * See https://doc.babylonjs.com/babylon101/picking_collisions
  5590. */
  5591. class PickingInfo {
  5592. /**
  5593. * If the pick collided with an object
  5594. */
  5595. hit: boolean;
  5596. /**
  5597. * Distance away where the pick collided
  5598. */
  5599. distance: number;
  5600. /**
  5601. * The location of pick collision
  5602. */
  5603. pickedPoint: Nullable<Vector3>;
  5604. /**
  5605. * The mesh corrisponding the the pick collision
  5606. */
  5607. pickedMesh: Nullable<AbstractMesh>;
  5608. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  5609. bu: number;
  5610. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  5611. bv: number;
  5612. /** The id of the face on the mesh that was picked */
  5613. faceId: number;
  5614. /** Id of the the submesh that was picked */
  5615. subMeshId: number;
  5616. /** If a sprite was picked, this will be the sprite the pick collided with */
  5617. pickedSprite: Nullable<Sprite>;
  5618. /**
  5619. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  5620. */
  5621. originMesh: Nullable<AbstractMesh>;
  5622. /**
  5623. * The ray that was used to perform the picking.
  5624. */
  5625. ray: Nullable<Ray>;
  5626. /**
  5627. * Gets the normal corrispodning to the face the pick collided with
  5628. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  5629. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  5630. * @returns The normal corrispodning to the face the pick collided with
  5631. */
  5632. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  5633. /**
  5634. * Gets the texture coordinates of where the pick occured
  5635. * @returns the vector containing the coordnates of the texture
  5636. */
  5637. getTextureCoordinates(): Nullable<Vector2>;
  5638. }
  5639. }
  5640. declare module BABYLON {
  5641. class ArcRotateCamera extends TargetCamera {
  5642. alpha: number;
  5643. beta: number;
  5644. radius: number;
  5645. protected _target: Vector3;
  5646. protected _targetHost: Nullable<AbstractMesh>;
  5647. target: Vector3;
  5648. inertialAlphaOffset: number;
  5649. inertialBetaOffset: number;
  5650. inertialRadiusOffset: number;
  5651. lowerAlphaLimit: Nullable<number>;
  5652. upperAlphaLimit: Nullable<number>;
  5653. lowerBetaLimit: number;
  5654. upperBetaLimit: number;
  5655. lowerRadiusLimit: Nullable<number>;
  5656. upperRadiusLimit: Nullable<number>;
  5657. inertialPanningX: number;
  5658. inertialPanningY: number;
  5659. pinchToPanMaxDistance: number;
  5660. panningDistanceLimit: Nullable<number>;
  5661. panningOriginTarget: Vector3;
  5662. panningInertia: number;
  5663. angularSensibilityX: number;
  5664. angularSensibilityY: number;
  5665. pinchPrecision: number;
  5666. pinchDeltaPercentage: number;
  5667. panningSensibility: number;
  5668. keysUp: number[];
  5669. keysDown: number[];
  5670. keysLeft: number[];
  5671. keysRight: number[];
  5672. wheelPrecision: number;
  5673. wheelDeltaPercentage: number;
  5674. zoomOnFactor: number;
  5675. targetScreenOffset: Vector2;
  5676. allowUpsideDown: boolean;
  5677. inputs: ArcRotateCameraInputsManager;
  5678. panningAxis: Vector3;
  5679. protected _localDirection: Vector3;
  5680. protected _transformedDirection: Vector3;
  5681. private _bouncingBehavior;
  5682. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  5683. useBouncingBehavior: boolean;
  5684. private _framingBehavior;
  5685. readonly framingBehavior: Nullable<FramingBehavior>;
  5686. useFramingBehavior: boolean;
  5687. private _autoRotationBehavior;
  5688. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  5689. useAutoRotationBehavior: boolean;
  5690. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  5691. onCollide: (collidedMesh: AbstractMesh) => void;
  5692. checkCollisions: boolean;
  5693. collisionRadius: Vector3;
  5694. protected _collider: Collider;
  5695. protected _previousPosition: Vector3;
  5696. protected _collisionVelocity: Vector3;
  5697. protected _newPosition: Vector3;
  5698. protected _previousAlpha: number;
  5699. protected _previousBeta: number;
  5700. protected _previousRadius: number;
  5701. protected _collisionTriggered: boolean;
  5702. protected _targetBoundingCenter: Nullable<Vector3>;
  5703. private _computationVector;
  5704. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  5705. protected _getTargetPosition(): Vector3;
  5706. /**
  5707. * Store current camera state (fov, position, etc..)
  5708. */
  5709. private _storedAlpha;
  5710. private _storedBeta;
  5711. private _storedRadius;
  5712. private _storedTarget;
  5713. storeState(): Camera;
  5714. /**
  5715. * Restored camera state. You must call storeState() first
  5716. */
  5717. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  5718. detachControl(element: HTMLElement): void;
  5719. protected _checkLimits(): void;
  5720. rebuildAnglesAndRadius(): void;
  5721. setPosition(position: Vector3): void;
  5722. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  5723. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  5724. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  5725. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  5726. min: Vector3;
  5727. max: Vector3;
  5728. distance: number;
  5729. }, doNotUpdateMaxZ?: boolean): void;
  5730. /**
  5731. * @override
  5732. * Override Camera.createRigCamera
  5733. */
  5734. createRigCamera(name: string, cameraIndex: number): Camera;
  5735. /**
  5736. * @override
  5737. * Override Camera._updateRigCameras
  5738. */
  5739. dispose(): void;
  5740. getClassName(): string;
  5741. }
  5742. }
  5743. declare module BABYLON {
  5744. class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  5745. constructor(camera: ArcRotateCamera);
  5746. addMouseWheel(): ArcRotateCameraInputsManager;
  5747. addPointers(): ArcRotateCameraInputsManager;
  5748. addKeyboard(): ArcRotateCameraInputsManager;
  5749. addGamepad(): ArcRotateCameraInputsManager;
  5750. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  5751. }
  5752. }
  5753. declare module BABYLON {
  5754. class Camera extends Node {
  5755. inputs: CameraInputsManager<Camera>;
  5756. private static _PERSPECTIVE_CAMERA;
  5757. private static _ORTHOGRAPHIC_CAMERA;
  5758. private static _FOVMODE_VERTICAL_FIXED;
  5759. private static _FOVMODE_HORIZONTAL_FIXED;
  5760. private static _RIG_MODE_NONE;
  5761. private static _RIG_MODE_STEREOSCOPIC_ANAGLYPH;
  5762. private static _RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL;
  5763. private static _RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED;
  5764. private static _RIG_MODE_STEREOSCOPIC_OVERUNDER;
  5765. private static _RIG_MODE_VR;
  5766. private static _RIG_MODE_WEBVR;
  5767. static readonly PERSPECTIVE_CAMERA: number;
  5768. static readonly ORTHOGRAPHIC_CAMERA: number;
  5769. /**
  5770. * This is the default FOV mode for perspective cameras.
  5771. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  5772. *
  5773. */
  5774. static readonly FOVMODE_VERTICAL_FIXED: number;
  5775. /**
  5776. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  5777. *
  5778. */
  5779. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  5780. static readonly RIG_MODE_NONE: number;
  5781. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  5782. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  5783. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  5784. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  5785. static readonly RIG_MODE_VR: number;
  5786. static readonly RIG_MODE_WEBVR: number;
  5787. static ForceAttachControlToAlwaysPreventDefault: boolean;
  5788. static UseAlternateWebVRRendering: boolean;
  5789. position: Vector3;
  5790. /**
  5791. * The vector the camera should consider as up.
  5792. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  5793. */
  5794. upVector: Vector3;
  5795. orthoLeft: Nullable<number>;
  5796. orthoRight: Nullable<number>;
  5797. orthoBottom: Nullable<number>;
  5798. orthoTop: Nullable<number>;
  5799. /**
  5800. * FOV is set in Radians. (default is 0.8)
  5801. */
  5802. fov: number;
  5803. minZ: number;
  5804. maxZ: number;
  5805. inertia: number;
  5806. mode: number;
  5807. isIntermediate: boolean;
  5808. viewport: Viewport;
  5809. /**
  5810. * Restricts the camera to viewing objects with the same layerMask.
  5811. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  5812. */
  5813. layerMask: number;
  5814. /**
  5815. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  5816. */
  5817. fovMode: number;
  5818. cameraRigMode: number;
  5819. interaxialDistance: number;
  5820. isStereoscopicSideBySide: boolean;
  5821. protected _webvrViewMatrix: Matrix;
  5822. customRenderTargets: RenderTargetTexture[];
  5823. onViewMatrixChangedObservable: Observable<Camera>;
  5824. onProjectionMatrixChangedObservable: Observable<Camera>;
  5825. onAfterCheckInputsObservable: Observable<Camera>;
  5826. onRestoreStateObservable: Observable<Camera>;
  5827. private _computedViewMatrix;
  5828. private _doNotComputeProjectionMatrix;
  5829. private _worldMatrix;
  5830. private _transformMatrix;
  5831. protected _globalPosition: Vector3;
  5832. private _frustumPlanes;
  5833. private _refreshFrustumPlanes;
  5834. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  5835. private _storedFov;
  5836. private _stateStored;
  5837. /**
  5838. * Store current camera state (fov, position, etc..)
  5839. */
  5840. storeState(): Camera;
  5841. /**
  5842. * Restores the camera state values if it has been stored. You must call storeState() first
  5843. */
  5844. protected _restoreStateValues(): boolean;
  5845. /**
  5846. * Restored camera state. You must call storeState() first
  5847. */
  5848. restoreState(): boolean;
  5849. getClassName(): string;
  5850. /**
  5851. * @param {boolean} fullDetails - support for multiple levels of logging within scene loading
  5852. */
  5853. toString(fullDetails?: boolean): string;
  5854. readonly globalPosition: Vector3;
  5855. getActiveMeshes(): SmartArray<AbstractMesh>;
  5856. isActiveMesh(mesh: Mesh): boolean;
  5857. /**
  5858. * Is this camera ready to be used/rendered
  5859. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  5860. * @return true if the camera is ready
  5861. */
  5862. isReady(completeCheck?: boolean): boolean;
  5863. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  5864. detachControl(element: HTMLElement): void;
  5865. update(): void;
  5866. readonly rigCameras: Camera[];
  5867. readonly rigPostProcess: Nullable<PostProcess>;
  5868. /**
  5869. * Internal, gets the first post proces.
  5870. * @returns the first post process to be run on this camera.
  5871. */
  5872. private _cascadePostProcessesToRigCams();
  5873. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  5874. detachPostProcess(postProcess: PostProcess): void;
  5875. getWorldMatrix(): Matrix;
  5876. getViewMatrix(force?: boolean): Matrix;
  5877. freezeProjectionMatrix(projection?: Matrix): void;
  5878. unfreezeProjectionMatrix(): void;
  5879. getProjectionMatrix(force?: boolean): Matrix;
  5880. getTranformationMatrix(): Matrix;
  5881. private updateFrustumPlanes();
  5882. isInFrustum(target: ICullable): boolean;
  5883. isCompletelyInFrustum(target: ICullable): boolean;
  5884. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  5885. /**
  5886. * Releases resources associated with this node.
  5887. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  5888. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  5889. */
  5890. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  5891. readonly leftCamera: Nullable<FreeCamera>;
  5892. readonly rightCamera: Nullable<FreeCamera>;
  5893. getLeftTarget(): Nullable<Vector3>;
  5894. getRightTarget(): Nullable<Vector3>;
  5895. setCameraRigMode(mode: number, rigParams: any): void;
  5896. private _getVRProjectionMatrix();
  5897. protected _updateCameraRotationMatrix(): void;
  5898. protected _updateWebVRCameraRotationMatrix(): void;
  5899. /**
  5900. * This function MUST be overwritten by the different WebVR cameras available.
  5901. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  5902. */
  5903. protected _getWebVRProjectionMatrix(): Matrix;
  5904. /**
  5905. * This function MUST be overwritten by the different WebVR cameras available.
  5906. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  5907. */
  5908. protected _getWebVRViewMatrix(): Matrix;
  5909. setCameraRigParameter(name: string, value: any): void;
  5910. /**
  5911. * needs to be overridden by children so sub has required properties to be copied
  5912. */
  5913. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  5914. /**
  5915. * May need to be overridden by children
  5916. */
  5917. serialize(): any;
  5918. clone(name: string): Camera;
  5919. getDirection(localAxis: Vector3): Vector3;
  5920. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  5921. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  5922. computeWorldMatrix(): Matrix;
  5923. static Parse(parsedCamera: any, scene: Scene): Camera;
  5924. }
  5925. }
  5926. declare module BABYLON {
  5927. var CameraInputTypes: {};
  5928. interface ICameraInput<TCamera extends Camera> {
  5929. camera: Nullable<TCamera>;
  5930. getClassName(): string;
  5931. getSimpleName(): string;
  5932. attachControl: (element: HTMLElement, noPreventDefault?: boolean) => void;
  5933. detachControl: (element: Nullable<HTMLElement>) => void;
  5934. checkInputs?: () => void;
  5935. }
  5936. interface CameraInputsMap<TCamera extends Camera> {
  5937. [name: string]: ICameraInput<TCamera>;
  5938. [idx: number]: ICameraInput<TCamera>;
  5939. }
  5940. class CameraInputsManager<TCamera extends Camera> {
  5941. attached: CameraInputsMap<TCamera>;
  5942. attachedElement: Nullable<HTMLElement>;
  5943. noPreventDefault: boolean;
  5944. camera: TCamera;
  5945. checkInputs: () => void;
  5946. constructor(camera: TCamera);
  5947. /**
  5948. * Add an input method to a camera.
  5949. * builtin inputs example: camera.inputs.addGamepad();
  5950. * custom inputs example: camera.inputs.add(new BABYLON.FreeCameraGamepadInput());
  5951. * @param input camera input method
  5952. */
  5953. add(input: ICameraInput<TCamera>): void;
  5954. /**
  5955. * Remove a specific input method from a camera
  5956. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  5957. * @param inputToRemove camera input method
  5958. */
  5959. remove(inputToRemove: ICameraInput<TCamera>): void;
  5960. removeByType(inputType: string): void;
  5961. private _addCheckInputs(fn);
  5962. attachInput(input: ICameraInput<TCamera>): void;
  5963. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  5964. detachElement(element: HTMLElement, disconnect?: boolean): void;
  5965. rebuildInputCheck(): void;
  5966. /**
  5967. * Remove all attached input methods from a camera
  5968. */
  5969. clear(): void;
  5970. serialize(serializedCamera: any): void;
  5971. parse(parsedCamera: any): void;
  5972. }
  5973. }
  5974. declare module BABYLON {
  5975. /**
  5976. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  5977. * being tilted forward or back and left or right.
  5978. */
  5979. class DeviceOrientationCamera extends FreeCamera {
  5980. private _initialQuaternion;
  5981. private _quaternionCache;
  5982. /**
  5983. * Creates a new device orientation camera
  5984. * @param name The name of the camera
  5985. * @param position The start position camera
  5986. * @param scene The scene the camera belongs to
  5987. */
  5988. constructor(name: string, position: Vector3, scene: Scene);
  5989. /**
  5990. * Gets the current instance class name ("DeviceOrientationCamera").
  5991. * This helps avoiding instanceof at run time.
  5992. * @returns the class name
  5993. */
  5994. getClassName(): string;
  5995. /**
  5996. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  5997. */
  5998. /**
  5999. * Reset the camera to its default orientation on the specified axis only.
  6000. * @param axis The axis to reset
  6001. */
  6002. resetToCurrentRotation(axis?: Axis): void;
  6003. }
  6004. }
  6005. declare module BABYLON {
  6006. class FollowCamera extends TargetCamera {
  6007. radius: number;
  6008. rotationOffset: number;
  6009. heightOffset: number;
  6010. cameraAcceleration: number;
  6011. maxCameraSpeed: number;
  6012. lockedTarget: Nullable<AbstractMesh>;
  6013. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  6014. private getRadians(degrees);
  6015. private follow(cameraTarget);
  6016. getClassName(): string;
  6017. }
  6018. class ArcFollowCamera extends TargetCamera {
  6019. alpha: number;
  6020. beta: number;
  6021. radius: number;
  6022. target: Nullable<AbstractMesh>;
  6023. private _cartesianCoordinates;
  6024. constructor(name: string, alpha: number, beta: number, radius: number, target: Nullable<AbstractMesh>, scene: Scene);
  6025. private follow();
  6026. getClassName(): string;
  6027. }
  6028. }
  6029. declare module BABYLON {
  6030. class FreeCamera extends TargetCamera {
  6031. ellipsoid: Vector3;
  6032. ellipsoidOffset: Vector3;
  6033. checkCollisions: boolean;
  6034. applyGravity: boolean;
  6035. inputs: FreeCameraInputsManager;
  6036. /**
  6037. * Gets the input sensibility for a mouse input. (default is 2000.0)
  6038. * Higher values reduce sensitivity.
  6039. */
  6040. /**
  6041. * Sets the input sensibility for a mouse input. (default is 2000.0)
  6042. * Higher values reduce sensitivity.
  6043. */
  6044. angularSensibility: number;
  6045. keysUp: number[];
  6046. keysDown: number[];
  6047. keysLeft: number[];
  6048. keysRight: number[];
  6049. onCollide: (collidedMesh: AbstractMesh) => void;
  6050. private _collider;
  6051. private _needMoveForGravity;
  6052. private _oldPosition;
  6053. private _diffPosition;
  6054. private _newPosition;
  6055. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  6056. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6057. detachControl(element: HTMLElement): void;
  6058. private _collisionMask;
  6059. collisionMask: number;
  6060. private _onCollisionPositionChange;
  6061. dispose(): void;
  6062. getClassName(): string;
  6063. }
  6064. }
  6065. declare module BABYLON {
  6066. class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  6067. constructor(camera: FreeCamera);
  6068. addKeyboard(): FreeCameraInputsManager;
  6069. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  6070. addGamepad(): FreeCameraInputsManager;
  6071. addDeviceOrientation(): FreeCameraInputsManager;
  6072. addTouch(): FreeCameraInputsManager;
  6073. addVirtualJoystick(): FreeCameraInputsManager;
  6074. }
  6075. }
  6076. declare module BABYLON {
  6077. class GamepadCamera extends UniversalCamera {
  6078. gamepadAngularSensibility: number;
  6079. gamepadMoveSensibility: number;
  6080. constructor(name: string, position: Vector3, scene: Scene);
  6081. getClassName(): string;
  6082. }
  6083. }
  6084. declare module BABYLON {
  6085. /**
  6086. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  6087. */
  6088. class AnaglyphFreeCamera extends FreeCamera {
  6089. /**
  6090. * Creates a new AnaglyphFreeCamera
  6091. * @param name defines camera name
  6092. * @param position defines initial position
  6093. * @param interaxialDistance defines distance between each color axis
  6094. * @param scene defines the hosting scene
  6095. */
  6096. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  6097. /**
  6098. * Gets camera class name
  6099. * @returns AnaglyphFreeCamera
  6100. */
  6101. getClassName(): string;
  6102. }
  6103. /**
  6104. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  6105. */
  6106. class AnaglyphArcRotateCamera extends ArcRotateCamera {
  6107. /**
  6108. * Creates a new AnaglyphArcRotateCamera
  6109. * @param name defines camera name
  6110. * @param alpha defines alpha angle (in radians)
  6111. * @param beta defines beta angle (in radians)
  6112. * @param radius defines radius
  6113. * @param target defines camera target
  6114. * @param interaxialDistance defines distance between each color axis
  6115. * @param scene defines the hosting scene
  6116. */
  6117. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  6118. /**
  6119. * Gets camera class name
  6120. * @returns AnaglyphArcRotateCamera
  6121. */
  6122. getClassName(): string;
  6123. }
  6124. /**
  6125. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  6126. */
  6127. class AnaglyphGamepadCamera extends GamepadCamera {
  6128. /**
  6129. * Creates a new AnaglyphGamepadCamera
  6130. * @param name defines camera name
  6131. * @param position defines initial position
  6132. * @param interaxialDistance defines distance between each color axis
  6133. * @param scene defines the hosting scene
  6134. */
  6135. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  6136. /**
  6137. * Gets camera class name
  6138. * @returns AnaglyphGamepadCamera
  6139. */
  6140. getClassName(): string;
  6141. }
  6142. /**
  6143. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  6144. */
  6145. class AnaglyphUniversalCamera extends UniversalCamera {
  6146. /**
  6147. * Creates a new AnaglyphUniversalCamera
  6148. * @param name defines camera name
  6149. * @param position defines initial position
  6150. * @param interaxialDistance defines distance between each color axis
  6151. * @param scene defines the hosting scene
  6152. */
  6153. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  6154. /**
  6155. * Gets camera class name
  6156. * @returns AnaglyphUniversalCamera
  6157. */
  6158. getClassName(): string;
  6159. }
  6160. /**
  6161. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  6162. */
  6163. class StereoscopicFreeCamera extends FreeCamera {
  6164. /**
  6165. * Creates a new StereoscopicFreeCamera
  6166. * @param name defines camera name
  6167. * @param position defines initial position
  6168. * @param interaxialDistance defines distance between each color axis
  6169. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  6170. * @param scene defines the hosting scene
  6171. */
  6172. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  6173. /**
  6174. * Gets camera class name
  6175. * @returns StereoscopicFreeCamera
  6176. */
  6177. getClassName(): string;
  6178. }
  6179. /**
  6180. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  6181. */
  6182. class StereoscopicArcRotateCamera extends ArcRotateCamera {
  6183. /**
  6184. * Creates a new StereoscopicArcRotateCamera
  6185. * @param name defines camera name
  6186. * @param alpha defines alpha angle (in radians)
  6187. * @param beta defines beta angle (in radians)
  6188. * @param radius defines radius
  6189. * @param target defines camera target
  6190. * @param interaxialDistance defines distance between each color axis
  6191. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  6192. * @param scene defines the hosting scene
  6193. */
  6194. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  6195. /**
  6196. * Gets camera class name
  6197. * @returns StereoscopicArcRotateCamera
  6198. */
  6199. getClassName(): string;
  6200. }
  6201. /**
  6202. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  6203. */
  6204. class StereoscopicGamepadCamera extends GamepadCamera {
  6205. /**
  6206. * Creates a new StereoscopicGamepadCamera
  6207. * @param name defines camera name
  6208. * @param position defines initial position
  6209. * @param interaxialDistance defines distance between each color axis
  6210. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  6211. * @param scene defines the hosting scene
  6212. */
  6213. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  6214. /**
  6215. * Gets camera class name
  6216. * @returns StereoscopicGamepadCamera
  6217. */
  6218. getClassName(): string;
  6219. }
  6220. /**
  6221. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  6222. */
  6223. class StereoscopicUniversalCamera extends UniversalCamera {
  6224. /**
  6225. * Creates a new StereoscopicUniversalCamera
  6226. * @param name defines camera name
  6227. * @param position defines initial position
  6228. * @param interaxialDistance defines distance between each color axis
  6229. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  6230. * @param scene defines the hosting scene
  6231. */
  6232. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  6233. /**
  6234. * Gets camera class name
  6235. * @returns StereoscopicUniversalCamera
  6236. */
  6237. getClassName(): string;
  6238. }
  6239. }
  6240. declare module BABYLON {
  6241. class TargetCamera extends Camera {
  6242. cameraDirection: Vector3;
  6243. cameraRotation: Vector2;
  6244. rotation: Vector3;
  6245. rotationQuaternion: Quaternion;
  6246. speed: number;
  6247. noRotationConstraint: boolean;
  6248. lockedTarget: any;
  6249. private _rigCamTransformMatrix;
  6250. private _currentUpVector;
  6251. protected _globalCurrentTarget: Vector3;
  6252. protected _globalCurrentUpVector: Vector3;
  6253. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  6254. getFrontPosition(distance: number): Vector3;
  6255. /**
  6256. * Store current camera state (fov, position, etc..)
  6257. */
  6258. private _storedPosition;
  6259. private _storedRotation;
  6260. private _storedRotationQuaternion;
  6261. storeState(): Camera;
  6262. /**
  6263. * Restored camera state. You must call storeState() first
  6264. */
  6265. setTarget(target: Vector3): void;
  6266. /**
  6267. * Return the current target position of the camera. This value is expressed in local space.
  6268. */
  6269. getTarget(): Vector3;
  6270. protected _updateCameraRotationMatrix(): void;
  6271. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  6272. /**
  6273. * @override
  6274. * Override Camera.createRigCamera
  6275. */
  6276. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  6277. /**
  6278. * @override
  6279. * Override Camera._updateRigCameras
  6280. */
  6281. private _getRigCamPosition(halfSpace, result);
  6282. getClassName(): string;
  6283. }
  6284. }
  6285. declare module BABYLON {
  6286. class TouchCamera extends FreeCamera {
  6287. touchAngularSensibility: number;
  6288. touchMoveSensibility: number;
  6289. constructor(name: string, position: Vector3, scene: Scene);
  6290. getClassName(): string;
  6291. }
  6292. }
  6293. declare module BABYLON {
  6294. class UniversalCamera extends TouchCamera {
  6295. gamepadAngularSensibility: number;
  6296. gamepadMoveSensibility: number;
  6297. constructor(name: string, position: Vector3, scene: Scene);
  6298. getClassName(): string;
  6299. }
  6300. }
  6301. declare module BABYLON {
  6302. class VirtualJoysticksCamera extends FreeCamera {
  6303. constructor(name: string, position: Vector3, scene: Scene);
  6304. getClassName(): string;
  6305. }
  6306. }
  6307. interface VRDisplay extends EventTarget {
  6308. /**
  6309. * Dictionary of capabilities describing the VRDisplay.
  6310. */
  6311. readonly capabilities: VRDisplayCapabilities;
  6312. /**
  6313. * z-depth defining the far plane of the eye view frustum
  6314. * enables mapping of values in the render target depth
  6315. * attachment to scene coordinates. Initially set to 10000.0.
  6316. */
  6317. depthFar: number;
  6318. /**
  6319. * z-depth defining the near plane of the eye view frustum
  6320. * enables mapping of values in the render target depth
  6321. * attachment to scene coordinates. Initially set to 0.01.
  6322. */
  6323. depthNear: number;
  6324. /**
  6325. * An identifier for this distinct VRDisplay. Used as an
  6326. * association point in the Gamepad API.
  6327. */
  6328. readonly displayId: number;
  6329. /**
  6330. * A display name, a user-readable name identifying it.
  6331. */
  6332. readonly displayName: string;
  6333. readonly isConnected: boolean;
  6334. readonly isPresenting: boolean;
  6335. /**
  6336. * If this VRDisplay supports room-scale experiences, the optional
  6337. * stage attribute contains details on the room-scale parameters.
  6338. */
  6339. readonly stageParameters: VRStageParameters | null;
  6340. /**
  6341. * Passing the value returned by `requestAnimationFrame` to
  6342. * `cancelAnimationFrame` will unregister the callback.
  6343. */
  6344. cancelAnimationFrame(handle: number): void;
  6345. /**
  6346. * Stops presenting to the VRDisplay.
  6347. */
  6348. exitPresent(): Promise<void>;
  6349. getEyeParameters(whichEye: string): VREyeParameters;
  6350. /**
  6351. * Populates the passed VRFrameData with the information required to render
  6352. * the current frame.
  6353. */
  6354. getFrameData(frameData: VRFrameData): boolean;
  6355. /**
  6356. * Get the layers currently being presented.
  6357. */
  6358. getLayers(): VRLayer[];
  6359. /**
  6360. * Return a VRPose containing the future predicted pose of the VRDisplay
  6361. * when the current frame will be presented. The value returned will not
  6362. * change until JavaScript has returned control to the browser.
  6363. *
  6364. * The VRPose will contain the position, orientation, velocity,
  6365. * and acceleration of each of these properties.
  6366. */
  6367. getPose(): VRPose;
  6368. /**
  6369. * Return the current instantaneous pose of the VRDisplay, with no
  6370. * prediction applied.
  6371. */
  6372. getImmediatePose(): VRPose;
  6373. /**
  6374. * The callback passed to `requestAnimationFrame` will be called
  6375. * any time a new frame should be rendered. When the VRDisplay is
  6376. * presenting the callback will be called at the native refresh
  6377. * rate of the HMD. When not presenting this function acts
  6378. * identically to how window.requestAnimationFrame acts. Content should
  6379. * make no assumptions of frame rate or vsync behavior as the HMD runs
  6380. * asynchronously from other displays and at differing refresh rates.
  6381. */
  6382. requestAnimationFrame(callback: FrameRequestCallback): number;
  6383. /**
  6384. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  6385. * Repeat calls while already presenting will update the VRLayers being displayed.
  6386. */
  6387. requestPresent(layers: VRLayer[]): Promise<void>;
  6388. /**
  6389. * Reset the pose for this display, treating its current position and
  6390. * orientation as the "origin/zero" values. VRPose.position,
  6391. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  6392. * updated when calling resetPose(). This should be called in only
  6393. * sitting-space experiences.
  6394. */
  6395. resetPose(): void;
  6396. /**
  6397. * The VRLayer provided to the VRDisplay will be captured and presented
  6398. * in the HMD. Calling this function has the same effect on the source
  6399. * canvas as any other operation that uses its source image, and canvases
  6400. * created without preserveDrawingBuffer set to true will be cleared.
  6401. */
  6402. submitFrame(pose?: VRPose): void;
  6403. }
  6404. declare var VRDisplay: {
  6405. prototype: VRDisplay;
  6406. new (): VRDisplay;
  6407. };
  6408. interface VRLayer {
  6409. leftBounds?: number[] | null;
  6410. rightBounds?: number[] | null;
  6411. source?: HTMLCanvasElement | null;
  6412. }
  6413. interface VRDisplayCapabilities {
  6414. readonly canPresent: boolean;
  6415. readonly hasExternalDisplay: boolean;
  6416. readonly hasOrientation: boolean;
  6417. readonly hasPosition: boolean;
  6418. readonly maxLayers: number;
  6419. }
  6420. interface VREyeParameters {
  6421. /** @deprecated */
  6422. readonly fieldOfView: VRFieldOfView;
  6423. readonly offset: Float32Array;
  6424. readonly renderHeight: number;
  6425. readonly renderWidth: number;
  6426. }
  6427. interface VRFieldOfView {
  6428. readonly downDegrees: number;
  6429. readonly leftDegrees: number;
  6430. readonly rightDegrees: number;
  6431. readonly upDegrees: number;
  6432. }
  6433. interface VRFrameData {
  6434. readonly leftProjectionMatrix: Float32Array;
  6435. readonly leftViewMatrix: Float32Array;
  6436. readonly pose: VRPose;
  6437. readonly rightProjectionMatrix: Float32Array;
  6438. readonly rightViewMatrix: Float32Array;
  6439. readonly timestamp: number;
  6440. }
  6441. interface VRPose {
  6442. readonly angularAcceleration: Float32Array | null;
  6443. readonly angularVelocity: Float32Array | null;
  6444. readonly linearAcceleration: Float32Array | null;
  6445. readonly linearVelocity: Float32Array | null;
  6446. readonly orientation: Float32Array | null;
  6447. readonly position: Float32Array | null;
  6448. readonly timestamp: number;
  6449. }
  6450. interface VRStageParameters {
  6451. sittingToStandingTransform?: Float32Array;
  6452. sizeX?: number;
  6453. sizeY?: number;
  6454. }
  6455. interface Navigator {
  6456. getVRDisplays(): Promise<VRDisplay[]>;
  6457. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  6458. }
  6459. interface Window {
  6460. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  6461. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  6462. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  6463. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  6464. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  6465. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  6466. }
  6467. interface Gamepad {
  6468. readonly displayId: number;
  6469. }
  6470. declare module BABYLON {
  6471. class BoundingBox implements ICullable {
  6472. vectors: Vector3[];
  6473. center: Vector3;
  6474. centerWorld: Vector3;
  6475. extendSize: Vector3;
  6476. extendSizeWorld: Vector3;
  6477. directions: Vector3[];
  6478. vectorsWorld: Vector3[];
  6479. minimumWorld: Vector3;
  6480. maximumWorld: Vector3;
  6481. minimum: Vector3;
  6482. maximum: Vector3;
  6483. private _worldMatrix;
  6484. /**
  6485. * Creates a new bounding box
  6486. * @param min defines the minimum vector (in local space)
  6487. * @param max defines the maximum vector (in local space)
  6488. */
  6489. constructor(min: Vector3, max: Vector3);
  6490. /**
  6491. * Recreates the entire bounding box from scratch
  6492. * @param min defines the new minimum vector (in local space)
  6493. * @param max defines the new maximum vector (in local space)
  6494. */
  6495. reConstruct(min: Vector3, max: Vector3): void;
  6496. getWorldMatrix(): Matrix;
  6497. setWorldMatrix(matrix: Matrix): BoundingBox;
  6498. isInFrustum(frustumPlanes: Plane[]): boolean;
  6499. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  6500. intersectsPoint(point: Vector3): boolean;
  6501. intersectsSphere(sphere: BoundingSphere): boolean;
  6502. intersectsMinMax(min: Vector3, max: Vector3): boolean;
  6503. static Intersects(box0: BoundingBox, box1: BoundingBox): boolean;
  6504. static IntersectsSphere(minPoint: Vector3, maxPoint: Vector3, sphereCenter: Vector3, sphereRadius: number): boolean;
  6505. static IsCompletelyInFrustum(boundingVectors: Vector3[], frustumPlanes: Plane[]): boolean;
  6506. static IsInFrustum(boundingVectors: Vector3[], frustumPlanes: Plane[]): boolean;
  6507. }
  6508. }
  6509. declare module BABYLON {
  6510. interface ICullable {
  6511. isInFrustum(frustumPlanes: Plane[]): boolean;
  6512. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  6513. }
  6514. class BoundingInfo implements ICullable {
  6515. minimum: Vector3;
  6516. maximum: Vector3;
  6517. boundingBox: BoundingBox;
  6518. boundingSphere: BoundingSphere;
  6519. private _isLocked;
  6520. constructor(minimum: Vector3, maximum: Vector3);
  6521. isLocked: boolean;
  6522. update(world: Matrix): void;
  6523. /**
  6524. * Recreate the bounding info to be centered around a specific point given a specific extend.
  6525. * @param center New center of the bounding info
  6526. * @param extend New extend of the bounding info
  6527. */
  6528. centerOn(center: Vector3, extend: Vector3): BoundingInfo;
  6529. isInFrustum(frustumPlanes: Plane[]): boolean;
  6530. /**
  6531. * Gets the world distance between the min and max points of the bounding box
  6532. */
  6533. readonly diagonalLength: number;
  6534. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  6535. intersectsPoint(point: Vector3): boolean;
  6536. intersects(boundingInfo: BoundingInfo, precise: boolean): boolean;
  6537. }
  6538. }
  6539. declare module BABYLON {
  6540. class BoundingSphere {
  6541. center: Vector3;
  6542. radius: number;
  6543. centerWorld: Vector3;
  6544. radiusWorld: number;
  6545. minimum: Vector3;
  6546. maximum: Vector3;
  6547. private _tempRadiusVector;
  6548. /**
  6549. * Creates a new bounding sphere
  6550. * @param min defines the minimum vector (in local space)
  6551. * @param max defines the maximum vector (in local space)
  6552. */
  6553. constructor(min: Vector3, max: Vector3);
  6554. /**
  6555. * Recreates the entire bounding sphere from scratch
  6556. * @param min defines the new minimum vector (in local space)
  6557. * @param max defines the new maximum vector (in local space)
  6558. */
  6559. reConstruct(min: Vector3, max: Vector3): void;
  6560. isInFrustum(frustumPlanes: Plane[]): boolean;
  6561. intersectsPoint(point: Vector3): boolean;
  6562. static Intersects(sphere0: BoundingSphere, sphere1: BoundingSphere): boolean;
  6563. }
  6564. }
  6565. declare module BABYLON {
  6566. class Ray {
  6567. origin: Vector3;
  6568. direction: Vector3;
  6569. length: number;
  6570. private _edge1;
  6571. private _edge2;
  6572. private _pvec;
  6573. private _tvec;
  6574. private _qvec;
  6575. private _tmpRay;
  6576. constructor(origin: Vector3, direction: Vector3, length?: number);
  6577. intersectsBoxMinMax(minimum: Vector3, maximum: Vector3): boolean;
  6578. intersectsBox(box: BoundingBox): boolean;
  6579. intersectsSphere(sphere: BoundingSphere): boolean;
  6580. intersectsTriangle(vertex0: Vector3, vertex1: Vector3, vertex2: Vector3): Nullable<IntersectionInfo>;
  6581. intersectsPlane(plane: Plane): Nullable<number>;
  6582. intersectsMesh(mesh: AbstractMesh, fastCheck?: boolean): PickingInfo;
  6583. intersectsMeshes(meshes: Array<AbstractMesh>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  6584. private _comparePickingInfo(pickingInfoA, pickingInfoB);
  6585. private static smallnum;
  6586. private static rayl;
  6587. /**
  6588. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  6589. * @param sega the first point of the segment to test the intersection against
  6590. * @param segb the second point of the segment to test the intersection against
  6591. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  6592. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  6593. */
  6594. intersectionSegment(sega: Vector3, segb: Vector3, threshold: number): number;
  6595. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Ray;
  6596. static Zero(): Ray;
  6597. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Ray;
  6598. /**
  6599. * 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
  6600. * transformed to the given world matrix.
  6601. * @param origin The origin point
  6602. * @param end The end point
  6603. * @param world a matrix to transform the ray to. Default is the identity matrix.
  6604. */
  6605. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: Matrix): Ray;
  6606. static Transform(ray: Ray, matrix: Matrix): Ray;
  6607. static TransformToRef(ray: Ray, matrix: Matrix, result: Ray): void;
  6608. }
  6609. }
  6610. declare module BABYLON {
  6611. /**
  6612. * Interface for attribute information associated with buffer instanciation
  6613. */
  6614. class InstancingAttributeInfo {
  6615. /**
  6616. * Index/offset of the attribute in the vertex shader
  6617. */
  6618. index: number;
  6619. /**
  6620. * size of the attribute, 1, 2, 3 or 4
  6621. */
  6622. attributeSize: number;
  6623. /**
  6624. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  6625. * default is FLOAT
  6626. */
  6627. attribyteType: number;
  6628. /**
  6629. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  6630. */
  6631. normalized: boolean;
  6632. /**
  6633. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  6634. */
  6635. offset: number;
  6636. /**
  6637. * Name of the GLSL attribute, for debugging purpose only
  6638. */
  6639. attributeName: string;
  6640. }
  6641. /**
  6642. * Define options used to create a render target texture
  6643. */
  6644. class RenderTargetCreationOptions {
  6645. /**
  6646. * Specifies is mipmaps must be generated
  6647. */
  6648. generateMipMaps?: boolean;
  6649. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  6650. generateDepthBuffer?: boolean;
  6651. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  6652. generateStencilBuffer?: boolean;
  6653. /** Defines texture type (int by default) */
  6654. type?: number;
  6655. /** Defines sampling mode (trilinear by default) */
  6656. samplingMode?: number;
  6657. /** Defines format (RGBA by default) */
  6658. format?: number;
  6659. }
  6660. /**
  6661. * Define options used to create a depth texture
  6662. */
  6663. class DepthTextureCreationOptions {
  6664. /** Specifies whether or not a stencil should be allocated in the texture */
  6665. generateStencil?: boolean;
  6666. /** Specifies whether or not bilinear filtering is enable on the texture */
  6667. bilinearFiltering?: boolean;
  6668. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  6669. comparisonFunction?: number;
  6670. /** Specifies if the created texture is a cube texture */
  6671. isCube?: boolean;
  6672. }
  6673. /**
  6674. * Class used to describe the capabilities of the engine relatively to the current browser
  6675. */
  6676. class EngineCapabilities {
  6677. /** Maximum textures units per fragment shader */
  6678. maxTexturesImageUnits: number;
  6679. /** Maximum texture units per vertex shader */
  6680. maxVertexTextureImageUnits: number;
  6681. /** Maximum textures units in the entire pipeline */
  6682. maxCombinedTexturesImageUnits: number;
  6683. /** Maximum texture size */
  6684. maxTextureSize: number;
  6685. /** Maximum cube texture size */
  6686. maxCubemapTextureSize: number;
  6687. /** Maximum render texture size */
  6688. maxRenderTextureSize: number;
  6689. /** Maximum number of vertex attributes */
  6690. maxVertexAttribs: number;
  6691. /** Maximum number of varyings */
  6692. maxVaryingVectors: number;
  6693. /** Maximum number of uniforms per vertex shader */
  6694. maxVertexUniformVectors: number;
  6695. /** Maximum number of uniforms per fragment shader */
  6696. maxFragmentUniformVectors: number;
  6697. /** Defines if standard derivates (dx/dy) are supported */
  6698. standardDerivatives: boolean;
  6699. /** Defines if s3tc texture compression is supported */
  6700. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  6701. /** Defines if pvrtc texture compression is supported */
  6702. pvrtc: any;
  6703. /** Defines if etc1 texture compression is supported */
  6704. etc1: any;
  6705. /** Defines if etc2 texture compression is supported */
  6706. etc2: any;
  6707. /** Defines if astc texture compression is supported */
  6708. astc: any;
  6709. /** Defines if float textures are supported */
  6710. textureFloat: boolean;
  6711. /** Defines if vertex array objects are supported */
  6712. vertexArrayObject: boolean;
  6713. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  6714. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  6715. /** Gets the maximum level of anisotropy supported */
  6716. maxAnisotropy: number;
  6717. /** Defines if instancing is supported */
  6718. instancedArrays: boolean;
  6719. /** Defines if 32 bits indices are supported */
  6720. uintIndices: boolean;
  6721. /** Defines if high precision shaders are supported */
  6722. highPrecisionShaderSupported: boolean;
  6723. /** Defines if depth reading in the fragment shader is supported */
  6724. fragmentDepthSupported: boolean;
  6725. /** Defines if float texture linear filtering is supported*/
  6726. textureFloatLinearFiltering: boolean;
  6727. /** Defines if rendering to float textures is supported */
  6728. textureFloatRender: boolean;
  6729. /** Defines if half float textures are supported*/
  6730. textureHalfFloat: boolean;
  6731. /** Defines if half float texture linear filtering is supported*/
  6732. textureHalfFloatLinearFiltering: boolean;
  6733. /** Defines if rendering to half float textures is supported */
  6734. textureHalfFloatRender: boolean;
  6735. /** Defines if textureLOD shader command is supported */
  6736. textureLOD: boolean;
  6737. /** Defines if draw buffers extension is supported */
  6738. drawBuffersExtension: boolean;
  6739. /** Defines if depth textures are supported */
  6740. depthTextureExtension: boolean;
  6741. /** Defines if float color buffer are supported */
  6742. colorBufferFloat: boolean;
  6743. /** Gets disjoint timer query extension (null if not supported) */
  6744. timerQuery: EXT_disjoint_timer_query;
  6745. /** Defines if timestamp can be used with timer query */
  6746. canUseTimestampForTimerQuery: boolean;
  6747. }
  6748. /** Interface defining initialization parameters for Engine class */
  6749. interface EngineOptions extends WebGLContextAttributes {
  6750. /**
  6751. * Defines if the engine should no exceed a specified device ratio
  6752. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  6753. */
  6754. limitDeviceRatio?: number;
  6755. /**
  6756. * Defines if webvr should be enabled automatically
  6757. * @see http://doc.babylonjs.com/how_to/webvr_camera
  6758. */
  6759. autoEnableWebVR?: boolean;
  6760. /**
  6761. * Defines if webgl2 should be turned off even if supported
  6762. * @see http://doc.babylonjs.com/features/webgl2
  6763. */
  6764. disableWebGL2Support?: boolean;
  6765. /**
  6766. * Defines if webaudio should be initialized as well
  6767. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  6768. */
  6769. audioEngine?: boolean;
  6770. /**
  6771. * Defines if animations should run using a deterministic lock step
  6772. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  6773. */
  6774. deterministicLockstep?: boolean;
  6775. /** Defines the maximum steps to use with deterministic lock step mode */
  6776. lockstepMaxSteps?: number;
  6777. /**
  6778. * Defines that engine should ignore context lost events
  6779. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  6780. */
  6781. doNotHandleContextLost?: boolean;
  6782. }
  6783. /**
  6784. * Defines the interface used by display changed events
  6785. */
  6786. interface IDisplayChangedEventArgs {
  6787. /** Gets the vrDisplay object (if any) */
  6788. vrDisplay: Nullable<any>;
  6789. /** Gets a boolean indicating if webVR is supported */
  6790. vrSupported: boolean;
  6791. }
  6792. /**
  6793. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  6794. */
  6795. class Engine {
  6796. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  6797. static ExceptionList: ({
  6798. key: string;
  6799. capture: string;
  6800. captureConstraint: number;
  6801. targets: string[];
  6802. } | {
  6803. key: string;
  6804. capture: null;
  6805. captureConstraint: null;
  6806. targets: string[];
  6807. })[];
  6808. /** Gets the list of created engines */
  6809. static Instances: Engine[];
  6810. /**
  6811. * Gets the latest created engine
  6812. */
  6813. static readonly LastCreatedEngine: Nullable<Engine>;
  6814. /**
  6815. * Gets the latest created scene
  6816. */
  6817. static readonly LastCreatedScene: Nullable<Scene>;
  6818. /**
  6819. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  6820. * @param flag defines which part of the materials must be marked as dirty
  6821. * @param predicate defines a predicate used to filter which materials should be affected
  6822. */
  6823. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  6824. private static _ALPHA_DISABLE;
  6825. private static _ALPHA_ADD;
  6826. private static _ALPHA_COMBINE;
  6827. private static _ALPHA_SUBTRACT;
  6828. private static _ALPHA_MULTIPLY;
  6829. private static _ALPHA_MAXIMIZED;
  6830. private static _ALPHA_ONEONE;
  6831. private static _ALPHA_PREMULTIPLIED;
  6832. private static _ALPHA_PREMULTIPLIED_PORTERDUFF;
  6833. private static _ALPHA_INTERPOLATE;
  6834. private static _ALPHA_SCREENMODE;
  6835. private static _DELAYLOADSTATE_NONE;
  6836. private static _DELAYLOADSTATE_LOADED;
  6837. private static _DELAYLOADSTATE_LOADING;
  6838. private static _DELAYLOADSTATE_NOTLOADED;
  6839. private static _TEXTUREFORMAT_ALPHA;
  6840. private static _TEXTUREFORMAT_LUMINANCE;
  6841. private static _TEXTUREFORMAT_LUMINANCE_ALPHA;
  6842. private static _TEXTUREFORMAT_RGB;
  6843. private static _TEXTUREFORMAT_RGBA;
  6844. private static _TEXTUREFORMAT_R;
  6845. private static _TEXTUREFORMAT_RG;
  6846. private static _TEXTURETYPE_UNSIGNED_INT;
  6847. private static _TEXTURETYPE_FLOAT;
  6848. private static _TEXTURETYPE_HALF_FLOAT;
  6849. private static _NEVER;
  6850. private static _ALWAYS;
  6851. private static _LESS;
  6852. private static _EQUAL;
  6853. private static _LEQUAL;
  6854. private static _GREATER;
  6855. private static _GEQUAL;
  6856. private static _NOTEQUAL;
  6857. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  6858. static readonly NEVER: number;
  6859. /** 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 */
  6860. static readonly ALWAYS: number;
  6861. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  6862. static readonly LESS: number;
  6863. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  6864. static readonly EQUAL: number;
  6865. /** 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 */
  6866. static readonly LEQUAL: number;
  6867. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  6868. static readonly GREATER: number;
  6869. /** 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 */
  6870. static readonly GEQUAL: number;
  6871. /** 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 */
  6872. static readonly NOTEQUAL: number;
  6873. private static _KEEP;
  6874. private static _REPLACE;
  6875. private static _INCR;
  6876. private static _DECR;
  6877. private static _INVERT;
  6878. private static _INCR_WRAP;
  6879. private static _DECR_WRAP;
  6880. /** Passed to stencilOperation to specify that stencil value must be kept */
  6881. static readonly KEEP: number;
  6882. /** Passed to stencilOperation to specify that stencil value must be replaced */
  6883. static readonly REPLACE: number;
  6884. /** Passed to stencilOperation to specify that stencil value must be incremented */
  6885. static readonly INCR: number;
  6886. /** Passed to stencilOperation to specify that stencil value must be decremented */
  6887. static readonly DECR: number;
  6888. /** Passed to stencilOperation to specify that stencil value must be inverted */
  6889. static readonly INVERT: number;
  6890. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  6891. static readonly INCR_WRAP: number;
  6892. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  6893. static readonly DECR_WRAP: number;
  6894. /** Defines that alpha blending is disabled */
  6895. static readonly ALPHA_DISABLE: number;
  6896. /** Defines that alpha blending to SRC + DEST */
  6897. static readonly ALPHA_ONEONE: number;
  6898. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  6899. static readonly ALPHA_ADD: number;
  6900. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  6901. static readonly ALPHA_COMBINE: number;
  6902. /** Defines that alpha blending to DEST - SRC * DEST */
  6903. static readonly ALPHA_SUBTRACT: number;
  6904. /** Defines that alpha blending to SRC * DEST */
  6905. static readonly ALPHA_MULTIPLY: number;
  6906. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  6907. static readonly ALPHA_MAXIMIZED: number;
  6908. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  6909. static readonly ALPHA_PREMULTIPLIED: number;
  6910. /**
  6911. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  6912. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  6913. */
  6914. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  6915. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  6916. static readonly ALPHA_INTERPOLATE: number;
  6917. /**
  6918. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  6919. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  6920. */
  6921. static readonly ALPHA_SCREENMODE: number;
  6922. /** Defines that the ressource is not delayed*/
  6923. static readonly DELAYLOADSTATE_NONE: number;
  6924. /** Defines that the ressource was successfully delay loaded */
  6925. static readonly DELAYLOADSTATE_LOADED: number;
  6926. /** Defines that the ressource is currently delay loading */
  6927. static readonly DELAYLOADSTATE_LOADING: number;
  6928. /** Defines that the ressource is delayed and has not started loading */
  6929. static readonly DELAYLOADSTATE_NOTLOADED: number;
  6930. /** ALPHA */
  6931. static readonly TEXTUREFORMAT_ALPHA: number;
  6932. /** LUMINANCE */
  6933. static readonly TEXTUREFORMAT_LUMINANCE: number;
  6934. /**
  6935. * R
  6936. */
  6937. static readonly TEXTUREFORMAT_R: number;
  6938. /**
  6939. * RG
  6940. */
  6941. static readonly TEXTUREFORMAT_RG: number;
  6942. /** LUMINANCE_ALPHA */
  6943. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  6944. /** RGB */
  6945. static readonly TEXTUREFORMAT_RGB: number;
  6946. /** RGBA */
  6947. static readonly TEXTUREFORMAT_RGBA: number;
  6948. /** UNSIGNED_INT */
  6949. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  6950. /** FLOAT */
  6951. static readonly TEXTURETYPE_FLOAT: number;
  6952. /** HALF_FLOAT */
  6953. static readonly TEXTURETYPE_HALF_FLOAT: number;
  6954. private static _SCALEMODE_FLOOR;
  6955. private static _SCALEMODE_NEAREST;
  6956. private static _SCALEMODE_CEILING;
  6957. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  6958. static readonly SCALEMODE_FLOOR: number;
  6959. /** Defines that texture rescaling will look for the nearest power of 2 size */
  6960. static readonly SCALEMODE_NEAREST: number;
  6961. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  6962. static readonly SCALEMODE_CEILING: number;
  6963. /**
  6964. * Returns the current version of the framework
  6965. */
  6966. static readonly Version: string;
  6967. /**
  6968. * Gets or sets the epsilon value used by collision engine
  6969. */
  6970. static CollisionsEpsilon: number;
  6971. /**
  6972. * Gets or sets the relative url used to load code if using the engine in non-minified mode
  6973. */
  6974. static CodeRepository: string;
  6975. /**
  6976. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  6977. */
  6978. static ShadersRepository: string;
  6979. /**
  6980. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  6981. */
  6982. forcePOTTextures: boolean;
  6983. /**
  6984. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  6985. */
  6986. isFullscreen: boolean;
  6987. /**
  6988. * Gets a boolean indicating if the pointer is currently locked
  6989. */
  6990. isPointerLock: boolean;
  6991. /**
  6992. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  6993. */
  6994. cullBackFaces: boolean;
  6995. /**
  6996. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  6997. */
  6998. renderEvenInBackground: boolean;
  6999. /**
  7000. * Gets or sets a boolean indicating that cache can be kept between frames
  7001. */
  7002. preventCacheWipeBetweenFrames: boolean;
  7003. /**
  7004. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  7005. **/
  7006. enableOfflineSupport: boolean;
  7007. /**
  7008. * 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)
  7009. **/
  7010. disableManifestCheck: boolean;
  7011. /**
  7012. * Gets the list of created scenes
  7013. */
  7014. scenes: Scene[];
  7015. /**
  7016. * Gets the list of created postprocesses
  7017. */
  7018. postProcesses: PostProcess[];
  7019. /**
  7020. * Observable event triggered each time the rendering canvas is resized
  7021. */
  7022. onResizeObservable: Observable<Engine>;
  7023. /**
  7024. * Observable event triggered each time the canvas loses focus
  7025. */
  7026. onCanvasBlurObservable: Observable<Engine>;
  7027. /**
  7028. * Observable event triggered each time the canvas gains focus
  7029. */
  7030. onCanvasFocusObservable: Observable<Engine>;
  7031. /**
  7032. * Observable event triggered each time the canvas receives pointerout event
  7033. */
  7034. onCanvasPointerOutObservable: Observable<PointerEvent>;
  7035. /**
  7036. * Observable event triggered before each texture is initialized
  7037. */
  7038. onBeforeTextureInitObservable: Observable<Texture>;
  7039. private _vrDisplay;
  7040. private _vrSupported;
  7041. private _oldSize;
  7042. private _oldHardwareScaleFactor;
  7043. private _vrExclusivePointerMode;
  7044. private _webVRInitPromise;
  7045. /**
  7046. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  7047. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  7048. */
  7049. readonly isInVRExclusivePointerMode: boolean;
  7050. /**
  7051. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  7052. */
  7053. disableUniformBuffers: boolean;
  7054. /** @hidden */
  7055. /**
  7056. * Gets a boolean indicating that the engine supports uniform buffers
  7057. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7058. */
  7059. readonly supportsUniformBuffers: boolean;
  7060. /**
  7061. * Observable raised when the engine begins a new frame
  7062. */
  7063. onBeginFrameObservable: Observable<Engine>;
  7064. /**
  7065. * Observable raised when the engine ends the current frame
  7066. */
  7067. onEndFrameObservable: Observable<Engine>;
  7068. /**
  7069. * Observable raised when the engine is about to compile a shader
  7070. */
  7071. onBeforeShaderCompilationObservable: Observable<Engine>;
  7072. /**
  7073. * Observable raised when the engine has jsut compiled a shader
  7074. */
  7075. onAfterShaderCompilationObservable: Observable<Engine>;
  7076. private _gl;
  7077. private _renderingCanvas;
  7078. private _windowIsBackground;
  7079. private _webGLVersion;
  7080. /**
  7081. * Gets a boolean indicating that only power of 2 textures are supported
  7082. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  7083. */
  7084. readonly needPOTTextures: boolean;
  7085. /** @hidden */
  7086. /** @hidden */
  7087. /**
  7088. * Gets or sets a value indicating if we want to disable texture binding optmization.
  7089. * This could be required on some buggy drivers which wants to have textures bound in a progressive order.
  7090. * By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is
  7091. */
  7092. disableTextureBindingOptimization: boolean;
  7093. /**
  7094. * Gets the audio engine
  7095. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  7096. * @ignorenaming
  7097. */
  7098. static audioEngine: AudioEngine;
  7099. private _onFocus;
  7100. private _onBlur;
  7101. private _onCanvasPointerOut;
  7102. private _onCanvasBlur;
  7103. private _onCanvasFocus;
  7104. private _onFullscreenChange;
  7105. private _onPointerLockChange;
  7106. private _onVRDisplayPointerRestricted;
  7107. private _onVRDisplayPointerUnrestricted;
  7108. private _onVrDisplayConnect;
  7109. private _onVrDisplayDisconnect;
  7110. private _onVrDisplayPresentChange;
  7111. /**
  7112. * Observable signaled when VR display mode changes
  7113. */
  7114. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  7115. /**
  7116. * Observable signaled when VR request present is complete
  7117. */
  7118. onVRRequestPresentComplete: Observable<boolean>;
  7119. /**
  7120. * Observable signaled when VR request present starts
  7121. */
  7122. onVRRequestPresentStart: Observable<Engine>;
  7123. private _hardwareScalingLevel;
  7124. /** @hidden */
  7125. protected _caps: EngineCapabilities;
  7126. private _pointerLockRequested;
  7127. private _isStencilEnable;
  7128. private _colorWrite;
  7129. private _loadingScreen;
  7130. /** @hidden */
  7131. /** @hidden */
  7132. private _glVersion;
  7133. private _glRenderer;
  7134. private _glVendor;
  7135. private _videoTextureSupported;
  7136. private _renderingQueueLaunched;
  7137. private _activeRenderLoops;
  7138. private _deterministicLockstep;
  7139. private _lockstepMaxSteps;
  7140. /**
  7141. * Observable signaled when a context lost event is raised
  7142. */
  7143. onContextLostObservable: Observable<Engine>;
  7144. /**
  7145. * Observable signaled when a context restored event is raised
  7146. */
  7147. onContextRestoredObservable: Observable<Engine>;
  7148. private _onContextLost;
  7149. private _onContextRestored;
  7150. private _contextWasLost;
  7151. private _doNotHandleContextLost;
  7152. /**
  7153. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  7154. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  7155. */
  7156. doNotHandleContextLost: boolean;
  7157. private _performanceMonitor;
  7158. private _fps;
  7159. private _deltaTime;
  7160. /**
  7161. * Turn this value on if you want to pause FPS computation when in background
  7162. */
  7163. disablePerformanceMonitorInBackground: boolean;
  7164. /**
  7165. * Gets the performance monitor attached to this engine
  7166. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  7167. */
  7168. readonly performanceMonitor: PerformanceMonitor;
  7169. /** @hidden */
  7170. protected _depthCullingState: _DepthCullingState;
  7171. /** @hidden */
  7172. protected _stencilState: _StencilState;
  7173. /** @hidden */
  7174. protected _alphaState: _AlphaState;
  7175. /** @hidden */
  7176. protected _alphaMode: number;
  7177. protected _internalTexturesCache: InternalTexture[];
  7178. /** @hidden */
  7179. protected _activeChannel: number;
  7180. private _currentTextureChannel;
  7181. /** @hidden */
  7182. protected _boundTexturesCache: {
  7183. [key: string]: Nullable<InternalTexture>;
  7184. };
  7185. /** @hidden */
  7186. protected _currentEffect: Nullable<Effect>;
  7187. /** @hidden */
  7188. protected _currentProgram: Nullable<WebGLProgram>;
  7189. private _compiledEffects;
  7190. private _vertexAttribArraysEnabled;
  7191. /** @hidden */
  7192. protected _cachedViewport: Nullable<Viewport>;
  7193. private _cachedVertexArrayObject;
  7194. /** @hidden */
  7195. protected _cachedVertexBuffers: any;
  7196. /** @hidden */
  7197. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  7198. /** @hidden */
  7199. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  7200. /** @hidden */
  7201. protected _currentRenderTarget: Nullable<InternalTexture>;
  7202. private _uintIndicesCurrentlySet;
  7203. private _currentBoundBuffer;
  7204. /** @hidden */
  7205. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  7206. private _currentBufferPointers;
  7207. private _currentInstanceLocations;
  7208. private _currentInstanceBuffers;
  7209. private _textureUnits;
  7210. private _firstBoundInternalTextureTracker;
  7211. private _lastBoundInternalTextureTracker;
  7212. private _workingCanvas;
  7213. private _workingContext;
  7214. private _rescalePostProcess;
  7215. private _dummyFramebuffer;
  7216. private _externalData;
  7217. private _bindedRenderFunction;
  7218. private _vaoRecordInProgress;
  7219. private _mustWipeVertexAttributes;
  7220. private _emptyTexture;
  7221. private _emptyCubeTexture;
  7222. private _emptyTexture3D;
  7223. private _frameHandler;
  7224. private _nextFreeTextureSlots;
  7225. private _maxSimultaneousTextures;
  7226. private _activeRequests;
  7227. private _texturesSupported;
  7228. private _textureFormatInUse;
  7229. /**
  7230. * Gets the list of texture formats supported
  7231. */
  7232. readonly texturesSupported: Array<string>;
  7233. /**
  7234. * Gets the list of texture formats in use
  7235. */
  7236. readonly textureFormatInUse: Nullable<string>;
  7237. /**
  7238. * Gets the current viewport
  7239. */
  7240. readonly currentViewport: Nullable<Viewport>;
  7241. /**
  7242. * Gets the default empty texture
  7243. */
  7244. readonly emptyTexture: InternalTexture;
  7245. /**
  7246. * Gets the default empty 3D texture
  7247. */
  7248. readonly emptyTexture3D: InternalTexture;
  7249. /**
  7250. * Gets the default empty cube texture
  7251. */
  7252. readonly emptyCubeTexture: InternalTexture;
  7253. /**
  7254. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  7255. */
  7256. readonly premultipliedAlpha: boolean;
  7257. /**
  7258. * Creates a new engine
  7259. * @param canvasOrContext defines the canvas or WebGL context to use for rendering
  7260. * @param antialias defines enable antialiasing (default: false)
  7261. * @param options defines further options to be sent to the getContext() function
  7262. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  7263. */
  7264. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  7265. private _rebuildInternalTextures();
  7266. private _rebuildEffects();
  7267. private _rebuildBuffers();
  7268. private _initGLContext();
  7269. /**
  7270. * Gets version of the current webGL context
  7271. */
  7272. readonly webGLVersion: number;
  7273. /**
  7274. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  7275. */
  7276. readonly isStencilEnable: boolean;
  7277. private _prepareWorkingCanvas();
  7278. /**
  7279. * Reset the texture cache to empty state
  7280. */
  7281. resetTextureCache(): void;
  7282. /**
  7283. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  7284. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  7285. * @returns true if engine is in deterministic lock step mode
  7286. */
  7287. isDeterministicLockStep(): boolean;
  7288. /**
  7289. * Gets the max steps when engine is running in deterministic lock step
  7290. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  7291. * @returns the max steps
  7292. */
  7293. getLockstepMaxSteps(): number;
  7294. /**
  7295. * Gets an object containing information about the current webGL context
  7296. * @returns an object containing the vender, the renderer and the version of the current webGL context
  7297. */
  7298. getGlInfo(): {
  7299. vendor: string;
  7300. renderer: string;
  7301. version: string;
  7302. };
  7303. /**
  7304. * Gets current aspect ratio
  7305. * @param camera defines the camera to use to get the aspect ratio
  7306. * @param useScreen defines if screen size must be used (or the current render target if any)
  7307. * @returns a number defining the aspect ratio
  7308. */
  7309. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  7310. /**
  7311. * Gets current screen aspect ratio
  7312. * @returns a number defining the aspect ratio
  7313. */
  7314. getScreenAspectRatio(): number;
  7315. /**
  7316. * Gets the current render width
  7317. * @param useScreen defines if screen size must be used (or the current render target if any)
  7318. * @returns a number defining the current render width
  7319. */
  7320. getRenderWidth(useScreen?: boolean): number;
  7321. /**
  7322. * Gets the current render height
  7323. * @param useScreen defines if screen size must be used (or the current render target if any)
  7324. * @returns a number defining the current render height
  7325. */
  7326. getRenderHeight(useScreen?: boolean): number;
  7327. /**
  7328. * Gets the HTML canvas attached with the current webGL context
  7329. * @returns a HTML canvas
  7330. */
  7331. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  7332. /**
  7333. * Gets the client rect of the HTML canvas attached with the current webGL context
  7334. * @returns a client rectanglee
  7335. */
  7336. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  7337. /**
  7338. * Defines the hardware scaling level.
  7339. * By default the hardware scaling level is computed from the window device ratio.
  7340. * 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.
  7341. * @param level defines the level to use
  7342. */
  7343. setHardwareScalingLevel(level: number): void;
  7344. /**
  7345. * Gets the current hardware scaling level.
  7346. * By default the hardware scaling level is computed from the window device ratio.
  7347. * 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.
  7348. * @returns a number indicating the current hardware scaling level
  7349. */
  7350. getHardwareScalingLevel(): number;
  7351. /**
  7352. * Gets the list of loaded textures
  7353. * @returns an array containing all loaded textures
  7354. */
  7355. getLoadedTexturesCache(): InternalTexture[];
  7356. /**
  7357. * Gets the object containing all engine capabilities
  7358. * @returns the EngineCapabilities object
  7359. */
  7360. getCaps(): EngineCapabilities;
  7361. /** @hidden */
  7362. readonly drawCalls: number;
  7363. /** @hidden */
  7364. readonly drawCallsPerfCounter: Nullable<PerfCounter>;
  7365. /**
  7366. * Gets the current depth function
  7367. * @returns a number defining the depth function
  7368. */
  7369. getDepthFunction(): Nullable<number>;
  7370. /**
  7371. * Sets the current depth function
  7372. * @param depthFunc defines the function to use
  7373. */
  7374. setDepthFunction(depthFunc: number): void;
  7375. /**
  7376. * Sets the current depth function to GREATER
  7377. */
  7378. setDepthFunctionToGreater(): void;
  7379. /**
  7380. * Sets the current depth function to GEQUAL
  7381. */
  7382. setDepthFunctionToGreaterOrEqual(): void;
  7383. /**
  7384. * Sets the current depth function to LESS
  7385. */
  7386. setDepthFunctionToLess(): void;
  7387. /**
  7388. * Sets the current depth function to LEQUAL
  7389. */
  7390. setDepthFunctionToLessOrEqual(): void;
  7391. /**
  7392. * Gets a boolean indicating if stencil buffer is enabled
  7393. * @returns the current stencil buffer state
  7394. */
  7395. getStencilBuffer(): boolean;
  7396. /**
  7397. * Enable or disable the stencil buffer
  7398. * @param enable defines if the stencil buffer must be enabled or disabled
  7399. */
  7400. setStencilBuffer(enable: boolean): void;
  7401. /**
  7402. * Gets the current stencil mask
  7403. * @returns a number defining the new stencil mask to use
  7404. */
  7405. getStencilMask(): number;
  7406. /**
  7407. * Sets the current stencil mask
  7408. * @param mask defines the new stencil mask to use
  7409. */
  7410. setStencilMask(mask: number): void;
  7411. /**
  7412. * Gets the current stencil function
  7413. * @returns a number defining the stencil function to use
  7414. */
  7415. getStencilFunction(): number;
  7416. /**
  7417. * Gets the current stencil reference value
  7418. * @returns a number defining the stencil reference value to use
  7419. */
  7420. getStencilFunctionReference(): number;
  7421. /**
  7422. * Gets the current stencil mask
  7423. * @returns a number defining the stencil mask to use
  7424. */
  7425. getStencilFunctionMask(): number;
  7426. /**
  7427. * Sets the current stencil function
  7428. * @param stencilFunc defines the new stencil function to use
  7429. */
  7430. setStencilFunction(stencilFunc: number): void;
  7431. /**
  7432. * Sets the current stencil reference
  7433. * @param reference defines the new stencil reference to use
  7434. */
  7435. setStencilFunctionReference(reference: number): void;
  7436. /**
  7437. * Sets the current stencil mask
  7438. * @param mask defines the new stencil mask to use
  7439. */
  7440. setStencilFunctionMask(mask: number): void;
  7441. /**
  7442. * Gets the current stencil operation when stencil fails
  7443. * @returns a number defining stencil operation to use when stencil fails
  7444. */
  7445. getStencilOperationFail(): number;
  7446. /**
  7447. * Gets the current stencil operation when depth fails
  7448. * @returns a number defining stencil operation to use when depth fails
  7449. */
  7450. getStencilOperationDepthFail(): number;
  7451. /**
  7452. * Gets the current stencil operation when stencil passes
  7453. * @returns a number defining stencil operation to use when stencil passes
  7454. */
  7455. getStencilOperationPass(): number;
  7456. /**
  7457. * Sets the stencil operation to use when stencil fails
  7458. * @param operation defines the stencil operation to use when stencil fails
  7459. */
  7460. setStencilOperationFail(operation: number): void;
  7461. /**
  7462. * Sets the stencil operation to use when depth fails
  7463. * @param operation defines the stencil operation to use when depth fails
  7464. */
  7465. setStencilOperationDepthFail(operation: number): void;
  7466. /**
  7467. * Sets the stencil operation to use when stencil passes
  7468. * @param operation defines the stencil operation to use when stencil passes
  7469. */
  7470. setStencilOperationPass(operation: number): void;
  7471. /**
  7472. * Sets a boolean indicating if the dithering state is enabled or disabled
  7473. * @param value defines the dithering state
  7474. */
  7475. setDitheringState(value: boolean): void;
  7476. /**
  7477. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  7478. * @param value defines the rasterizer state
  7479. */
  7480. setRasterizerState(value: boolean): void;
  7481. /**
  7482. * stop executing a render loop function and remove it from the execution array
  7483. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  7484. */
  7485. stopRenderLoop(renderFunction?: () => void): void;
  7486. /** @hidden */
  7487. /**
  7488. * Register and execute a render loop. The engine can have more than one render function
  7489. * @param renderFunction defines the function to continuously execute
  7490. */
  7491. runRenderLoop(renderFunction: () => void): void;
  7492. /**
  7493. * Toggle full screen mode
  7494. * @param requestPointerLock defines if a pointer lock should be requested from the user
  7495. * @param options defines an option object to be sent to the requestFullscreen function
  7496. */
  7497. switchFullscreen(requestPointerLock: boolean): void;
  7498. /**
  7499. * Clear the current render buffer or the current render target (if any is set up)
  7500. * @param color defines the color to use
  7501. * @param backBuffer defines if the back buffer must be cleared
  7502. * @param depth defines if the depth buffer must be cleared
  7503. * @param stencil defines if the stencil buffer must be cleared
  7504. */
  7505. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  7506. /**
  7507. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  7508. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  7509. * @param y defines the y-coordinate of the corner of the clear rectangle
  7510. * @param width defines the width of the clear rectangle
  7511. * @param height defines the height of the clear rectangle
  7512. * @param clearColor defines the clear color
  7513. */
  7514. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  7515. private _viewportCached;
  7516. /** @hidden */
  7517. /**
  7518. * Set the WebGL's viewport
  7519. * @param viewport defines the viewport element to be used
  7520. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  7521. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  7522. */
  7523. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  7524. /**
  7525. * Directly set the WebGL Viewport
  7526. * @param x defines the x coordinate of the viewport (in screen space)
  7527. * @param y defines the y coordinate of the viewport (in screen space)
  7528. * @param width defines the width of the viewport (in screen space)
  7529. * @param height defines the height of the viewport (in screen space)
  7530. * @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
  7531. */
  7532. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  7533. /**
  7534. * Begin a new frame
  7535. */
  7536. beginFrame(): void;
  7537. /**
  7538. * Enf the current frame
  7539. */
  7540. endFrame(): void;
  7541. /**
  7542. * Resize the view according to the canvas' size
  7543. */
  7544. resize(): void;
  7545. /**
  7546. * Force a specific size of the canvas
  7547. * @param width defines the new canvas' width
  7548. * @param height defines the new canvas' height
  7549. */
  7550. setSize(width: number, height: number): void;
  7551. /**
  7552. * Gets a boolean indicating if a webVR device was detected
  7553. * @returns true if a webVR device was detected
  7554. */
  7555. isVRDevicePresent(): boolean;
  7556. /**
  7557. * Gets the current webVR device
  7558. * @returns the current webVR device (or null)
  7559. */
  7560. getVRDevice(): any;
  7561. /**
  7562. * Initializes a webVR display and starts listening to display change events
  7563. * The onVRDisplayChangedObservable will be notified upon these changes
  7564. * @returns The onVRDisplayChangedObservable
  7565. */
  7566. initWebVR(): Observable<IDisplayChangedEventArgs>;
  7567. /**
  7568. * Initializes a webVR display and starts listening to display change events
  7569. * The onVRDisplayChangedObservable will be notified upon these changes
  7570. * @returns A promise containing a VRDisplay and if vr is supported
  7571. */
  7572. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  7573. /**
  7574. * Call this function to switch to webVR mode
  7575. * Will do nothing if webVR is not supported or if there is no webVR device
  7576. * @see http://doc.babylonjs.com/how_to/webvr_camera
  7577. */
  7578. enableVR(): void;
  7579. /**
  7580. * Call this function to leave webVR mode
  7581. * Will do nothing if webVR is not supported or if there is no webVR device
  7582. * @see http://doc.babylonjs.com/how_to/webvr_camera
  7583. */
  7584. disableVR(): void;
  7585. private _onVRFullScreenTriggered;
  7586. private _getVRDisplaysAsync();
  7587. /**
  7588. * Binds the frame buffer to the specified texture.
  7589. * @param texture The texture to render to or null for the default canvas
  7590. * @param faceIndex The face of the texture to render to in case of cube texture
  7591. * @param requiredWidth The width of the target to render to
  7592. * @param requiredHeight The height of the target to render to
  7593. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  7594. * @param depthStencilTexture The depth stencil texture to use to render
  7595. * @param lodLevel defines le lod level to bind to the frame buffer
  7596. */
  7597. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  7598. private bindUnboundFramebuffer(framebuffer);
  7599. /**
  7600. * Unbind the current render target texture from the webGL context
  7601. * @param texture defines the render target texture to unbind
  7602. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  7603. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  7604. */
  7605. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  7606. /**
  7607. * Unbind a list of render target textures from the webGL context
  7608. * This is used only when drawBuffer extension or webGL2 are active
  7609. * @param textures defines the render target textures to unbind
  7610. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  7611. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  7612. */
  7613. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  7614. /**
  7615. * Force the mipmap generation for the given render target texture
  7616. * @param texture defines the render target texture to use
  7617. */
  7618. generateMipMapsForCubemap(texture: InternalTexture): void;
  7619. /**
  7620. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  7621. */
  7622. flushFramebuffer(): void;
  7623. /**
  7624. * Unbind the current render target and bind the default framebuffer
  7625. */
  7626. restoreDefaultFramebuffer(): void;
  7627. /**
  7628. * Create an uniform buffer
  7629. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7630. * @param elements defines the content of the uniform buffer
  7631. * @returns the webGL uniform buffer
  7632. */
  7633. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  7634. /**
  7635. * Create a dynamic uniform buffer
  7636. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7637. * @param elements defines the content of the uniform buffer
  7638. * @returns the webGL uniform buffer
  7639. */
  7640. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  7641. /**
  7642. * Update an existing uniform buffer
  7643. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7644. * @param uniformBuffer defines the target uniform buffer
  7645. * @param elements defines the content to update
  7646. * @param offset defines the offset in the uniform buffer where update should start
  7647. * @param count defines the size of the data to update
  7648. */
  7649. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7650. private _resetVertexBufferBinding();
  7651. /**
  7652. * Creates a vertex buffer
  7653. * @param data the data for the vertex buffer
  7654. * @returns the new WebGL static buffer
  7655. */
  7656. createVertexBuffer(data: DataArray): WebGLBuffer;
  7657. /**
  7658. * Creates a dynamic vertex buffer
  7659. * @param data the data for the dynamic vertex buffer
  7660. * @returns the new WebGL dynamic buffer
  7661. */
  7662. createDynamicVertexBuffer(data: DataArray): WebGLBuffer;
  7663. /**
  7664. * Update a dynamic index buffer
  7665. * @param indexBuffer defines the target index buffer
  7666. * @param indices defines the data to update
  7667. * @param offset defines the offset in the target index buffer where update should start
  7668. */
  7669. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  7670. /**
  7671. * Updates a dynamic vertex buffer.
  7672. * @param vertexBuffer the vertex buffer to update
  7673. * @param data the data used to update the vertex buffer
  7674. * @param byteOffset the byte offset of the data
  7675. * @param byteLength the byte length of the data
  7676. */
  7677. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  7678. private _resetIndexBufferBinding();
  7679. /**
  7680. * Creates a new index buffer
  7681. * @param indices defines the content of the index buffer
  7682. * @param updatable defines if the index buffer must be updatable
  7683. * @returns a new webGL buffer
  7684. */
  7685. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  7686. /**
  7687. * Bind a webGL buffer to the webGL context
  7688. * @param buffer defines the buffer to bind
  7689. */
  7690. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  7691. /**
  7692. * Bind an uniform buffer to the current webGL context
  7693. * @param buffer defines the buffer to bind
  7694. */
  7695. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  7696. /**
  7697. * Bind a buffer to the current webGL context at a given location
  7698. * @param buffer defines the buffer to bind
  7699. * @param location defines the index where to bind the buffer
  7700. */
  7701. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  7702. /**
  7703. * Bind a specific block at a given index in a specific shader program
  7704. * @param shaderProgram defines the shader program
  7705. * @param blockName defines the block name
  7706. * @param index defines the index where to bind the block
  7707. */
  7708. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  7709. private bindIndexBuffer(buffer);
  7710. private bindBuffer(buffer, target);
  7711. /**
  7712. * update the bound buffer with the given data
  7713. * @param data defines the data to update
  7714. */
  7715. updateArrayBuffer(data: Float32Array): void;
  7716. private _vertexAttribPointer(buffer, indx, size, type, normalized, stride, offset);
  7717. private _bindIndexBufferWithCache(indexBuffer);
  7718. private _bindVertexBuffersAttributes(vertexBuffers, effect);
  7719. /**
  7720. * Records a vertex array object
  7721. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  7722. * @param vertexBuffers defines the list of vertex buffers to store
  7723. * @param indexBuffer defines the index buffer to store
  7724. * @param effect defines the effect to store
  7725. * @returns the new vertex array object
  7726. */
  7727. recordVertexArrayObject(vertexBuffers: {
  7728. [key: string]: VertexBuffer;
  7729. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  7730. /**
  7731. * Bind a specific vertex array object
  7732. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  7733. * @param vertexArrayObject defines the vertex array object to bind
  7734. * @param indexBuffer defines the index buffer to bind
  7735. */
  7736. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  7737. /**
  7738. * Bind webGl buffers directly to the webGL context
  7739. * @param vertexBuffer defines the vertex buffer to bind
  7740. * @param indexBuffer defines the index buffer to bind
  7741. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  7742. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  7743. * @param effect defines the effect associated with the vertex buffer
  7744. */
  7745. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  7746. private _unbindVertexArrayObject();
  7747. /**
  7748. * Bind a list of vertex buffers to the webGL context
  7749. * @param vertexBuffers defines the list of vertex buffers to bind
  7750. * @param indexBuffer defines the index buffer to bind
  7751. * @param effect defines the effect associated with the vertex buffers
  7752. */
  7753. bindBuffers(vertexBuffers: {
  7754. [key: string]: Nullable<VertexBuffer>;
  7755. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  7756. /**
  7757. * Unbind all instance attributes
  7758. */
  7759. unbindInstanceAttributes(): void;
  7760. /**
  7761. * Release and free the memory of a vertex array object
  7762. * @param vao defines the vertex array object to delete
  7763. */
  7764. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  7765. /** @hidden */
  7766. /**
  7767. * Creates a webGL buffer to use with instanciation
  7768. * @param capacity defines the size of the buffer
  7769. * @returns the webGL buffer
  7770. */
  7771. createInstancesBuffer(capacity: number): WebGLBuffer;
  7772. /**
  7773. * Delete a webGL buffer used with instanciation
  7774. * @param buffer defines the webGL buffer to delete
  7775. */
  7776. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  7777. /**
  7778. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  7779. * @param instancesBuffer defines the webGL buffer to update and bind
  7780. * @param data defines the data to store in the buffer
  7781. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  7782. */
  7783. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  7784. /**
  7785. * Apply all cached states (depth, culling, stencil and alpha)
  7786. */
  7787. applyStates(): void;
  7788. /**
  7789. * Send a draw order
  7790. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  7791. * @param indexStart defines the starting index
  7792. * @param indexCount defines the number of index to draw
  7793. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  7794. */
  7795. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  7796. /**
  7797. * Draw a list of points
  7798. * @param verticesStart defines the index of first vertex to draw
  7799. * @param verticesCount defines the count of vertices to draw
  7800. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  7801. */
  7802. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  7803. /**
  7804. * Draw a list of unindexed primitives
  7805. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  7806. * @param verticesStart defines the index of first vertex to draw
  7807. * @param verticesCount defines the count of vertices to draw
  7808. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  7809. */
  7810. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  7811. /**
  7812. * Draw a list of indexed primitives
  7813. * @param fillMode defines the primitive to use
  7814. * @param indexStart defines the starting index
  7815. * @param indexCount defines the number of index to draw
  7816. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  7817. */
  7818. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  7819. /**
  7820. * Draw a list of unindexed primitives
  7821. * @param fillMode defines the primitive to use
  7822. * @param verticesStart defines the index of first vertex to draw
  7823. * @param verticesCount defines the count of vertices to draw
  7824. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  7825. */
  7826. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  7827. private _drawMode(fillMode);
  7828. /** @hidden */
  7829. /** @hidden */
  7830. /**
  7831. * Create a new effect (used to store vertex/fragment shaders)
  7832. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  7833. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  7834. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  7835. * @param samplers defines an array of string used to represent textures
  7836. * @param defines defines the string containing the defines to use to compile the shaders
  7837. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  7838. * @param onCompiled defines a function to call when the effect creation is successful
  7839. * @param onError defines a function to call when the effect creation has failed
  7840. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  7841. * @returns the new Effect
  7842. */
  7843. 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;
  7844. /**
  7845. * Create an effect to use with particle systems
  7846. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  7847. * @param uniformsNames defines a list of attribute names
  7848. * @param samplers defines an array of string used to represent textures
  7849. * @param defines defines the string containing the defines to use to compile the shaders
  7850. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  7851. * @param onCompiled defines a function to call when the effect creation is successful
  7852. * @param onError defines a function to call when the effect creation has failed
  7853. * @returns the new Effect
  7854. */
  7855. createEffectForParticles(fragmentName: string, uniformsNames?: string[], samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  7856. /**
  7857. * Directly creates a webGL program
  7858. * @param vertexCode defines the vertex shader code to use
  7859. * @param fragmentCode defines the fragment shader code to use
  7860. * @param context defines the webGL context to use (if not set, the current one will be used)
  7861. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  7862. * @returns the new webGL program
  7863. */
  7864. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  7865. /**
  7866. * Creates a webGL program
  7867. * @param vertexCode defines the vertex shader code to use
  7868. * @param fragmentCode defines the fragment shader code to use
  7869. * @param defines defines the string containing the defines to use to compile the shaders
  7870. * @param context defines the webGL context to use (if not set, the current one will be used)
  7871. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  7872. * @returns the new webGL program
  7873. */
  7874. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  7875. private _createShaderProgram(vertexShader, fragmentShader, context, transformFeedbackVaryings?);
  7876. /**
  7877. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  7878. * @param shaderProgram defines the webGL program to use
  7879. * @param uniformsNames defines the list of uniform names
  7880. * @returns an array of webGL uniform locations
  7881. */
  7882. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  7883. /**
  7884. * Gets the lsit of active attributes for a given webGL program
  7885. * @param shaderProgram defines the webGL program to use
  7886. * @param attributesNames defines the list of attribute names to get
  7887. * @returns an array of indices indicating the offset of each attribute
  7888. */
  7889. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  7890. /**
  7891. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  7892. * @param effect defines the effect to activate
  7893. */
  7894. enableEffect(effect: Nullable<Effect>): void;
  7895. /**
  7896. * Set the value of an uniform to an array of int32
  7897. * @param uniform defines the webGL uniform location where to store the value
  7898. * @param array defines the array of int32 to store
  7899. */
  7900. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  7901. /**
  7902. * Set the value of an uniform to an array of int32 (stored as vec2)
  7903. * @param uniform defines the webGL uniform location where to store the value
  7904. * @param array defines the array of int32 to store
  7905. */
  7906. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  7907. /**
  7908. * Set the value of an uniform to an array of int32 (stored as vec3)
  7909. * @param uniform defines the webGL uniform location where to store the value
  7910. * @param array defines the array of int32 to store
  7911. */
  7912. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  7913. /**
  7914. * Set the value of an uniform to an array of int32 (stored as vec4)
  7915. * @param uniform defines the webGL uniform location where to store the value
  7916. * @param array defines the array of int32 to store
  7917. */
  7918. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  7919. /**
  7920. * Set the value of an uniform to an array of float32
  7921. * @param uniform defines the webGL uniform location where to store the value
  7922. * @param array defines the array of float32 to store
  7923. */
  7924. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  7925. /**
  7926. * Set the value of an uniform to an array of float32 (stored as vec2)
  7927. * @param uniform defines the webGL uniform location where to store the value
  7928. * @param array defines the array of float32 to store
  7929. */
  7930. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  7931. /**
  7932. * Set the value of an uniform to an array of float32 (stored as vec3)
  7933. * @param uniform defines the webGL uniform location where to store the value
  7934. * @param array defines the array of float32 to store
  7935. */
  7936. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  7937. /**
  7938. * Set the value of an uniform to an array of float32 (stored as vec4)
  7939. * @param uniform defines the webGL uniform location where to store the value
  7940. * @param array defines the array of float32 to store
  7941. */
  7942. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  7943. /**
  7944. * Set the value of an uniform to an array of number
  7945. * @param uniform defines the webGL uniform location where to store the value
  7946. * @param array defines the array of number to store
  7947. */
  7948. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  7949. /**
  7950. * Set the value of an uniform to an array of number (stored as vec2)
  7951. * @param uniform defines the webGL uniform location where to store the value
  7952. * @param array defines the array of number to store
  7953. */
  7954. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  7955. /**
  7956. * Set the value of an uniform to an array of number (stored as vec3)
  7957. * @param uniform defines the webGL uniform location where to store the value
  7958. * @param array defines the array of number to store
  7959. */
  7960. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  7961. /**
  7962. * Set the value of an uniform to an array of number (stored as vec4)
  7963. * @param uniform defines the webGL uniform location where to store the value
  7964. * @param array defines the array of number to store
  7965. */
  7966. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  7967. /**
  7968. * Set the value of an uniform to an array of float32 (stored as matrices)
  7969. * @param uniform defines the webGL uniform location where to store the value
  7970. * @param matrices defines the array of float32 to store
  7971. */
  7972. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  7973. /**
  7974. * Set the value of an uniform to a matrix
  7975. * @param uniform defines the webGL uniform location where to store the value
  7976. * @param matrix defines the matrix to store
  7977. */
  7978. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  7979. /**
  7980. * Set the value of an uniform to a matrix (3x3)
  7981. * @param uniform defines the webGL uniform location where to store the value
  7982. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  7983. */
  7984. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  7985. /**
  7986. * Set the value of an uniform to a matrix (2x2)
  7987. * @param uniform defines the webGL uniform location where to store the value
  7988. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  7989. */
  7990. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  7991. /**
  7992. * Set the value of an uniform to a number (int)
  7993. * @param uniform defines the webGL uniform location where to store the value
  7994. * @param value defines the int number to store
  7995. */
  7996. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  7997. /**
  7998. * Set the value of an uniform to a number (float)
  7999. * @param uniform defines the webGL uniform location where to store the value
  8000. * @param value defines the float number to store
  8001. */
  8002. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  8003. /**
  8004. * Set the value of an uniform to a vec2
  8005. * @param uniform defines the webGL uniform location where to store the value
  8006. * @param x defines the 1st component of the value
  8007. * @param y defines the 2nd component of the value
  8008. */
  8009. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  8010. /**
  8011. * Set the value of an uniform to a vec3
  8012. * @param uniform defines the webGL uniform location where to store the value
  8013. * @param x defines the 1st component of the value
  8014. * @param y defines the 2nd component of the value
  8015. * @param z defines the 3rd component of the value
  8016. */
  8017. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  8018. /**
  8019. * Set the value of an uniform to a boolean
  8020. * @param uniform defines the webGL uniform location where to store the value
  8021. * @param bool defines the boolean to store
  8022. */
  8023. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  8024. /**
  8025. * Set the value of an uniform to a vec4
  8026. * @param uniform defines the webGL uniform location where to store the value
  8027. * @param x defines the 1st component of the value
  8028. * @param y defines the 2nd component of the value
  8029. * @param z defines the 3rd component of the value
  8030. * @param w defines the 4th component of the value
  8031. */
  8032. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  8033. /**
  8034. * Set the value of an uniform to a Color3
  8035. * @param uniform defines the webGL uniform location where to store the value
  8036. * @param color3 defines the color to store
  8037. */
  8038. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  8039. /**
  8040. * Set the value of an uniform to a Color3 and an alpha value
  8041. * @param uniform defines the webGL uniform location where to store the value
  8042. * @param color3 defines the color to store
  8043. * @param alpha defines the alpha component to store
  8044. */
  8045. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  8046. /**
  8047. * Sets a Color4 on a uniform variable
  8048. * @param uniform defines the uniform location
  8049. * @param color4 defines the value to be set
  8050. */
  8051. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  8052. /**
  8053. * Set various states to the webGL context
  8054. * @param culling defines backface culling state
  8055. * @param zOffset defines the value to apply to zOffset (0 by default)
  8056. * @param force defines if states must be applied even if cache is up to date
  8057. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  8058. */
  8059. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  8060. /**
  8061. * Set the z offset to apply to current rendering
  8062. * @param value defines the offset to apply
  8063. */
  8064. setZOffset(value: number): void;
  8065. /**
  8066. * Gets the current value of the zOffset
  8067. * @returns the current zOffset state
  8068. */
  8069. getZOffset(): number;
  8070. /**
  8071. * Enable or disable depth buffering
  8072. * @param enable defines the state to set
  8073. */
  8074. setDepthBuffer(enable: boolean): void;
  8075. /**
  8076. * Gets a boolean indicating if depth writing is enabled
  8077. * @returns the current depth writing state
  8078. */
  8079. getDepthWrite(): boolean;
  8080. /**
  8081. * Enable or disable depth writing
  8082. * @param enable defines the state to set
  8083. */
  8084. setDepthWrite(enable: boolean): void;
  8085. /**
  8086. * Enable or disable color writing
  8087. * @param enable defines the state to set
  8088. */
  8089. setColorWrite(enable: boolean): void;
  8090. /**
  8091. * Gets a boolean indicating if color writing is enabled
  8092. * @returns the current color writing state
  8093. */
  8094. getColorWrite(): boolean;
  8095. /**
  8096. * Sets alpha constants used by some alpha blending modes
  8097. * @param r defines the red component
  8098. * @param g defines the green component
  8099. * @param b defines the blue component
  8100. * @param a defines the alpha component
  8101. */
  8102. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  8103. /**
  8104. * Sets the current alpha mode
  8105. * @param mode defines the mode to use (one of the BABYLON.Engine.ALPHA_XXX)
  8106. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  8107. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  8108. */
  8109. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  8110. /**
  8111. * Gets the current alpha mode
  8112. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  8113. * @returns the current alpha mode
  8114. */
  8115. getAlphaMode(): number;
  8116. /**
  8117. * Clears the list of texture accessible through engine.
  8118. * This can help preventing texture load conflict due to name collision.
  8119. */
  8120. clearInternalTexturesCache(): void;
  8121. /**
  8122. * Force the entire cache to be cleared
  8123. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  8124. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  8125. */
  8126. wipeCaches(bruteForce?: boolean): void;
  8127. /**
  8128. * Set the compressed texture format to use, based on the formats you have, and the formats
  8129. * supported by the hardware / browser.
  8130. *
  8131. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  8132. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  8133. * to API arguments needed to compressed textures. This puts the burden on the container
  8134. * generator to house the arcane code for determining these for current & future formats.
  8135. *
  8136. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  8137. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  8138. *
  8139. * Note: The result of this call is not taken into account when a texture is base64.
  8140. *
  8141. * @param formatsAvailable defines the list of those format families you have created
  8142. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  8143. *
  8144. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  8145. * @returns The extension selected.
  8146. */
  8147. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  8148. /** @hidden */
  8149. /**
  8150. * Usually called from BABYLON.Texture.ts.
  8151. * Passed information to create a WebGLTexture
  8152. * @param urlArg defines a value which contains one of the following:
  8153. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  8154. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  8155. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  8156. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  8157. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  8158. * @param scene needed for loading to the correct scene
  8159. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  8160. * @param onLoad optional callback to be called upon successful completion
  8161. * @param onError optional callback to be called upon failure
  8162. * @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
  8163. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  8164. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  8165. * @returns a InternalTexture for assignment back into BABYLON.Texture
  8166. */
  8167. 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>): InternalTexture;
  8168. private _rescaleTexture(source, destination, scene, internalFormat, onComplete);
  8169. /**
  8170. * Update a raw texture
  8171. * @param texture defines the texture to update
  8172. * @param data defines the data to store in the texture
  8173. * @param format defines the format of the data
  8174. * @param invertY defines if data must be stored with Y axis inverted
  8175. * @param compression defines the compression used (null by default)
  8176. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  8177. */
  8178. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  8179. /**
  8180. * Creates a raw texture
  8181. * @param data defines the data to store in the texture
  8182. * @param width defines the width of the texture
  8183. * @param height defines the height of the texture
  8184. * @param format defines the format of the data
  8185. * @param generateMipMaps defines if the engine should generate the mip levels
  8186. * @param invertY defines if data must be stored with Y axis inverted
  8187. * @param samplingMode defines the required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  8188. * @param compression defines the compression used (null by default)
  8189. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  8190. * @returns the raw texture inside an InternalTexture
  8191. */
  8192. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  8193. private _unpackFlipYCached;
  8194. /** @hidden */
  8195. /**
  8196. * Creates a dynamic texture
  8197. * @param width defines the width of the texture
  8198. * @param height defines the height of the texture
  8199. * @param generateMipMaps defines if the engine should generate the mip levels
  8200. * @param samplingMode defines the required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  8201. * @returns the dynamic texture inside an InternalTexture
  8202. */
  8203. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  8204. /**
  8205. * Update the sampling mode of a given texture
  8206. * @param samplingMode defines the required sampling mode
  8207. * @param texture defines the texture to update
  8208. */
  8209. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  8210. /**
  8211. * Update the content of a dynamic texture
  8212. * @param texture defines the texture to update
  8213. * @param canvas defines the canvas containing the source
  8214. * @param invertY defines if data must be stored with Y axis inverted
  8215. * @param premulAlpha defines if alpha is stored as premultiplied
  8216. * @param format defines the format of the data
  8217. */
  8218. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  8219. /**
  8220. * Update a video texture
  8221. * @param texture defines the texture to update
  8222. * @param video defines the video element to use
  8223. * @param invertY defines if data must be stored with Y axis inverted
  8224. */
  8225. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  8226. /**
  8227. * Updates a depth texture Comparison Mode and Function.
  8228. * If the comparison Function is equal to 0, the mode will be set to none.
  8229. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  8230. * @param texture The texture to set the comparison function for
  8231. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  8232. */
  8233. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  8234. private _setupDepthStencilTexture(internalTexture, size, generateStencil, bilinearFiltering, comparisonFunction);
  8235. /**
  8236. * Creates a depth stencil texture.
  8237. * This is only available in WebGL 2 or with the depth texture extension available.
  8238. * @param size The size of face edge in the texture.
  8239. * @param options The options defining the texture.
  8240. * @returns The texture
  8241. */
  8242. createDepthStencilTexture(size: number | {
  8243. width: number;
  8244. height: number;
  8245. }, options: DepthTextureCreationOptions): InternalTexture;
  8246. /**
  8247. * Creates a depth stencil texture.
  8248. * This is only available in WebGL 2 or with the depth texture extension available.
  8249. * @param size The size of face edge in the texture.
  8250. * @param options The options defining the texture.
  8251. * @returns The texture
  8252. */
  8253. private _createDepthStencilTexture(size, options);
  8254. /**
  8255. * Creates a depth stencil cube texture.
  8256. * This is only available in WebGL 2.
  8257. * @param size The size of face edge in the cube texture.
  8258. * @param options The options defining the cube texture.
  8259. * @returns The cube texture
  8260. */
  8261. private _createDepthStencilCubeTexture(size, options);
  8262. /**
  8263. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  8264. * @param renderTarget The render target to set the frame buffer for
  8265. */
  8266. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  8267. /**
  8268. * Creates a new render target texture
  8269. * @param size defines the size of the texture
  8270. * @param options defines the options used to create the texture
  8271. * @returns a new render target texture stored in an InternalTexture
  8272. */
  8273. createRenderTargetTexture(size: number | {
  8274. width: number;
  8275. height: number;
  8276. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8277. /**
  8278. * Create a multi render target texture
  8279. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  8280. * @param size defines the size of the texture
  8281. * @param options defines the creation options
  8282. * @returns the cube texture as an InternalTexture
  8283. */
  8284. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  8285. private _setupFramebufferDepthAttachments(generateStencilBuffer, generateDepthBuffer, width, height, samples?);
  8286. /**
  8287. * Updates the sample count of a render target texture
  8288. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  8289. * @param texture defines the texture to update
  8290. * @param samples defines the sample count to set
  8291. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  8292. */
  8293. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  8294. /**
  8295. * Update the sample count for a given multiple render target texture
  8296. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  8297. * @param textures defines the textures to update
  8298. * @param samples defines the sample count to set
  8299. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  8300. */
  8301. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  8302. /** @hidden */
  8303. /** @hidden */
  8304. /** @hidden */
  8305. /**
  8306. * Creates a new render target cube texture
  8307. * @param size defines the size of the texture
  8308. * @param options defines the options used to create the texture
  8309. * @returns a new render target cube texture stored in an InternalTexture
  8310. */
  8311. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  8312. /**
  8313. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  8314. * @param rootUrl defines the url where the file to load is located
  8315. * @param scene defines the current scene
  8316. * @param lodScale defines scale to apply to the mip map selection
  8317. * @param lodOffset defines offset to apply to the mip map selection
  8318. * @param onLoad defines an optional callback raised when the texture is loaded
  8319. * @param onError defines an optional callback raised if there is an issue to load the texture
  8320. * @param format defines the format of the data
  8321. * @param forcedExtension defines the extension to use to pick the right loader
  8322. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  8323. * @returns the cube texture as an InternalTexture
  8324. */
  8325. 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;
  8326. /**
  8327. * Creates a cube texture
  8328. * @param rootUrl defines the url where the files to load is located
  8329. * @param scene defines the current scene
  8330. * @param files defines the list of files to load (1 per face)
  8331. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  8332. * @param onLoad defines an optional callback raised when the texture is loaded
  8333. * @param onError defines an optional callback raised if there is an issue to load the texture
  8334. * @param format defines the format of the data
  8335. * @param forcedExtension defines the extension to use to pick the right loader
  8336. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  8337. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8338. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8339. * @returns the cube texture as an InternalTexture
  8340. */
  8341. 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): InternalTexture;
  8342. private setCubeMapTextureParams(gl, loadMipmap);
  8343. /**
  8344. * Update a raw cube texture
  8345. * @param texture defines the texture to udpdate
  8346. * @param data defines the data to store
  8347. * @param format defines the data format
  8348. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  8349. * @param invertY defines if data must be stored with Y axis inverted
  8350. * @param compression defines the compression used (null by default)
  8351. * @param level defines which level of the texture to update
  8352. */
  8353. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  8354. /**
  8355. * Creates a new raw cube texture
  8356. * @param data defines the array of data to use to create each face
  8357. * @param size defines the size of the textures
  8358. * @param format defines the format of the data
  8359. * @param type defines the type fo the data (like BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT)
  8360. * @param generateMipMaps defines if the engine should generate the mip levels
  8361. * @param invertY defines if data must be stored with Y axis inverted
  8362. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  8363. * @param compression defines the compression used (null by default)
  8364. * @returns the cube texture as an InternalTexture
  8365. */
  8366. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  8367. /**
  8368. * Creates a new raw cube texture from a specified url
  8369. * @param url defines the url where the data is located
  8370. * @param scene defines the current scene
  8371. * @param size defines the size of the textures
  8372. * @param format defines the format of the data
  8373. * @param type defines the type fo the data (like BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT)
  8374. * @param noMipmap defines if the engine should avoid generating the mip levels
  8375. * @param callback defines a callback used to extract texture data from loaded data
  8376. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  8377. * @param onLoad defines a callback called when texture is loaded
  8378. * @param onError defines a callback called if there is an error
  8379. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  8380. * @param invertY defines if data must be stored with Y axis inverted
  8381. * @returns the cube texture as an InternalTexture
  8382. */
  8383. 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;
  8384. /**
  8385. * Update a raw 3D texture
  8386. * @param texture defines the texture to update
  8387. * @param data defines the data to store
  8388. * @param format defines the data format
  8389. * @param invertY defines if data must be stored with Y axis inverted
  8390. * @param compression defines the used compression (can be null)
  8391. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  8392. */
  8393. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  8394. /**
  8395. * Creates a new raw 3D texture
  8396. * @param data defines the data used to create the texture
  8397. * @param width defines the width of the texture
  8398. * @param height defines the height of the texture
  8399. * @param depth defines the depth of the texture
  8400. * @param format defines the format of the texture
  8401. * @param generateMipMaps defines if the engine must generate mip levels
  8402. * @param invertY defines if data must be stored with Y axis inverted
  8403. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  8404. * @param compression defines the compressed used (can be null)
  8405. * @param textureType defines the compressed used (can be null)
  8406. * @returns a new raw 3D texture (stored in an InternalTexture)
  8407. */
  8408. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  8409. private _prepareWebGLTextureContinuation(texture, scene, noMipmap, isCompressed, samplingMode);
  8410. private _prepareWebGLTexture(texture, scene, width, height, invertY, noMipmap, isCompressed, processFunction, samplingMode?);
  8411. private _convertRGBtoRGBATextureData(rgbData, width, height, textureType);
  8412. /** @hidden */
  8413. /** @hidden */
  8414. private setProgram(program);
  8415. private _boundUniforms;
  8416. /**
  8417. * Binds an effect to the webGL context
  8418. * @param effect defines the effect to bind
  8419. */
  8420. bindSamplers(effect: Effect): void;
  8421. private _moveBoundTextureOnTop(internalTexture);
  8422. private _getCorrectTextureChannel(channel, internalTexture);
  8423. private _linkTrackers(previous, next);
  8424. private _removeDesignatedSlot(internalTexture);
  8425. private _activateCurrentTexture();
  8426. /** @hidden */
  8427. protected _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  8428. /** @hidden */
  8429. /**
  8430. * Sets a texture to the webGL context from a postprocess
  8431. * @param channel defines the channel to use
  8432. * @param postProcess defines the source postprocess
  8433. */
  8434. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  8435. /**
  8436. * Binds the output of the passed in post process to the texture channel specified
  8437. * @param channel The channel the texture should be bound to
  8438. * @param postProcess The post process which's output should be bound
  8439. */
  8440. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  8441. /**
  8442. * Unbind all textures from the webGL context
  8443. */
  8444. unbindAllTextures(): void;
  8445. /**
  8446. * Sets a texture to the according uniform.
  8447. * @param channel The texture channel
  8448. * @param uniform The uniform to set
  8449. * @param texture The texture to apply
  8450. */
  8451. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  8452. /**
  8453. * Sets a depth stencil texture from a render target to the according uniform.
  8454. * @param channel The texture channel
  8455. * @param uniform The uniform to set
  8456. * @param texture The render target texture containing the depth stencil texture to apply
  8457. */
  8458. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  8459. private _bindSamplerUniformToChannel(sourceSlot, destination);
  8460. private _getTextureWrapMode(mode);
  8461. private _setTexture(channel, texture, isPartOfTextureArray?, depthStencilTexture?);
  8462. /**
  8463. * Sets an array of texture to the webGL context
  8464. * @param channel defines the channel where the texture array must be set
  8465. * @param uniform defines the associated uniform location
  8466. * @param textures defines the array of textures to bind
  8467. */
  8468. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  8469. /** @hidden */
  8470. private _setTextureParameterFloat(target, parameter, value, texture);
  8471. private _setTextureParameterInteger(target, parameter, value, texture?);
  8472. /**
  8473. * Reads pixels from the current frame buffer. Please note that this function can be slow
  8474. * @param x defines the x coordinate of the rectangle where pixels must be read
  8475. * @param y defines the y coordinate of the rectangle where pixels must be read
  8476. * @param width defines the width of the rectangle where pixels must be read
  8477. * @param height defines the height of the rectangle where pixels must be read
  8478. * @returns a Uint8Array containing RGBA colors
  8479. */
  8480. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  8481. /**
  8482. * Add an externaly attached data from its key.
  8483. * This method call will fail and return false, if such key already exists.
  8484. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  8485. * @param key the unique key that identifies the data
  8486. * @param data the data object to associate to the key for this Engine instance
  8487. * @return true if no such key were already present and the data was added successfully, false otherwise
  8488. */
  8489. addExternalData<T>(key: string, data: T): boolean;
  8490. /**
  8491. * Get an externaly attached data from its key
  8492. * @param key the unique key that identifies the data
  8493. * @return the associated data, if present (can be null), or undefined if not present
  8494. */
  8495. getExternalData<T>(key: string): T;
  8496. /**
  8497. * Get an externaly attached data from its key, create it using a factory if it's not already present
  8498. * @param key the unique key that identifies the data
  8499. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  8500. * @return the associated data, can be null if the factory returned null.
  8501. */
  8502. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  8503. /**
  8504. * Remove an externaly attached data from the Engine instance
  8505. * @param key the unique key that identifies the data
  8506. * @return true if the data was successfully removed, false if it doesn't exist
  8507. */
  8508. removeExternalData(key: string): boolean;
  8509. /**
  8510. * Unbind all vertex attributes from the webGL context
  8511. */
  8512. unbindAllAttributes(): void;
  8513. /**
  8514. * 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
  8515. */
  8516. releaseEffects(): void;
  8517. /**
  8518. * Dispose and release all associated resources
  8519. */
  8520. dispose(): void;
  8521. /**
  8522. * Display the loading screen
  8523. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  8524. */
  8525. displayLoadingUI(): void;
  8526. /**
  8527. * Hide the loading screen
  8528. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  8529. */
  8530. hideLoadingUI(): void;
  8531. /**
  8532. * Gets the current loading screen object
  8533. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  8534. */
  8535. /**
  8536. * Sets the current loading screen object
  8537. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  8538. */
  8539. loadingScreen: ILoadingScreen;
  8540. /**
  8541. * Sets the current loading screen text
  8542. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  8543. */
  8544. loadingUIText: string;
  8545. /**
  8546. * Sets the current loading screen background color
  8547. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  8548. */
  8549. loadingUIBackgroundColor: string;
  8550. /**
  8551. * Attach a new callback raised when context lost event is fired
  8552. * @param callback defines the callback to call
  8553. */
  8554. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  8555. /**
  8556. * Attach a new callback raised when context restored event is fired
  8557. * @param callback defines the callback to call
  8558. */
  8559. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  8560. /**
  8561. * Gets the source code of the vertex shader associated with a specific webGL program
  8562. * @param program defines the program to use
  8563. * @returns a string containing the source code of the vertex shader associated with the program
  8564. */
  8565. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  8566. /**
  8567. * Gets the source code of the fragment shader associated with a specific webGL program
  8568. * @param program defines the program to use
  8569. * @returns a string containing the source code of the fragment shader associated with the program
  8570. */
  8571. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  8572. /**
  8573. * Get the current error code of the webGL context
  8574. * @returns the error code
  8575. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  8576. */
  8577. getError(): number;
  8578. /**
  8579. * Gets the current framerate
  8580. * @returns a number representing the framerate
  8581. */
  8582. getFps(): number;
  8583. /**
  8584. * Gets the time spent between current and previous frame
  8585. * @returns a number representing the delta time in ms
  8586. */
  8587. getDeltaTime(): number;
  8588. private _measureFps();
  8589. /** @hidden */
  8590. private _canRenderToFloatFramebuffer();
  8591. private _canRenderToHalfFloatFramebuffer();
  8592. private _canRenderToFramebuffer(type);
  8593. /** @hidden */
  8594. private _getInternalFormat(format);
  8595. /** @hidden */
  8596. /** @hidden */
  8597. /**
  8598. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  8599. * @return the new query
  8600. */
  8601. createQuery(): WebGLQuery;
  8602. /**
  8603. * Delete and release a webGL query
  8604. * @param query defines the query to delete
  8605. * @return the current engine
  8606. */
  8607. deleteQuery(query: WebGLQuery): Engine;
  8608. /**
  8609. * Check if a given query has resolved and got its value
  8610. * @param query defines the query to check
  8611. * @returns true if the query got its value
  8612. */
  8613. isQueryResultAvailable(query: WebGLQuery): boolean;
  8614. /**
  8615. * Gets the value of a given query
  8616. * @param query defines the query to check
  8617. * @returns the value of the query
  8618. */
  8619. getQueryResult(query: WebGLQuery): number;
  8620. /**
  8621. * Initiates an occlusion query
  8622. * @param algorithmType defines the algorithm to use
  8623. * @param query defines the query to use
  8624. * @returns the current engine
  8625. * @see http://doc.babylonjs.com/features/occlusionquery
  8626. */
  8627. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  8628. /**
  8629. * Ends an occlusion query
  8630. * @see http://doc.babylonjs.com/features/occlusionquery
  8631. * @param algorithmType defines the algorithm to use
  8632. * @returns the current engine
  8633. */
  8634. endOcclusionQuery(algorithmType: number): Engine;
  8635. private _createTimeQuery();
  8636. private _deleteTimeQuery(query);
  8637. private _getTimeQueryResult(query);
  8638. private _getTimeQueryAvailability(query);
  8639. private _currentNonTimestampToken;
  8640. /**
  8641. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  8642. * Please note that only one query can be issued at a time
  8643. * @returns a time token used to track the time span
  8644. */
  8645. startTimeQuery(): Nullable<_TimeToken>;
  8646. /**
  8647. * Ends a time query
  8648. * @param token defines the token used to measure the time span
  8649. * @returns the time spent (in ns)
  8650. */
  8651. endTimeQuery(token: _TimeToken): int;
  8652. private getGlAlgorithmType(algorithmType);
  8653. /**
  8654. * Creates a webGL transform feedback object
  8655. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  8656. * @returns the webGL transform feedback object
  8657. */
  8658. createTransformFeedback(): WebGLTransformFeedback;
  8659. /**
  8660. * Delete a webGL transform feedback object
  8661. * @param value defines the webGL transform feedback object to delete
  8662. */
  8663. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  8664. /**
  8665. * Bind a webGL transform feedback object to the webgl context
  8666. * @param value defines the webGL transform feedback object to bind
  8667. */
  8668. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  8669. /**
  8670. * Begins a transform feedback operation
  8671. * @param usePoints defines if points or triangles must be used
  8672. */
  8673. beginTransformFeedback(usePoints?: boolean): void;
  8674. /**
  8675. * Ends a transform feedback operation
  8676. */
  8677. endTransformFeedback(): void;
  8678. /**
  8679. * Specify the varyings to use with transform feedback
  8680. * @param program defines the associated webGL program
  8681. * @param value defines the list of strings representing the varying names
  8682. */
  8683. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  8684. /**
  8685. * Bind a webGL buffer for a transform feedback operation
  8686. * @param value defines the webGL buffer to bind
  8687. */
  8688. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  8689. /** @hidden */
  8690. /** @hidden */
  8691. private _partialLoadFile(url, index, loadedFiles, scene, onfinish, onErrorCallBack?);
  8692. private _cascadeLoadFiles(scene, onfinish, files, onError?);
  8693. /**
  8694. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  8695. * @returns true if the engine can be created
  8696. * @ignorenaming
  8697. */
  8698. static isSupported(): boolean;
  8699. }
  8700. }
  8701. declare module BABYLON {
  8702. class NullEngineOptions {
  8703. renderWidth: number;
  8704. renderHeight: number;
  8705. textureSize: number;
  8706. deterministicLockstep: boolean;
  8707. lockstepMaxSteps: number;
  8708. }
  8709. /**
  8710. * The null engine class provides support for headless version of babylon.js.
  8711. * This can be used in server side scenario or for testing purposes
  8712. */
  8713. class NullEngine extends Engine {
  8714. private _options;
  8715. isDeterministicLockStep(): boolean;
  8716. getLockstepMaxSteps(): number;
  8717. getHardwareScalingLevel(): number;
  8718. constructor(options?: NullEngineOptions);
  8719. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  8720. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  8721. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  8722. getRenderWidth(useScreen?: boolean): number;
  8723. getRenderHeight(useScreen?: boolean): number;
  8724. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  8725. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  8726. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  8727. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  8728. bindSamplers(effect: Effect): void;
  8729. enableEffect(effect: Effect): void;
  8730. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  8731. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  8732. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  8733. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  8734. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  8735. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  8736. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  8737. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  8738. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  8739. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  8740. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  8741. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  8742. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  8743. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  8744. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  8745. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  8746. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  8747. setFloat(uniform: WebGLUniformLocation, value: number): void;
  8748. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  8749. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  8750. setBool(uniform: WebGLUniformLocation, bool: number): void;
  8751. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  8752. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  8753. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  8754. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  8755. bindBuffers(vertexBuffers: {
  8756. [key: string]: VertexBuffer;
  8757. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  8758. wipeCaches(bruteForce?: boolean): void;
  8759. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  8760. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  8761. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  8762. 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;
  8763. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8764. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  8765. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  8766. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  8767. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  8768. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  8769. /**
  8770. * Updates a dynamic vertex buffer.
  8771. * @param vertexBuffer the vertex buffer to update
  8772. * @param data the data used to update the vertex buffer
  8773. * @param byteOffset the byte offset of the data (optional)
  8774. * @param byteLength the byte length of the data (optional)
  8775. */
  8776. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  8777. protected _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  8778. releaseEffects(): void;
  8779. }
  8780. }
  8781. interface WebGLRenderingContext {
  8782. readonly RASTERIZER_DISCARD: number;
  8783. readonly DEPTH_COMPONENT24: number;
  8784. readonly TEXTURE_3D: number;
  8785. readonly TEXTURE_2D_ARRAY: number;
  8786. readonly TEXTURE_COMPARE_FUNC: number;
  8787. readonly TEXTURE_COMPARE_MODE: number;
  8788. readonly COMPARE_REF_TO_TEXTURE: number;
  8789. readonly TEXTURE_WRAP_R: number;
  8790. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  8791. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  8792. 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;
  8793. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  8794. readonly TRANSFORM_FEEDBACK: number;
  8795. readonly INTERLEAVED_ATTRIBS: number;
  8796. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  8797. createTransformFeedback(): WebGLTransformFeedback;
  8798. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  8799. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  8800. beginTransformFeedback(primitiveMode: number): void;
  8801. endTransformFeedback(): void;
  8802. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  8803. }
  8804. interface ImageBitmap {
  8805. readonly width: number;
  8806. readonly height: number;
  8807. close(): void;
  8808. }
  8809. interface WebGLQuery extends WebGLObject {
  8810. }
  8811. declare var WebGLQuery: {
  8812. prototype: WebGLQuery;
  8813. new (): WebGLQuery;
  8814. };
  8815. interface WebGLSampler extends WebGLObject {
  8816. }
  8817. declare var WebGLSampler: {
  8818. prototype: WebGLSampler;
  8819. new (): WebGLSampler;
  8820. };
  8821. interface WebGLSync extends WebGLObject {
  8822. }
  8823. declare var WebGLSync: {
  8824. prototype: WebGLSync;
  8825. new (): WebGLSync;
  8826. };
  8827. interface WebGLTransformFeedback extends WebGLObject {
  8828. }
  8829. declare var WebGLTransformFeedback: {
  8830. prototype: WebGLTransformFeedback;
  8831. new (): WebGLTransformFeedback;
  8832. };
  8833. interface WebGLVertexArrayObject extends WebGLObject {
  8834. }
  8835. declare var WebGLVertexArrayObject: {
  8836. prototype: WebGLVertexArrayObject;
  8837. new (): WebGLVertexArrayObject;
  8838. };
  8839. declare module BABYLON {
  8840. class KeyboardEventTypes {
  8841. private static _KEYDOWN: number;
  8842. private static _KEYUP: number;
  8843. static readonly KEYDOWN: number;
  8844. static readonly KEYUP: number;
  8845. }
  8846. class KeyboardInfo {
  8847. type: number;
  8848. event: KeyboardEvent;
  8849. constructor(type: number, event: KeyboardEvent);
  8850. }
  8851. /**
  8852. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8853. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8854. */
  8855. class KeyboardInfoPre extends KeyboardInfo {
  8856. constructor(type: number, event: KeyboardEvent);
  8857. skipOnPointerObservable: boolean;
  8858. }
  8859. }
  8860. declare module BABYLON {
  8861. class PointerEventTypes {
  8862. private static _POINTERDOWN: number;
  8863. private static _POINTERUP: number;
  8864. private static _POINTERMOVE: number;
  8865. private static _POINTERWHEEL: number;
  8866. private static _POINTERPICK: number;
  8867. private static _POINTERTAP: number;
  8868. private static _POINTERDOUBLETAP: number;
  8869. static readonly POINTERDOWN: number;
  8870. static readonly POINTERUP: number;
  8871. static readonly POINTERMOVE: number;
  8872. static readonly POINTERWHEEL: number;
  8873. static readonly POINTERPICK: number;
  8874. static readonly POINTERTAP: number;
  8875. static readonly POINTERDOUBLETAP: number;
  8876. }
  8877. class PointerInfoBase {
  8878. type: number;
  8879. event: PointerEvent | MouseWheelEvent;
  8880. constructor(type: number, event: PointerEvent | MouseWheelEvent);
  8881. }
  8882. /**
  8883. * This class is used to store pointer related info for the onPrePointerObservable event.
  8884. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  8885. */
  8886. class PointerInfoPre extends PointerInfoBase {
  8887. /**
  8888. * Ray from a pointer if availible (eg. 6dof controller)
  8889. */
  8890. ray: Nullable<Ray>;
  8891. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  8892. localPosition: Vector2;
  8893. skipOnPointerObservable: boolean;
  8894. }
  8895. /**
  8896. * This type contains all the data related to a pointer event in Babylon.js.
  8897. * 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.
  8898. */
  8899. class PointerInfo extends PointerInfoBase {
  8900. pickInfo: Nullable<PickingInfo>;
  8901. constructor(type: number, event: PointerEvent | MouseWheelEvent, pickInfo: Nullable<PickingInfo>);
  8902. }
  8903. }
  8904. /**
  8905. * Module Debug contains the (visual) components to debug a scene correctly
  8906. */
  8907. declare module BABYLON.Debug {
  8908. /**
  8909. * The Axes viewer will show 3 axes in a specific point in space
  8910. */
  8911. class AxesViewer {
  8912. private _xline;
  8913. private _yline;
  8914. private _zline;
  8915. private _xmesh;
  8916. private _ymesh;
  8917. private _zmesh;
  8918. /**
  8919. * Gets the hosting scene
  8920. */
  8921. scene: Nullable<Scene>;
  8922. /**
  8923. * Gets or sets a number used to scale line length
  8924. */
  8925. scaleLines: number;
  8926. /**
  8927. * Creates a new AxesViewer
  8928. * @param scene defines the hosting scene
  8929. * @param scaleLines defines a number used to scale line length (1 by default)
  8930. */
  8931. constructor(scene: Scene, scaleLines?: number);
  8932. /**
  8933. * Force the viewer to update
  8934. * @param position defines the position of the viewer
  8935. * @param xaxis defines the x axis of the viewer
  8936. * @param yaxis defines the y axis of the viewer
  8937. * @param zaxis defines the z axis of the viewer
  8938. */
  8939. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  8940. /** Releases resources */
  8941. dispose(): void;
  8942. }
  8943. }
  8944. declare module BABYLON.Debug {
  8945. /**
  8946. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  8947. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  8948. */
  8949. class BoneAxesViewer extends AxesViewer {
  8950. /**
  8951. * Gets or sets the target mesh where to display the axes viewer
  8952. */
  8953. mesh: Nullable<Mesh>;
  8954. /**
  8955. * Gets or sets the target bone where to display the axes viewer
  8956. */
  8957. bone: Nullable<Bone>;
  8958. /** Gets current position */
  8959. pos: Vector3;
  8960. /** Gets direction of X axis */
  8961. xaxis: Vector3;
  8962. /** Gets direction of Y axis */
  8963. yaxis: Vector3;
  8964. /** Gets direction of Z axis */
  8965. zaxis: Vector3;
  8966. /**
  8967. * Creates a new BoneAxesViewer
  8968. * @param scene defines the hosting scene
  8969. * @param bone defines the target bone
  8970. * @param mesh defines the target mesh
  8971. * @param scaleLines defines a scaling factor for line length (1 by default)
  8972. */
  8973. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  8974. /**
  8975. * Force the viewer to update
  8976. */
  8977. update(): void;
  8978. /** Releases resources */
  8979. dispose(): void;
  8980. }
  8981. }
  8982. declare module BABYLON {
  8983. class DebugLayer {
  8984. private _scene;
  8985. static InspectorURL: string;
  8986. private _inspector;
  8987. private BJSINSPECTOR;
  8988. onPropertyChangedObservable: BABYLON.Observable<{
  8989. object: any;
  8990. property: string;
  8991. value: any;
  8992. initialValue: any;
  8993. }>;
  8994. constructor(scene: Scene);
  8995. /** Creates the inspector window. */
  8996. private _createInspector(config?);
  8997. isVisible(): boolean;
  8998. hide(): void;
  8999. /**
  9000. *
  9001. * Launch the debugLayer.
  9002. *
  9003. * initialTab:
  9004. * | Value | Tab Name |
  9005. * | --- | --- |
  9006. * | 0 | Scene |
  9007. * | 1 | Console |
  9008. * | 2 | Stats |
  9009. * | 3 | Textures |
  9010. * | 4 | Mesh |
  9011. * | 5 | Light |
  9012. * | 6 | Material |
  9013. * | 7 | GLTF |
  9014. * | 8 | GUI |
  9015. * | 9 | Physics |
  9016. * | 10 | Camera |
  9017. * | 11 | Audio |
  9018. *
  9019. */
  9020. show(config?: {
  9021. popup?: boolean;
  9022. initialTab?: number;
  9023. parentElement?: HTMLElement;
  9024. newColors?: {
  9025. backgroundColor?: string;
  9026. backgroundColorLighter?: string;
  9027. backgroundColorLighter2?: string;
  9028. backgroundColorLighter3?: string;
  9029. color?: string;
  9030. colorTop?: string;
  9031. colorBot?: string;
  9032. };
  9033. }): void;
  9034. /**
  9035. * Gets the active tab
  9036. * @return the index of the active tab or -1 if the inspector is hidden
  9037. */
  9038. getActiveTab(): number;
  9039. }
  9040. }
  9041. declare module BABYLON.Debug {
  9042. /**
  9043. * Used to show the physics impostor around the specific mesh
  9044. */
  9045. class PhysicsViewer {
  9046. /** @hidden */
  9047. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  9048. /** @hidden */
  9049. protected _meshes: Array<Nullable<AbstractMesh>>;
  9050. /** @hidden */
  9051. protected _scene: Nullable<Scene>;
  9052. /** @hidden */
  9053. protected _numMeshes: number;
  9054. /** @hidden */
  9055. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  9056. private _renderFunction;
  9057. private _debugBoxMesh;
  9058. private _debugSphereMesh;
  9059. private _debugMaterial;
  9060. /**
  9061. * Creates a new PhysicsViewer
  9062. * @param scene defines the hosting scene
  9063. */
  9064. constructor(scene: Scene);
  9065. /** @hidden */
  9066. protected _updateDebugMeshes(): void;
  9067. /**
  9068. * Renders a specified physic impostor
  9069. * @param impostor defines the impostor to render
  9070. */
  9071. showImpostor(impostor: PhysicsImpostor): void;
  9072. /**
  9073. * Hides a specified physic impostor
  9074. * @param impostor defines the impostor to hide
  9075. */
  9076. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  9077. private _getDebugMaterial(scene);
  9078. private _getDebugBoxMesh(scene);
  9079. private _getDebugSphereMesh(scene);
  9080. private _getDebugMesh(impostor, scene);
  9081. /** Releases all resources */
  9082. dispose(): void;
  9083. }
  9084. }
  9085. declare module BABYLON {
  9086. class RayHelper {
  9087. ray: Nullable<Ray>;
  9088. private _renderPoints;
  9089. private _renderLine;
  9090. private _renderFunction;
  9091. private _scene;
  9092. private _updateToMeshFunction;
  9093. private _attachedToMesh;
  9094. private _meshSpaceDirection;
  9095. private _meshSpaceOrigin;
  9096. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  9097. constructor(ray: Ray);
  9098. show(scene: Scene, color?: Color3): void;
  9099. hide(): void;
  9100. private _render();
  9101. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  9102. detachFromMesh(): void;
  9103. private _updateToMesh();
  9104. dispose(): void;
  9105. }
  9106. }
  9107. declare module BABYLON.Debug {
  9108. /**
  9109. * Class used to render a debug view of a given skeleton
  9110. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  9111. */
  9112. class SkeletonViewer {
  9113. /** defines the skeleton to render */
  9114. skeleton: Skeleton;
  9115. /** defines the mesh attached to the skeleton */
  9116. mesh: AbstractMesh;
  9117. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  9118. autoUpdateBonesMatrices: boolean;
  9119. /** defines the rendering group id to use with the viewer */
  9120. renderingGroupId: number;
  9121. /** Gets or sets the color used to render the skeleton */
  9122. color: Color3;
  9123. private _scene;
  9124. private _debugLines;
  9125. private _debugMesh;
  9126. private _isEnabled;
  9127. private _renderFunction;
  9128. /**
  9129. * Creates a new SkeletonViewer
  9130. * @param skeleton defines the skeleton to render
  9131. * @param mesh defines the mesh attached to the skeleton
  9132. * @param scene defines the hosting scene
  9133. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  9134. * @param renderingGroupId defines the rendering group id to use with the viewer
  9135. */
  9136. constructor(
  9137. /** defines the skeleton to render */
  9138. skeleton: Skeleton,
  9139. /** defines the mesh attached to the skeleton */
  9140. mesh: AbstractMesh, scene: Scene,
  9141. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  9142. autoUpdateBonesMatrices?: boolean,
  9143. /** defines the rendering group id to use with the viewer */
  9144. renderingGroupId?: number);
  9145. /** Gets or sets a boolean indicating if the viewer is enabled */
  9146. isEnabled: boolean;
  9147. private _getBonePosition(position, bone, meshMat, x?, y?, z?);
  9148. private _getLinesForBonesWithLength(bones, meshMat);
  9149. private _getLinesForBonesNoLength(bones, meshMat);
  9150. /** Update the viewer to sync with current skeleton state */
  9151. update(): void;
  9152. /** Release associated resources */
  9153. dispose(): void;
  9154. }
  9155. }
  9156. declare module BABYLON {
  9157. class StickValues {
  9158. x: number;
  9159. y: number;
  9160. constructor(x: number, y: number);
  9161. }
  9162. interface GamepadButtonChanges {
  9163. changed: boolean;
  9164. pressChanged: boolean;
  9165. touchChanged: boolean;
  9166. valueChanged: boolean;
  9167. }
  9168. class Gamepad {
  9169. id: string;
  9170. index: number;
  9171. browserGamepad: any;
  9172. type: number;
  9173. private _leftStick;
  9174. private _rightStick;
  9175. private _leftStickAxisX;
  9176. private _leftStickAxisY;
  9177. private _rightStickAxisX;
  9178. private _rightStickAxisY;
  9179. private _onleftstickchanged;
  9180. private _onrightstickchanged;
  9181. static GAMEPAD: number;
  9182. static GENERIC: number;
  9183. static XBOX: number;
  9184. static POSE_ENABLED: number;
  9185. protected _invertLeftStickY: boolean;
  9186. readonly isConnected: boolean;
  9187. constructor(id: string, index: number, browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  9188. onleftstickchanged(callback: (values: StickValues) => void): void;
  9189. onrightstickchanged(callback: (values: StickValues) => void): void;
  9190. leftStick: StickValues;
  9191. rightStick: StickValues;
  9192. update(): void;
  9193. dispose(): void;
  9194. }
  9195. class GenericPad extends Gamepad {
  9196. private _buttons;
  9197. private _onbuttondown;
  9198. private _onbuttonup;
  9199. onButtonDownObservable: Observable<number>;
  9200. onButtonUpObservable: Observable<number>;
  9201. onbuttondown(callback: (buttonPressed: number) => void): void;
  9202. onbuttonup(callback: (buttonReleased: number) => void): void;
  9203. constructor(id: string, index: number, browserGamepad: any);
  9204. private _setButtonValue(newValue, currentValue, buttonIndex);
  9205. update(): void;
  9206. dispose(): void;
  9207. }
  9208. }
  9209. declare module BABYLON {
  9210. class GamepadManager {
  9211. private _scene;
  9212. private _babylonGamepads;
  9213. private _oneGamepadConnected;
  9214. private _gamepadEventSupported;
  9215. private _gamepadSupport;
  9216. onGamepadConnectedObservable: Observable<Gamepad>;
  9217. onGamepadDisconnectedObservable: Observable<Gamepad>;
  9218. private _onGamepadConnectedEvent;
  9219. private _onGamepadDisconnectedEvent;
  9220. constructor(_scene?: Scene | undefined);
  9221. readonly gamepads: Gamepad[];
  9222. getGamepadByType(type?: number): Nullable<Gamepad>;
  9223. dispose(): void;
  9224. private _addNewGamepad(gamepad);
  9225. private _startMonitoringGamepads();
  9226. private _stopMonitoringGamepads();
  9227. private _updateGamepadObjects();
  9228. }
  9229. }
  9230. declare module BABYLON {
  9231. /**
  9232. * Defines supported buttons for XBox360 compatible gamepads
  9233. */
  9234. enum Xbox360Button {
  9235. /** A */
  9236. A = 0,
  9237. /** B */
  9238. B = 1,
  9239. /** X */
  9240. X = 2,
  9241. /** Y */
  9242. Y = 3,
  9243. /** Start */
  9244. Start = 4,
  9245. /** Back */
  9246. Back = 5,
  9247. /** Left button */
  9248. LB = 6,
  9249. /** Right button */
  9250. RB = 7,
  9251. /** Left stick */
  9252. LeftStick = 8,
  9253. /** Right stick */
  9254. RightStick = 9,
  9255. }
  9256. /** Defines values for XBox360 DPad */
  9257. enum Xbox360Dpad {
  9258. /** Up */
  9259. Up = 0,
  9260. /** Down */
  9261. Down = 1,
  9262. /** Left */
  9263. Left = 2,
  9264. /** Right */
  9265. Right = 3,
  9266. }
  9267. /**
  9268. * Defines a XBox360 gamepad
  9269. */
  9270. class Xbox360Pad extends Gamepad {
  9271. private _leftTrigger;
  9272. private _rightTrigger;
  9273. private _onlefttriggerchanged;
  9274. private _onrighttriggerchanged;
  9275. private _onbuttondown;
  9276. private _onbuttonup;
  9277. private _ondpaddown;
  9278. private _ondpadup;
  9279. /** Observable raised when a button is pressed */
  9280. onButtonDownObservable: Observable<Xbox360Button>;
  9281. /** Observable raised when a button is released */
  9282. onButtonUpObservable: Observable<Xbox360Button>;
  9283. /** Observable raised when a pad is pressed */
  9284. onPadDownObservable: Observable<Xbox360Dpad>;
  9285. /** Observable raised when a pad is released */
  9286. onPadUpObservable: Observable<Xbox360Dpad>;
  9287. private _buttonA;
  9288. private _buttonB;
  9289. private _buttonX;
  9290. private _buttonY;
  9291. private _buttonBack;
  9292. private _buttonStart;
  9293. private _buttonLB;
  9294. private _buttonRB;
  9295. private _buttonLeftStick;
  9296. private _buttonRightStick;
  9297. private _dPadUp;
  9298. private _dPadDown;
  9299. private _dPadLeft;
  9300. private _dPadRight;
  9301. private _isXboxOnePad;
  9302. /**
  9303. * Creates a new XBox360 gamepad object
  9304. * @param id defines the id of this gamepad
  9305. * @param index defines its index
  9306. * @param gamepad defines the internal HTML gamepad object
  9307. * @param xboxOne defines if it is a XBox One gamepad
  9308. */
  9309. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  9310. /**
  9311. * Defines the callback to call when left trigger is pressed
  9312. * @param callback defines the callback to use
  9313. */
  9314. onlefttriggerchanged(callback: (value: number) => void): void;
  9315. /**
  9316. * Defines the callback to call when right trigger is pressed
  9317. * @param callback defines the callback to use
  9318. */
  9319. onrighttriggerchanged(callback: (value: number) => void): void;
  9320. /**
  9321. * Gets or sets left trigger value
  9322. */
  9323. leftTrigger: number;
  9324. /**
  9325. * Gets or sets right trigger value
  9326. */
  9327. rightTrigger: number;
  9328. /**
  9329. * Defines the callback to call when a button is pressed
  9330. * @param callback defines the callback to use
  9331. */
  9332. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  9333. /**
  9334. * Defines the callback to call when a button is released
  9335. * @param callback defines the callback to use
  9336. */
  9337. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  9338. /**
  9339. * Defines the callback to call when a pad is pressed
  9340. * @param callback defines the callback to use
  9341. */
  9342. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  9343. /**
  9344. * Defines the callback to call when a pad is released
  9345. * @param callback defines the callback to use
  9346. */
  9347. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  9348. private _setButtonValue(newValue, currentValue, buttonType);
  9349. private _setDPadValue(newValue, currentValue, buttonType);
  9350. /** Gets or sets value of A button */
  9351. buttonA: number;
  9352. /** Gets or sets value of B button */
  9353. buttonB: number;
  9354. /** Gets or sets value of X button */
  9355. buttonX: number;
  9356. /** Gets or sets value of Y button */
  9357. buttonY: number;
  9358. /** Gets or sets value of Start button */
  9359. buttonStart: number;
  9360. /** Gets or sets value of Back button */
  9361. buttonBack: number;
  9362. /** Gets or sets value of Left button */
  9363. buttonLB: number;
  9364. /** Gets or sets value of Right button */
  9365. buttonRB: number;
  9366. /** Gets or sets value of left stick */
  9367. buttonLeftStick: number;
  9368. /** Gets or sets value of right stick */
  9369. buttonRightStick: number;
  9370. /** Gets or sets value of DPad up */
  9371. dPadUp: number;
  9372. /** Gets or sets value of DPad down */
  9373. dPadDown: number;
  9374. /** Gets or sets value of DPad left */
  9375. dPadLeft: number;
  9376. /** Gets or sets value of DPad right */
  9377. dPadRight: number;
  9378. /**
  9379. * Force the gamepad to synchronize with device values
  9380. */
  9381. update(): void;
  9382. dispose(): void;
  9383. }
  9384. }
  9385. declare module BABYLON {
  9386. /**
  9387. * Single axis drag gizmo
  9388. */
  9389. class AxisDragGizmo extends Gizmo {
  9390. private _dragBehavior;
  9391. /**
  9392. * Creates an AxisDragGizmo
  9393. * @param gizmoLayer The utility layer the gizmo will be added to
  9394. * @param dragAxis The axis which the gizmo will be able to drag on
  9395. * @param color The color of the gizmo
  9396. */
  9397. constructor(gizmoLayer: UtilityLayerRenderer, dragAxis: Vector3, color: Color3);
  9398. protected _onInteractionsEnabledChanged(value: boolean): void;
  9399. /**
  9400. * Disposes of the gizmo
  9401. */
  9402. dispose(): void;
  9403. }
  9404. }
  9405. declare module BABYLON {
  9406. /**
  9407. * Single axis scale gizmo
  9408. */
  9409. class AxisScaleGizmo extends Gizmo {
  9410. private _dragBehavior;
  9411. /**
  9412. * Creates an AxisScaleGizmo
  9413. * @param gizmoLayer The utility layer the gizmo will be added to
  9414. * @param dragAxis The axis which the gizmo will be able to scale on
  9415. * @param color The color of the gizmo
  9416. */
  9417. constructor(gizmoLayer: UtilityLayerRenderer, dragAxis: Vector3, color: Color3);
  9418. protected _onInteractionsEnabledChanged(value: boolean): void;
  9419. /**
  9420. * Disposes of the gizmo
  9421. */
  9422. dispose(): void;
  9423. }
  9424. }
  9425. declare module BABYLON {
  9426. /**
  9427. * Bounding box gizmo
  9428. */
  9429. class BoundingBoxGizmo extends Gizmo {
  9430. private _lineBoundingBox;
  9431. private _rotateSpheresParent;
  9432. private _scaleBoxesParent;
  9433. private _boundingDimensions;
  9434. private _renderObserver;
  9435. private _pointerObserver;
  9436. private _scaleDragSpeed;
  9437. private _tmpQuaternion;
  9438. private _tmpVector;
  9439. /**
  9440. * Creates an BoundingBoxGizmo
  9441. * @param gizmoLayer The utility layer the gizmo will be added to
  9442. * @param color The color of the gizmo
  9443. */
  9444. constructor(gizmoLayer: UtilityLayerRenderer, color: Color3);
  9445. private _selectNode(selectedMesh);
  9446. private _updateBoundingBox();
  9447. /**
  9448. * Disposes of the gizmo
  9449. */
  9450. dispose(): void;
  9451. }
  9452. }
  9453. declare module BABYLON {
  9454. /**
  9455. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  9456. */
  9457. class Gizmo implements IDisposable {
  9458. /** The utility layer the gizmo will be added to */ gizmoLayer: UtilityLayerRenderer;
  9459. /**
  9460. * The root mesh of the gizmo
  9461. */
  9462. protected _rootMesh: Mesh;
  9463. /**
  9464. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  9465. */
  9466. attachedMesh: Nullable<AbstractMesh>;
  9467. /**
  9468. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  9469. */
  9470. updateGizmoRotationToMatchAttachedMesh: boolean;
  9471. /**
  9472. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  9473. */
  9474. updateGizmoPositionToMatchAttachedMesh: boolean;
  9475. /**
  9476. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  9477. */
  9478. protected _updateScale: boolean;
  9479. protected _interactionsEnabled: boolean;
  9480. protected _onInteractionsEnabledChanged(value: boolean): void;
  9481. /**
  9482. * If interactions are enabled with this gizmo. (eg. dragging/rotation)
  9483. */
  9484. interactionsEnabled: boolean;
  9485. private _beforeRenderObserver;
  9486. /**
  9487. * Creates a gizmo
  9488. * @param gizmoLayer The utility layer the gizmo will be added to
  9489. */
  9490. constructor(/** The utility layer the gizmo will be added to */ gizmoLayer: UtilityLayerRenderer);
  9491. /**
  9492. * Disposes of the gizmo
  9493. */
  9494. dispose(): void;
  9495. }
  9496. }
  9497. declare module BABYLON {
  9498. /**
  9499. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  9500. */
  9501. class GizmoManager implements IDisposable {
  9502. private scene;
  9503. private _gizmoLayer;
  9504. private _gizmoSet;
  9505. private _pointerObserver;
  9506. /**
  9507. * Instatiates a gizmo manager
  9508. * @param scene the scene to overlay the gizmos on top of
  9509. * @param options If only a single gizmo should exist at one time
  9510. */
  9511. constructor(scene: Scene, options?: {
  9512. singleGizmo?: boolean;
  9513. });
  9514. /**
  9515. * Disposes of the gizmo manager
  9516. */
  9517. dispose(): void;
  9518. private _clearGizmos();
  9519. }
  9520. }
  9521. declare module BABYLON {
  9522. /**
  9523. * Single plane rotation gizmo
  9524. */
  9525. class PlaneRotationGizmo extends Gizmo {
  9526. private _dragBehavior;
  9527. /**
  9528. * Creates a PlaneRotationGizmo
  9529. * @param gizmoLayer The utility layer the gizmo will be added to
  9530. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  9531. * @param color The color of the gizmo
  9532. */
  9533. constructor(gizmoLayer: UtilityLayerRenderer, planeNormal: Vector3, color: Color3);
  9534. protected _onInteractionsEnabledChanged(value: boolean): void;
  9535. /**
  9536. * Disposes of the gizmo
  9537. */
  9538. dispose(): void;
  9539. }
  9540. }
  9541. declare module BABYLON {
  9542. /**
  9543. * Gizmo that enables dragging a mesh along 3 axis
  9544. */
  9545. class PositionGizmo extends Gizmo {
  9546. private _xDrag;
  9547. private _yDrag;
  9548. private _zDrag;
  9549. attachedMesh: Nullable<AbstractMesh>;
  9550. /**
  9551. * Creates a PositionGizmo
  9552. * @param gizmoLayer The utility layer the gizmo will be added to
  9553. */
  9554. constructor(gizmoLayer: UtilityLayerRenderer);
  9555. protected _onInteractionsEnabledChanged(value: boolean): void;
  9556. /**
  9557. * Disposes of the gizmo
  9558. */
  9559. dispose(): void;
  9560. }
  9561. }
  9562. declare module BABYLON {
  9563. /**
  9564. * Gizmo that enables rotating a mesh along 3 axis
  9565. */
  9566. class RotationGizmo extends Gizmo {
  9567. private _xDrag;
  9568. private _yDrag;
  9569. private _zDrag;
  9570. attachedMesh: Nullable<AbstractMesh>;
  9571. /**
  9572. * Creates a RotationGizmo
  9573. * @param gizmoLayer The utility layer the gizmo will be added to
  9574. */
  9575. constructor(gizmoLayer: UtilityLayerRenderer);
  9576. protected _onInteractionsEnabledChanged(value: boolean): void;
  9577. /**
  9578. * Disposes of the gizmo
  9579. */
  9580. dispose(): void;
  9581. }
  9582. }
  9583. declare module BABYLON {
  9584. /**
  9585. * Gizmo that enables scaling a mesh along 3 axis
  9586. */
  9587. class ScaleGizmo extends Gizmo {
  9588. private _xDrag;
  9589. private _yDrag;
  9590. private _zDrag;
  9591. attachedMesh: Nullable<AbstractMesh>;
  9592. /**
  9593. * Creates a ScaleGizmo
  9594. * @param gizmoLayer The utility layer the gizmo will be added to
  9595. */
  9596. constructor(gizmoLayer: UtilityLayerRenderer);
  9597. protected _onInteractionsEnabledChanged(value: boolean): void;
  9598. /**
  9599. * Disposes of the gizmo
  9600. */
  9601. dispose(): void;
  9602. }
  9603. }
  9604. declare module BABYLON {
  9605. /**
  9606. * Represents the different options available during the creation of
  9607. * a Environment helper.
  9608. *
  9609. * This can control the default ground, skybox and image processing setup of your scene.
  9610. */
  9611. interface IEnvironmentHelperOptions {
  9612. /**
  9613. * Specifies wether or not to create a ground.
  9614. * True by default.
  9615. */
  9616. createGround: boolean;
  9617. /**
  9618. * Specifies the ground size.
  9619. * 15 by default.
  9620. */
  9621. groundSize: number;
  9622. /**
  9623. * The texture used on the ground for the main color.
  9624. * Comes from the BabylonJS CDN by default.
  9625. *
  9626. * Remarks: Can be either a texture or a url.
  9627. */
  9628. groundTexture: string | BaseTexture;
  9629. /**
  9630. * The color mixed in the ground texture by default.
  9631. * BabylonJS clearColor by default.
  9632. */
  9633. groundColor: Color3;
  9634. /**
  9635. * Specifies the ground opacity.
  9636. * 1 by default.
  9637. */
  9638. groundOpacity: number;
  9639. /**
  9640. * Enables the ground to receive shadows.
  9641. * True by default.
  9642. */
  9643. enableGroundShadow: boolean;
  9644. /**
  9645. * Helps preventing the shadow to be fully black on the ground.
  9646. * 0.5 by default.
  9647. */
  9648. groundShadowLevel: number;
  9649. /**
  9650. * Creates a mirror texture attach to the ground.
  9651. * false by default.
  9652. */
  9653. enableGroundMirror: boolean;
  9654. /**
  9655. * Specifies the ground mirror size ratio.
  9656. * 0.3 by default as the default kernel is 64.
  9657. */
  9658. groundMirrorSizeRatio: number;
  9659. /**
  9660. * Specifies the ground mirror blur kernel size.
  9661. * 64 by default.
  9662. */
  9663. groundMirrorBlurKernel: number;
  9664. /**
  9665. * Specifies the ground mirror visibility amount.
  9666. * 1 by default
  9667. */
  9668. groundMirrorAmount: number;
  9669. /**
  9670. * Specifies the ground mirror reflectance weight.
  9671. * This uses the standard weight of the background material to setup the fresnel effect
  9672. * of the mirror.
  9673. * 1 by default.
  9674. */
  9675. groundMirrorFresnelWeight: number;
  9676. /**
  9677. * Specifies the ground mirror Falloff distance.
  9678. * This can helps reducing the size of the reflection.
  9679. * 0 by Default.
  9680. */
  9681. groundMirrorFallOffDistance: number;
  9682. /**
  9683. * Specifies the ground mirror texture type.
  9684. * Unsigned Int by Default.
  9685. */
  9686. groundMirrorTextureType: number;
  9687. /**
  9688. * Specifies a bias applied to the ground vertical position to prevent z-fighyting with
  9689. * the shown objects.
  9690. */
  9691. groundYBias: number;
  9692. /**
  9693. * Specifies wether or not to create a skybox.
  9694. * True by default.
  9695. */
  9696. createSkybox: boolean;
  9697. /**
  9698. * Specifies the skybox size.
  9699. * 20 by default.
  9700. */
  9701. skyboxSize: number;
  9702. /**
  9703. * The texture used on the skybox for the main color.
  9704. * Comes from the BabylonJS CDN by default.
  9705. *
  9706. * Remarks: Can be either a texture or a url.
  9707. */
  9708. skyboxTexture: string | BaseTexture;
  9709. /**
  9710. * The color mixed in the skybox texture by default.
  9711. * BabylonJS clearColor by default.
  9712. */
  9713. skyboxColor: Color3;
  9714. /**
  9715. * The background rotation around the Y axis of the scene.
  9716. * This helps aligning the key lights of your scene with the background.
  9717. * 0 by default.
  9718. */
  9719. backgroundYRotation: number;
  9720. /**
  9721. * Compute automatically the size of the elements to best fit with the scene.
  9722. */
  9723. sizeAuto: boolean;
  9724. /**
  9725. * Default position of the rootMesh if autoSize is not true.
  9726. */
  9727. rootPosition: Vector3;
  9728. /**
  9729. * Sets up the image processing in the scene.
  9730. * true by default.
  9731. */
  9732. setupImageProcessing: boolean;
  9733. /**
  9734. * The texture used as your environment texture in the scene.
  9735. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  9736. *
  9737. * Remarks: Can be either a texture or a url.
  9738. */
  9739. environmentTexture: string | BaseTexture;
  9740. /**
  9741. * The value of the exposure to apply to the scene.
  9742. * 0.6 by default if setupImageProcessing is true.
  9743. */
  9744. cameraExposure: number;
  9745. /**
  9746. * The value of the contrast to apply to the scene.
  9747. * 1.6 by default if setupImageProcessing is true.
  9748. */
  9749. cameraContrast: number;
  9750. /**
  9751. * Specifies wether or not tonemapping should be enabled in the scene.
  9752. * true by default if setupImageProcessing is true.
  9753. */
  9754. toneMappingEnabled: boolean;
  9755. }
  9756. /**
  9757. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  9758. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  9759. * It also helps with the default setup of your imageProcessing configuration.
  9760. */
  9761. class EnvironmentHelper {
  9762. /**
  9763. * Default ground texture URL.
  9764. */
  9765. private static _groundTextureCDNUrl;
  9766. /**
  9767. * Default skybox texture URL.
  9768. */
  9769. private static _skyboxTextureCDNUrl;
  9770. /**
  9771. * Default environment texture URL.
  9772. */
  9773. private static _environmentTextureCDNUrl;
  9774. /**
  9775. * Creates the default options for the helper.
  9776. */
  9777. private static _getDefaultOptions();
  9778. private _rootMesh;
  9779. /**
  9780. * Gets the root mesh created by the helper.
  9781. */
  9782. readonly rootMesh: Mesh;
  9783. private _skybox;
  9784. /**
  9785. * Gets the skybox created by the helper.
  9786. */
  9787. readonly skybox: Nullable<Mesh>;
  9788. private _skyboxTexture;
  9789. /**
  9790. * Gets the skybox texture created by the helper.
  9791. */
  9792. readonly skyboxTexture: Nullable<BaseTexture>;
  9793. private _skyboxMaterial;
  9794. /**
  9795. * Gets the skybox material created by the helper.
  9796. */
  9797. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  9798. private _ground;
  9799. /**
  9800. * Gets the ground mesh created by the helper.
  9801. */
  9802. readonly ground: Nullable<Mesh>;
  9803. private _groundTexture;
  9804. /**
  9805. * Gets the ground texture created by the helper.
  9806. */
  9807. readonly groundTexture: Nullable<BaseTexture>;
  9808. private _groundMirror;
  9809. /**
  9810. * Gets the ground mirror created by the helper.
  9811. */
  9812. readonly groundMirror: Nullable<MirrorTexture>;
  9813. /**
  9814. * Gets the ground mirror render list to helps pushing the meshes
  9815. * you wish in the ground reflection.
  9816. */
  9817. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  9818. private _groundMaterial;
  9819. /**
  9820. * Gets the ground material created by the helper.
  9821. */
  9822. readonly groundMaterial: Nullable<BackgroundMaterial>;
  9823. /**
  9824. * Stores the creation options.
  9825. */
  9826. private readonly _scene;
  9827. private _options;
  9828. /**
  9829. * This observable will be notified with any error during the creation of the environment,
  9830. * mainly texture creation errors.
  9831. */
  9832. onErrorObservable: Observable<{
  9833. message?: string;
  9834. exception?: any;
  9835. }>;
  9836. /**
  9837. * constructor
  9838. * @param options
  9839. * @param scene The scene to add the material to
  9840. */
  9841. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  9842. /**
  9843. * Updates the background according to the new options
  9844. * @param options
  9845. */
  9846. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  9847. /**
  9848. * Sets the primary color of all the available elements.
  9849. * @param color the main color to affect to the ground and the background
  9850. */
  9851. setMainColor(color: Color3): void;
  9852. /**
  9853. * Setup the image processing according to the specified options.
  9854. */
  9855. private _setupImageProcessing();
  9856. /**
  9857. * Setup the environment texture according to the specified options.
  9858. */
  9859. private _setupEnvironmentTexture();
  9860. /**
  9861. * Setup the background according to the specified options.
  9862. */
  9863. private _setupBackground();
  9864. /**
  9865. * Get the scene sizes according to the setup.
  9866. */
  9867. private _getSceneSize();
  9868. /**
  9869. * Setup the ground according to the specified options.
  9870. */
  9871. private _setupGround(sceneSize);
  9872. /**
  9873. * Setup the ground material according to the specified options.
  9874. */
  9875. private _setupGroundMaterial();
  9876. /**
  9877. * Setup the ground diffuse texture according to the specified options.
  9878. */
  9879. private _setupGroundDiffuseTexture();
  9880. /**
  9881. * Setup the ground mirror texture according to the specified options.
  9882. */
  9883. private _setupGroundMirrorTexture(sceneSize);
  9884. /**
  9885. * Setup the ground to receive the mirror texture.
  9886. */
  9887. private _setupMirrorInGroundMaterial();
  9888. /**
  9889. * Setup the skybox according to the specified options.
  9890. */
  9891. private _setupSkybox(sceneSize);
  9892. /**
  9893. * Setup the skybox material according to the specified options.
  9894. */
  9895. private _setupSkyboxMaterial();
  9896. /**
  9897. * Setup the skybox reflection texture according to the specified options.
  9898. */
  9899. private _setupSkyboxReflectionTexture();
  9900. private _errorHandler;
  9901. /**
  9902. * Dispose all the elements created by the Helper.
  9903. */
  9904. dispose(): void;
  9905. }
  9906. }
  9907. declare module BABYLON {
  9908. /**
  9909. * Represents all the data needed to create a ParticleSystem.
  9910. */
  9911. interface IParticleSystemData {
  9912. /**
  9913. * ParticleSystem type
  9914. */
  9915. type: string;
  9916. /**
  9917. * Shape of the emitter
  9918. */
  9919. emitterType: string;
  9920. /**
  9921. * Maximum number of particles in the system
  9922. */
  9923. capacity: number;
  9924. /**
  9925. * Link for the texture file
  9926. */
  9927. textureFile: string;
  9928. /**
  9929. * minEmitBox Vector3
  9930. */
  9931. minEmitBox?: {
  9932. x: number;
  9933. y: number;
  9934. z: number;
  9935. };
  9936. /**
  9937. * maxEmitBox Vector3
  9938. */
  9939. maxEmitBox?: {
  9940. x: number;
  9941. y: number;
  9942. z: number;
  9943. };
  9944. /**
  9945. * color1 Color4
  9946. */
  9947. color1: {
  9948. r: number;
  9949. g: number;
  9950. b: number;
  9951. a: number;
  9952. };
  9953. /**
  9954. * color2 Color4
  9955. */
  9956. color2: {
  9957. r: number;
  9958. g: number;
  9959. b: number;
  9960. a: number;
  9961. };
  9962. /**
  9963. * colorDead Color4
  9964. */
  9965. colorDead: {
  9966. r: number;
  9967. g: number;
  9968. b: number;
  9969. a: number;
  9970. };
  9971. /**
  9972. * Minimum size of each particle
  9973. */
  9974. minSize: number;
  9975. /**
  9976. * Maximum size of each particle
  9977. */
  9978. maxSize: number;
  9979. /**
  9980. * Minimum scale of each particle on X axis
  9981. */
  9982. minScaleX: number;
  9983. /**
  9984. * Maximum scale of each particle on X axis
  9985. */
  9986. maxScaleX: number;
  9987. /**
  9988. * Minimum scale of each particle on Y axis
  9989. */
  9990. minScaleY: number;
  9991. /**
  9992. * Maximum scale of each particle on Y axis
  9993. */
  9994. maxScaleY: number;
  9995. /**
  9996. * Minimum lifetime for each particle
  9997. */
  9998. minLifeTime: number;
  9999. /**
  10000. * Maximum lifetime for each particle
  10001. */
  10002. maxLifeTime: number;
  10003. /**
  10004. * Emit rate
  10005. */
  10006. emitRate: number;
  10007. /**
  10008. * Blend Mode
  10009. */
  10010. blendMode: number;
  10011. /**
  10012. * gravity Vector3
  10013. */
  10014. gravity: {
  10015. x: number;
  10016. y: number;
  10017. z: number;
  10018. };
  10019. /**
  10020. * direction1 Vector3
  10021. */
  10022. direction1?: {
  10023. x: number;
  10024. y: number;
  10025. z: number;
  10026. };
  10027. /**
  10028. * direction2 Vector3
  10029. */
  10030. direction2?: {
  10031. x: number;
  10032. y: number;
  10033. z: number;
  10034. };
  10035. /**
  10036. * Minimum Angular Speed
  10037. */
  10038. minAngularSpeed: number;
  10039. /**
  10040. * Maximum Angular Speed
  10041. */
  10042. maxAngularSpeed: number;
  10043. /**
  10044. * Minimum Emit Power
  10045. */
  10046. minEmitPower: number;
  10047. /**
  10048. * Maximum Emit Power
  10049. */
  10050. maxEmitPower: number;
  10051. /**
  10052. * Update Speed
  10053. */
  10054. updateSpeed: number;
  10055. /**
  10056. * Radius
  10057. */
  10058. radius?: number;
  10059. /**
  10060. * Angle
  10061. */
  10062. angle?: number;
  10063. }
  10064. /**
  10065. * This class is made for on one-liner static method to help creating particle systems.
  10066. */
  10067. class ParticleHelper {
  10068. /**
  10069. * Base Assets URL.
  10070. */
  10071. private static _baseAssetsUrl;
  10072. /**
  10073. * This is the main static method (one-liner) of this helper to create different particle systems.
  10074. * @param type This string represents the type to the particle system to create
  10075. * @param emitter The object where the particle system will start to emit from.
  10076. * @param scene The scene where the particle system should live.
  10077. * @param gpu If the system will use gpu.
  10078. * @returns the ParticleSystem created.
  10079. */
  10080. static CreateAsync(type: string, emitter: AbstractMesh, scene?: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystem>;
  10081. /**
  10082. * Static function used to create a new particle system from a IParticleSystemData
  10083. * @param data defines the source data
  10084. * @param scene defines the hosting scene
  10085. * @param emitter defines the particle emitter
  10086. * @returns a new ParticleSystem based on referenced data
  10087. */
  10088. static CreateSystem(data: IParticleSystemData, scene: Scene, emitter: AbstractMesh): ParticleSystem;
  10089. /**
  10090. * Static function used to update a particle system from a IParticleSystemData
  10091. * @param system defines the particle system to update
  10092. * @param data defines the source data
  10093. * @param scene defines the hosting scene
  10094. */
  10095. static UpdateSystem(system: ParticleSystem, data: IParticleSystemData, scene: Scene): void;
  10096. /**
  10097. * Static function used to export a particle system to a IParticleSystemData variable.
  10098. * Please note that texture file name is not exported and must be added manually
  10099. * @param system defines the particle system to export
  10100. */
  10101. static ExportSystem(system: ParticleSystem): IParticleSystemData;
  10102. }
  10103. }
  10104. declare module BABYLON {
  10105. /**
  10106. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  10107. * As a subclass of Node, this allow parenting to the camera with different locations in the scene.
  10108. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  10109. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  10110. */
  10111. class PhotoDome extends Node {
  10112. private _useDirectMapping;
  10113. /**
  10114. * The texture being displayed on the sphere
  10115. */
  10116. protected _photoTexture: Texture;
  10117. /**
  10118. * Gets or sets the texture being displayed on the sphere
  10119. */
  10120. photoTexture: Texture;
  10121. /**
  10122. * The skybox material
  10123. */
  10124. protected _material: BackgroundMaterial;
  10125. /**
  10126. * The surface used for the skybox
  10127. */
  10128. protected _mesh: Mesh;
  10129. /**
  10130. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  10131. * Also see the options.resolution property.
  10132. */
  10133. fovMultiplier: number;
  10134. /**
  10135. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  10136. * @param name Element's name, child elements will append suffixes for their own names.
  10137. * @param urlsOfPhoto define the url of the photo to display
  10138. * @param options An object containing optional or exposed sub element properties
  10139. */
  10140. constructor(name: string, urlOfPhoto: string, options: {
  10141. resolution?: number;
  10142. size?: number;
  10143. useDirectMapping?: boolean;
  10144. }, scene: Scene);
  10145. /**
  10146. * Releases resources associated with this node.
  10147. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10148. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10149. */
  10150. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10151. }
  10152. }
  10153. declare module BABYLON {
  10154. /**
  10155. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  10156. * As a subclass of Node, this allow parenting to the camera or multiple videos with different locations in the scene.
  10157. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  10158. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  10159. */
  10160. class VideoDome extends Node {
  10161. private _useDirectMapping;
  10162. /**
  10163. * The video texture being displayed on the sphere
  10164. */
  10165. protected _videoTexture: VideoTexture;
  10166. /**
  10167. * Gets the video texture being displayed on the sphere
  10168. */
  10169. readonly videoTexture: VideoTexture;
  10170. /**
  10171. * The skybox material
  10172. */
  10173. protected _material: BackgroundMaterial;
  10174. /**
  10175. * The surface used for the skybox
  10176. */
  10177. protected _mesh: Mesh;
  10178. /**
  10179. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  10180. * Also see the options.resolution property.
  10181. */
  10182. fovMultiplier: number;
  10183. /**
  10184. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  10185. * @param name Element's name, child elements will append suffixes for their own names.
  10186. * @param urlsOrVideo defines the url(s) or the video element to use
  10187. * @param options An object containing optional or exposed sub element properties
  10188. */
  10189. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  10190. resolution?: number;
  10191. clickToPlay?: boolean;
  10192. autoPlay?: boolean;
  10193. loop?: boolean;
  10194. size?: number;
  10195. poster?: string;
  10196. useDirectMapping?: boolean;
  10197. }, scene: Scene);
  10198. /**
  10199. * Releases resources associated with this node.
  10200. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10201. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10202. */
  10203. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10204. }
  10205. }
  10206. declare module BABYLON {
  10207. /**
  10208. * This class can be used to get instrumentation data from a Babylon engine
  10209. */
  10210. class EngineInstrumentation implements IDisposable {
  10211. engine: Engine;
  10212. private _captureGPUFrameTime;
  10213. private _gpuFrameTimeToken;
  10214. private _gpuFrameTime;
  10215. private _captureShaderCompilationTime;
  10216. private _shaderCompilationTime;
  10217. private _onBeginFrameObserver;
  10218. private _onEndFrameObserver;
  10219. private _onBeforeShaderCompilationObserver;
  10220. private _onAfterShaderCompilationObserver;
  10221. /**
  10222. * Gets the perf counter used for GPU frame time
  10223. */
  10224. readonly gpuFrameTimeCounter: PerfCounter;
  10225. /**
  10226. * Gets the GPU frame time capture status
  10227. */
  10228. /**
  10229. * Enable or disable the GPU frame time capture
  10230. */
  10231. captureGPUFrameTime: boolean;
  10232. /**
  10233. * Gets the perf counter used for shader compilation time
  10234. */
  10235. readonly shaderCompilationTimeCounter: PerfCounter;
  10236. /**
  10237. * Gets the shader compilation time capture status
  10238. */
  10239. /**
  10240. * Enable or disable the shader compilation time capture
  10241. */
  10242. captureShaderCompilationTime: boolean;
  10243. constructor(engine: Engine);
  10244. dispose(): void;
  10245. }
  10246. }
  10247. declare module BABYLON {
  10248. /**
  10249. * This class can be used to get instrumentation data from a Babylon engine
  10250. */
  10251. class SceneInstrumentation implements IDisposable {
  10252. scene: Scene;
  10253. private _captureActiveMeshesEvaluationTime;
  10254. private _activeMeshesEvaluationTime;
  10255. private _captureRenderTargetsRenderTime;
  10256. private _renderTargetsRenderTime;
  10257. private _captureFrameTime;
  10258. private _frameTime;
  10259. private _captureRenderTime;
  10260. private _renderTime;
  10261. private _captureInterFrameTime;
  10262. private _interFrameTime;
  10263. private _captureParticlesRenderTime;
  10264. private _particlesRenderTime;
  10265. private _captureSpritesRenderTime;
  10266. private _spritesRenderTime;
  10267. private _capturePhysicsTime;
  10268. private _physicsTime;
  10269. private _captureAnimationsTime;
  10270. private _animationsTime;
  10271. private _captureCameraRenderTime;
  10272. private _cameraRenderTime;
  10273. private _onBeforeActiveMeshesEvaluationObserver;
  10274. private _onAfterActiveMeshesEvaluationObserver;
  10275. private _onBeforeRenderTargetsRenderObserver;
  10276. private _onAfterRenderTargetsRenderObserver;
  10277. private _onAfterRenderObserver;
  10278. private _onBeforeDrawPhaseObserver;
  10279. private _onAfterDrawPhaseObserver;
  10280. private _onBeforeAnimationsObserver;
  10281. private _onBeforeParticlesRenderingObserver;
  10282. private _onAfterParticlesRenderingObserver;
  10283. private _onBeforeSpritesRenderingObserver;
  10284. private _onAfterSpritesRenderingObserver;
  10285. private _onBeforePhysicsObserver;
  10286. private _onAfterPhysicsObserver;
  10287. private _onAfterAnimationsObserver;
  10288. private _onBeforeCameraRenderObserver;
  10289. private _onAfterCameraRenderObserver;
  10290. /**
  10291. * Gets the perf counter used for active meshes evaluation time
  10292. */
  10293. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  10294. /**
  10295. * Gets the active meshes evaluation time capture status
  10296. */
  10297. /**
  10298. * Enable or disable the active meshes evaluation time capture
  10299. */
  10300. captureActiveMeshesEvaluationTime: boolean;
  10301. /**
  10302. * Gets the perf counter used for render targets render time
  10303. */
  10304. readonly renderTargetsRenderTimeCounter: PerfCounter;
  10305. /**
  10306. * Gets the render targets render time capture status
  10307. */
  10308. /**
  10309. * Enable or disable the render targets render time capture
  10310. */
  10311. captureRenderTargetsRenderTime: boolean;
  10312. /**
  10313. * Gets the perf counter used for particles render time
  10314. */
  10315. readonly particlesRenderTimeCounter: PerfCounter;
  10316. /**
  10317. * Gets the particles render time capture status
  10318. */
  10319. /**
  10320. * Enable or disable the particles render time capture
  10321. */
  10322. captureParticlesRenderTime: boolean;
  10323. /**
  10324. * Gets the perf counter used for sprites render time
  10325. */
  10326. readonly spritesRenderTimeCounter: PerfCounter;
  10327. /**
  10328. * Gets the sprites render time capture status
  10329. */
  10330. /**
  10331. * Enable or disable the sprites render time capture
  10332. */
  10333. captureSpritesRenderTime: boolean;
  10334. /**
  10335. * Gets the perf counter used for physics time
  10336. */
  10337. readonly physicsTimeCounter: PerfCounter;
  10338. /**
  10339. * Gets the physics time capture status
  10340. */
  10341. /**
  10342. * Enable or disable the physics time capture
  10343. */
  10344. capturePhysicsTime: boolean;
  10345. /**
  10346. * Gets the perf counter used for animations time
  10347. */
  10348. readonly animationsTimeCounter: PerfCounter;
  10349. /**
  10350. * Gets the animations time capture status
  10351. */
  10352. /**
  10353. * Enable or disable the animations time capture
  10354. */
  10355. captureAnimationsTime: boolean;
  10356. /**
  10357. * Gets the perf counter used for frame time capture
  10358. */
  10359. readonly frameTimeCounter: PerfCounter;
  10360. /**
  10361. * Gets the frame time capture status
  10362. */
  10363. /**
  10364. * Enable or disable the frame time capture
  10365. */
  10366. captureFrameTime: boolean;
  10367. /**
  10368. * Gets the perf counter used for inter-frames time capture
  10369. */
  10370. readonly interFrameTimeCounter: PerfCounter;
  10371. /**
  10372. * Gets the inter-frames time capture status
  10373. */
  10374. /**
  10375. * Enable or disable the inter-frames time capture
  10376. */
  10377. captureInterFrameTime: boolean;
  10378. /**
  10379. * Gets the perf counter used for render time capture
  10380. */
  10381. readonly renderTimeCounter: PerfCounter;
  10382. /**
  10383. * Gets the render time capture status
  10384. */
  10385. /**
  10386. * Enable or disable the render time capture
  10387. */
  10388. captureRenderTime: boolean;
  10389. /**
  10390. * Gets the perf counter used for camera render time capture
  10391. */
  10392. readonly cameraRenderTimeCounter: PerfCounter;
  10393. /**
  10394. * Gets the camera render time capture status
  10395. */
  10396. /**
  10397. * Enable or disable the camera render time capture
  10398. */
  10399. captureCameraRenderTime: boolean;
  10400. /**
  10401. * Gets the perf counter used for draw calls
  10402. */
  10403. readonly drawCallsCounter: PerfCounter;
  10404. /**
  10405. * Gets the perf counter used for texture collisions
  10406. */
  10407. readonly textureCollisionsCounter: PerfCounter;
  10408. constructor(scene: Scene);
  10409. dispose(): void;
  10410. }
  10411. }
  10412. declare module BABYLON {
  10413. /**
  10414. * @hidden
  10415. **/
  10416. class _TimeToken {
  10417. }
  10418. }
  10419. declare module BABYLON {
  10420. /**
  10421. * Effect layer options. This helps customizing the behaviour
  10422. * of the effect layer.
  10423. */
  10424. interface IEffectLayerOptions {
  10425. /**
  10426. * Multiplication factor apply to the canvas size to compute the render target size
  10427. * used to generated the objects (the smaller the faster).
  10428. */
  10429. mainTextureRatio: number;
  10430. /**
  10431. * Enforces a fixed size texture to ensure effect stability across devices.
  10432. */
  10433. mainTextureFixedSize?: number;
  10434. /**
  10435. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  10436. */
  10437. alphaBlendingMode: number;
  10438. /**
  10439. * The camera attached to the layer.
  10440. */
  10441. camera: Nullable<Camera>;
  10442. }
  10443. /**
  10444. * The effect layer Helps adding post process effect blended with the main pass.
  10445. *
  10446. * This can be for instance use to generate glow or higlight effects on the scene.
  10447. *
  10448. * The effect layer class can not be used directly and is intented to inherited from to be
  10449. * customized per effects.
  10450. */
  10451. abstract class EffectLayer {
  10452. private _vertexBuffers;
  10453. private _indexBuffer;
  10454. private _cachedDefines;
  10455. private _effectLayerMapGenerationEffect;
  10456. private _effectLayerOptions;
  10457. private _mergeEffect;
  10458. protected _scene: Scene;
  10459. protected _engine: Engine;
  10460. protected _maxSize: number;
  10461. protected _mainTextureDesiredSize: ISize;
  10462. protected _mainTexture: RenderTargetTexture;
  10463. protected _shouldRender: boolean;
  10464. protected _postProcesses: PostProcess[];
  10465. protected _textures: BaseTexture[];
  10466. protected _emissiveTextureAndColor: {
  10467. texture: Nullable<BaseTexture>;
  10468. color: Color4;
  10469. };
  10470. /**
  10471. * The name of the layer
  10472. */
  10473. name: string;
  10474. /**
  10475. * The clear color of the texture used to generate the glow map.
  10476. */
  10477. neutralColor: Color4;
  10478. /**
  10479. * Specifies wether the highlight layer is enabled or not.
  10480. */
  10481. isEnabled: boolean;
  10482. /**
  10483. * Gets the camera attached to the layer.
  10484. */
  10485. readonly camera: Nullable<Camera>;
  10486. /**
  10487. * An event triggered when the effect layer has been disposed.
  10488. */
  10489. onDisposeObservable: Observable<EffectLayer>;
  10490. /**
  10491. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  10492. */
  10493. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  10494. /**
  10495. * An event triggered when the generated texture is being merged in the scene.
  10496. */
  10497. onBeforeComposeObservable: Observable<EffectLayer>;
  10498. /**
  10499. * An event triggered when the generated texture has been merged in the scene.
  10500. */
  10501. onAfterComposeObservable: Observable<EffectLayer>;
  10502. /**
  10503. * An event triggered when the efffect layer changes its size.
  10504. */
  10505. onSizeChangedObservable: Observable<EffectLayer>;
  10506. /**
  10507. * Instantiates a new effect Layer and references it in the scene.
  10508. * @param name The name of the layer
  10509. * @param scene The scene to use the layer in
  10510. */
  10511. constructor(
  10512. /** The Friendly of the effect in the scene */
  10513. name: string, scene: Scene);
  10514. /**
  10515. * Get the effect name of the layer.
  10516. * @return The effect name
  10517. */
  10518. abstract getEffectName(): string;
  10519. /**
  10520. * Checks for the readiness of the element composing the layer.
  10521. * @param subMesh the mesh to check for
  10522. * @param useInstances specify wether or not to use instances to render the mesh
  10523. * @return true if ready otherwise, false
  10524. */
  10525. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  10526. /**
  10527. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  10528. * @returns true if the effect requires stencil during the main canvas render pass.
  10529. */
  10530. abstract needStencil(): boolean;
  10531. /**
  10532. * Create the merge effect. This is the shader use to blit the information back
  10533. * to the main canvas at the end of the scene rendering.
  10534. * @returns The effect containing the shader used to merge the effect on the main canvas
  10535. */
  10536. protected abstract _createMergeEffect(): Effect;
  10537. /**
  10538. * Creates the render target textures and post processes used in the effect layer.
  10539. */
  10540. protected abstract _createTextureAndPostProcesses(): void;
  10541. /**
  10542. * Implementation specific of rendering the generating effect on the main canvas.
  10543. * @param effect The effect used to render through
  10544. */
  10545. protected abstract _internalRender(effect: Effect): void;
  10546. /**
  10547. * Sets the required values for both the emissive texture and and the main color.
  10548. */
  10549. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  10550. /**
  10551. * Free any resources and references associated to a mesh.
  10552. * Internal use
  10553. * @param mesh The mesh to free.
  10554. */
  10555. disposeMesh(mesh: Mesh): void;
  10556. /**
  10557. * Serializes this layer (Glow or Highlight for example)
  10558. * @returns a serialized layer object
  10559. */
  10560. abstract serialize?(): any;
  10561. /**
  10562. * Initializes the effect layer with the required options.
  10563. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  10564. */
  10565. protected _init(options: Partial<IEffectLayerOptions>): void;
  10566. /**
  10567. * Generates the index buffer of the full screen quad blending to the main canvas.
  10568. */
  10569. private _generateIndexBuffer();
  10570. /**
  10571. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  10572. */
  10573. private _genrateVertexBuffer();
  10574. /**
  10575. * Sets the main texture desired size which is the closest power of two
  10576. * of the engine canvas size.
  10577. */
  10578. private _setMainTextureSize();
  10579. /**
  10580. * Creates the main texture for the effect layer.
  10581. */
  10582. protected _createMainTexture(): void;
  10583. /**
  10584. * Checks for the readiness of the element composing the layer.
  10585. * @param subMesh the mesh to check for
  10586. * @param useInstances specify wether or not to use instances to render the mesh
  10587. * @param emissiveTexture the associated emissive texture used to generate the glow
  10588. * @return true if ready otherwise, false
  10589. */
  10590. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  10591. /**
  10592. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  10593. */
  10594. render(): void;
  10595. /**
  10596. * Determine if a given mesh will be used in the current effect.
  10597. * @param mesh mesh to test
  10598. * @returns true if the mesh will be used
  10599. */
  10600. hasMesh(mesh: AbstractMesh): boolean;
  10601. /**
  10602. * Returns true if the layer contains information to display, otherwise false.
  10603. * @returns true if the glow layer should be rendered
  10604. */
  10605. shouldRender(): boolean;
  10606. /**
  10607. * Returns true if the mesh should render, otherwise false.
  10608. * @param mesh The mesh to render
  10609. * @returns true if it should render otherwise false
  10610. */
  10611. protected _shouldRenderMesh(mesh: Mesh): boolean;
  10612. /**
  10613. * Returns true if the mesh should render, otherwise false.
  10614. * @param mesh The mesh to render
  10615. * @returns true if it should render otherwise false
  10616. */
  10617. protected _shouldRenderEmissiveTextureForMesh(mesh: Mesh): boolean;
  10618. /**
  10619. * Renders the submesh passed in parameter to the generation map.
  10620. */
  10621. protected _renderSubMesh(subMesh: SubMesh): void;
  10622. /**
  10623. * Rebuild the required buffers.
  10624. * @hidden Internal use only.
  10625. */
  10626. /**
  10627. * Dispose only the render target textures and post process.
  10628. */
  10629. private _disposeTextureAndPostProcesses();
  10630. /**
  10631. * Dispose the highlight layer and free resources.
  10632. */
  10633. dispose(): void;
  10634. /**
  10635. * Gets the class name of the effect layer
  10636. * @returns the string with the class name of the effect layer
  10637. */
  10638. getClassName(): string;
  10639. /**
  10640. * Creates an effect layer from parsed effect layer data
  10641. * @param parsedEffectLayer defines effect layer data
  10642. * @param scene defines the current scene
  10643. * @param rootUrl defines the root URL containing the effect layer information
  10644. * @returns a parsed effect Layer
  10645. */
  10646. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  10647. }
  10648. }
  10649. declare module BABYLON {
  10650. /**
  10651. * Glow layer options. This helps customizing the behaviour
  10652. * of the glow layer.
  10653. */
  10654. interface IGlowLayerOptions {
  10655. /**
  10656. * Multiplication factor apply to the canvas size to compute the render target size
  10657. * used to generated the glowing objects (the smaller the faster).
  10658. */
  10659. mainTextureRatio: number;
  10660. /**
  10661. * Enforces a fixed size texture to ensure resize independant blur.
  10662. */
  10663. mainTextureFixedSize?: number;
  10664. /**
  10665. * How big is the kernel of the blur texture.
  10666. */
  10667. blurKernelSize: number;
  10668. /**
  10669. * The camera attached to the layer.
  10670. */
  10671. camera: Nullable<Camera>;
  10672. /**
  10673. * Enable MSAA by chosing the number of samples.
  10674. */
  10675. mainTextureSamples?: number;
  10676. }
  10677. /**
  10678. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  10679. *
  10680. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  10681. * glowy meshes to your scene.
  10682. *
  10683. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  10684. */
  10685. class GlowLayer extends EffectLayer {
  10686. /**
  10687. * Effect Name of the layer.
  10688. */
  10689. static readonly EffectName: string;
  10690. /**
  10691. * The default blur kernel size used for the glow.
  10692. */
  10693. static DefaultBlurKernelSize: number;
  10694. /**
  10695. * The default texture size ratio used for the glow.
  10696. */
  10697. static DefaultTextureRatio: number;
  10698. /**
  10699. * Gets the kernel size of the blur.
  10700. */
  10701. /**
  10702. * Sets the kernel size of the blur.
  10703. */
  10704. blurKernelSize: number;
  10705. /**
  10706. * Gets the glow intensity.
  10707. */
  10708. /**
  10709. * Sets the glow intensity.
  10710. */
  10711. intensity: number;
  10712. private _options;
  10713. private _intensity;
  10714. private _horizontalBlurPostprocess1;
  10715. private _verticalBlurPostprocess1;
  10716. private _horizontalBlurPostprocess2;
  10717. private _verticalBlurPostprocess2;
  10718. private _blurTexture1;
  10719. private _blurTexture2;
  10720. private _postProcesses1;
  10721. private _postProcesses2;
  10722. private _includedOnlyMeshes;
  10723. private _excludedMeshes;
  10724. /**
  10725. * Callback used to let the user override the color selection on a per mesh basis
  10726. */
  10727. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  10728. /**
  10729. * Callback used to let the user override the texture selection on a per mesh basis
  10730. */
  10731. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  10732. /**
  10733. * Instantiates a new glow Layer and references it to the scene.
  10734. * @param name The name of the layer
  10735. * @param scene The scene to use the layer in
  10736. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  10737. */
  10738. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  10739. /**
  10740. * Get the effect name of the layer.
  10741. * @return The effect name
  10742. */
  10743. getEffectName(): string;
  10744. /**
  10745. * Create the merge effect. This is the shader use to blit the information back
  10746. * to the main canvas at the end of the scene rendering.
  10747. */
  10748. protected _createMergeEffect(): Effect;
  10749. /**
  10750. * Creates the render target textures and post processes used in the glow layer.
  10751. */
  10752. protected _createTextureAndPostProcesses(): void;
  10753. /**
  10754. * Checks for the readiness of the element composing the layer.
  10755. * @param subMesh the mesh to check for
  10756. * @param useInstances specify wether or not to use instances to render the mesh
  10757. * @param emissiveTexture the associated emissive texture used to generate the glow
  10758. * @return true if ready otherwise, false
  10759. */
  10760. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  10761. /**
  10762. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  10763. */
  10764. needStencil(): boolean;
  10765. /**
  10766. * Implementation specific of rendering the generating effect on the main canvas.
  10767. * @param effect The effect used to render through
  10768. */
  10769. protected _internalRender(effect: Effect): void;
  10770. /**
  10771. * Sets the required values for both the emissive texture and and the main color.
  10772. */
  10773. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  10774. /**
  10775. * Returns true if the mesh should render, otherwise false.
  10776. * @param mesh The mesh to render
  10777. * @returns true if it should render otherwise false
  10778. */
  10779. protected _shouldRenderMesh(mesh: Mesh): boolean;
  10780. /**
  10781. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  10782. * @param mesh The mesh to exclude from the glow layer
  10783. */
  10784. addExcludedMesh(mesh: Mesh): void;
  10785. /**
  10786. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  10787. * @param mesh The mesh to remove
  10788. */
  10789. removeExcludedMesh(mesh: Mesh): void;
  10790. /**
  10791. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  10792. * @param mesh The mesh to include in the glow layer
  10793. */
  10794. addIncludedOnlyMesh(mesh: Mesh): void;
  10795. /**
  10796. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  10797. * @param mesh The mesh to remove
  10798. */
  10799. removeIncludedOnlyMesh(mesh: Mesh): void;
  10800. /**
  10801. * Determine if a given mesh will be used in the glow layer
  10802. * @param mesh The mesh to test
  10803. * @returns true if the mesh will be highlighted by the current glow layer
  10804. */
  10805. hasMesh(mesh: AbstractMesh): boolean;
  10806. /**
  10807. * Free any resources and references associated to a mesh.
  10808. * Internal use
  10809. * @param mesh The mesh to free.
  10810. */
  10811. /**
  10812. * Gets the class name of the effect layer
  10813. * @returns the string with the class name of the effect layer
  10814. */
  10815. getClassName(): string;
  10816. /**
  10817. * Serializes this glow layer
  10818. * @returns a serialized glow layer object
  10819. */
  10820. serialize(): any;
  10821. /**
  10822. * Creates a Glow Layer from parsed glow layer data
  10823. * @param parsedGlowLayer defines glow layer data
  10824. * @param scene defines the current scene
  10825. * @param rootUrl defines the root URL containing the glow layer information
  10826. * @returns a parsed Glow Layer
  10827. */
  10828. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  10829. }
  10830. }
  10831. declare module BABYLON {
  10832. /**
  10833. * Highlight layer options. This helps customizing the behaviour
  10834. * of the highlight layer.
  10835. */
  10836. interface IHighlightLayerOptions {
  10837. /**
  10838. * Multiplication factor apply to the canvas size to compute the render target size
  10839. * used to generated the glowing objects (the smaller the faster).
  10840. */
  10841. mainTextureRatio: number;
  10842. /**
  10843. * Enforces a fixed size texture to ensure resize independant blur.
  10844. */
  10845. mainTextureFixedSize?: number;
  10846. /**
  10847. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  10848. * of the picture to blur (the smaller the faster).
  10849. */
  10850. blurTextureSizeRatio: number;
  10851. /**
  10852. * How big in texel of the blur texture is the vertical blur.
  10853. */
  10854. blurVerticalSize: number;
  10855. /**
  10856. * How big in texel of the blur texture is the horizontal blur.
  10857. */
  10858. blurHorizontalSize: number;
  10859. /**
  10860. * Alpha blending mode used to apply the blur. Default is combine.
  10861. */
  10862. alphaBlendingMode: number;
  10863. /**
  10864. * The camera attached to the layer.
  10865. */
  10866. camera: Nullable<Camera>;
  10867. /**
  10868. * Should we display highlight as a solid stroke?
  10869. */
  10870. isStroke?: boolean;
  10871. }
  10872. /**
  10873. * The highlight layer Helps adding a glow effect around a mesh.
  10874. *
  10875. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  10876. * glowy meshes to your scene.
  10877. *
  10878. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  10879. */
  10880. class HighlightLayer extends EffectLayer {
  10881. name: string;
  10882. /**
  10883. * Effect Name of the highlight layer.
  10884. */
  10885. static readonly EffectName: string;
  10886. /**
  10887. * The neutral color used during the preparation of the glow effect.
  10888. * This is black by default as the blend operation is a blend operation.
  10889. */
  10890. static NeutralColor: Color4;
  10891. /**
  10892. * Stencil value used for glowing meshes.
  10893. */
  10894. static GlowingMeshStencilReference: number;
  10895. /**
  10896. * Stencil value used for the other meshes in the scene.
  10897. */
  10898. static NormalMeshStencilReference: number;
  10899. /**
  10900. * Specifies whether or not the inner glow is ACTIVE in the layer.
  10901. */
  10902. innerGlow: boolean;
  10903. /**
  10904. * Specifies whether or not the outer glow is ACTIVE in the layer.
  10905. */
  10906. outerGlow: boolean;
  10907. /**
  10908. * Gets the horizontal size of the blur.
  10909. */
  10910. /**
  10911. * Specifies the horizontal size of the blur.
  10912. */
  10913. blurHorizontalSize: number;
  10914. /**
  10915. * Gets the vertical size of the blur.
  10916. */
  10917. /**
  10918. * Specifies the vertical size of the blur.
  10919. */
  10920. blurVerticalSize: number;
  10921. /**
  10922. * An event triggered when the highlight layer is being blurred.
  10923. */
  10924. onBeforeBlurObservable: Observable<HighlightLayer>;
  10925. /**
  10926. * An event triggered when the highlight layer has been blurred.
  10927. */
  10928. onAfterBlurObservable: Observable<HighlightLayer>;
  10929. private _instanceGlowingMeshStencilReference;
  10930. private _options;
  10931. private _downSamplePostprocess;
  10932. private _horizontalBlurPostprocess;
  10933. private _verticalBlurPostprocess;
  10934. private _blurTexture;
  10935. private _meshes;
  10936. private _excludedMeshes;
  10937. /**
  10938. * Instantiates a new highlight Layer and references it to the scene..
  10939. * @param name The name of the layer
  10940. * @param scene The scene to use the layer in
  10941. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  10942. */
  10943. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  10944. /**
  10945. * Get the effect name of the layer.
  10946. * @return The effect name
  10947. */
  10948. getEffectName(): string;
  10949. /**
  10950. * Create the merge effect. This is the shader use to blit the information back
  10951. * to the main canvas at the end of the scene rendering.
  10952. */
  10953. protected _createMergeEffect(): Effect;
  10954. /**
  10955. * Creates the render target textures and post processes used in the highlight layer.
  10956. */
  10957. protected _createTextureAndPostProcesses(): void;
  10958. /**
  10959. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  10960. */
  10961. needStencil(): boolean;
  10962. /**
  10963. * Checks for the readiness of the element composing the layer.
  10964. * @param subMesh the mesh to check for
  10965. * @param useInstances specify wether or not to use instances to render the mesh
  10966. * @param emissiveTexture the associated emissive texture used to generate the glow
  10967. * @return true if ready otherwise, false
  10968. */
  10969. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  10970. /**
  10971. * Implementation specific of rendering the generating effect on the main canvas.
  10972. * @param effect The effect used to render through
  10973. */
  10974. protected _internalRender(effect: Effect): void;
  10975. /**
  10976. * Returns true if the layer contains information to display, otherwise false.
  10977. */
  10978. shouldRender(): boolean;
  10979. /**
  10980. * Returns true if the mesh should render, otherwise false.
  10981. * @param mesh The mesh to render
  10982. * @returns true if it should render otherwise false
  10983. */
  10984. protected _shouldRenderMesh(mesh: Mesh): boolean;
  10985. /**
  10986. * Sets the required values for both the emissive texture and and the main color.
  10987. */
  10988. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  10989. /**
  10990. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  10991. * @param mesh The mesh to exclude from the highlight layer
  10992. */
  10993. addExcludedMesh(mesh: Mesh): void;
  10994. /**
  10995. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  10996. * @param mesh The mesh to highlight
  10997. */
  10998. removeExcludedMesh(mesh: Mesh): void;
  10999. /**
  11000. * Determine if a given mesh will be highlighted by the current HighlightLayer
  11001. * @param mesh mesh to test
  11002. * @returns true if the mesh will be highlighted by the current HighlightLayer
  11003. */
  11004. hasMesh(mesh: AbstractMesh): boolean;
  11005. /**
  11006. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  11007. * @param mesh The mesh to highlight
  11008. * @param color The color of the highlight
  11009. * @param glowEmissiveOnly Extract the glow from the emissive texture
  11010. */
  11011. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  11012. /**
  11013. * Remove a mesh from the highlight layer in order to make it stop glowing.
  11014. * @param mesh The mesh to highlight
  11015. */
  11016. removeMesh(mesh: Mesh): void;
  11017. /**
  11018. * Force the stencil to the normal expected value for none glowing parts
  11019. */
  11020. private _defaultStencilReference(mesh);
  11021. /**
  11022. * Free any resources and references associated to a mesh.
  11023. * Internal use
  11024. * @param mesh The mesh to free.
  11025. */
  11026. /**
  11027. * Dispose the highlight layer and free resources.
  11028. */
  11029. dispose(): void;
  11030. /**
  11031. * Gets the class name of the effect layer
  11032. * @returns the string with the class name of the effect layer
  11033. */
  11034. getClassName(): string;
  11035. /**
  11036. * Serializes this Highlight layer
  11037. * @returns a serialized Highlight layer object
  11038. */
  11039. serialize(): any;
  11040. /**
  11041. * Creates a Highlight layer from parsed Highlight layer data
  11042. * @param parsedHightlightLayer defines the Highlight layer data
  11043. * @param scene defines the current scene
  11044. * @param rootUrl defines the root URL containing the Highlight layer information
  11045. * @returns a parsed Highlight layer
  11046. */
  11047. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  11048. }
  11049. }
  11050. declare module BABYLON {
  11051. class Layer {
  11052. name: string;
  11053. texture: Nullable<Texture>;
  11054. isBackground: boolean;
  11055. color: Color4;
  11056. scale: Vector2;
  11057. offset: Vector2;
  11058. alphaBlendingMode: number;
  11059. alphaTest: boolean;
  11060. layerMask: number;
  11061. private _scene;
  11062. private _vertexBuffers;
  11063. private _indexBuffer;
  11064. private _effect;
  11065. private _alphaTestEffect;
  11066. /**
  11067. * An event triggered when the layer is disposed.
  11068. */
  11069. onDisposeObservable: Observable<Layer>;
  11070. private _onDisposeObserver;
  11071. onDispose: () => void;
  11072. /**
  11073. * An event triggered before rendering the scene
  11074. */
  11075. onBeforeRenderObservable: Observable<Layer>;
  11076. private _onBeforeRenderObserver;
  11077. onBeforeRender: () => void;
  11078. /**
  11079. * An event triggered after rendering the scene
  11080. */
  11081. onAfterRenderObservable: Observable<Layer>;
  11082. private _onAfterRenderObserver;
  11083. onAfterRender: () => void;
  11084. constructor(name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  11085. private _createIndexBuffer();
  11086. render(): void;
  11087. dispose(): void;
  11088. }
  11089. }
  11090. declare module BABYLON {
  11091. class LensFlare {
  11092. size: number;
  11093. position: number;
  11094. color: Color3;
  11095. texture: Nullable<Texture>;
  11096. alphaMode: number;
  11097. private _system;
  11098. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  11099. constructor(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  11100. dispose(): void;
  11101. }
  11102. }
  11103. declare module BABYLON {
  11104. class LensFlareSystem {
  11105. name: string;
  11106. lensFlares: LensFlare[];
  11107. borderLimit: number;
  11108. viewportBorder: number;
  11109. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  11110. layerMask: number;
  11111. id: string;
  11112. private _scene;
  11113. private _emitter;
  11114. private _vertexBuffers;
  11115. private _indexBuffer;
  11116. private _effect;
  11117. private _positionX;
  11118. private _positionY;
  11119. private _isEnabled;
  11120. constructor(name: string, emitter: any, scene: Scene);
  11121. isEnabled: boolean;
  11122. getScene(): Scene;
  11123. getEmitter(): any;
  11124. setEmitter(newEmitter: any): void;
  11125. getEmitterPosition(): Vector3;
  11126. computeEffectivePosition(globalViewport: Viewport): boolean;
  11127. render(): boolean;
  11128. dispose(): void;
  11129. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  11130. serialize(): any;
  11131. }
  11132. }
  11133. declare module BABYLON {
  11134. /**
  11135. * A directional light is defined by a direction (what a surprise!).
  11136. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  11137. * 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.
  11138. * Documentation: https://doc.babylonjs.com/babylon101/lights
  11139. */
  11140. class DirectionalLight extends ShadowLight {
  11141. private _shadowFrustumSize;
  11142. /**
  11143. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  11144. */
  11145. /**
  11146. * Specifies a fix frustum size for the shadow generation.
  11147. */
  11148. shadowFrustumSize: number;
  11149. private _shadowOrthoScale;
  11150. /**
  11151. * Gets the shadow projection scale against the optimal computed one.
  11152. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  11153. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  11154. */
  11155. /**
  11156. * Sets the shadow projection scale against the optimal computed one.
  11157. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  11158. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  11159. */
  11160. shadowOrthoScale: number;
  11161. /**
  11162. * Automatically compute the projection matrix to best fit (including all the casters)
  11163. * on each frame.
  11164. */
  11165. autoUpdateExtends: boolean;
  11166. private _orthoLeft;
  11167. private _orthoRight;
  11168. private _orthoTop;
  11169. private _orthoBottom;
  11170. /**
  11171. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  11172. * The directional light is emitted from everywhere in the given direction.
  11173. * It can cast shawdows.
  11174. * Documentation : http://doc.babylonjs.com/tutorials/lights
  11175. * @param name The friendly name of the light
  11176. * @param direction The direction of the light
  11177. * @param scene The scene the light belongs to
  11178. */
  11179. constructor(name: string, direction: Vector3, scene: Scene);
  11180. /**
  11181. * Returns the string "DirectionalLight".
  11182. * @return The class name
  11183. */
  11184. getClassName(): string;
  11185. /**
  11186. * Returns the integer 1.
  11187. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  11188. */
  11189. getTypeID(): number;
  11190. /**
  11191. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  11192. * Returns the DirectionalLight Shadow projection matrix.
  11193. */
  11194. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  11195. /**
  11196. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  11197. * Returns the DirectionalLight Shadow projection matrix.
  11198. */
  11199. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix): void;
  11200. /**
  11201. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  11202. * Returns the DirectionalLight Shadow projection matrix.
  11203. */
  11204. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  11205. protected _buildUniformLayout(): void;
  11206. /**
  11207. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  11208. * @param effect The effect to update
  11209. * @param lightIndex The index of the light in the effect to update
  11210. * @returns The directional light
  11211. */
  11212. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  11213. /**
  11214. * Gets the minZ used for shadow according to both the scene and the light.
  11215. *
  11216. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  11217. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  11218. * @param activeCamera The camera we are returning the min for
  11219. * @returns the depth min z
  11220. */
  11221. getDepthMinZ(activeCamera: Camera): number;
  11222. /**
  11223. * Gets the maxZ used for shadow according to both the scene and the light.
  11224. *
  11225. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  11226. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  11227. * @param activeCamera The camera we are returning the max for
  11228. * @returns the depth max z
  11229. */
  11230. getDepthMaxZ(activeCamera: Camera): number;
  11231. }
  11232. }
  11233. declare module BABYLON {
  11234. /**
  11235. * The HemisphericLight simulates the ambient environment light,
  11236. * so the passed direction is the light reflection direction, not the incoming direction.
  11237. */
  11238. class HemisphericLight extends Light {
  11239. /**
  11240. * The groundColor is the light in the opposite direction to the one specified during creation.
  11241. * 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.
  11242. */
  11243. groundColor: Color3;
  11244. /**
  11245. * The light reflection direction, not the incoming direction.
  11246. */
  11247. direction: Vector3;
  11248. private _worldMatrix;
  11249. /**
  11250. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  11251. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  11252. * The HemisphericLight can't cast shadows.
  11253. * Documentation : http://doc.babylonjs.com/tutorials/lights
  11254. * @param name The friendly name of the light
  11255. * @param direction The direction of the light reflection
  11256. * @param scene The scene the light belongs to
  11257. */
  11258. constructor(name: string, direction: Vector3, scene: Scene);
  11259. protected _buildUniformLayout(): void;
  11260. /**
  11261. * Returns the string "HemisphericLight".
  11262. * @return The class name
  11263. */
  11264. getClassName(): string;
  11265. /**
  11266. * Sets the HemisphericLight direction towards the passed target (Vector3).
  11267. * Returns the updated direction.
  11268. * @param target The target the direction should point to
  11269. * @return The computed direction
  11270. */
  11271. setDirectionToTarget(target: Vector3): Vector3;
  11272. /**
  11273. * Returns the shadow generator associated to the light.
  11274. * @returns Always null for hemispheric lights because it does not support shadows.
  11275. */
  11276. getShadowGenerator(): Nullable<ShadowGenerator>;
  11277. /**
  11278. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  11279. * @param effect The effect to update
  11280. * @param lightIndex The index of the light in the effect to update
  11281. * @returns The hemispheric light
  11282. */
  11283. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  11284. /**
  11285. * @hidden internal use only.
  11286. */
  11287. /**
  11288. * Returns the integer 3.
  11289. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  11290. */
  11291. getTypeID(): number;
  11292. }
  11293. }
  11294. declare module BABYLON {
  11295. /**
  11296. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  11297. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  11298. * 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.
  11299. */
  11300. abstract class Light extends Node {
  11301. private static _LIGHTMAP_DEFAULT;
  11302. private static _LIGHTMAP_SPECULAR;
  11303. private static _LIGHTMAP_SHADOWSONLY;
  11304. /**
  11305. * If every light affecting the material is in this lightmapMode,
  11306. * material.lightmapTexture adds or multiplies
  11307. * (depends on material.useLightmapAsShadowmap)
  11308. * after every other light calculations.
  11309. */
  11310. static readonly LIGHTMAP_DEFAULT: number;
  11311. /**
  11312. * material.lightmapTexture as only diffuse lighting from this light
  11313. * adds only specular lighting from this light
  11314. * adds dynamic shadows
  11315. */
  11316. static readonly LIGHTMAP_SPECULAR: number;
  11317. /**
  11318. * material.lightmapTexture as only lighting
  11319. * no light calculation from this light
  11320. * only adds dynamic shadows from this light
  11321. */
  11322. static readonly LIGHTMAP_SHADOWSONLY: number;
  11323. private static _INTENSITYMODE_AUTOMATIC;
  11324. private static _INTENSITYMODE_LUMINOUSPOWER;
  11325. private static _INTENSITYMODE_LUMINOUSINTENSITY;
  11326. private static _INTENSITYMODE_ILLUMINANCE;
  11327. private static _INTENSITYMODE_LUMINANCE;
  11328. /**
  11329. * Each light type uses the default quantity according to its type:
  11330. * point/spot lights use luminous intensity
  11331. * directional lights use illuminance
  11332. */
  11333. static readonly INTENSITYMODE_AUTOMATIC: number;
  11334. /**
  11335. * lumen (lm)
  11336. */
  11337. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  11338. /**
  11339. * candela (lm/sr)
  11340. */
  11341. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  11342. /**
  11343. * lux (lm/m^2)
  11344. */
  11345. static readonly INTENSITYMODE_ILLUMINANCE: number;
  11346. /**
  11347. * nit (cd/m^2)
  11348. */
  11349. static readonly INTENSITYMODE_LUMINANCE: number;
  11350. private static _LIGHTTYPEID_POINTLIGHT;
  11351. private static _LIGHTTYPEID_DIRECTIONALLIGHT;
  11352. private static _LIGHTTYPEID_SPOTLIGHT;
  11353. private static _LIGHTTYPEID_HEMISPHERICLIGHT;
  11354. /**
  11355. * Light type const id of the point light.
  11356. */
  11357. static readonly LIGHTTYPEID_POINTLIGHT: number;
  11358. /**
  11359. * Light type const id of the directional light.
  11360. */
  11361. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  11362. /**
  11363. * Light type const id of the spot light.
  11364. */
  11365. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  11366. /**
  11367. * Light type const id of the hemispheric light.
  11368. */
  11369. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  11370. /**
  11371. * Diffuse gives the basic color to an object.
  11372. */
  11373. diffuse: Color3;
  11374. /**
  11375. * Specular produces a highlight color on an object.
  11376. * Note: This is note affecting PBR materials.
  11377. */
  11378. specular: Color3;
  11379. /**
  11380. * Strength of the light.
  11381. * Note: By default it is define in the framework own unit.
  11382. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  11383. */
  11384. intensity: number;
  11385. /**
  11386. * Defines how far from the source the light is impacting in scene units.
  11387. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  11388. */
  11389. range: number;
  11390. /**
  11391. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  11392. * of light.
  11393. */
  11394. private _photometricScale;
  11395. private _intensityMode;
  11396. /**
  11397. * Gets the photometric scale used to interpret the intensity.
  11398. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  11399. */
  11400. /**
  11401. * Sets the photometric scale used to interpret the intensity.
  11402. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  11403. */
  11404. intensityMode: number;
  11405. private _radius;
  11406. /**
  11407. * Gets the light radius used by PBR Materials to simulate soft area lights.
  11408. */
  11409. /**
  11410. * sets the light radius used by PBR Materials to simulate soft area lights.
  11411. */
  11412. radius: number;
  11413. private _renderPriority;
  11414. /**
  11415. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  11416. * exceeding the number allowed of the materials.
  11417. */
  11418. renderPriority: number;
  11419. private _shadowEnabled;
  11420. /**
  11421. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  11422. * the current shadow generator.
  11423. */
  11424. /**
  11425. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  11426. * the current shadow generator.
  11427. */
  11428. shadowEnabled: boolean;
  11429. private _includedOnlyMeshes;
  11430. /**
  11431. * Gets the only meshes impacted by this light.
  11432. */
  11433. /**
  11434. * Sets the only meshes impacted by this light.
  11435. */
  11436. includedOnlyMeshes: AbstractMesh[];
  11437. private _excludedMeshes;
  11438. /**
  11439. * Gets the meshes not impacted by this light.
  11440. */
  11441. /**
  11442. * Sets the meshes not impacted by this light.
  11443. */
  11444. excludedMeshes: AbstractMesh[];
  11445. private _excludeWithLayerMask;
  11446. /**
  11447. * Gets the layer id use to find what meshes are not impacted by the light.
  11448. * Inactive if 0
  11449. */
  11450. /**
  11451. * Sets the layer id use to find what meshes are not impacted by the light.
  11452. * Inactive if 0
  11453. */
  11454. excludeWithLayerMask: number;
  11455. private _includeOnlyWithLayerMask;
  11456. /**
  11457. * Gets the layer id use to find what meshes are impacted by the light.
  11458. * Inactive if 0
  11459. */
  11460. /**
  11461. * Sets the layer id use to find what meshes are impacted by the light.
  11462. * Inactive if 0
  11463. */
  11464. includeOnlyWithLayerMask: number;
  11465. private _lightmapMode;
  11466. /**
  11467. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  11468. */
  11469. /**
  11470. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  11471. */
  11472. lightmapMode: number;
  11473. private _parentedWorldMatrix;
  11474. /**
  11475. * Shadow generator associted to the light.
  11476. * Internal use only.
  11477. */
  11478. /**
  11479. * @hidden Internal use only.
  11480. */
  11481. /**
  11482. * @hidden Internal use only.
  11483. */
  11484. /**
  11485. * The current light unifom buffer.
  11486. * @hidden Internal use only.
  11487. */
  11488. /**
  11489. * Creates a Light object in the scene.
  11490. * Documentation : http://doc.babylonjs.com/tutorials/lights
  11491. * @param name The firendly name of the light
  11492. * @param scene The scene the light belongs too
  11493. */
  11494. constructor(name: string, scene: Scene);
  11495. protected abstract _buildUniformLayout(): void;
  11496. /**
  11497. * Sets the passed Effect "effect" with the Light information.
  11498. * @param effect The effect to update
  11499. * @param lightIndex The index of the light in the effect to update
  11500. * @returns The light
  11501. */
  11502. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  11503. /**
  11504. * @hidden internal use only.
  11505. */
  11506. getWorldMatrix(): Matrix;
  11507. /**
  11508. * Returns the string "Light".
  11509. * @returns the class name
  11510. */
  11511. getClassName(): string;
  11512. /**
  11513. * Converts the light information to a readable string for debug purpose.
  11514. * @param fullDetails Supports for multiple levels of logging within scene loading
  11515. * @returns the human readable light info
  11516. */
  11517. toString(fullDetails?: boolean): string;
  11518. /**
  11519. * Set the enabled state of this node.
  11520. * @param value - the new enabled state
  11521. */
  11522. setEnabled(value: boolean): void;
  11523. /**
  11524. * Returns the Light associated shadow generator if any.
  11525. * @return the associated shadow generator.
  11526. */
  11527. getShadowGenerator(): Nullable<IShadowGenerator>;
  11528. /**
  11529. * Returns a Vector3, the absolute light position in the World.
  11530. * @returns the world space position of the light
  11531. */
  11532. getAbsolutePosition(): Vector3;
  11533. /**
  11534. * Specifies if the light will affect the passed mesh.
  11535. * @param mesh The mesh to test against the light
  11536. * @return true the mesh is affected otherwise, false.
  11537. */
  11538. canAffectMesh(mesh: AbstractMesh): boolean;
  11539. /**
  11540. * Computes and Returns the light World matrix.
  11541. * @returns the world matrix
  11542. */
  11543. getWorldMatrix(): Matrix;
  11544. /**
  11545. * Sort function to order lights for rendering.
  11546. * @param a First Light object to compare to second.
  11547. * @param b Second Light object to compare first.
  11548. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  11549. */
  11550. static CompareLightsPriority(a: Light, b: Light): number;
  11551. /**
  11552. * Releases resources associated with this node.
  11553. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  11554. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  11555. */
  11556. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  11557. /**
  11558. * Returns the light type ID (integer).
  11559. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  11560. */
  11561. getTypeID(): number;
  11562. /**
  11563. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  11564. * @returns the scaled intensity in intensity mode unit
  11565. */
  11566. getScaledIntensity(): number;
  11567. /**
  11568. * Returns a new Light object, named "name", from the current one.
  11569. * @param name The name of the cloned light
  11570. * @returns the new created light
  11571. */
  11572. clone(name: string): Nullable<Light>;
  11573. /**
  11574. * Serializes the current light into a Serialization object.
  11575. * @returns the serialized object.
  11576. */
  11577. serialize(): any;
  11578. /**
  11579. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  11580. * This new light is named "name" and added to the passed scene.
  11581. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  11582. * @param name The friendly name of the light
  11583. * @param scene The scene the new light will belong to
  11584. * @returns the constructor function
  11585. */
  11586. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  11587. /**
  11588. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  11589. * @param parsedLight The JSON representation of the light
  11590. * @param scene The scene to create the parsed light in
  11591. * @returns the created light after parsing
  11592. */
  11593. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  11594. private _hookArrayForExcluded(array);
  11595. private _hookArrayForIncludedOnly(array);
  11596. private _resyncMeshes();
  11597. /**
  11598. * Forces the meshes to update their light related information in their rendering used effects
  11599. * @hidden Internal Use Only
  11600. */
  11601. /**
  11602. * Recomputes the cached photometric scale if needed.
  11603. */
  11604. private _computePhotometricScale();
  11605. /**
  11606. * Returns the Photometric Scale according to the light type and intensity mode.
  11607. */
  11608. private _getPhotometricScale();
  11609. /**
  11610. * Reorder the light in the scene according to their defined priority.
  11611. * @hidden Internal Use Only
  11612. */
  11613. }
  11614. }
  11615. declare module BABYLON {
  11616. /**
  11617. * A point light is a light defined by an unique point in world space.
  11618. * The light is emitted in every direction from this point.
  11619. * A good example of a point light is a standard light bulb.
  11620. * Documentation: https://doc.babylonjs.com/babylon101/lights
  11621. */
  11622. class PointLight extends ShadowLight {
  11623. private _shadowAngle;
  11624. /**
  11625. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  11626. * This specifies what angle the shadow will use to be created.
  11627. *
  11628. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  11629. */
  11630. /**
  11631. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  11632. * This specifies what angle the shadow will use to be created.
  11633. *
  11634. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  11635. */
  11636. shadowAngle: number;
  11637. /**
  11638. * Gets the direction if it has been set.
  11639. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  11640. */
  11641. /**
  11642. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  11643. */
  11644. direction: Vector3;
  11645. /**
  11646. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  11647. * A PointLight emits the light in every direction.
  11648. * It can cast shadows.
  11649. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  11650. * ```javascript
  11651. * var pointLight = new BABYLON.PointLight("pl", camera.position, scene);
  11652. * ```
  11653. * Documentation : http://doc.babylonjs.com/tutorials/lights
  11654. * @param name The light friendly name
  11655. * @param position The position of the point light in the scene
  11656. * @param scene The scene the lights belongs to
  11657. */
  11658. constructor(name: string, position: Vector3, scene: Scene);
  11659. /**
  11660. * Returns the string "PointLight"
  11661. * @returns the class name
  11662. */
  11663. getClassName(): string;
  11664. /**
  11665. * Returns the integer 0.
  11666. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  11667. */
  11668. getTypeID(): number;
  11669. /**
  11670. * Specifies wether or not the shadowmap should be a cube texture.
  11671. * @returns true if the shadowmap needs to be a cube texture.
  11672. */
  11673. needCube(): boolean;
  11674. /**
  11675. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  11676. * @param faceIndex The index of the face we are computed the direction to generate shadow
  11677. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  11678. */
  11679. getShadowDirection(faceIndex?: number): Vector3;
  11680. /**
  11681. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  11682. * - fov = PI / 2
  11683. * - aspect ratio : 1.0
  11684. * - z-near and far equal to the active camera minZ and maxZ.
  11685. * Returns the PointLight.
  11686. */
  11687. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  11688. protected _buildUniformLayout(): void;
  11689. /**
  11690. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  11691. * @param effect The effect to update
  11692. * @param lightIndex The index of the light in the effect to update
  11693. * @returns The point light
  11694. */
  11695. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  11696. }
  11697. }
  11698. declare module BABYLON {
  11699. /**
  11700. * Interface describing all the common properties and methods a shadow light needs to implement.
  11701. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  11702. * as well as binding the different shadow properties to the effects.
  11703. */
  11704. interface IShadowLight extends Light {
  11705. /**
  11706. * The light id in the scene (used in scene.findLighById for instance)
  11707. */
  11708. id: string;
  11709. /**
  11710. * The position the shdow will be casted from.
  11711. */
  11712. position: Vector3;
  11713. /**
  11714. * In 2d mode (needCube being false), the direction used to cast the shadow.
  11715. */
  11716. direction: Vector3;
  11717. /**
  11718. * The transformed position. Position of the light in world space taking parenting in account.
  11719. */
  11720. transformedPosition: Vector3;
  11721. /**
  11722. * The transformed direction. Direction of the light in world space taking parenting in account.
  11723. */
  11724. transformedDirection: Vector3;
  11725. /**
  11726. * The friendly name of the light in the scene.
  11727. */
  11728. name: string;
  11729. /**
  11730. * Defines the shadow projection clipping minimum z value.
  11731. */
  11732. shadowMinZ: number;
  11733. /**
  11734. * Defines the shadow projection clipping maximum z value.
  11735. */
  11736. shadowMaxZ: number;
  11737. /**
  11738. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  11739. * @returns true if the information has been computed, false if it does not need to (no parenting)
  11740. */
  11741. computeTransformedInformation(): boolean;
  11742. /**
  11743. * Gets the scene the light belongs to.
  11744. * @returns The scene
  11745. */
  11746. getScene(): Scene;
  11747. /**
  11748. * Callback defining a custom Projection Matrix Builder.
  11749. * This can be used to override the default projection matrix computation.
  11750. */
  11751. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  11752. /**
  11753. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  11754. * @param matrix The materix to updated with the projection information
  11755. * @param viewMatrix The transform matrix of the light
  11756. * @param renderList The list of mesh to render in the map
  11757. * @returns The current light
  11758. */
  11759. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  11760. /**
  11761. * Gets the current depth scale used in ESM.
  11762. * @returns The scale
  11763. */
  11764. getDepthScale(): number;
  11765. /**
  11766. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  11767. * @returns true if a cube texture needs to be use
  11768. */
  11769. needCube(): boolean;
  11770. /**
  11771. * Detects if the projection matrix requires to be recomputed this frame.
  11772. * @returns true if it requires to be recomputed otherwise, false.
  11773. */
  11774. needProjectionMatrixCompute(): boolean;
  11775. /**
  11776. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  11777. */
  11778. forceProjectionMatrixCompute(): void;
  11779. /**
  11780. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  11781. * @param faceIndex The index of the face we are computed the direction to generate shadow
  11782. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  11783. */
  11784. getShadowDirection(faceIndex?: number): Vector3;
  11785. /**
  11786. * Gets the minZ used for shadow according to both the scene and the light.
  11787. * @param activeCamera The camera we are returning the min for
  11788. * @returns the depth min z
  11789. */
  11790. getDepthMinZ(activeCamera: Camera): number;
  11791. /**
  11792. * Gets the maxZ used for shadow according to both the scene and the light.
  11793. * @param activeCamera The camera we are returning the max for
  11794. * @returns the depth max z
  11795. */
  11796. getDepthMaxZ(activeCamera: Camera): number;
  11797. }
  11798. /**
  11799. * Base implementation IShadowLight
  11800. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  11801. */
  11802. abstract class ShadowLight extends Light implements IShadowLight {
  11803. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  11804. protected _position: Vector3;
  11805. protected _setPosition(value: Vector3): void;
  11806. /**
  11807. * Sets the position the shadow will be casted from. Also use as the light position for both
  11808. * point and spot lights.
  11809. */
  11810. /**
  11811. * Sets the position the shadow will be casted from. Also use as the light position for both
  11812. * point and spot lights.
  11813. */
  11814. position: Vector3;
  11815. protected _direction: Vector3;
  11816. protected _setDirection(value: Vector3): void;
  11817. /**
  11818. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  11819. * Also use as the light direction on spot and directional lights.
  11820. */
  11821. /**
  11822. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  11823. * Also use as the light direction on spot and directional lights.
  11824. */
  11825. direction: Vector3;
  11826. private _shadowMinZ;
  11827. /**
  11828. * Gets the shadow projection clipping minimum z value.
  11829. */
  11830. /**
  11831. * Sets the shadow projection clipping minimum z value.
  11832. */
  11833. shadowMinZ: number;
  11834. private _shadowMaxZ;
  11835. /**
  11836. * Sets the shadow projection clipping maximum z value.
  11837. */
  11838. /**
  11839. * Gets the shadow projection clipping maximum z value.
  11840. */
  11841. shadowMaxZ: number;
  11842. /**
  11843. * Callback defining a custom Projection Matrix Builder.
  11844. * This can be used to override the default projection matrix computation.
  11845. */
  11846. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  11847. /**
  11848. * The transformed position. Position of the light in world space taking parenting in account.
  11849. */
  11850. transformedPosition: Vector3;
  11851. /**
  11852. * The transformed direction. Direction of the light in world space taking parenting in account.
  11853. */
  11854. transformedDirection: Vector3;
  11855. private _worldMatrix;
  11856. private _needProjectionMatrixCompute;
  11857. /**
  11858. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  11859. * @returns true if the information has been computed, false if it does not need to (no parenting)
  11860. */
  11861. computeTransformedInformation(): boolean;
  11862. /**
  11863. * Return the depth scale used for the shadow map.
  11864. * @returns the depth scale.
  11865. */
  11866. getDepthScale(): number;
  11867. /**
  11868. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  11869. * @param faceIndex The index of the face we are computed the direction to generate shadow
  11870. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  11871. */
  11872. getShadowDirection(faceIndex?: number): Vector3;
  11873. /**
  11874. * Returns the ShadowLight absolute position in the World.
  11875. * @returns the position vector in world space
  11876. */
  11877. getAbsolutePosition(): Vector3;
  11878. /**
  11879. * Sets the ShadowLight direction toward the passed target.
  11880. * @param target The point tot target in local space
  11881. * @returns the updated ShadowLight direction
  11882. */
  11883. setDirectionToTarget(target: Vector3): Vector3;
  11884. /**
  11885. * Returns the light rotation in euler definition.
  11886. * @returns the x y z rotation in local space.
  11887. */
  11888. getRotation(): Vector3;
  11889. /**
  11890. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  11891. * @returns true if a cube texture needs to be use
  11892. */
  11893. needCube(): boolean;
  11894. /**
  11895. * Detects if the projection matrix requires to be recomputed this frame.
  11896. * @returns true if it requires to be recomputed otherwise, false.
  11897. */
  11898. needProjectionMatrixCompute(): boolean;
  11899. /**
  11900. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  11901. */
  11902. forceProjectionMatrixCompute(): void;
  11903. /**
  11904. * Get the world matrix of the sahdow lights.
  11905. * @hidden Internal Use Only
  11906. */
  11907. /**
  11908. * Gets the minZ used for shadow according to both the scene and the light.
  11909. * @param activeCamera The camera we are returning the min for
  11910. * @returns the depth min z
  11911. */
  11912. getDepthMinZ(activeCamera: Camera): number;
  11913. /**
  11914. * Gets the maxZ used for shadow according to both the scene and the light.
  11915. * @param activeCamera The camera we are returning the max for
  11916. * @returns the depth max z
  11917. */
  11918. getDepthMaxZ(activeCamera: Camera): number;
  11919. /**
  11920. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  11921. * @param matrix The materix to updated with the projection information
  11922. * @param viewMatrix The transform matrix of the light
  11923. * @param renderList The list of mesh to render in the map
  11924. * @returns The current light
  11925. */
  11926. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  11927. }
  11928. }
  11929. declare module BABYLON {
  11930. /**
  11931. * A spot light is defined by a position, a direction, an angle, and an exponent.
  11932. * These values define a cone of light starting from the position, emitting toward the direction.
  11933. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  11934. * and the exponent defines the speed of the decay of the light with distance (reach).
  11935. * Documentation: https://doc.babylonjs.com/babylon101/lights
  11936. */
  11937. class SpotLight extends ShadowLight {
  11938. private _angle;
  11939. /**
  11940. * Gets the cone angle of the spot light in Radians.
  11941. */
  11942. /**
  11943. * Sets the cone angle of the spot light in Radians.
  11944. */
  11945. angle: number;
  11946. private _shadowAngleScale;
  11947. /**
  11948. * Allows scaling the angle of the light for shadow generation only.
  11949. */
  11950. /**
  11951. * Allows scaling the angle of the light for shadow generation only.
  11952. */
  11953. shadowAngleScale: number;
  11954. /**
  11955. * The light decay speed with the distance from the emission spot.
  11956. */
  11957. exponent: number;
  11958. private _projectionTextureMatrix;
  11959. /**
  11960. * Allows reading the projecton texture
  11961. */
  11962. readonly projectionTextureMatrix: Matrix;
  11963. protected _projectionTextureLightNear: number;
  11964. /**
  11965. * Gets the near clip of the Spotlight for texture projection.
  11966. */
  11967. /**
  11968. * Sets the near clip of the Spotlight for texture projection.
  11969. */
  11970. projectionTextureLightNear: number;
  11971. protected _projectionTextureLightFar: number;
  11972. /**
  11973. * Gets the far clip of the Spotlight for texture projection.
  11974. */
  11975. /**
  11976. * Sets the far clip of the Spotlight for texture projection.
  11977. */
  11978. projectionTextureLightFar: number;
  11979. protected _projectionTextureUpDirection: Vector3;
  11980. /**
  11981. * Gets the Up vector of the Spotlight for texture projection.
  11982. */
  11983. /**
  11984. * Sets the Up vector of the Spotlight for texture projection.
  11985. */
  11986. projectionTextureUpDirection: Vector3;
  11987. private _projectionTexture;
  11988. /**
  11989. * Gets the projection texture of the light.
  11990. */
  11991. /**
  11992. * Sets the projection texture of the light.
  11993. */
  11994. projectionTexture: Nullable<BaseTexture>;
  11995. private _projectionTextureViewLightDirty;
  11996. private _projectionTextureProjectionLightDirty;
  11997. private _projectionTextureDirty;
  11998. private _projectionTextureViewTargetVector;
  11999. private _projectionTextureViewLightMatrix;
  12000. private _projectionTextureProjectionLightMatrix;
  12001. private _projectionTextureScalingMatrix;
  12002. /**
  12003. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  12004. * It can cast shadows.
  12005. * Documentation : http://doc.babylonjs.com/tutorials/lights
  12006. * @param name The light friendly name
  12007. * @param position The position of the spot light in the scene
  12008. * @param direction The direction of the light in the scene
  12009. * @param angle The cone angle of the light in Radians
  12010. * @param exponent The light decay speed with the distance from the emission spot
  12011. * @param scene The scene the lights belongs to
  12012. */
  12013. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  12014. /**
  12015. * Returns the string "SpotLight".
  12016. * @returns the class name
  12017. */
  12018. getClassName(): string;
  12019. /**
  12020. * Returns the integer 2.
  12021. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  12022. */
  12023. getTypeID(): number;
  12024. /**
  12025. * Overrides the direction setter to recompute the projection texture view light Matrix.
  12026. */
  12027. protected _setDirection(value: Vector3): void;
  12028. /**
  12029. * Overrides the position setter to recompute the projection texture view light Matrix.
  12030. */
  12031. protected _setPosition(value: Vector3): void;
  12032. /**
  12033. * 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.
  12034. * Returns the SpotLight.
  12035. */
  12036. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  12037. protected _computeProjectionTextureViewLightMatrix(): void;
  12038. protected _computeProjectionTextureProjectionLightMatrix(): void;
  12039. /**
  12040. * Main function for light texture projection matrix computing.
  12041. */
  12042. protected _computeProjectionTextureMatrix(): void;
  12043. protected _buildUniformLayout(): void;
  12044. /**
  12045. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  12046. * @param effect The effect to update
  12047. * @param lightIndex The index of the light in the effect to update
  12048. * @returns The spot light
  12049. */
  12050. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  12051. /**
  12052. * Disposes the light and the associated resources.
  12053. */
  12054. dispose(): void;
  12055. }
  12056. }
  12057. declare module BABYLON {
  12058. interface ILoadingScreen {
  12059. displayLoadingUI: () => void;
  12060. hideLoadingUI: () => void;
  12061. loadingUIBackgroundColor: string;
  12062. loadingUIText: string;
  12063. }
  12064. class DefaultLoadingScreen implements ILoadingScreen {
  12065. private _renderingCanvas;
  12066. private _loadingText;
  12067. private _loadingDivBackgroundColor;
  12068. private _loadingDiv;
  12069. private _loadingTextDiv;
  12070. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  12071. displayLoadingUI(): void;
  12072. hideLoadingUI(): void;
  12073. loadingUIText: string;
  12074. loadingUIBackgroundColor: string;
  12075. private _resizeLoadingUI;
  12076. }
  12077. }
  12078. declare module BABYLON {
  12079. class SceneLoaderProgressEvent {
  12080. readonly lengthComputable: boolean;
  12081. readonly loaded: number;
  12082. readonly total: number;
  12083. constructor(lengthComputable: boolean, loaded: number, total: number);
  12084. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  12085. }
  12086. interface ISceneLoaderPluginExtensions {
  12087. [extension: string]: {
  12088. isBinary: boolean;
  12089. };
  12090. }
  12091. interface ISceneLoaderPluginFactory {
  12092. name: string;
  12093. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  12094. canDirectLoad?: (data: string) => boolean;
  12095. }
  12096. interface ISceneLoaderPlugin {
  12097. /**
  12098. * The friendly name of this plugin.
  12099. */
  12100. name: string;
  12101. /**
  12102. * The file extensions supported by this plugin.
  12103. */
  12104. extensions: string | ISceneLoaderPluginExtensions;
  12105. /**
  12106. * Import meshes into a scene.
  12107. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  12108. * @param scene The scene to import into
  12109. * @param data The data to import
  12110. * @param rootUrl The root url for scene and resources
  12111. * @param meshes The meshes array to import into
  12112. * @param particleSystems The particle systems array to import into
  12113. * @param skeletons The skeletons array to import into
  12114. * @param onError The callback when import fails
  12115. * @returns True if successful or false otherwise
  12116. */
  12117. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: ParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  12118. /**
  12119. * Load into a scene.
  12120. * @param scene The scene to load into
  12121. * @param data The data to import
  12122. * @param rootUrl The root url for scene and resources
  12123. * @param onError The callback when import fails
  12124. * @returns true if successful or false otherwise
  12125. */
  12126. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  12127. /**
  12128. * The callback that returns true if the data can be directly loaded.
  12129. */
  12130. canDirectLoad?: (data: string) => boolean;
  12131. /**
  12132. * The callback that allows custom handling of the root url based on the response url.
  12133. */
  12134. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  12135. /**
  12136. * Load into an asset container.
  12137. * @param scene The scene to load into
  12138. * @param data The data to import
  12139. * @param rootUrl The root url for scene and resources
  12140. * @param onError The callback when import fails
  12141. * @returns The loaded asset container
  12142. */
  12143. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  12144. }
  12145. interface ISceneLoaderPluginAsync {
  12146. /**
  12147. * The friendly name of this plugin.
  12148. */
  12149. name: string;
  12150. /**
  12151. * The file extensions supported by this plugin.
  12152. */
  12153. extensions: string | ISceneLoaderPluginExtensions;
  12154. /**
  12155. * Import meshes into a scene.
  12156. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  12157. * @param scene The scene to import into
  12158. * @param data The data to import
  12159. * @param rootUrl The root url for scene and resources
  12160. * @param onProgress The callback when the load progresses
  12161. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  12162. */
  12163. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<{
  12164. meshes: AbstractMesh[];
  12165. particleSystems: ParticleSystem[];
  12166. skeletons: Skeleton[];
  12167. animationGroups: AnimationGroup[];
  12168. }>;
  12169. /**
  12170. * Load into a scene.
  12171. * @param scene The scene to load into
  12172. * @param data The data to import
  12173. * @param rootUrl The root url for scene and resources
  12174. * @param onProgress The callback when the load progresses
  12175. * @returns Nothing
  12176. */
  12177. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  12178. /**
  12179. * The callback that returns true if the data can be directly loaded.
  12180. */
  12181. canDirectLoad?: (data: string) => boolean;
  12182. /**
  12183. * The callback that allows custom handling of the root url based on the response url.
  12184. */
  12185. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  12186. /**
  12187. * Load into an asset container.
  12188. * @param scene The scene to load into
  12189. * @param data The data to import
  12190. * @param rootUrl The root url for scene and resources
  12191. * @param onProgress The callback when the load progresses
  12192. * @returns The loaded asset container
  12193. */
  12194. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<AssetContainer>;
  12195. }
  12196. class SceneLoader {
  12197. private static _ForceFullSceneLoadingForIncremental;
  12198. private static _ShowLoadingScreen;
  12199. private static _CleanBoneMatrixWeights;
  12200. static readonly NO_LOGGING: number;
  12201. static readonly MINIMAL_LOGGING: number;
  12202. static readonly SUMMARY_LOGGING: number;
  12203. static readonly DETAILED_LOGGING: number;
  12204. private static _loggingLevel;
  12205. static ForceFullSceneLoadingForIncremental: boolean;
  12206. static ShowLoadingScreen: boolean;
  12207. static loggingLevel: number;
  12208. static CleanBoneMatrixWeights: boolean;
  12209. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  12210. private static _registeredPlugins;
  12211. private static _getDefaultPlugin();
  12212. private static _getPluginForExtension(extension);
  12213. private static _getPluginForDirectLoad(data);
  12214. private static _getPluginForFilename(sceneFilename);
  12215. private static _getDirectLoad(sceneFilename);
  12216. private static _loadData(rootUrl, sceneFilename, scene, onSuccess, onProgress, onError, onDispose, pluginExtension);
  12217. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  12218. static IsPluginForExtensionAvailable(extension: string): boolean;
  12219. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  12220. /**
  12221. * Import meshes into a scene
  12222. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  12223. * @param rootUrl a string that defines the root url for scene and resources OR the concatenation of rootURL and filename (eg. http://example.com/test.glb)
  12224. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene (default: empty string)
  12225. * @param scene the instance of BABYLON.Scene to append to
  12226. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  12227. * @param onProgress a callback with a progress event for each file being loaded
  12228. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  12229. * @param pluginExtension the extension used to determine the plugin
  12230. * @returns The loaded plugin
  12231. */
  12232. static ImportMesh(meshNames: any, rootUrl: string, sceneFilename?: any, scene?: Nullable<Scene>, onSuccess?: Nullable<(meshes: AbstractMesh[], particleSystems: ParticleSystem[], 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>;
  12233. /**
  12234. * Import meshes into a scene
  12235. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  12236. * @param rootUrl a string that defines the root url for scene and resources OR the concatenation of rootURL and filename (eg. http://example.com/test.glb)
  12237. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene (default: empty string)
  12238. * @param scene the instance of BABYLON.Scene to append to
  12239. * @param onProgress a callback with a progress event for each file being loaded
  12240. * @param pluginExtension the extension used to determine the plugin
  12241. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  12242. */
  12243. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: any, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  12244. meshes: AbstractMesh[];
  12245. particleSystems: ParticleSystem[];
  12246. skeletons: Skeleton[];
  12247. animationGroups: AnimationGroup[];
  12248. }>;
  12249. /**
  12250. * Load a scene
  12251. * @param rootUrl a string that defines the root url for scene and resources OR the concatenation of rootURL and filename (eg. http://example.com/test.glb)
  12252. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene (default: empty string)
  12253. * @param engine is the instance of BABYLON.Engine to use to create the scene
  12254. * @param onSuccess a callback with the scene when import succeeds
  12255. * @param onProgress a callback with a progress event for each file being loaded
  12256. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  12257. * @param pluginExtension the extension used to determine the plugin
  12258. * @returns The loaded plugin
  12259. */
  12260. static Load(rootUrl: string, sceneFilename: any, 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>;
  12261. /**
  12262. * Load a scene
  12263. * @param rootUrl a string that defines the root url for scene and resources OR the concatenation of rootURL and filename (eg. http://example.com/test.glb)
  12264. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene (default: empty string)
  12265. * @param engine is the instance of BABYLON.Engine to use to create the scene
  12266. * @param onProgress a callback with a progress event for each file being loaded
  12267. * @param pluginExtension the extension used to determine the plugin
  12268. * @returns The loaded scene
  12269. */
  12270. static LoadAsync(rootUrl: string, sceneFilename: any, engine: Engine, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  12271. /**
  12272. * Append a scene
  12273. * @param rootUrl a string that defines the root url for scene and resources OR the concatenation of rootURL and filename (eg. http://example.com/test.glb)
  12274. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene (default: empty string)
  12275. * @param scene is the instance of BABYLON.Scene to append to
  12276. * @param onSuccess a callback with the scene when import succeeds
  12277. * @param onProgress a callback with a progress event for each file being loaded
  12278. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  12279. * @param pluginExtension the extension used to determine the plugin
  12280. * @returns The loaded plugin
  12281. */
  12282. static Append(rootUrl: string, sceneFilename?: any, 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>;
  12283. /**
  12284. * Append a scene
  12285. * @param rootUrl a string that defines the root url for scene and resources OR the concatenation of rootURL and filename (eg. http://example.com/test.glb)
  12286. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene (default: empty string)
  12287. * @param scene is the instance of BABYLON.Scene to append to
  12288. * @param onProgress a callback with a progress event for each file being loaded
  12289. * @param pluginExtension the extension used to determine the plugin
  12290. * @returns The given scene
  12291. */
  12292. static AppendAsync(rootUrl: string, sceneFilename?: any, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  12293. /**
  12294. * Load a scene into an asset container
  12295. * @param rootUrl a string that defines the root url for scene and resources OR the concatenation of rootURL and filename (eg. http://example.com/test.glb)
  12296. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene (default: empty string)
  12297. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  12298. * @param onSuccess a callback with the scene when import succeeds
  12299. * @param onProgress a callback with a progress event for each file being loaded
  12300. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  12301. * @param pluginExtension the extension used to determine the plugin
  12302. * @returns The loaded plugin
  12303. */
  12304. static LoadAssetContainer(rootUrl: string, sceneFilename?: any, 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>;
  12305. /**
  12306. * Load a scene into an asset container
  12307. * @param rootUrl a string that defines the root url for scene and resources OR the concatenation of rootURL and filename (eg. http://example.com/test.glb)
  12308. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene (default: empty string)
  12309. * @param scene is the instance of BABYLON.Scene to append to
  12310. * @param onProgress a callback with a progress event for each file being loaded
  12311. * @param pluginExtension the extension used to determine the plugin
  12312. * @returns The loaded asset container
  12313. */
  12314. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: any, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  12315. }
  12316. }
  12317. declare module BABYLON {
  12318. class Scalar {
  12319. /**
  12320. * Two pi constants convenient for computation.
  12321. */
  12322. static TwoPi: number;
  12323. /**
  12324. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  12325. */
  12326. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  12327. /**
  12328. * Returns a string : the upper case translation of the number i to hexadecimal.
  12329. */
  12330. static ToHex(i: number): string;
  12331. /**
  12332. * Returns -1 if value is negative and +1 is value is positive.
  12333. * Returns the value itself if it's equal to zero.
  12334. */
  12335. static Sign(value: number): number;
  12336. /**
  12337. * Returns the value itself if it's between min and max.
  12338. * Returns min if the value is lower than min.
  12339. * Returns max if the value is greater than max.
  12340. */
  12341. static Clamp(value: number, min?: number, max?: number): number;
  12342. /**
  12343. * Returns the log2 of value.
  12344. */
  12345. static Log2(value: number): number;
  12346. /**
  12347. * Loops the value, so that it is never larger than length and never smaller than 0.
  12348. *
  12349. * This is similar to the modulo operator but it works with floating point numbers.
  12350. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  12351. * With t = 5 and length = 2.5, the result would be 0.0.
  12352. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  12353. */
  12354. static Repeat(value: number, length: number): number;
  12355. /**
  12356. * Normalize the value between 0.0 and 1.0 using min and max values
  12357. */
  12358. static Normalize(value: number, min: number, max: number): number;
  12359. /**
  12360. * Denormalize the value from 0.0 and 1.0 using min and max values
  12361. */
  12362. static Denormalize(normalized: number, min: number, max: number): number;
  12363. /**
  12364. * Calculates the shortest difference between two given angles given in degrees.
  12365. */
  12366. static DeltaAngle(current: number, target: number): number;
  12367. /**
  12368. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  12369. *
  12370. * The returned value will move back and forth between 0 and length
  12371. */
  12372. static PingPong(tx: number, length: number): number;
  12373. /**
  12374. * Interpolates between min and max with smoothing at the limits.
  12375. *
  12376. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  12377. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  12378. */
  12379. static SmoothStep(from: number, to: number, tx: number): number;
  12380. /**
  12381. * Moves a value current towards target.
  12382. *
  12383. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  12384. * Negative values of maxDelta pushes the value away from target.
  12385. */
  12386. static MoveTowards(current: number, target: number, maxDelta: number): number;
  12387. /**
  12388. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  12389. *
  12390. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  12391. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  12392. */
  12393. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  12394. /**
  12395. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  12396. */
  12397. static Lerp(start: number, end: number, amount: number): number;
  12398. /**
  12399. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  12400. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  12401. */
  12402. static LerpAngle(start: number, end: number, amount: number): number;
  12403. /**
  12404. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  12405. */
  12406. static InverseLerp(a: number, b: number, value: number): number;
  12407. /**
  12408. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  12409. */
  12410. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  12411. /**
  12412. * Returns a random float number between and min and max values
  12413. */
  12414. static RandomRange(min: number, max: number): number;
  12415. /**
  12416. * This function returns percentage of a number in a given range.
  12417. *
  12418. * RangeToPercent(40,20,60) will return 0.5 (50%)
  12419. * RangeToPercent(34,0,100) will return 0.34 (34%)
  12420. */
  12421. static RangeToPercent(number: number, min: number, max: number): number;
  12422. /**
  12423. * This function returns number that corresponds to the percentage in a given range.
  12424. *
  12425. * PercentToRange(0.34,0,100) will return 34.
  12426. */
  12427. static PercentToRange(percent: number, min: number, max: number): number;
  12428. /**
  12429. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  12430. * @param angle The angle to normalize in radian.
  12431. * @return The converted angle.
  12432. */
  12433. static NormalizeRadians(angle: number): number;
  12434. }
  12435. }
  12436. declare module BABYLON {
  12437. const ToGammaSpace: number;
  12438. const ToLinearSpace = 2.2;
  12439. const Epsilon = 0.001;
  12440. /**
  12441. * Class used to hold a RBG color
  12442. */
  12443. class Color3 {
  12444. /**
  12445. * Defines the red component (between 0 and 1, default is 0)
  12446. */
  12447. r: number;
  12448. /**
  12449. * Defines the green component (between 0 and 1, default is 0)
  12450. */
  12451. g: number;
  12452. /**
  12453. * Defines the blue component (between 0 and 1, default is 0)
  12454. */
  12455. b: number;
  12456. /**
  12457. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  12458. * @param r defines the red component (between 0 and 1, default is 0)
  12459. * @param g defines the green component (between 0 and 1, default is 0)
  12460. * @param b defines the blue component (between 0 and 1, default is 0)
  12461. */
  12462. constructor(
  12463. /**
  12464. * Defines the red component (between 0 and 1, default is 0)
  12465. */
  12466. r?: number,
  12467. /**
  12468. * Defines the green component (between 0 and 1, default is 0)
  12469. */
  12470. g?: number,
  12471. /**
  12472. * Defines the blue component (between 0 and 1, default is 0)
  12473. */
  12474. b?: number);
  12475. /**
  12476. * Creates a string with the Color3 current values
  12477. * @returns the string representation of the Color3 object
  12478. */
  12479. toString(): string;
  12480. /**
  12481. * Returns the string "Color3"
  12482. * @returns "Color3"
  12483. */
  12484. getClassName(): string;
  12485. /**
  12486. * Compute the Color3 hash code
  12487. * @returns an unique number that can be used to hash Color3 objects
  12488. */
  12489. getHashCode(): number;
  12490. /**
  12491. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  12492. * @param array defines the array where to store the r,g,b components
  12493. * @param index defines an optional index in the target array to define where to start storing values
  12494. * @returns the current Color3 object
  12495. */
  12496. toArray(array: FloatArray, index?: number): Color3;
  12497. /**
  12498. * Returns a new {BABYLON.Color4} object from the current Color3 and the given alpha
  12499. * @param alpha defines the alpha component on the new {BABYLON.Color4} object (default is 1)
  12500. * @returns a new {BABYLON.Color4} object
  12501. */
  12502. toColor4(alpha?: number): Color4;
  12503. /**
  12504. * Returns a new array populated with 3 numeric elements : red, green and blue values
  12505. * @returns the new array
  12506. */
  12507. asArray(): number[];
  12508. /**
  12509. * Returns the luminance value
  12510. * @returns a float value
  12511. */
  12512. toLuminance(): number;
  12513. /**
  12514. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  12515. * @param otherColor defines the second operand
  12516. * @returns the new Color3 object
  12517. */
  12518. multiply(otherColor: Color3): Color3;
  12519. /**
  12520. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  12521. * @param otherColor defines the second operand
  12522. * @param result defines the Color3 object where to store the result
  12523. * @returns the current Color3
  12524. */
  12525. multiplyToRef(otherColor: Color3, result: Color3): Color3;
  12526. /**
  12527. * Determines equality between Color3 objects
  12528. * @param otherColor defines the second operand
  12529. * @returns true if the rgb values are equal to the given ones
  12530. */
  12531. equals(otherColor: Color3): boolean;
  12532. /**
  12533. * Determines equality between the current Color3 object and a set of r,b,g values
  12534. * @param r defines the red component to check
  12535. * @param g defines the green component to check
  12536. * @param b defines the blue component to check
  12537. * @returns true if the rgb values are equal to the given ones
  12538. */
  12539. equalsFloats(r: number, g: number, b: number): boolean;
  12540. /**
  12541. * Multiplies in place each rgb value by scale
  12542. * @param scale defines the scaling factor
  12543. * @returns the updated Color3
  12544. */
  12545. scale(scale: number): Color3;
  12546. /**
  12547. * Multiplies the rgb values by scale and stores the result into "result"
  12548. * @param scale defines the scaling factor
  12549. * @param result defines the Color3 object where to store the result
  12550. * @returns the unmodified current Color3
  12551. */
  12552. scaleToRef(scale: number, result: Color3): Color3;
  12553. /**
  12554. * Scale the current Color3 values by a factor and add the result to a given Color3
  12555. * @param scale defines the scale factor
  12556. * @param result defines color to store the result into
  12557. * @returns the unmodified current Color3
  12558. */
  12559. scaleAndAddToRef(scale: number, result: Color3): Color3;
  12560. /**
  12561. * Clamps the rgb values by the min and max values and stores the result into "result"
  12562. * @param min defines minimum clamping value (default is 0)
  12563. * @param max defines maximum clamping value (default is 1)
  12564. * @param result defines color to store the result into
  12565. * @returns the original Color3
  12566. */
  12567. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  12568. /**
  12569. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  12570. * @param otherColor defines the second operand
  12571. * @returns the new Color3
  12572. */
  12573. add(otherColor: Color3): Color3;
  12574. /**
  12575. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  12576. * @param otherColor defines the second operand
  12577. * @param result defines Color3 object to store the result into
  12578. * @returns the unmodified current Color3
  12579. */
  12580. addToRef(otherColor: Color3, result: Color3): Color3;
  12581. /**
  12582. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  12583. * @param otherColor defines the second operand
  12584. * @returns the new Color3
  12585. */
  12586. subtract(otherColor: Color3): Color3;
  12587. /**
  12588. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  12589. * @param otherColor defines the second operand
  12590. * @param result defines Color3 object to store the result into
  12591. * @returns the unmodified current Color3
  12592. */
  12593. subtractToRef(otherColor: Color3, result: Color3): Color3;
  12594. /**
  12595. * Copy the current object
  12596. * @returns a new Color3 copied the current one
  12597. */
  12598. clone(): Color3;
  12599. /**
  12600. * Copies the rgb values from the source in the current Color3
  12601. * @param source defines the source Color3 object
  12602. * @returns the updated Color3 object
  12603. */
  12604. copyFrom(source: Color3): Color3;
  12605. /**
  12606. * Updates the Color3 rgb values from the given floats
  12607. * @param r defines the red component to read from
  12608. * @param g defines the green component to read from
  12609. * @param b defines the blue component to read from
  12610. * @returns the current Color3 object
  12611. */
  12612. copyFromFloats(r: number, g: number, b: number): Color3;
  12613. /**
  12614. * Updates the Color3 rgb values from the given floats
  12615. * @param r defines the red component to read from
  12616. * @param g defines the green component to read from
  12617. * @param b defines the blue component to read from
  12618. * @returns the current Color3 object
  12619. */
  12620. set(r: number, g: number, b: number): Color3;
  12621. /**
  12622. * Compute the Color3 hexadecimal code as a string
  12623. * @returns a string containing the hexadecimal representation of the Color3 object
  12624. */
  12625. toHexString(): string;
  12626. /**
  12627. * Computes a new Color3 converted from the current one to linear space
  12628. * @returns a new Color3 object
  12629. */
  12630. toLinearSpace(): Color3;
  12631. /**
  12632. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  12633. * @param convertedColor defines the Color3 object where to store the linear space version
  12634. * @returns the unmodified Color3
  12635. */
  12636. toLinearSpaceToRef(convertedColor: Color3): Color3;
  12637. /**
  12638. * Computes a new Color3 converted from the current one to gamma space
  12639. * @returns a new Color3 object
  12640. */
  12641. toGammaSpace(): Color3;
  12642. /**
  12643. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  12644. * @param convertedColor defines the Color3 object where to store the gamma space version
  12645. * @returns the unmodified Color3
  12646. */
  12647. toGammaSpaceToRef(convertedColor: Color3): Color3;
  12648. /**
  12649. * Creates a new Color3 from the string containing valid hexadecimal values
  12650. * @param hex defines a string containing valid hexadecimal values
  12651. * @returns a new Color3 object
  12652. */
  12653. static FromHexString(hex: string): Color3;
  12654. /**
  12655. * Creates a new Vector3 from the starting index of the given array
  12656. * @param array defines the source array
  12657. * @param offset defines an offset in the source array
  12658. * @returns a new Color3 object
  12659. */
  12660. static FromArray(array: ArrayLike<number>, offset?: number): Color3;
  12661. /**
  12662. * Creates a new Color3 from integer values (< 256)
  12663. * @param r defines the red component to read from (value between 0 and 255)
  12664. * @param g defines the green component to read from (value between 0 and 255)
  12665. * @param b defines the blue component to read from (value between 0 and 255)
  12666. * @returns a new Color3 object
  12667. */
  12668. static FromInts(r: number, g: number, b: number): Color3;
  12669. /**
  12670. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  12671. * @param start defines the start Color3 value
  12672. * @param end defines the end Color3 value
  12673. * @param amount defines the gradient value between start and end
  12674. * @returns a new Color3 object
  12675. */
  12676. static Lerp(start: Color3, end: Color3, amount: number): Color3;
  12677. /**
  12678. * Returns a Color3 value containing a red color
  12679. * @returns a new Color3 object
  12680. */
  12681. static Red(): Color3;
  12682. /**
  12683. * Returns a Color3 value containing a green color
  12684. * @returns a new Color3 object
  12685. */
  12686. static Green(): Color3;
  12687. /**
  12688. * Returns a Color3 value containing a blue color
  12689. * @returns a new Color3 object
  12690. */
  12691. static Blue(): Color3;
  12692. /**
  12693. * Returns a Color3 value containing a black color
  12694. * @returns a new Color3 object
  12695. */
  12696. static Black(): Color3;
  12697. /**
  12698. * Returns a Color3 value containing a white color
  12699. * @returns a new Color3 object
  12700. */
  12701. static White(): Color3;
  12702. /**
  12703. * Returns a Color3 value containing a purple color
  12704. * @returns a new Color3 object
  12705. */
  12706. static Purple(): Color3;
  12707. /**
  12708. * Returns a Color3 value containing a magenta color
  12709. * @returns a new Color3 object
  12710. */
  12711. static Magenta(): Color3;
  12712. /**
  12713. * Returns a Color3 value containing a yellow color
  12714. * @returns a new Color3 object
  12715. */
  12716. static Yellow(): Color3;
  12717. /**
  12718. * Returns a Color3 value containing a gray color
  12719. * @returns a new Color3 object
  12720. */
  12721. static Gray(): Color3;
  12722. /**
  12723. * Returns a Color3 value containing a teal color
  12724. * @returns a new Color3 object
  12725. */
  12726. static Teal(): Color3;
  12727. /**
  12728. * Returns a Color3 value containing a random color
  12729. * @returns a new Color3 object
  12730. */
  12731. static Random(): Color3;
  12732. }
  12733. /**
  12734. * Class used to hold a RBGA color
  12735. */
  12736. class Color4 {
  12737. /**
  12738. * Defines the red component (between 0 and 1, default is 0)
  12739. */
  12740. r: number;
  12741. /**
  12742. * Defines the green component (between 0 and 1, default is 0)
  12743. */
  12744. g: number;
  12745. /**
  12746. * Defines the blue component (between 0 and 1, default is 0)
  12747. */
  12748. b: number;
  12749. /**
  12750. * Defines the alpha component (between 0 and 1, default is 1)
  12751. */
  12752. a: number;
  12753. /**
  12754. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  12755. * @param r defines the red component (between 0 and 1, default is 0)
  12756. * @param g defines the green component (between 0 and 1, default is 0)
  12757. * @param b defines the blue component (between 0 and 1, default is 0)
  12758. * @param a defines the alpha component (between 0 and 1, default is 1)
  12759. */
  12760. constructor(
  12761. /**
  12762. * Defines the red component (between 0 and 1, default is 0)
  12763. */
  12764. r?: number,
  12765. /**
  12766. * Defines the green component (between 0 and 1, default is 0)
  12767. */
  12768. g?: number,
  12769. /**
  12770. * Defines the blue component (between 0 and 1, default is 0)
  12771. */
  12772. b?: number,
  12773. /**
  12774. * Defines the alpha component (between 0 and 1, default is 1)
  12775. */
  12776. a?: number);
  12777. /**
  12778. * Adds in place the given Color4 values to the current Color4 object
  12779. * @param right defines the second operand
  12780. * @returns the current updated Color4 object
  12781. */
  12782. addInPlace(right: Color4): Color4;
  12783. /**
  12784. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  12785. * @returns the new array
  12786. */
  12787. asArray(): number[];
  12788. /**
  12789. * Stores from the starting index in the given array the Color4 successive values
  12790. * @param array defines the array where to store the r,g,b components
  12791. * @param index defines an optional index in the target array to define where to start storing values
  12792. * @returns the current Color4 object
  12793. */
  12794. toArray(array: number[], index?: number): Color4;
  12795. /**
  12796. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  12797. * @param right defines the second operand
  12798. * @returns a new Color4 object
  12799. */
  12800. add(right: Color4): Color4;
  12801. /**
  12802. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  12803. * @param right defines the second operand
  12804. * @returns a new Color4 object
  12805. */
  12806. subtract(right: Color4): Color4;
  12807. /**
  12808. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  12809. * @param right defines the second operand
  12810. * @param result defines the Color4 object where to store the result
  12811. * @returns the current Color4 object
  12812. */
  12813. subtractToRef(right: Color4, result: Color4): Color4;
  12814. /**
  12815. * Creates a new Color4 with the current Color4 values multiplied by scale
  12816. * @param scale defines the scaling factor to apply
  12817. * @returns a new Color4 object
  12818. */
  12819. scale(scale: number): Color4;
  12820. /**
  12821. * Multiplies the current Color4 values by scale and stores the result in "result"
  12822. * @param scale defines the scaling factor to apply
  12823. * @param result defines the Color4 object where to store the result
  12824. * @returns the current unmodified Color4
  12825. */
  12826. scaleToRef(scale: number, result: Color4): Color4;
  12827. /**
  12828. * Scale the current Color4 values by a factor and add the result to a given Color4
  12829. * @param scale defines the scale factor
  12830. * @param result defines the Color4 object where to store the result
  12831. * @returns the unmodified current Color4
  12832. */
  12833. scaleAndAddToRef(scale: number, result: Color4): Color4;
  12834. /**
  12835. * Clamps the rgb values by the min and max values and stores the result into "result"
  12836. * @param min defines minimum clamping value (default is 0)
  12837. * @param max defines maximum clamping value (default is 1)
  12838. * @param result defines color to store the result into.
  12839. * @returns the cuurent Color4
  12840. */
  12841. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  12842. /**
  12843. * Multipy an Color4 value by another and return a new Color4 object
  12844. * @param color defines the Color4 value to multiply by
  12845. * @returns a new Color4 object
  12846. */
  12847. multiply(color: Color4): Color4;
  12848. /**
  12849. * Multipy a Color4 value by another and push the result in a reference value
  12850. * @param color defines the Color4 value to multiply by
  12851. * @param result defines the Color4 to fill the result in
  12852. * @returns the result Color4
  12853. */
  12854. multiplyToRef(color: Color4, result: Color4): Color4;
  12855. /**
  12856. * Creates a string with the Color4 current values
  12857. * @returns the string representation of the Color4 object
  12858. */
  12859. toString(): string;
  12860. /**
  12861. * Returns the string "Color4"
  12862. * @returns "Color4"
  12863. */
  12864. getClassName(): string;
  12865. /**
  12866. * Compute the Color4 hash code
  12867. * @returns an unique number that can be used to hash Color4 objects
  12868. */
  12869. getHashCode(): number;
  12870. /**
  12871. * Creates a new Color4 copied from the current one
  12872. * @returns a new Color4 object
  12873. */
  12874. clone(): Color4;
  12875. /**
  12876. * Copies the given Color4 values into the current one
  12877. * @param source defines the source Color4 object
  12878. * @returns the current updated Color4 object
  12879. */
  12880. copyFrom(source: Color4): Color4;
  12881. /**
  12882. * Copies the given float values into the current one
  12883. * @param r defines the red component to read from
  12884. * @param g defines the green component to read from
  12885. * @param b defines the blue component to read from
  12886. * @param a defines the alpha component to read from
  12887. * @returns the current updated Color4 object
  12888. */
  12889. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  12890. /**
  12891. * Copies the given float values into the current one
  12892. * @param r defines the red component to read from
  12893. * @param g defines the green component to read from
  12894. * @param b defines the blue component to read from
  12895. * @param a defines the alpha component to read from
  12896. * @returns the current updated Color4 object
  12897. */
  12898. set(r: number, g: number, b: number, a: number): Color4;
  12899. /**
  12900. * Compute the Color4 hexadecimal code as a string
  12901. * @returns a string containing the hexadecimal representation of the Color4 object
  12902. */
  12903. toHexString(): string;
  12904. /**
  12905. * Computes a new Color4 converted from the current one to linear space
  12906. * @returns a new Color4 object
  12907. */
  12908. toLinearSpace(): Color4;
  12909. /**
  12910. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  12911. * @param convertedColor defines the Color4 object where to store the linear space version
  12912. * @returns the unmodified Color4
  12913. */
  12914. toLinearSpaceToRef(convertedColor: Color4): Color4;
  12915. /**
  12916. * Computes a new Color4 converted from the current one to gamma space
  12917. * @returns a new Color4 object
  12918. */
  12919. toGammaSpace(): Color4;
  12920. /**
  12921. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  12922. * @param convertedColor defines the Color4 object where to store the gamma space version
  12923. * @returns the unmodified Color4
  12924. */
  12925. toGammaSpaceToRef(convertedColor: Color4): Color4;
  12926. /**
  12927. * Creates a new Color4 from the string containing valid hexadecimal values
  12928. * @param hex defines a string containing valid hexadecimal values
  12929. * @returns a new Color4 object
  12930. */
  12931. static FromHexString(hex: string): Color4;
  12932. /**
  12933. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  12934. * @param left defines the start value
  12935. * @param right defines the end value
  12936. * @param amount defines the gradient factor
  12937. * @returns a new Color4 object
  12938. */
  12939. static Lerp(left: Color4, right: Color4, amount: number): Color4;
  12940. /**
  12941. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  12942. * @param left defines the start value
  12943. * @param right defines the end value
  12944. * @param amount defines the gradient factor
  12945. * @param result defines the Color4 object where to store data
  12946. */
  12947. static LerpToRef(left: Color4, right: Color4, amount: number, result: Color4): void;
  12948. /**
  12949. * Creates a new Color4 from the starting index element of the given array
  12950. * @param array defines the source array to read from
  12951. * @param offset defines the offset in the source array
  12952. * @returns a new Color4 object
  12953. */
  12954. static FromArray(array: ArrayLike<number>, offset?: number): Color4;
  12955. /**
  12956. * Creates a new Color3 from integer values (< 256)
  12957. * @param r defines the red component to read from (value between 0 and 255)
  12958. * @param g defines the green component to read from (value between 0 and 255)
  12959. * @param b defines the blue component to read from (value between 0 and 255)
  12960. * @param a defines the alpha component to read from (value between 0 and 255)
  12961. * @returns a new Color3 object
  12962. */
  12963. static FromInts(r: number, g: number, b: number, a: number): Color4;
  12964. /**
  12965. * Check the content of a given array and convert it to an array containing RGBA data
  12966. * If the original array was already containing count * 4 values then it is returned directly
  12967. * @param colors defines the array to check
  12968. * @param count defines the number of RGBA data to expect
  12969. * @returns an array containing count * 4 values (RGBA)
  12970. */
  12971. static CheckColors4(colors: number[], count: number): number[];
  12972. }
  12973. /**
  12974. * Class representing a vector containing 2 coordinates
  12975. */
  12976. class Vector2 {
  12977. /** defines the first coordinate */
  12978. x: number;
  12979. /** defines the second coordinate */
  12980. y: number;
  12981. /**
  12982. * Creates a new Vector2 from the given x and y coordinates
  12983. * @param x defines the first coordinate
  12984. * @param y defines the second coordinate
  12985. */
  12986. constructor(
  12987. /** defines the first coordinate */
  12988. x?: number,
  12989. /** defines the second coordinate */
  12990. y?: number);
  12991. /**
  12992. * Gets a string with the Vector2 coordinates
  12993. * @returns a string with the Vector2 coordinates
  12994. */
  12995. toString(): string;
  12996. /**
  12997. * Gets class name
  12998. * @returns the string "Vector2"
  12999. */
  13000. getClassName(): string;
  13001. /**
  13002. * Gets current vector hash code
  13003. * @returns the Vector2 hash code as a number
  13004. */
  13005. getHashCode(): number;
  13006. /**
  13007. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  13008. * @param array defines the source array
  13009. * @param index defines the offset in source array
  13010. * @returns the current Vector2
  13011. */
  13012. toArray(array: FloatArray, index?: number): Vector2;
  13013. /**
  13014. * Copy the current vector to an array
  13015. * @returns a new array with 2 elements: the Vector2 coordinates.
  13016. */
  13017. asArray(): number[];
  13018. /**
  13019. * Sets the Vector2 coordinates with the given Vector2 coordinates
  13020. * @param source defines the source Vector2
  13021. * @returns the current updated Vector2
  13022. */
  13023. copyFrom(source: Vector2): Vector2;
  13024. /**
  13025. * Sets the Vector2 coordinates with the given floats
  13026. * @param x defines the first coordinate
  13027. * @param y defines the second coordinate
  13028. * @returns the current updated Vector2
  13029. */
  13030. copyFromFloats(x: number, y: number): Vector2;
  13031. /**
  13032. * Sets the Vector2 coordinates with the given floats
  13033. * @param x defines the first coordinate
  13034. * @param y defines the second coordinate
  13035. * @returns the current updated Vector2
  13036. */
  13037. set(x: number, y: number): Vector2;
  13038. /**
  13039. * Add another vector with the current one
  13040. * @param otherVector defines the other vector
  13041. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  13042. */
  13043. add(otherVector: Vector2): Vector2;
  13044. /**
  13045. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  13046. * @param otherVector defines the other vector
  13047. * @param result defines the target vector
  13048. * @returns the unmodified current Vector2
  13049. */
  13050. addToRef(otherVector: Vector2, result: Vector2): Vector2;
  13051. /**
  13052. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  13053. * @param otherVector defines the other vector
  13054. * @returns the current updated Vector2
  13055. */
  13056. addInPlace(otherVector: Vector2): Vector2;
  13057. /**
  13058. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  13059. * @param otherVector defines the other vector
  13060. * @returns a new Vector2
  13061. */
  13062. addVector3(otherVector: Vector3): Vector2;
  13063. /**
  13064. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  13065. * @param otherVector defines the other vector
  13066. * @returns a new Vector2
  13067. */
  13068. subtract(otherVector: Vector2): Vector2;
  13069. /**
  13070. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  13071. * @param otherVector defines the other vector
  13072. * @param result defines the target vector
  13073. * @returns the unmodified current Vector2
  13074. */
  13075. subtractToRef(otherVector: Vector2, result: Vector2): Vector2;
  13076. /**
  13077. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  13078. * @param otherVector defines the other vector
  13079. * @returns the current updated Vector2
  13080. */
  13081. subtractInPlace(otherVector: Vector2): Vector2;
  13082. /**
  13083. * Multiplies in place the current Vector2 coordinates by the given ones
  13084. * @param otherVector defines the other vector
  13085. * @returns the current updated Vector2
  13086. */
  13087. multiplyInPlace(otherVector: Vector2): Vector2;
  13088. /**
  13089. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  13090. * @param otherVector defines the other vector
  13091. * @returns a new Vector2
  13092. */
  13093. multiply(otherVector: Vector2): Vector2;
  13094. /**
  13095. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  13096. * @param otherVector defines the other vector
  13097. * @param result defines the target vector
  13098. * @returns the unmodified current Vector2
  13099. */
  13100. multiplyToRef(otherVector: Vector2, result: Vector2): Vector2;
  13101. /**
  13102. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  13103. * @param x defines the first coordinate
  13104. * @param y defines the second coordinate
  13105. * @returns a new Vector2
  13106. */
  13107. multiplyByFloats(x: number, y: number): Vector2;
  13108. /**
  13109. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  13110. * @param otherVector defines the other vector
  13111. * @returns a new Vector2
  13112. */
  13113. divide(otherVector: Vector2): Vector2;
  13114. /**
  13115. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  13116. * @param otherVector defines the other vector
  13117. * @param result defines the target vector
  13118. * @returns the unmodified current Vector2
  13119. */
  13120. divideToRef(otherVector: Vector2, result: Vector2): Vector2;
  13121. /**
  13122. * Divides the current Vector3 coordinates by the given ones
  13123. * @param otherVector defines the other vector
  13124. * @returns the current updated Vector2
  13125. */
  13126. divideInPlace(otherVector: Vector2): Vector2;
  13127. /**
  13128. * Gets a new Vector2 with current Vector2 negated coordinates
  13129. * @returns a new Vector2
  13130. */
  13131. negate(): Vector2;
  13132. /**
  13133. * Multiply the Vector2 coordinates by scale
  13134. * @param scale defines the scaling factor
  13135. * @returns the current updated Vector2
  13136. */
  13137. scaleInPlace(scale: number): Vector2;
  13138. /**
  13139. * Returns a new Vector2 scaled by "scale" from the current Vector2
  13140. * @param scale defines the scaling factor
  13141. * @returns a new Vector2
  13142. */
  13143. scale(scale: number): Vector2;
  13144. /**
  13145. * Scale the current Vector2 values by a factor to a given Vector2
  13146. * @param scale defines the scale factor
  13147. * @param result defines the Vector2 object where to store the result
  13148. * @returns the unmodified current Vector2
  13149. */
  13150. scaleToRef(scale: number, result: Vector2): Vector2;
  13151. /**
  13152. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  13153. * @param scale defines the scale factor
  13154. * @param result defines the Vector2 object where to store the result
  13155. * @returns the unmodified current Vector2
  13156. */
  13157. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  13158. /**
  13159. * Gets a boolean if two vectors are equals
  13160. * @param otherVector defines the other vector
  13161. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  13162. */
  13163. equals(otherVector: Vector2): boolean;
  13164. /**
  13165. * Gets a boolean if two vectors are equals (using an epsilon value)
  13166. * @param otherVector defines the other vector
  13167. * @param epsilon defines the minimal distance to consider equality
  13168. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  13169. */
  13170. equalsWithEpsilon(otherVector: Vector2, epsilon?: number): boolean;
  13171. /**
  13172. * Gets the length of the vector
  13173. * @returns the vector length (float)
  13174. */
  13175. length(): number;
  13176. /**
  13177. * Gets the vector squared length
  13178. * @returns the vector squared length (float)
  13179. */
  13180. lengthSquared(): number;
  13181. /**
  13182. * Normalize the vector
  13183. * @returns the current updated Vector2
  13184. */
  13185. normalize(): Vector2;
  13186. /**
  13187. * Gets a new Vector2 copied from the Vector2
  13188. * @returns a new Vector2
  13189. */
  13190. clone(): Vector2;
  13191. /**
  13192. * Gets a new Vector2(0, 0)
  13193. * @returns a new Vector2
  13194. */
  13195. static Zero(): Vector2;
  13196. /**
  13197. * Gets a new Vector2(1, 1)
  13198. * @returns a new Vector2
  13199. */
  13200. static One(): Vector2;
  13201. /**
  13202. * Gets a new Vector2 set from the given index element of the given array
  13203. * @param array defines the data source
  13204. * @param offset defines the offset in the data source
  13205. * @returns a new Vector2
  13206. */
  13207. static FromArray(array: ArrayLike<number>, offset?: number): Vector2;
  13208. /**
  13209. * Sets "result" from the given index element of the given array
  13210. * @param array defines the data source
  13211. * @param offset defines the offset in the data source
  13212. * @param result defines the target vector
  13213. */
  13214. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Vector2): void;
  13215. /**
  13216. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  13217. * @param value1 defines 1st point of control
  13218. * @param value2 defines 2nd point of control
  13219. * @param value3 defines 3rd point of control
  13220. * @param value4 defines 4th point of control
  13221. * @param amount defines the interpolation factor
  13222. * @returns a new Vector2
  13223. */
  13224. static CatmullRom(value1: Vector2, value2: Vector2, value3: Vector2, value4: Vector2, amount: number): Vector2;
  13225. /**
  13226. * 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".
  13227. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  13228. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  13229. * @param value defines the value to clamp
  13230. * @param min defines the lower limit
  13231. * @param max defines the upper limit
  13232. * @returns a new Vector2
  13233. */
  13234. static Clamp(value: Vector2, min: Vector2, max: Vector2): Vector2;
  13235. /**
  13236. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  13237. * @param value1 defines the 1st control point
  13238. * @param tangent1 defines the outgoing tangent
  13239. * @param value2 defines the 2nd control point
  13240. * @param tangent2 defines the incoming tangent
  13241. * @param amount defines the interpolation factor
  13242. * @returns a new Vector2
  13243. */
  13244. static Hermite(value1: Vector2, tangent1: Vector2, value2: Vector2, tangent2: Vector2, amount: number): Vector2;
  13245. /**
  13246. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  13247. * @param start defines the start vector
  13248. * @param end defines the end vector
  13249. * @param amount defines the interpolation factor
  13250. * @returns a new Vector2
  13251. */
  13252. static Lerp(start: Vector2, end: Vector2, amount: number): Vector2;
  13253. /**
  13254. * Gets the dot product of the vector "left" and the vector "right"
  13255. * @param left defines first vector
  13256. * @param right defines second vector
  13257. * @returns the dot product (float)
  13258. */
  13259. static Dot(left: Vector2, right: Vector2): number;
  13260. /**
  13261. * Returns a new Vector2 equal to the normalized given vector
  13262. * @param vector defines the vector to normalize
  13263. * @returns a new Vector2
  13264. */
  13265. static Normalize(vector: Vector2): Vector2;
  13266. /**
  13267. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  13268. * @param left defines 1st vector
  13269. * @param right defines 2nd vector
  13270. * @returns a new Vector2
  13271. */
  13272. static Minimize(left: Vector2, right: Vector2): Vector2;
  13273. /**
  13274. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  13275. * @param left defines 1st vector
  13276. * @param right defines 2nd vector
  13277. * @returns a new Vector2
  13278. */
  13279. static Maximize(left: Vector2, right: Vector2): Vector2;
  13280. /**
  13281. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  13282. * @param vector defines the vector to transform
  13283. * @param transformation defines the matrix to apply
  13284. * @returns a new Vector2
  13285. */
  13286. static Transform(vector: Vector2, transformation: Matrix): Vector2;
  13287. /**
  13288. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  13289. * @param vector defines the vector to transform
  13290. * @param transformation defines the matrix to apply
  13291. * @param result defines the target vector
  13292. */
  13293. static TransformToRef(vector: Vector2, transformation: Matrix, result: Vector2): void;
  13294. /**
  13295. * Determines if a given vector is included in a triangle
  13296. * @param p defines the vector to test
  13297. * @param p0 defines 1st triangle point
  13298. * @param p1 defines 2nd triangle point
  13299. * @param p2 defines 3rd triangle point
  13300. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  13301. */
  13302. static PointInTriangle(p: Vector2, p0: Vector2, p1: Vector2, p2: Vector2): boolean;
  13303. /**
  13304. * Gets the distance between the vectors "value1" and "value2"
  13305. * @param value1 defines first vector
  13306. * @param value2 defines second vector
  13307. * @returns the distance between vectors
  13308. */
  13309. static Distance(value1: Vector2, value2: Vector2): number;
  13310. /**
  13311. * Returns the squared distance between the vectors "value1" and "value2"
  13312. * @param value1 defines first vector
  13313. * @param value2 defines second vector
  13314. * @returns the squared distance between vectors
  13315. */
  13316. static DistanceSquared(value1: Vector2, value2: Vector2): number;
  13317. /**
  13318. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  13319. * @param value1 defines first vector
  13320. * @param value2 defines second vector
  13321. * @returns a new Vector2
  13322. */
  13323. static Center(value1: Vector2, value2: Vector2): Vector2;
  13324. /**
  13325. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  13326. * @param p defines the middle point
  13327. * @param segA defines one point of the segment
  13328. * @param segB defines the other point of the segment
  13329. * @returns the shortest distance
  13330. */
  13331. static DistanceOfPointFromSegment(p: Vector2, segA: Vector2, segB: Vector2): number;
  13332. }
  13333. /**
  13334. * Classed used to store (x,y,z) vector representation
  13335. * A Vector3 is the main object used in 3D geometry
  13336. * It can represent etiher the coordinates of a point the space, either a direction
  13337. * Reminder: Babylon.js uses a left handed forward facing system
  13338. */
  13339. class Vector3 {
  13340. /**
  13341. * Defines the first coordinates (on X axis)
  13342. */
  13343. x: number;
  13344. /**
  13345. * Defines the second coordinates (on Y axis)
  13346. */
  13347. y: number;
  13348. /**
  13349. * Defines the third coordinates (on Z axis)
  13350. */
  13351. z: number;
  13352. /**
  13353. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  13354. * @param x defines the first coordinates (on X axis)
  13355. * @param y defines the second coordinates (on Y axis)
  13356. * @param z defines the third coordinates (on Z axis)
  13357. */
  13358. constructor(
  13359. /**
  13360. * Defines the first coordinates (on X axis)
  13361. */
  13362. x?: number,
  13363. /**
  13364. * Defines the second coordinates (on Y axis)
  13365. */
  13366. y?: number,
  13367. /**
  13368. * Defines the third coordinates (on Z axis)
  13369. */
  13370. z?: number);
  13371. /**
  13372. * Creates a string representation of the Vector3
  13373. * @returns a string with the Vector3 coordinates.
  13374. */
  13375. toString(): string;
  13376. /**
  13377. * Gets the class name
  13378. * @returns the string "Vector3"
  13379. */
  13380. getClassName(): string;
  13381. /**
  13382. * Creates the Vector3 hash code
  13383. * @returns a number which tends to be unique between Vector3 instances
  13384. */
  13385. getHashCode(): number;
  13386. /**
  13387. * Creates an array containing three elements : the coordinates of the Vector3
  13388. * @returns a new array of numbers
  13389. */
  13390. asArray(): number[];
  13391. /**
  13392. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  13393. * @param array defines the destination array
  13394. * @param index defines the offset in the destination array
  13395. * @returns the current Vector3
  13396. */
  13397. toArray(array: FloatArray, index?: number): Vector3;
  13398. /**
  13399. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  13400. * @returns a new Quaternion object, computed from the Vector3 coordinates
  13401. */
  13402. toQuaternion(): Quaternion;
  13403. /**
  13404. * Adds the given vector to the current Vector3
  13405. * @param otherVector defines the second operand
  13406. * @returns the current updated Vector3
  13407. */
  13408. addInPlace(otherVector: Vector3): Vector3;
  13409. /**
  13410. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  13411. * @param otherVector defines the second operand
  13412. * @returns the resulting Vector3
  13413. */
  13414. add(otherVector: Vector3): Vector3;
  13415. /**
  13416. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  13417. * @param otherVector defines the second operand
  13418. * @param result defines the Vector3 object where to store the result
  13419. * @returns the current Vector3
  13420. */
  13421. addToRef(otherVector: Vector3, result: Vector3): Vector3;
  13422. /**
  13423. * Subtract the given vector from the current Vector3
  13424. * @param otherVector defines the second operand
  13425. * @returns the current updated Vector3
  13426. */
  13427. subtractInPlace(otherVector: Vector3): Vector3;
  13428. /**
  13429. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  13430. * @param otherVector defines the second operand
  13431. * @returns the resulting Vector3
  13432. */
  13433. subtract(otherVector: Vector3): Vector3;
  13434. /**
  13435. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  13436. * @param otherVector defines the second operand
  13437. * @param result defines the Vector3 object where to store the result
  13438. * @returns the current Vector3
  13439. */
  13440. subtractToRef(otherVector: Vector3, result: Vector3): Vector3;
  13441. /**
  13442. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  13443. * @param x defines the x coordinate of the operand
  13444. * @param y defines the y coordinate of the operand
  13445. * @param z defines the z coordinate of the operand
  13446. * @returns the resulting Vector3
  13447. */
  13448. subtractFromFloats(x: number, y: number, z: number): Vector3;
  13449. /**
  13450. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  13451. * @param x defines the x coordinate of the operand
  13452. * @param y defines the y coordinate of the operand
  13453. * @param z defines the z coordinate of the operand
  13454. * @param result defines the Vector3 object where to store the result
  13455. * @returns the current Vector3
  13456. */
  13457. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  13458. /**
  13459. * Gets a new Vector3 set with the current Vector3 negated coordinates
  13460. * @returns a new Vector3
  13461. */
  13462. negate(): Vector3;
  13463. /**
  13464. * Multiplies the Vector3 coordinates by the float "scale"
  13465. * @param scale defines the multiplier factor
  13466. * @returns the current updated Vector3
  13467. */
  13468. scaleInPlace(scale: number): Vector3;
  13469. /**
  13470. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  13471. * @param scale defines the multiplier factor
  13472. * @returns a new Vector3
  13473. */
  13474. scale(scale: number): Vector3;
  13475. /**
  13476. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  13477. * @param scale defines the multiplier factor
  13478. * @param result defines the Vector3 object where to store the result
  13479. * @returns the current Vector3
  13480. */
  13481. scaleToRef(scale: number, result: Vector3): Vector3;
  13482. /**
  13483. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  13484. * @param scale defines the scale factor
  13485. * @param result defines the Vector3 object where to store the result
  13486. * @returns the unmodified current Vector3
  13487. */
  13488. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  13489. /**
  13490. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  13491. * @param otherVector defines the second operand
  13492. * @returns true if both vectors are equals
  13493. */
  13494. equals(otherVector: Vector3): boolean;
  13495. /**
  13496. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  13497. * @param otherVector defines the second operand
  13498. * @param epsilon defines the minimal distance to define values as equals
  13499. * @returns true if both vectors are distant less than epsilon
  13500. */
  13501. equalsWithEpsilon(otherVector: Vector3, epsilon?: number): boolean;
  13502. /**
  13503. * Returns true if the current Vector3 coordinates equals the given floats
  13504. * @param x defines the x coordinate of the operand
  13505. * @param y defines the y coordinate of the operand
  13506. * @param z defines the z coordinate of the operand
  13507. * @returns true if both vectors are equals
  13508. */
  13509. equalsToFloats(x: number, y: number, z: number): boolean;
  13510. /**
  13511. * Multiplies the current Vector3 coordinates by the given ones
  13512. * @param otherVector defines the second operand
  13513. * @returns the current updated Vector3
  13514. */
  13515. multiplyInPlace(otherVector: Vector3): Vector3;
  13516. /**
  13517. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  13518. * @param otherVector defines the second operand
  13519. * @returns the new Vector3
  13520. */
  13521. multiply(otherVector: Vector3): Vector3;
  13522. /**
  13523. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  13524. * @param otherVector defines the second operand
  13525. * @param result defines the Vector3 object where to store the result
  13526. * @returns the current Vector3
  13527. */
  13528. multiplyToRef(otherVector: Vector3, result: Vector3): Vector3;
  13529. /**
  13530. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  13531. * @param x defines the x coordinate of the operand
  13532. * @param y defines the y coordinate of the operand
  13533. * @param z defines the z coordinate of the operand
  13534. * @returns the new Vector3
  13535. */
  13536. multiplyByFloats(x: number, y: number, z: number): Vector3;
  13537. /**
  13538. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  13539. * @param otherVector defines the second operand
  13540. * @returns the new Vector3
  13541. */
  13542. divide(otherVector: Vector3): Vector3;
  13543. /**
  13544. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  13545. * @param otherVector defines the second operand
  13546. * @param result defines the Vector3 object where to store the result
  13547. * @returns the current Vector3
  13548. */
  13549. divideToRef(otherVector: Vector3, result: Vector3): Vector3;
  13550. /**
  13551. * Divides the current Vector3 coordinates by the given ones.
  13552. * @param otherVector defines the second operand
  13553. * @returns the current updated Vector3
  13554. */
  13555. divideInPlace(otherVector: Vector3): Vector3;
  13556. /**
  13557. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  13558. * @param other defines the second operand
  13559. * @returns the current updated Vector3
  13560. */
  13561. minimizeInPlace(other: Vector3): Vector3;
  13562. /**
  13563. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  13564. * @param other defines the second operand
  13565. * @returns the current updated Vector3
  13566. */
  13567. maximizeInPlace(other: Vector3): Vector3;
  13568. /**
  13569. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  13570. */
  13571. readonly isNonUniform: boolean;
  13572. /**
  13573. * Gets the length of the Vector3
  13574. * @returns the length of the Vecto3
  13575. */
  13576. length(): number;
  13577. /**
  13578. * Gets the squared length of the Vector3
  13579. * @returns squared length of the Vector3
  13580. */
  13581. lengthSquared(): number;
  13582. /**
  13583. * Normalize the current Vector3.
  13584. * Please note that this is an in place operation.
  13585. * @returns the current updated Vector3
  13586. */
  13587. normalize(): Vector3;
  13588. /**
  13589. * Normalize the current Vector3 to a new vector
  13590. * @returns the new Vector3
  13591. */
  13592. normalizeToNew(): Vector3;
  13593. /**
  13594. * Normalize the current Vector3 to the reference
  13595. * @param reference define the Vector3 to update
  13596. * @returns the updated Vector3
  13597. */
  13598. normalizeToRef(reference: Vector3): Vector3;
  13599. /**
  13600. * Creates a new Vector3 copied from the current Vector3
  13601. * @returns the new Vector3
  13602. */
  13603. clone(): Vector3;
  13604. /**
  13605. * Copies the given vector coordinates to the current Vector3 ones
  13606. * @param source defines the source Vector3
  13607. * @returns the current updated Vector3
  13608. */
  13609. copyFrom(source: Vector3): Vector3;
  13610. /**
  13611. * Copies the given floats to the current Vector3 coordinates
  13612. * @param x defines the x coordinate of the operand
  13613. * @param y defines the y coordinate of the operand
  13614. * @param z defines the z coordinate of the operand
  13615. * @returns the current updated Vector3
  13616. */
  13617. copyFromFloats(x: number, y: number, z: number): Vector3;
  13618. /**
  13619. * Copies the given floats to the current Vector3 coordinates
  13620. * @param x defines the x coordinate of the operand
  13621. * @param y defines the y coordinate of the operand
  13622. * @param z defines the z coordinate of the operand
  13623. * @returns the current updated Vector3
  13624. */
  13625. set(x: number, y: number, z: number): Vector3;
  13626. /**
  13627. * Get the clip factor between two vectors
  13628. * @param vector0 defines the first operand
  13629. * @param vector1 defines the second operand
  13630. * @param axis defines the axis to use
  13631. * @param size defines the size along the axis
  13632. * @returns the clip factor
  13633. */
  13634. static GetClipFactor(vector0: Vector3, vector1: Vector3, axis: Vector3, size: number): number;
  13635. /**
  13636. * Get angle between two vectors
  13637. * @param vector0 angle between vector0 and vector1
  13638. * @param vector1 angle between vector0 and vector1
  13639. * @param normal direction of the normal
  13640. * @return the angle between vector0 and vector1
  13641. */
  13642. static GetAngleBetweenVectors(vector0: Vector3, vector1: Vector3, normal: Vector3): number;
  13643. /**
  13644. * Returns a new Vector3 set from the index "offset" of the given array
  13645. * @param array defines the source array
  13646. * @param offset defines the offset in the source array
  13647. * @returns the new Vector3
  13648. */
  13649. static FromArray(array: ArrayLike<number>, offset?: number): Vector3;
  13650. /**
  13651. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  13652. * This function is deprecated. Use FromArray instead
  13653. * @param array defines the source array
  13654. * @param offset defines the offset in the source array
  13655. * @returns the new Vector3
  13656. */
  13657. static FromFloatArray(array: Float32Array, offset?: number): Vector3;
  13658. /**
  13659. * Sets the given vector "result" with the element values from the index "offset" of the given array
  13660. * @param array defines the source array
  13661. * @param offset defines the offset in the source array
  13662. * @param result defines the Vector3 where to store the result
  13663. */
  13664. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Vector3): void;
  13665. /**
  13666. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  13667. * This function is deprecated. Use FromArrayToRef instead.
  13668. * @param array defines the source array
  13669. * @param offset defines the offset in the source array
  13670. * @param result defines the Vector3 where to store the result
  13671. */
  13672. static FromFloatArrayToRef(array: Float32Array, offset: number, result: Vector3): void;
  13673. /**
  13674. * Sets the given vector "result" with the given floats.
  13675. * @param x defines the x coordinate of the source
  13676. * @param y defines the y coordinate of the source
  13677. * @param z defines the z coordinate of the source
  13678. * @param result defines the Vector3 where to store the result
  13679. */
  13680. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  13681. /**
  13682. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  13683. * @returns a new empty Vector3
  13684. */
  13685. static Zero(): Vector3;
  13686. /**
  13687. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  13688. * @returns a new unit Vector3
  13689. */
  13690. static One(): Vector3;
  13691. /**
  13692. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  13693. * @returns a new up Vector3
  13694. */
  13695. static Up(): Vector3;
  13696. /**
  13697. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  13698. * @returns a new down Vector3
  13699. */
  13700. static Down(): Vector3;
  13701. /**
  13702. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  13703. * @returns a new forward Vector3
  13704. */
  13705. static Forward(): Vector3;
  13706. /**
  13707. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  13708. * @returns a new right Vector3
  13709. */
  13710. static Right(): Vector3;
  13711. /**
  13712. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  13713. * @returns a new left Vector3
  13714. */
  13715. static Left(): Vector3;
  13716. /**
  13717. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  13718. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  13719. * @param vector defines the Vector3 to transform
  13720. * @param transformation defines the transformation matrix
  13721. * @returns the transformed Vector3
  13722. */
  13723. static TransformCoordinates(vector: Vector3, transformation: Matrix): Vector3;
  13724. /**
  13725. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  13726. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  13727. * @param vector defines the Vector3 to transform
  13728. * @param transformation defines the transformation matrix
  13729. * @param result defines the Vector3 where to store the result
  13730. */
  13731. static TransformCoordinatesToRef(vector: Vector3, transformation: Matrix, result: Vector3): void;
  13732. /**
  13733. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  13734. * This method computes tranformed coordinates only, not transformed direction vectors
  13735. * @param x define the x coordinate of the source vector
  13736. * @param y define the y coordinate of the source vector
  13737. * @param z define the z coordinate of the source vector
  13738. * @param transformation defines the transformation matrix
  13739. * @param result defines the Vector3 where to store the result
  13740. */
  13741. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: Matrix, result: Vector3): void;
  13742. /**
  13743. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  13744. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  13745. * @param vector defines the Vector3 to transform
  13746. * @param transformation defines the transformation matrix
  13747. * @returns the new Vector3
  13748. */
  13749. static TransformNormal(vector: Vector3, transformation: Matrix): Vector3;
  13750. /**
  13751. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  13752. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  13753. * @param vector defines the Vector3 to transform
  13754. * @param transformation defines the transformation matrix
  13755. * @param result defines the Vector3 where to store the result
  13756. */
  13757. static TransformNormalToRef(vector: Vector3, transformation: Matrix, result: Vector3): void;
  13758. /**
  13759. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  13760. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  13761. * @param x define the x coordinate of the source vector
  13762. * @param y define the y coordinate of the source vector
  13763. * @param z define the z coordinate of the source vector
  13764. * @param transformation defines the transformation matrix
  13765. * @param result defines the Vector3 where to store the result
  13766. */
  13767. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: Matrix, result: Vector3): void;
  13768. /**
  13769. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  13770. * @param value1 defines the first control point
  13771. * @param value2 defines the second control point
  13772. * @param value3 defines the third control point
  13773. * @param value4 defines the fourth control point
  13774. * @param amount defines the amount on the spline to use
  13775. * @returns the new Vector3
  13776. */
  13777. static CatmullRom(value1: Vector3, value2: Vector3, value3: Vector3, value4: Vector3, amount: number): Vector3;
  13778. /**
  13779. * 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"
  13780. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  13781. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  13782. * @param value defines the current value
  13783. * @param min defines the lower range value
  13784. * @param max defines the upper range value
  13785. * @returns the new Vector3
  13786. */
  13787. static Clamp(value: Vector3, min: Vector3, max: Vector3): Vector3;
  13788. /**
  13789. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  13790. * @param value1 defines the first control point
  13791. * @param tangent1 defines the first tangent vector
  13792. * @param value2 defines the second control point
  13793. * @param tangent2 defines the second tangent vector
  13794. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  13795. * @returns the new Vector3
  13796. */
  13797. static Hermite(value1: Vector3, tangent1: Vector3, value2: Vector3, tangent2: Vector3, amount: number): Vector3;
  13798. /**
  13799. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  13800. * @param start defines the start value
  13801. * @param end defines the end value
  13802. * @param amount max defines amount between both (between 0 and 1)
  13803. * @returns the new Vector3
  13804. */
  13805. static Lerp(start: Vector3, end: Vector3, amount: number): Vector3;
  13806. /**
  13807. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  13808. * @param start defines the start value
  13809. * @param end defines the end value
  13810. * @param amount max defines amount between both (between 0 and 1)
  13811. * @param result defines the Vector3 where to store the result
  13812. */
  13813. static LerpToRef(start: Vector3, end: Vector3, amount: number, result: Vector3): void;
  13814. /**
  13815. * Returns the dot product (float) between the vectors "left" and "right"
  13816. * @param left defines the left operand
  13817. * @param right defines the right operand
  13818. * @returns the dot product
  13819. */
  13820. static Dot(left: Vector3, right: Vector3): number;
  13821. /**
  13822. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  13823. * The cross product is then orthogonal to both "left" and "right"
  13824. * @param left defines the left operand
  13825. * @param right defines the right operand
  13826. * @returns the cross product
  13827. */
  13828. static Cross(left: Vector3, right: Vector3): Vector3;
  13829. /**
  13830. * Sets the given vector "result" with the cross product of "left" and "right"
  13831. * The cross product is then orthogonal to both "left" and "right"
  13832. * @param left defines the left operand
  13833. * @param right defines the right operand
  13834. * @param result defines the Vector3 where to store the result
  13835. */
  13836. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  13837. /**
  13838. * Returns a new Vector3 as the normalization of the given vector
  13839. * @param vector defines the Vector3 to normalize
  13840. * @returns the new Vector3
  13841. */
  13842. static Normalize(vector: Vector3): Vector3;
  13843. /**
  13844. * Sets the given vector "result" with the normalization of the given first vector
  13845. * @param vector defines the Vector3 to normalize
  13846. * @param result defines the Vector3 where to store the result
  13847. */
  13848. static NormalizeToRef(vector: Vector3, result: Vector3): void;
  13849. private static _viewportMatrixCache;
  13850. /**
  13851. * Project a Vector3 onto screen space
  13852. * @param vector defines the Vector3 to project
  13853. * @param world defines the world matrix to use
  13854. * @param transform defines the transform (view x projection) matrix to use
  13855. * @param viewport defines the screen viewport to use
  13856. * @returns the new Vector3
  13857. */
  13858. static Project(vector: Vector3, world: Matrix, transform: Matrix, viewport: Viewport): Vector3;
  13859. /**
  13860. * Unproject from screen space to object space
  13861. * @param source defines the screen space Vector3 to use
  13862. * @param viewportWidth defines the current width of the viewport
  13863. * @param viewportHeight defines the current height of the viewport
  13864. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  13865. * @param transform defines the transform (view x projection) matrix to use
  13866. * @returns the new Vector3
  13867. */
  13868. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, transform: Matrix): Vector3;
  13869. /**
  13870. * Unproject from screen space to object space
  13871. * @param source defines the screen space Vector3 to use
  13872. * @param viewportWidth defines the current width of the viewport
  13873. * @param viewportHeight defines the current height of the viewport
  13874. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  13875. * @param view defines the view matrix to use
  13876. * @param projection defines the projection matrix to use
  13877. * @returns the new Vector3
  13878. */
  13879. static Unproject(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Vector3;
  13880. /**
  13881. * Unproject from screen space to object space
  13882. * @param source defines the screen space Vector3 to use
  13883. * @param viewportWidth defines the current width of the viewport
  13884. * @param viewportHeight defines the current height of the viewport
  13885. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  13886. * @param view defines the view matrix to use
  13887. * @param projection defines the projection matrix to use
  13888. * @param result defines the Vector3 where to store the result
  13889. */
  13890. static UnprojectToRef(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix, result: Vector3): void;
  13891. /**
  13892. * Unproject from screen space to object space
  13893. * @param sourceX defines the screen space x coordinate to use
  13894. * @param sourceY defines the screen space y coordinate to use
  13895. * @param sourceZ defines the screen space z coordinate to use
  13896. * @param viewportWidth defines the current width of the viewport
  13897. * @param viewportHeight defines the current height of the viewport
  13898. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  13899. * @param view defines the view matrix to use
  13900. * @param projection defines the projection matrix to use
  13901. * @param result defines the Vector3 where to store the result
  13902. */
  13903. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix, result: Vector3): void;
  13904. /**
  13905. * Gets the minimal coordinate values between two Vector3
  13906. * @param left defines the first operand
  13907. * @param right defines the second operand
  13908. * @returns the new Vector3
  13909. */
  13910. static Minimize(left: Vector3, right: Vector3): Vector3;
  13911. /**
  13912. * Gets the maximal coordinate values between two Vector3
  13913. * @param left defines the first operand
  13914. * @param right defines the second operand
  13915. * @returns the new Vector3
  13916. */
  13917. static Maximize(left: Vector3, right: Vector3): Vector3;
  13918. /**
  13919. * Returns the distance between the vectors "value1" and "value2"
  13920. * @param value1 defines the first operand
  13921. * @param value2 defines the second operand
  13922. * @returns the distance
  13923. */
  13924. static Distance(value1: Vector3, value2: Vector3): number;
  13925. /**
  13926. * Returns the squared distance between the vectors "value1" and "value2"
  13927. * @param value1 defines the first operand
  13928. * @param value2 defines the second operand
  13929. * @returns the squared distance
  13930. */
  13931. static DistanceSquared(value1: Vector3, value2: Vector3): number;
  13932. /**
  13933. * Returns a new Vector3 located at the center between "value1" and "value2"
  13934. * @param value1 defines the first operand
  13935. * @param value2 defines the second operand
  13936. * @returns the new Vector3
  13937. */
  13938. static Center(value1: Vector3, value2: Vector3): Vector3;
  13939. /**
  13940. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  13941. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  13942. * to something in order to rotate it from its local system to the given target system
  13943. * Note: axis1, axis2 and axis3 are normalized during this operation
  13944. * @param axis1 defines the first axis
  13945. * @param axis2 defines the second axis
  13946. * @param axis3 defines the third axis
  13947. * @returns a new Vector3
  13948. */
  13949. static RotationFromAxis(axis1: Vector3, axis2: Vector3, axis3: Vector3): Vector3;
  13950. /**
  13951. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  13952. * @param axis1 defines the first axis
  13953. * @param axis2 defines the second axis
  13954. * @param axis3 defines the third axis
  13955. * @param ref defines the Vector3 where to store the result
  13956. */
  13957. static RotationFromAxisToRef(axis1: Vector3, axis2: Vector3, axis3: Vector3, ref: Vector3): void;
  13958. }
  13959. class Vector4 {
  13960. x: number;
  13961. y: number;
  13962. z: number;
  13963. w: number;
  13964. /**
  13965. * Creates a Vector4 object from the given floats.
  13966. */
  13967. constructor(x: number, y: number, z: number, w: number);
  13968. /**
  13969. * Returns the string with the Vector4 coordinates.
  13970. */
  13971. toString(): string;
  13972. /**
  13973. * Returns the string "Vector4".
  13974. */
  13975. getClassName(): string;
  13976. /**
  13977. * Returns the Vector4 hash code.
  13978. */
  13979. getHashCode(): number;
  13980. /**
  13981. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  13982. */
  13983. asArray(): number[];
  13984. /**
  13985. * Populates the given array from the given index with the Vector4 coordinates.
  13986. * Returns the Vector4.
  13987. */
  13988. toArray(array: FloatArray, index?: number): Vector4;
  13989. /**
  13990. * Adds the given vector to the current Vector4.
  13991. * Returns the updated Vector4.
  13992. */
  13993. addInPlace(otherVector: Vector4): Vector4;
  13994. /**
  13995. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  13996. */
  13997. add(otherVector: Vector4): Vector4;
  13998. /**
  13999. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  14000. * Returns the current Vector4.
  14001. */
  14002. addToRef(otherVector: Vector4, result: Vector4): Vector4;
  14003. /**
  14004. * Subtract in place the given vector from the current Vector4.
  14005. * Returns the updated Vector4.
  14006. */
  14007. subtractInPlace(otherVector: Vector4): Vector4;
  14008. /**
  14009. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  14010. */
  14011. subtract(otherVector: Vector4): Vector4;
  14012. /**
  14013. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  14014. * Returns the current Vector4.
  14015. */
  14016. subtractToRef(otherVector: Vector4, result: Vector4): Vector4;
  14017. /**
  14018. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  14019. */
  14020. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  14021. /**
  14022. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  14023. * Returns the current Vector4.
  14024. */
  14025. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  14026. /**
  14027. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  14028. */
  14029. negate(): Vector4;
  14030. /**
  14031. * Multiplies the current Vector4 coordinates by scale (float).
  14032. * Returns the updated Vector4.
  14033. */
  14034. scaleInPlace(scale: number): Vector4;
  14035. /**
  14036. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  14037. */
  14038. scale(scale: number): Vector4;
  14039. /**
  14040. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  14041. * Returns the current Vector4.
  14042. */
  14043. scaleToRef(scale: number, result: Vector4): Vector4;
  14044. /**
  14045. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  14046. * @param scale defines the scale factor
  14047. * @param result defines the Vector4 object where to store the result
  14048. * @returns the unmodified current Vector4
  14049. */
  14050. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  14051. /**
  14052. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  14053. */
  14054. equals(otherVector: Vector4): boolean;
  14055. /**
  14056. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  14057. */
  14058. equalsWithEpsilon(otherVector: Vector4, epsilon?: number): boolean;
  14059. /**
  14060. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  14061. */
  14062. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  14063. /**
  14064. * Multiplies in place the current Vector4 by the given one.
  14065. * Returns the updated Vector4.
  14066. */
  14067. multiplyInPlace(otherVector: Vector4): Vector4;
  14068. /**
  14069. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  14070. */
  14071. multiply(otherVector: Vector4): Vector4;
  14072. /**
  14073. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  14074. * Returns the current Vector4.
  14075. */
  14076. multiplyToRef(otherVector: Vector4, result: Vector4): Vector4;
  14077. /**
  14078. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  14079. */
  14080. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  14081. /**
  14082. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  14083. */
  14084. divide(otherVector: Vector4): Vector4;
  14085. /**
  14086. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  14087. * Returns the current Vector4.
  14088. */
  14089. divideToRef(otherVector: Vector4, result: Vector4): Vector4;
  14090. /**
  14091. * Divides the current Vector3 coordinates by the given ones.
  14092. * @returns the updated Vector3.
  14093. */
  14094. divideInPlace(otherVector: Vector4): Vector4;
  14095. /**
  14096. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  14097. * @param other defines the second operand
  14098. * @returns the current updated Vector4
  14099. */
  14100. minimizeInPlace(other: Vector4): Vector4;
  14101. /**
  14102. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  14103. * @param other defines the second operand
  14104. * @returns the current updated Vector4
  14105. */
  14106. maximizeInPlace(other: Vector4): Vector4;
  14107. /**
  14108. * Returns the Vector4 length (float).
  14109. */
  14110. length(): number;
  14111. /**
  14112. * Returns the Vector4 squared length (float).
  14113. */
  14114. lengthSquared(): number;
  14115. /**
  14116. * Normalizes in place the Vector4.
  14117. * Returns the updated Vector4.
  14118. */
  14119. normalize(): Vector4;
  14120. /**
  14121. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  14122. */
  14123. toVector3(): Vector3;
  14124. /**
  14125. * Returns a new Vector4 copied from the current one.
  14126. */
  14127. clone(): Vector4;
  14128. /**
  14129. * Updates the current Vector4 with the given one coordinates.
  14130. * Returns the updated Vector4.
  14131. */
  14132. copyFrom(source: Vector4): Vector4;
  14133. /**
  14134. * Updates the current Vector4 coordinates with the given floats.
  14135. * Returns the updated Vector4.
  14136. */
  14137. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  14138. /**
  14139. * Updates the current Vector4 coordinates with the given floats.
  14140. * Returns the updated Vector4.
  14141. */
  14142. set(x: number, y: number, z: number, w: number): Vector4;
  14143. /**
  14144. * Returns a new Vector4 set from the starting index of the given array.
  14145. */
  14146. static FromArray(array: ArrayLike<number>, offset?: number): Vector4;
  14147. /**
  14148. * Updates the given vector "result" from the starting index of the given array.
  14149. */
  14150. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Vector4): void;
  14151. /**
  14152. * Updates the given vector "result" from the starting index of the given Float32Array.
  14153. */
  14154. static FromFloatArrayToRef(array: Float32Array, offset: number, result: Vector4): void;
  14155. /**
  14156. * Updates the given vector "result" coordinates from the given floats.
  14157. */
  14158. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  14159. /**
  14160. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  14161. */
  14162. static Zero(): Vector4;
  14163. /**
  14164. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  14165. */
  14166. static One(): Vector4;
  14167. /**
  14168. * Returns a new normalized Vector4 from the given one.
  14169. */
  14170. static Normalize(vector: Vector4): Vector4;
  14171. /**
  14172. * Updates the given vector "result" from the normalization of the given one.
  14173. */
  14174. static NormalizeToRef(vector: Vector4, result: Vector4): void;
  14175. static Minimize(left: Vector4, right: Vector4): Vector4;
  14176. static Maximize(left: Vector4, right: Vector4): Vector4;
  14177. /**
  14178. * Returns the distance (float) between the vectors "value1" and "value2".
  14179. */
  14180. static Distance(value1: Vector4, value2: Vector4): number;
  14181. /**
  14182. * Returns the squared distance (float) between the vectors "value1" and "value2".
  14183. */
  14184. static DistanceSquared(value1: Vector4, value2: Vector4): number;
  14185. /**
  14186. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  14187. */
  14188. static Center(value1: Vector4, value2: Vector4): Vector4;
  14189. /**
  14190. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  14191. * This methods computes transformed normalized direction vectors only.
  14192. */
  14193. static TransformNormal(vector: Vector4, transformation: Matrix): Vector4;
  14194. /**
  14195. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  14196. * This methods computes transformed normalized direction vectors only.
  14197. */
  14198. static TransformNormalToRef(vector: Vector4, transformation: Matrix, result: Vector4): void;
  14199. /**
  14200. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  14201. * This methods computes transformed normalized direction vectors only.
  14202. */
  14203. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: Matrix, result: Vector4): void;
  14204. }
  14205. interface ISize {
  14206. width: number;
  14207. height: number;
  14208. }
  14209. class Size implements ISize {
  14210. width: number;
  14211. height: number;
  14212. /**
  14213. * Creates a Size object from the given width and height (floats).
  14214. */
  14215. constructor(width: number, height: number);
  14216. toString(): string;
  14217. /**
  14218. * Returns the string "Size"
  14219. */
  14220. getClassName(): string;
  14221. /**
  14222. * Returns the Size hash code.
  14223. */
  14224. getHashCode(): number;
  14225. /**
  14226. * Updates the current size from the given one.
  14227. * Returns the updated Size.
  14228. */
  14229. copyFrom(src: Size): void;
  14230. /**
  14231. * Updates in place the current Size from the given floats.
  14232. * Returns the updated Size.
  14233. */
  14234. copyFromFloats(width: number, height: number): Size;
  14235. /**
  14236. * Updates in place the current Size from the given floats.
  14237. * Returns the updated Size.
  14238. */
  14239. set(width: number, height: number): Size;
  14240. /**
  14241. * Returns a new Size set with the multiplication result of the current Size and the given floats.
  14242. */
  14243. multiplyByFloats(w: number, h: number): Size;
  14244. /**
  14245. * Returns a new Size copied from the given one.
  14246. */
  14247. clone(): Size;
  14248. /**
  14249. * Boolean : True if the current Size and the given one width and height are strictly equal.
  14250. */
  14251. equals(other: Size): boolean;
  14252. /**
  14253. * Returns the surface of the Size : width * height (float).
  14254. */
  14255. readonly surface: number;
  14256. /**
  14257. * Returns a new Size set to (0.0, 0.0)
  14258. */
  14259. static Zero(): Size;
  14260. /**
  14261. * Returns a new Size set as the addition result of the current Size and the given one.
  14262. */
  14263. add(otherSize: Size): Size;
  14264. /**
  14265. * Returns a new Size set as the subtraction result of the given one from the current Size.
  14266. */
  14267. subtract(otherSize: Size): Size;
  14268. /**
  14269. * Returns a new Size set at the linear interpolation "amount" between "start" and "end".
  14270. */
  14271. static Lerp(start: Size, end: Size, amount: number): Size;
  14272. }
  14273. /**
  14274. * Class used to store quaternion data
  14275. * @see https://en.wikipedia.org/wiki/Quaternion
  14276. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  14277. */
  14278. class Quaternion {
  14279. /** defines the first component (0 by default) */
  14280. x: number;
  14281. /** defines the second component (0 by default) */
  14282. y: number;
  14283. /** defines the third component (0 by default) */
  14284. z: number;
  14285. /** defines the fourth component (1.0 by default) */
  14286. w: number;
  14287. /**
  14288. * Creates a new Quaternion from the given floats
  14289. * @param x defines the first component (0 by default)
  14290. * @param y defines the second component (0 by default)
  14291. * @param z defines the third component (0 by default)
  14292. * @param w defines the fourth component (1.0 by default)
  14293. */
  14294. constructor(
  14295. /** defines the first component (0 by default) */
  14296. x?: number,
  14297. /** defines the second component (0 by default) */
  14298. y?: number,
  14299. /** defines the third component (0 by default) */
  14300. z?: number,
  14301. /** defines the fourth component (1.0 by default) */
  14302. w?: number);
  14303. /**
  14304. * Gets a string representation for the current quaternion
  14305. * @returns a string with the Quaternion coordinates
  14306. */
  14307. toString(): string;
  14308. /**
  14309. * Gets the class name of the quaternion
  14310. * @returns the string "Quaternion"
  14311. */
  14312. getClassName(): string;
  14313. /**
  14314. * Gets a hash code for this quaternion
  14315. * @returns the quaternion hash code
  14316. */
  14317. getHashCode(): number;
  14318. /**
  14319. * Copy the quaternion to an array
  14320. * @returns a new array populated with 4 elements from the quaternion coordinates
  14321. */
  14322. asArray(): number[];
  14323. /**
  14324. * Check if two quaternions are equals
  14325. * @param otherQuaternion defines the second operand
  14326. * @return true if the current quaternion and the given one coordinates are strictly equals
  14327. */
  14328. equals(otherQuaternion: Quaternion): boolean;
  14329. /**
  14330. * Clone the current quaternion
  14331. * @returns a new quaternion copied from the current one
  14332. */
  14333. clone(): Quaternion;
  14334. /**
  14335. * Copy a quaternion to the current one
  14336. * @param other defines the other quaternion
  14337. * @returns the updated current quaternion
  14338. */
  14339. copyFrom(other: Quaternion): Quaternion;
  14340. /**
  14341. * Updates the current quaternion with the given float coordinates
  14342. * @param x defines the x coordinate
  14343. * @param y defines the y coordinate
  14344. * @param z defines the z coordinate
  14345. * @param w defines the w coordinate
  14346. * @returns the updated current quaternion
  14347. */
  14348. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  14349. /**
  14350. * Updates the current quaternion from the given float coordinates
  14351. * @param x defines the x coordinate
  14352. * @param y defines the y coordinate
  14353. * @param z defines the z coordinate
  14354. * @param w defines the w coordinate
  14355. * @returns the updated current quaternion
  14356. */
  14357. set(x: number, y: number, z: number, w: number): Quaternion;
  14358. /**
  14359. * Adds two quaternions
  14360. * @param other defines the second operand
  14361. * @returns a new quaternion as the addition result of the given one and the current quaternion
  14362. */
  14363. add(other: Quaternion): Quaternion;
  14364. /**
  14365. * Add a quaternion to the current one
  14366. * @param other defines the quaternion to add
  14367. * @returns the current quaternion
  14368. */
  14369. addInPlace(other: Quaternion): Quaternion;
  14370. /**
  14371. * Subtract two quaternions
  14372. * @param other defines the second operand
  14373. * @returns a new quaternion as the subtraction result of the given one from the current one
  14374. */
  14375. subtract(other: Quaternion): Quaternion;
  14376. /**
  14377. * Multiplies the current quaternion by a scale factor
  14378. * @param value defines the scale factor
  14379. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  14380. */
  14381. scale(value: number): Quaternion;
  14382. /**
  14383. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  14384. * @param scale defines the scale factor
  14385. * @param result defines the Quaternion object where to store the result
  14386. * @returns the unmodified current quaternion
  14387. */
  14388. scaleToRef(scale: number, result: Quaternion): Quaternion;
  14389. /**
  14390. * Multiplies in place the current quaternion by a scale factor
  14391. * @param value defines the scale factor
  14392. * @returns the current modified quaternion
  14393. */
  14394. scaleInPlace(value: number): Quaternion;
  14395. /**
  14396. * Scale the current quaternion values by a factor and add the result to a given quaternion
  14397. * @param scale defines the scale factor
  14398. * @param result defines the Quaternion object where to store the result
  14399. * @returns the unmodified current quaternion
  14400. */
  14401. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  14402. /**
  14403. * Multiplies two quaternions
  14404. * @param q1 defines the second operand
  14405. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  14406. */
  14407. multiply(q1: Quaternion): Quaternion;
  14408. /**
  14409. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  14410. * @param q1 defines the second operand
  14411. * @param result defines the target quaternion
  14412. * @returns the current quaternion
  14413. */
  14414. multiplyToRef(q1: Quaternion, result: Quaternion): Quaternion;
  14415. /**
  14416. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  14417. * @param q1 defines the second operand
  14418. * @returns the currentupdated quaternion
  14419. */
  14420. multiplyInPlace(q1: Quaternion): Quaternion;
  14421. /**
  14422. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  14423. * @param ref defines the target quaternion
  14424. * @returns the current quaternion
  14425. */
  14426. conjugateToRef(ref: Quaternion): Quaternion;
  14427. /**
  14428. * Conjugates in place (1-q) the current quaternion
  14429. * @returns the current updated quaternion
  14430. */
  14431. conjugateInPlace(): Quaternion;
  14432. /**
  14433. * Conjugates in place (1-q) the current quaternion
  14434. * @returns a new quaternion
  14435. */
  14436. conjugate(): Quaternion;
  14437. /**
  14438. * Gets length of current quaternion
  14439. * @returns the quaternion length (float)
  14440. */
  14441. length(): number;
  14442. /**
  14443. * Normalize in place the current quaternion
  14444. * @returns the current updated quaternion
  14445. */
  14446. normalize(): Quaternion;
  14447. /**
  14448. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  14449. * @param order is a reserved parameter and is ignore for now
  14450. * @returns a new Vector3 containing the Euler angles
  14451. */
  14452. toEulerAngles(order?: string): Vector3;
  14453. /**
  14454. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  14455. * @param result defines the vector which will be filled with the Euler angles
  14456. * @param order is a reserved parameter and is ignore for now
  14457. * @returns the current unchanged quaternion
  14458. */
  14459. toEulerAnglesToRef(result: Vector3, order?: string): Quaternion;
  14460. /**
  14461. * Updates the given rotation matrix with the current quaternion values
  14462. * @param result defines the target matrix
  14463. * @returns the current unchanged quaternion
  14464. */
  14465. toRotationMatrix(result: Matrix): Quaternion;
  14466. /**
  14467. * Updates the current quaternion from the given rotation matrix values
  14468. * @param matrix defines the source matrix
  14469. * @returns the current updated quaternion
  14470. */
  14471. fromRotationMatrix(matrix: Matrix): Quaternion;
  14472. /**
  14473. * Creates a new quaternion from a rotation matrix
  14474. * @param matrix defines the source matrix
  14475. * @returns a new quaternion created from the given rotation matrix values
  14476. */
  14477. static FromRotationMatrix(matrix: Matrix): Quaternion;
  14478. /**
  14479. * Updates the given quaternion with the given rotation matrix values
  14480. * @param matrix defines the source matrix
  14481. * @param result defines the target quaternion
  14482. */
  14483. static FromRotationMatrixToRef(matrix: Matrix, result: Quaternion): void;
  14484. /**
  14485. * Returns the dot product (float) between the quaternions "left" and "right"
  14486. * @param left defines the left operand
  14487. * @param right defines the right operand
  14488. * @returns the dot product
  14489. */
  14490. static Dot(left: Quaternion, right: Quaternion): number;
  14491. /**
  14492. * Checks if the two quaternions are close to each other
  14493. * @param quat0 defines the first quaternion to check
  14494. * @param quat1 defines the second quaternion to check
  14495. * @returns true if the two quaternions are close to each other
  14496. */
  14497. static AreClose(quat0: Quaternion, quat1: Quaternion): boolean;
  14498. /**
  14499. * Creates an empty quaternion
  14500. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  14501. */
  14502. static Zero(): Quaternion;
  14503. /**
  14504. * Inverse a given quaternion
  14505. * @param q defines the source quaternion
  14506. * @returns a new quaternion as the inverted current quaternion
  14507. */
  14508. static Inverse(q: Quaternion): Quaternion;
  14509. /**
  14510. * Creates an identity quaternion
  14511. * @returns the identity quaternion
  14512. */
  14513. static Identity(): Quaternion;
  14514. /**
  14515. * Gets a boolean indicating if the given quaternion is identity
  14516. * @param quaternion defines the quaternion to check
  14517. * @returns true if the quaternion is identity
  14518. */
  14519. static IsIdentity(quaternion: Quaternion): boolean;
  14520. /**
  14521. * Creates a quaternion from a rotation around an axis
  14522. * @param axis defines the axis to use
  14523. * @param angle defines the angle to use
  14524. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  14525. */
  14526. static RotationAxis(axis: Vector3, angle: number): Quaternion;
  14527. /**
  14528. * Creates a rotation around an axis and stores it into the given quaternion
  14529. * @param axis defines the axis to use
  14530. * @param angle defines the angle to use
  14531. * @param result defines the target quaternion
  14532. * @returns the target quaternion
  14533. */
  14534. static RotationAxisToRef(axis: Vector3, angle: number, result: Quaternion): Quaternion;
  14535. /**
  14536. * Creates a new quaternion from data stored into an array
  14537. * @param array defines the data source
  14538. * @param offset defines the offset in the source array where the data starts
  14539. * @returns a new quaternion
  14540. */
  14541. static FromArray(array: ArrayLike<number>, offset?: number): Quaternion;
  14542. /**
  14543. * Creates a new quaternion from the given Euler float angles (y, x, z)
  14544. * @param yaw defines the rotation around Y axis
  14545. * @param pitch defines the rotation around X axis
  14546. * @param roll defines the rotation around Z axis
  14547. * @returns the new quaternion
  14548. */
  14549. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  14550. /**
  14551. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  14552. * @param yaw defines the rotation around Y axis
  14553. * @param pitch defines the rotation around X axis
  14554. * @param roll defines the rotation around Z axis
  14555. * @param result defines the target quaternion
  14556. */
  14557. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  14558. /**
  14559. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  14560. * @param alpha defines the rotation around first axis
  14561. * @param beta defines the rotation around second axis
  14562. * @param gamma defines the rotation around third axis
  14563. * @returns the new quaternion
  14564. */
  14565. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  14566. /**
  14567. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  14568. * @param alpha defines the rotation around first axis
  14569. * @param beta defines the rotation around second axis
  14570. * @param gamma defines the rotation around third axis
  14571. * @param result defines the target quaternion
  14572. */
  14573. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  14574. /**
  14575. * 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)
  14576. * @param axis1 defines the first axis
  14577. * @param axis2 defines the second axis
  14578. * @param axis3 defines the third axis
  14579. * @returns the new quaternion
  14580. */
  14581. static RotationQuaternionFromAxis(axis1: Vector3, axis2: Vector3, axis3: Vector3): Quaternion;
  14582. /**
  14583. * 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
  14584. * @param axis1 defines the first axis
  14585. * @param axis2 defines the second axis
  14586. * @param axis3 defines the third axis
  14587. * @param ref defines the target quaternion
  14588. */
  14589. static RotationQuaternionFromAxisToRef(axis1: Vector3, axis2: Vector3, axis3: Vector3, ref: Quaternion): void;
  14590. /**
  14591. * Interpolates between two quaternions
  14592. * @param left defines first quaternion
  14593. * @param right defines second quaternion
  14594. * @param amount defines the gradient to use
  14595. * @returns the new interpolated quaternion
  14596. */
  14597. static Slerp(left: Quaternion, right: Quaternion, amount: number): Quaternion;
  14598. /**
  14599. * Interpolates between two quaternions and stores it into a target quaternion
  14600. * @param left defines first quaternion
  14601. * @param right defines second quaternion
  14602. * @param amount defines the gradient to use
  14603. * @param result defines the target quaternion
  14604. */
  14605. static SlerpToRef(left: Quaternion, right: Quaternion, amount: number, result: Quaternion): void;
  14606. /**
  14607. * Interpolate between two quaternions using Hermite interpolation
  14608. * @param value1 defines first quaternion
  14609. * @param tangent1 defines the incoming tangent
  14610. * @param value2 defines second quaternion
  14611. * @param tangent2 defines the outgoing tangent
  14612. * @param amount defines the target quaternion
  14613. * @returns the new interpolated quaternion
  14614. */
  14615. static Hermite(value1: Quaternion, tangent1: Quaternion, value2: Quaternion, tangent2: Quaternion, amount: number): Quaternion;
  14616. }
  14617. /**
  14618. * Class used to store matrix data (4x4)
  14619. */
  14620. class Matrix {
  14621. private static _tempQuaternion;
  14622. private static _xAxis;
  14623. private static _yAxis;
  14624. private static _zAxis;
  14625. private static _updateFlagSeed;
  14626. private static _identityReadOnly;
  14627. private _isIdentity;
  14628. private _isIdentityDirty;
  14629. /**
  14630. * Gets the update flag of the matrix which is an unique number for the matrix.
  14631. * It will be incremented every time the matrix data change.
  14632. * You can use it to speed the comparison between two versions of the same matrix.
  14633. */
  14634. updateFlag: number;
  14635. /**
  14636. * Gets or sets the internal data of the matrix
  14637. */
  14638. m: Float32Array;
  14639. /** @hidden */
  14640. /**
  14641. * Creates an empty matrix (filled with zeros)
  14642. */
  14643. constructor();
  14644. /**
  14645. * Check if the current matrix is indentity
  14646. * @param considerAsTextureMatrix defines if the current matrix must be considered as a texture matrix (3x2)
  14647. * @returns true is the matrix is the identity matrix
  14648. */
  14649. isIdentity(considerAsTextureMatrix?: boolean): boolean;
  14650. /**
  14651. * Gets the determinant of the matrix
  14652. * @returns the matrix determinant
  14653. */
  14654. determinant(): number;
  14655. /**
  14656. * Returns the matrix as a Float32Array
  14657. * @returns the matrix underlying array
  14658. */
  14659. toArray(): Float32Array;
  14660. /**
  14661. * Returns the matrix as a Float32Array
  14662. * @returns the matrix underlying array.
  14663. */
  14664. asArray(): Float32Array;
  14665. /**
  14666. * Inverts the current matrix in place
  14667. * @returns the current inverted matrix
  14668. */
  14669. invert(): Matrix;
  14670. /**
  14671. * Sets all the matrix elements to zero
  14672. * @returns the current matrix
  14673. */
  14674. reset(): Matrix;
  14675. /**
  14676. * Adds the current matrix with a second one
  14677. * @param other defines the matrix to add
  14678. * @returns a new matrix as the addition of the current matrix and the given one
  14679. */
  14680. add(other: Matrix): Matrix;
  14681. /**
  14682. * Sets the given matrix "result" to the addition of the current matrix and the given one
  14683. * @param other defines the matrix to add
  14684. * @param result defines the target matrix
  14685. * @returns the current matrix
  14686. */
  14687. addToRef(other: Matrix, result: Matrix): Matrix;
  14688. /**
  14689. * Adds in place the given matrix to the current matrix
  14690. * @param other defines the second operand
  14691. * @returns the current updated matrix
  14692. */
  14693. addToSelf(other: Matrix): Matrix;
  14694. /**
  14695. * Sets the given matrix to the current inverted Matrix
  14696. * @param other defines the target matrix
  14697. * @returns the unmodified current matrix
  14698. */
  14699. invertToRef(other: Matrix): Matrix;
  14700. /**
  14701. * Inserts the translation vector (using 3 floats) in the current matrix
  14702. * @param x defines the 1st component of the translation
  14703. * @param y defines the 2nd component of the translation
  14704. * @param z defines the 3rd component of the translation
  14705. * @returns the current updated matrix
  14706. */
  14707. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  14708. /**
  14709. * Inserts the translation vector in the current matrix
  14710. * @param vector3 defines the translation to insert
  14711. * @returns the current updated matrix
  14712. */
  14713. setTranslation(vector3: Vector3): Matrix;
  14714. /**
  14715. * Gets the translation value of the current matrix
  14716. * @returns a new Vector3 as the extracted translation from the matrix
  14717. */
  14718. getTranslation(): Vector3;
  14719. /**
  14720. * Fill a Vector3 with the extracted translation from the matrix
  14721. * @param result defines the Vector3 where to store the translation
  14722. * @returns the current matrix
  14723. */
  14724. getTranslationToRef(result: Vector3): Matrix;
  14725. /**
  14726. * Remove rotation and scaling part from the matrix
  14727. * @returns the updated matrix
  14728. */
  14729. removeRotationAndScaling(): Matrix;
  14730. /**
  14731. * Multiply two matrices
  14732. * @param other defines the second operand
  14733. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  14734. */
  14735. multiply(other: Matrix): Matrix;
  14736. /**
  14737. * Copy the current matrix from the given one
  14738. * @param other defines the source matrix
  14739. * @returns the current updated matrix
  14740. */
  14741. copyFrom(other: Matrix): Matrix;
  14742. /**
  14743. * Populates the given array from the starting index with the current matrix values
  14744. * @param array defines the target array
  14745. * @param offset defines the offset in the target array where to start storing values
  14746. * @returns the current matrix
  14747. */
  14748. copyToArray(array: Float32Array, offset?: number): Matrix;
  14749. /**
  14750. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  14751. * @param other defines the second operand
  14752. * @param result defines the matrix where to store the multiplication
  14753. * @returns the current matrix
  14754. */
  14755. multiplyToRef(other: Matrix, result: Matrix): Matrix;
  14756. /**
  14757. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  14758. * @param other defines the second operand
  14759. * @param result defines the array where to store the multiplication
  14760. * @param offset defines the offset in the target array where to start storing values
  14761. * @returns the current matrix
  14762. */
  14763. multiplyToArray(other: Matrix, result: Float32Array, offset: number): Matrix;
  14764. /**
  14765. * Check equality between this matrix and a second one
  14766. * @param value defines the second matrix to compare
  14767. * @returns true is the current matrix and the given one values are strictly equal
  14768. */
  14769. equals(value: Matrix): boolean;
  14770. /**
  14771. * Clone the current matrix
  14772. * @returns a new matrix from the current matrix
  14773. */
  14774. clone(): Matrix;
  14775. /**
  14776. * Returns the name of the current matrix class
  14777. * @returns the string "Matrix"
  14778. */
  14779. getClassName(): string;
  14780. /**
  14781. * Gets the hash code of the current matrix
  14782. * @returns the hash code
  14783. */
  14784. getHashCode(): number;
  14785. /**
  14786. * Decomposes the current Matrix into a translation, rotation and scaling components
  14787. * @param scale defines the scale vector3 given as a reference to update
  14788. * @param rotation defines the rotation quaternion given as a reference to update
  14789. * @param translation defines the translation vector3 given as a reference to update
  14790. * @returns true if operation was successful
  14791. */
  14792. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  14793. /**
  14794. * Gets specific row of the matrix
  14795. * @param index defines the number of the row to get
  14796. * @returns the index-th row of the current matrix as a new Vector4
  14797. */
  14798. getRow(index: number): Nullable<Vector4>;
  14799. /**
  14800. * Sets the index-th row of the current matrix to the vector4 values
  14801. * @param index defines the number of the row to set
  14802. * @param row defines the target vector4
  14803. * @returns the updated current matrix
  14804. */
  14805. setRow(index: number, row: Vector4): Matrix;
  14806. /**
  14807. * Compute the transpose of the matrix
  14808. * @returns the new transposed matrix
  14809. */
  14810. transpose(): Matrix;
  14811. /**
  14812. * Compute the transpose of the matrix and store it in a given matrix
  14813. * @param result defines the target matrix
  14814. * @returns the current matrix
  14815. */
  14816. transposeToRef(result: Matrix): Matrix;
  14817. /**
  14818. * Sets the index-th row of the current matrix with the given 4 x float values
  14819. * @param index defines the row index
  14820. * @param x defines the x component to set
  14821. * @param y defines the y component to set
  14822. * @param z defines the z component to set
  14823. * @param w defines the w component to set
  14824. * @returns the updated current matrix
  14825. */
  14826. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  14827. /**
  14828. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  14829. * @param scale defines the scale factor
  14830. * @returns a new matrix
  14831. */
  14832. scale(scale: number): Matrix;
  14833. /**
  14834. * Scale the current matrix values by a factor to a given result matrix
  14835. * @param scale defines the scale factor
  14836. * @param result defines the matrix to store the result
  14837. * @returns the current matrix
  14838. */
  14839. scaleToRef(scale: number, result: Matrix): Matrix;
  14840. /**
  14841. * Scale the current matrix values by a factor and add the result to a given matrix
  14842. * @param scale defines the scale factor
  14843. * @param result defines the Matrix to store the result
  14844. * @returns the current matrix
  14845. */
  14846. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  14847. /**
  14848. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  14849. * @param ref matrix to store the result
  14850. */
  14851. toNormalMatrix(ref: Matrix): void;
  14852. /**
  14853. * Gets only rotation part of the current matrix
  14854. * @returns a new matrix sets to the extracted rotation matrix from the current one
  14855. */
  14856. getRotationMatrix(): Matrix;
  14857. /**
  14858. * Extracts the rotation matrix from the current one and sets it as the given "result"
  14859. * @param result defines the target matrix to store data to
  14860. * @returns the current matrix
  14861. */
  14862. getRotationMatrixToRef(result: Matrix): Matrix;
  14863. /**
  14864. * Creates a matrix from an array
  14865. * @param array defines the source array
  14866. * @param offset defines an offset in the source array
  14867. * @returns a new Matrix set from the starting index of the given array
  14868. */
  14869. static FromArray(array: ArrayLike<number>, offset?: number): Matrix;
  14870. /**
  14871. * Copy the content of an array into a given matrix
  14872. * @param array defines the source array
  14873. * @param offset defines an offset in the source array
  14874. * @param result defines the target matrix
  14875. */
  14876. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Matrix): void;
  14877. /**
  14878. * Stores an array into a matrix after having multiplied each component by a given factor
  14879. * @param array defines the source array
  14880. * @param offset defines the offset in the source array
  14881. * @param scale defines the scaling factor
  14882. * @param result defines the target matrix
  14883. */
  14884. static FromFloat32ArrayToRefScaled(array: Float32Array, offset: number, scale: number, result: Matrix): void;
  14885. /**
  14886. * Stores a list of values (16) inside a given matrix
  14887. * @param initialM11 defines 1st value of 1st row
  14888. * @param initialM12 defines 2nd value of 1st row
  14889. * @param initialM13 defines 3rd value of 1st row
  14890. * @param initialM14 defines 4th value of 1st row
  14891. * @param initialM21 defines 1st value of 2nd row
  14892. * @param initialM22 defines 2nd value of 2nd row
  14893. * @param initialM23 defines 3rd value of 2nd row
  14894. * @param initialM24 defines 4th value of 2nd row
  14895. * @param initialM31 defines 1st value of 3rd row
  14896. * @param initialM32 defines 2nd value of 3rd row
  14897. * @param initialM33 defines 3rd value of 3rd row
  14898. * @param initialM34 defines 4th value of 3rd row
  14899. * @param initialM41 defines 1st value of 4th row
  14900. * @param initialM42 defines 2nd value of 4th row
  14901. * @param initialM43 defines 3rd value of 4th row
  14902. * @param initialM44 defines 4th value of 4th row
  14903. * @param result defines the target matrix
  14904. */
  14905. 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;
  14906. /**
  14907. * Gets an identity matrix that must not be updated
  14908. */
  14909. static readonly IdentityReadOnly: Matrix;
  14910. /**
  14911. * Creates new matrix from a list of values (16)
  14912. * @param initialM11 defines 1st value of 1st row
  14913. * @param initialM12 defines 2nd value of 1st row
  14914. * @param initialM13 defines 3rd value of 1st row
  14915. * @param initialM14 defines 4th value of 1st row
  14916. * @param initialM21 defines 1st value of 2nd row
  14917. * @param initialM22 defines 2nd value of 2nd row
  14918. * @param initialM23 defines 3rd value of 2nd row
  14919. * @param initialM24 defines 4th value of 2nd row
  14920. * @param initialM31 defines 1st value of 3rd row
  14921. * @param initialM32 defines 2nd value of 3rd row
  14922. * @param initialM33 defines 3rd value of 3rd row
  14923. * @param initialM34 defines 4th value of 3rd row
  14924. * @param initialM41 defines 1st value of 4th row
  14925. * @param initialM42 defines 2nd value of 4th row
  14926. * @param initialM43 defines 3rd value of 4th row
  14927. * @param initialM44 defines 4th value of 4th row
  14928. * @returns the new matrix
  14929. */
  14930. 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;
  14931. /**
  14932. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  14933. * @param scale defines the scale vector3
  14934. * @param rotation defines the rotation quaternion
  14935. * @param translation defines the translation vector3
  14936. * @returns a new matrix
  14937. */
  14938. static Compose(scale: Vector3, rotation: Quaternion, translation: Vector3): Matrix;
  14939. /**
  14940. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  14941. * @param scale defines the scale vector3
  14942. * @param rotation defines the rotation quaternion
  14943. * @param translation defines the translation vector3
  14944. * @param result defines the target matrix
  14945. */
  14946. static ComposeToRef(scale: Vector3, rotation: Quaternion, translation: Vector3, result: Matrix): void;
  14947. /**
  14948. * Creates a new identity matrix
  14949. * @returns a new identity matrix
  14950. */
  14951. static Identity(): Matrix;
  14952. /**
  14953. * Creates a new identity matrix and stores the result in a given matrix
  14954. * @param result defines the target matrix
  14955. */
  14956. static IdentityToRef(result: Matrix): void;
  14957. /**
  14958. * Creates a new zero matrix
  14959. * @returns a new zero matrix
  14960. */
  14961. static Zero(): Matrix;
  14962. /**
  14963. * Creates a new rotation matrix for "angle" radians around the X axis
  14964. * @param angle defines the angle (in radians) to use
  14965. * @return the new matrix
  14966. */
  14967. static RotationX(angle: number): Matrix;
  14968. /**
  14969. * Creates a new matrix as the invert of a given matrix
  14970. * @param source defines the source matrix
  14971. * @returns the new matrix
  14972. */
  14973. static Invert(source: Matrix): Matrix;
  14974. /**
  14975. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  14976. * @param angle defines the angle (in radians) to use
  14977. * @param result defines the target matrix
  14978. */
  14979. static RotationXToRef(angle: number, result: Matrix): void;
  14980. /**
  14981. * Creates a new rotation matrix for "angle" radians around the Y axis
  14982. * @param angle defines the angle (in radians) to use
  14983. * @return the new matrix
  14984. */
  14985. static RotationY(angle: number): Matrix;
  14986. /**
  14987. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  14988. * @param angle defines the angle (in radians) to use
  14989. * @param result defines the target matrix
  14990. */
  14991. static RotationYToRef(angle: number, result: Matrix): void;
  14992. /**
  14993. * Creates a new rotation matrix for "angle" radians around the Z axis
  14994. * @param angle defines the angle (in radians) to use
  14995. * @return the new matrix
  14996. */
  14997. static RotationZ(angle: number): Matrix;
  14998. /**
  14999. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  15000. * @param angle defines the angle (in radians) to use
  15001. * @param result defines the target matrix
  15002. */
  15003. static RotationZToRef(angle: number, result: Matrix): void;
  15004. /**
  15005. * Creates a new rotation matrix for "angle" radians around the given axis
  15006. * @param axis defines the axis to use
  15007. * @param angle defines the angle (in radians) to use
  15008. * @return the new matrix
  15009. */
  15010. static RotationAxis(axis: Vector3, angle: number): Matrix;
  15011. /**
  15012. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  15013. * @param axis defines the axis to use
  15014. * @param angle defines the angle (in radians) to use
  15015. * @param result defines the target matrix
  15016. */
  15017. static RotationAxisToRef(axis: Vector3, angle: number, result: Matrix): void;
  15018. /**
  15019. * Creates a rotation matrix
  15020. * @param yaw defines the yaw angle in radians (Y axis)
  15021. * @param pitch defines the pitch angle in radians (X axis)
  15022. * @param roll defines the roll angle in radians (X axis)
  15023. * @returns the new rotation matrix
  15024. */
  15025. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  15026. /**
  15027. * Creates a rotation matrix and stores it in a given matrix
  15028. * @param yaw defines the yaw angle in radians (Y axis)
  15029. * @param pitch defines the pitch angle in radians (X axis)
  15030. * @param roll defines the roll angle in radians (X axis)
  15031. * @param result defines the target matrix
  15032. */
  15033. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  15034. /**
  15035. * Creates a scaling matrix
  15036. * @param x defines the scale factor on X axis
  15037. * @param y defines the scale factor on Y axis
  15038. * @param z defines the scale factor on Z axis
  15039. * @returns the new matrix
  15040. */
  15041. static Scaling(x: number, y: number, z: number): Matrix;
  15042. /**
  15043. * Creates a scaling matrix and stores it in a given matrix
  15044. * @param x defines the scale factor on X axis
  15045. * @param y defines the scale factor on Y axis
  15046. * @param z defines the scale factor on Z axis
  15047. * @param result defines the target matrix
  15048. */
  15049. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  15050. /**
  15051. * Creates a translation matrix
  15052. * @param x defines the translation on X axis
  15053. * @param y defines the translation on Y axis
  15054. * @param z defines the translationon Z axis
  15055. * @returns the new matrix
  15056. */
  15057. static Translation(x: number, y: number, z: number): Matrix;
  15058. /**
  15059. * Creates a translation matrix and stores it in a given matrix
  15060. * @param x defines the translation on X axis
  15061. * @param y defines the translation on Y axis
  15062. * @param z defines the translationon Z axis
  15063. * @param result defines the target matrix
  15064. */
  15065. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  15066. /**
  15067. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  15068. * @param startValue defines the start value
  15069. * @param endValue defines the end value
  15070. * @param gradient defines the gradient factor
  15071. * @returns the new matrix
  15072. */
  15073. static Lerp(startValue: Matrix, endValue: Matrix, gradient: number): Matrix;
  15074. /**
  15075. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  15076. * @param startValue defines the start value
  15077. * @param endValue defines the end value
  15078. * @param gradient defines the gradient factor
  15079. * @param result defines the Matrix object where to store data
  15080. */
  15081. static LerpToRef(startValue: Matrix, endValue: Matrix, gradient: number, result: Matrix): void;
  15082. /**
  15083. * Builds a new matrix whose values are computed by:
  15084. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  15085. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  15086. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  15087. * @param startValue defines the first matrix
  15088. * @param endValue defines the second matrix
  15089. * @param gradient defines the gradient between the two matrices
  15090. * @returns the new matrix
  15091. */
  15092. static DecomposeLerp(startValue: Matrix, endValue: Matrix, gradient: number): Matrix;
  15093. /**
  15094. * Update a matrix to values which are computed by:
  15095. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  15096. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  15097. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  15098. * @param startValue defines the first matrix
  15099. * @param endValue defines the second matrix
  15100. * @param gradient defines the gradient between the two matrices
  15101. * @param result defines the target matrix
  15102. */
  15103. static DecomposeLerpToRef(startValue: Matrix, endValue: Matrix, gradient: number, result: Matrix): void;
  15104. /**
  15105. * 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"
  15106. * This function works in left handed mode
  15107. * @param eye defines the final position of the entity
  15108. * @param target defines where the entity should look at
  15109. * @param up defines the up vector for the entity
  15110. * @returns the new matrix
  15111. */
  15112. static LookAtLH(eye: Vector3, target: Vector3, up: Vector3): Matrix;
  15113. /**
  15114. * 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".
  15115. * This function works in left handed mode
  15116. * @param eye defines the final position of the entity
  15117. * @param target defines where the entity should look at
  15118. * @param up defines the up vector for the entity
  15119. * @param result defines the target matrix
  15120. */
  15121. static LookAtLHToRef(eye: Vector3, target: Vector3, up: Vector3, result: Matrix): void;
  15122. /**
  15123. * 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"
  15124. * This function works in right handed mode
  15125. * @param eye defines the final position of the entity
  15126. * @param target defines where the entity should look at
  15127. * @param up defines the up vector for the entity
  15128. * @returns the new matrix
  15129. */
  15130. static LookAtRH(eye: Vector3, target: Vector3, up: Vector3): Matrix;
  15131. /**
  15132. * 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".
  15133. * This function works in right handed mode
  15134. * @param eye defines the final position of the entity
  15135. * @param target defines where the entity should look at
  15136. * @param up defines the up vector for the entity
  15137. * @param result defines the target matrix
  15138. */
  15139. static LookAtRHToRef(eye: Vector3, target: Vector3, up: Vector3, result: Matrix): void;
  15140. /**
  15141. * Create a left-handed orthographic projection matrix
  15142. * @param width defines the viewport width
  15143. * @param height defines the viewport height
  15144. * @param znear defines the near clip plane
  15145. * @param zfar defines the far clip plane
  15146. * @returns a new matrix as a left-handed orthographic projection matrix
  15147. */
  15148. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  15149. /**
  15150. * Store a left-handed orthographic projection to a given matrix
  15151. * @param width defines the viewport width
  15152. * @param height defines the viewport height
  15153. * @param znear defines the near clip plane
  15154. * @param zfar defines the far clip plane
  15155. * @param result defines the target matrix
  15156. */
  15157. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  15158. /**
  15159. * Create a left-handed orthographic projection matrix
  15160. * @param left defines the viewport left coordinate
  15161. * @param right defines the viewport right coordinate
  15162. * @param bottom defines the viewport bottom coordinate
  15163. * @param top defines the viewport top coordinate
  15164. * @param znear defines the near clip plane
  15165. * @param zfar defines the far clip plane
  15166. * @returns a new matrix as a left-handed orthographic projection matrix
  15167. */
  15168. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  15169. /**
  15170. * Stores a left-handed orthographic projection into a given matrix
  15171. * @param left defines the viewport left coordinate
  15172. * @param right defines the viewport right coordinate
  15173. * @param bottom defines the viewport bottom coordinate
  15174. * @param top defines the viewport top coordinate
  15175. * @param znear defines the near clip plane
  15176. * @param zfar defines the far clip plane
  15177. * @param result defines the target matrix
  15178. */
  15179. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  15180. /**
  15181. * Creates a right-handed orthographic projection matrix
  15182. * @param left defines the viewport left coordinate
  15183. * @param right defines the viewport right coordinate
  15184. * @param bottom defines the viewport bottom coordinate
  15185. * @param top defines the viewport top coordinate
  15186. * @param znear defines the near clip plane
  15187. * @param zfar defines the far clip plane
  15188. * @returns a new matrix as a right-handed orthographic projection matrix
  15189. */
  15190. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  15191. /**
  15192. * Stores a right-handed orthographic projection into a given matrix
  15193. * @param left defines the viewport left coordinate
  15194. * @param right defines the viewport right coordinate
  15195. * @param bottom defines the viewport bottom coordinate
  15196. * @param top defines the viewport top coordinate
  15197. * @param znear defines the near clip plane
  15198. * @param zfar defines the far clip plane
  15199. * @param result defines the target matrix
  15200. */
  15201. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  15202. /**
  15203. * Creates a left-handed perspective projection matrix
  15204. * @param width defines the viewport width
  15205. * @param height defines the viewport height
  15206. * @param znear defines the near clip plane
  15207. * @param zfar defines the far clip plane
  15208. * @returns a new matrix as a left-handed perspective projection matrix
  15209. */
  15210. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  15211. /**
  15212. * Creates a left-handed perspective projection matrix
  15213. * @param fov defines the horizontal field of view
  15214. * @param aspect defines the aspect ratio
  15215. * @param znear defines the near clip plane
  15216. * @param zfar defines the far clip plane
  15217. * @returns a new matrix as a left-handed perspective projection matrix
  15218. */
  15219. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  15220. /**
  15221. * Stores a left-handed perspective projection into a given matrix
  15222. * @param fov defines the horizontal field of view
  15223. * @param aspect defines the aspect ratio
  15224. * @param znear defines the near clip plane
  15225. * @param zfar defines the far clip plane
  15226. * @param result defines the target matrix
  15227. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  15228. */
  15229. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  15230. /**
  15231. * Creates a right-handed perspective projection matrix
  15232. * @param fov defines the horizontal field of view
  15233. * @param aspect defines the aspect ratio
  15234. * @param znear defines the near clip plane
  15235. * @param zfar defines the far clip plane
  15236. * @returns a new matrix as a right-handed perspective projection matrix
  15237. */
  15238. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  15239. /**
  15240. * Stores a right-handed perspective projection into a given matrix
  15241. * @param fov defines the horizontal field of view
  15242. * @param aspect defines the aspect ratio
  15243. * @param znear defines the near clip plane
  15244. * @param zfar defines the far clip plane
  15245. * @param result defines the target matrix
  15246. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  15247. */
  15248. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  15249. /**
  15250. * Stores a perspective projection for WebVR info a given matrix
  15251. * @param fov defines the field of view
  15252. * @param znear defines the near clip plane
  15253. * @param zfar defines the far clip plane
  15254. * @param result defines the target matrix
  15255. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  15256. */
  15257. static PerspectiveFovWebVRToRef(fov: {
  15258. upDegrees: number;
  15259. downDegrees: number;
  15260. leftDegrees: number;
  15261. rightDegrees: number;
  15262. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  15263. /**
  15264. * Computes a complete transformation matrix
  15265. * @param viewport defines the viewport to use
  15266. * @param world defines the world matrix
  15267. * @param view defines the view matrix
  15268. * @param projection defines the projection matrix
  15269. * @param zmin defines the near clip plane
  15270. * @param zmax defines the far clip plane
  15271. * @returns the transformation matrix
  15272. */
  15273. static GetFinalMatrix(viewport: Viewport, world: Matrix, view: Matrix, projection: Matrix, zmin: number, zmax: number): Matrix;
  15274. /**
  15275. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  15276. * @param matrix defines the matrix to use
  15277. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  15278. */
  15279. static GetAsMatrix2x2(matrix: Matrix): Float32Array;
  15280. /**
  15281. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  15282. * @param matrix defines the matrix to use
  15283. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  15284. */
  15285. static GetAsMatrix3x3(matrix: Matrix): Float32Array;
  15286. /**
  15287. * Compute the transpose of a given matrix
  15288. * @param matrix defines the matrix to transpose
  15289. * @returns the new matrix
  15290. */
  15291. static Transpose(matrix: Matrix): Matrix;
  15292. /**
  15293. * Compute the transpose of a matrix and store it in a target matrix
  15294. * @param matrix defines the matrix to transpose
  15295. * @param result defines the target matrix
  15296. */
  15297. static TransposeToRef(matrix: Matrix, result: Matrix): void;
  15298. /**
  15299. * Computes a reflection matrix from a plane
  15300. * @param plane defines the reflection plane
  15301. * @returns a new matrix
  15302. */
  15303. static Reflection(plane: Plane): Matrix;
  15304. /**
  15305. * Computes a reflection matrix from a plane
  15306. * @param plane defines the reflection plane
  15307. * @param result defines the target matrix
  15308. */
  15309. static ReflectionToRef(plane: Plane, result: Matrix): void;
  15310. /**
  15311. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  15312. * @param xaxis defines the value of the 1st axis
  15313. * @param yaxis defines the value of the 2nd axis
  15314. * @param zaxis defines the value of the 3rd axis
  15315. * @param result defines the target matrix
  15316. */
  15317. static FromXYZAxesToRef(xaxis: Vector3, yaxis: Vector3, zaxis: Vector3, result: Matrix): void;
  15318. /**
  15319. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  15320. * @param quat defines the quaternion to use
  15321. * @param result defines the target matrix
  15322. */
  15323. static FromQuaternionToRef(quat: Quaternion, result: Matrix): void;
  15324. }
  15325. class Plane {
  15326. normal: Vector3;
  15327. d: number;
  15328. /**
  15329. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  15330. */
  15331. constructor(a: number, b: number, c: number, d: number);
  15332. /**
  15333. * Returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  15334. */
  15335. asArray(): number[];
  15336. /**
  15337. * Returns a new plane copied from the current Plane.
  15338. */
  15339. clone(): Plane;
  15340. /**
  15341. * Returns the string "Plane".
  15342. */
  15343. getClassName(): string;
  15344. /**
  15345. * Returns the Plane hash code.
  15346. */
  15347. getHashCode(): number;
  15348. /**
  15349. * Normalize the current Plane in place.
  15350. * Returns the updated Plane.
  15351. */
  15352. normalize(): Plane;
  15353. /**
  15354. * Returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  15355. */
  15356. transform(transformation: Matrix): Plane;
  15357. /**
  15358. * Returns the dot product (float) of the point coordinates and the plane normal.
  15359. */
  15360. dotCoordinate(point: Vector3): number;
  15361. /**
  15362. * Updates the current Plane from the plane defined by the three given points.
  15363. * Returns the updated Plane.
  15364. */
  15365. copyFromPoints(point1: Vector3, point2: Vector3, point3: Vector3): Plane;
  15366. /**
  15367. * Boolean : True is the vector "direction" is the same side than the plane normal.
  15368. */
  15369. isFrontFacingTo(direction: Vector3, epsilon: number): boolean;
  15370. /**
  15371. * Returns the signed distance (float) from the given point to the Plane.
  15372. */
  15373. signedDistanceTo(point: Vector3): number;
  15374. /**
  15375. * Returns a new Plane from the given array.
  15376. */
  15377. static FromArray(array: ArrayLike<number>): Plane;
  15378. /**
  15379. * Returns a new Plane defined by the three given points.
  15380. */
  15381. static FromPoints(point1: Vector3, point2: Vector3, point3: Vector3): Plane;
  15382. /**
  15383. * Returns a new Plane the normal vector to this plane at the given origin point.
  15384. * Note : the vector "normal" is updated because normalized.
  15385. */
  15386. static FromPositionAndNormal(origin: Vector3, normal: Vector3): Plane;
  15387. /**
  15388. * Returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  15389. */
  15390. static SignedDistanceToPlaneFromPositionAndNormal(origin: Vector3, normal: Vector3, point: Vector3): number;
  15391. }
  15392. class Viewport {
  15393. x: number;
  15394. y: number;
  15395. width: number;
  15396. height: number;
  15397. /**
  15398. * Creates a Viewport object located at (x, y) and sized (width, height).
  15399. */
  15400. constructor(x: number, y: number, width: number, height: number);
  15401. toGlobal(renderWidthOrEngine: number | Engine, renderHeight: number): Viewport;
  15402. /**
  15403. * Returns a new Viewport copied from the current one.
  15404. */
  15405. clone(): Viewport;
  15406. }
  15407. class Frustum {
  15408. /**
  15409. * Returns a new array of 6 Frustum planes computed by the given transformation matrix.
  15410. */
  15411. static GetPlanes(transform: Matrix): Plane[];
  15412. static GetNearPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  15413. static GetFarPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  15414. static GetLeftPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  15415. static GetRightPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  15416. static GetTopPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  15417. static GetBottomPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  15418. /**
  15419. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  15420. */
  15421. static GetPlanesToRef(transform: Matrix, frustumPlanes: Plane[]): void;
  15422. }
  15423. /** Defines supported spaces */
  15424. enum Space {
  15425. /** Local (object) space */
  15426. LOCAL = 0,
  15427. /** World space */
  15428. WORLD = 1,
  15429. /** Bone space */
  15430. BONE = 2,
  15431. }
  15432. /** Defines the 3 main axes */
  15433. class Axis {
  15434. /** X axis */
  15435. static X: Vector3;
  15436. /** Y axis */
  15437. static Y: Vector3;
  15438. /** Z axis */
  15439. static Z: Vector3;
  15440. }
  15441. class BezierCurve {
  15442. /**
  15443. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats.
  15444. */
  15445. static interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  15446. }
  15447. /**
  15448. * Defines potential orientation for back face culling
  15449. */
  15450. enum Orientation {
  15451. /**
  15452. * Clockwise
  15453. */
  15454. CW = 0,
  15455. /** Counter clockwise */
  15456. CCW = 1,
  15457. }
  15458. /**
  15459. * Defines angle representation
  15460. */
  15461. class Angle {
  15462. private _radians;
  15463. /**
  15464. * Creates an Angle object of "radians" radians (float).
  15465. */
  15466. constructor(radians: number);
  15467. /**
  15468. * Get value in degrees
  15469. * @returns the Angle value in degrees (float)
  15470. */
  15471. degrees(): number;
  15472. /**
  15473. * Get value in radians
  15474. * @returns the Angle value in radians (float)
  15475. */
  15476. radians(): number;
  15477. /**
  15478. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  15479. * @param a defines first vector
  15480. * @param b defines second vector
  15481. * @returns a new Angle
  15482. */
  15483. static BetweenTwoPoints(a: Vector2, b: Vector2): Angle;
  15484. /**
  15485. * Gets a new Angle object from the given float in radians
  15486. * @param radians defines the angle value in radians
  15487. * @returns a new Angle
  15488. */
  15489. static FromRadians(radians: number): Angle;
  15490. /**
  15491. * Gets a new Angle object from the given float in degrees
  15492. * @param degrees defines the angle value in degrees
  15493. * @returns a new Angle
  15494. */
  15495. static FromDegrees(degrees: number): Angle;
  15496. }
  15497. class Arc2 {
  15498. startPoint: Vector2;
  15499. midPoint: Vector2;
  15500. endPoint: Vector2;
  15501. centerPoint: Vector2;
  15502. radius: number;
  15503. angle: Angle;
  15504. startAngle: Angle;
  15505. orientation: Orientation;
  15506. /**
  15507. * Creates an Arc object from the three given points : start, middle and end.
  15508. */
  15509. constructor(startPoint: Vector2, midPoint: Vector2, endPoint: Vector2);
  15510. }
  15511. class Path2 {
  15512. private _points;
  15513. private _length;
  15514. closed: boolean;
  15515. /**
  15516. * Creates a Path2 object from the starting 2D coordinates x and y.
  15517. */
  15518. constructor(x: number, y: number);
  15519. /**
  15520. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  15521. * Returns the updated Path2.
  15522. */
  15523. addLineTo(x: number, y: number): Path2;
  15524. /**
  15525. * 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.
  15526. * Returns the updated Path2.
  15527. */
  15528. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  15529. /**
  15530. * Closes the Path2.
  15531. * Returns the Path2.
  15532. */
  15533. close(): Path2;
  15534. /**
  15535. * Returns the Path2 total length (float).
  15536. */
  15537. length(): number;
  15538. /**
  15539. * Returns the Path2 internal array of points.
  15540. */
  15541. getPoints(): Vector2[];
  15542. /**
  15543. * Returns a new Vector2 located at a percentage of the Path2 total length on this path.
  15544. */
  15545. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  15546. /**
  15547. * Returns a new Path2 starting at the coordinates (x, y).
  15548. */
  15549. static StartingAt(x: number, y: number): Path2;
  15550. }
  15551. class Path3D {
  15552. path: Vector3[];
  15553. private _curve;
  15554. private _distances;
  15555. private _tangents;
  15556. private _normals;
  15557. private _binormals;
  15558. private _raw;
  15559. /**
  15560. * new Path3D(path, normal, raw)
  15561. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  15562. * please read the description in the tutorial : http://doc.babylonjs.com/tutorials/How_to_use_Path3D
  15563. * path : an array of Vector3, the curve axis of the Path3D
  15564. * normal (optional) : Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  15565. * raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  15566. */
  15567. constructor(path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  15568. /**
  15569. * Returns the Path3D array of successive Vector3 designing its curve.
  15570. */
  15571. getCurve(): Vector3[];
  15572. /**
  15573. * Returns an array populated with tangent vectors on each Path3D curve point.
  15574. */
  15575. getTangents(): Vector3[];
  15576. /**
  15577. * Returns an array populated with normal vectors on each Path3D curve point.
  15578. */
  15579. getNormals(): Vector3[];
  15580. /**
  15581. * Returns an array populated with binormal vectors on each Path3D curve point.
  15582. */
  15583. getBinormals(): Vector3[];
  15584. /**
  15585. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  15586. */
  15587. getDistances(): number[];
  15588. /**
  15589. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  15590. * Returns the same object updated.
  15591. */
  15592. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  15593. private _compute(firstNormal);
  15594. private _getFirstNonNullVector(index);
  15595. private _getLastNonNullVector(index);
  15596. private _normalVector(v0, vt, va);
  15597. }
  15598. class Curve3 {
  15599. private _points;
  15600. private _length;
  15601. /**
  15602. * Returns a Curve3 object along a Quadratic Bezier curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#quadratic-bezier-curve
  15603. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  15604. * @param v1 (Vector3) the control point
  15605. * @param v2 (Vector3) the end point of the Quadratic Bezier
  15606. * @param nbPoints (integer) the wanted number of points in the curve
  15607. */
  15608. static CreateQuadraticBezier(v0: Vector3, v1: Vector3, v2: Vector3, nbPoints: number): Curve3;
  15609. /**
  15610. * Returns a Curve3 object along a Cubic Bezier curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#cubic-bezier-curve
  15611. * @param v0 (Vector3) the origin point of the Cubic Bezier
  15612. * @param v1 (Vector3) the first control point
  15613. * @param v2 (Vector3) the second control point
  15614. * @param v3 (Vector3) the end point of the Cubic Bezier
  15615. * @param nbPoints (integer) the wanted number of points in the curve
  15616. */
  15617. static CreateCubicBezier(v0: Vector3, v1: Vector3, v2: Vector3, v3: Vector3, nbPoints: number): Curve3;
  15618. /**
  15619. * Returns a Curve3 object along a Hermite Spline curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#hermite-spline
  15620. * @param p1 (Vector3) the origin point of the Hermite Spline
  15621. * @param t1 (Vector3) the tangent vector at the origin point
  15622. * @param p2 (Vector3) the end point of the Hermite Spline
  15623. * @param t2 (Vector3) the tangent vector at the end point
  15624. * @param nbPoints (integer) the wanted number of points in the curve
  15625. */
  15626. static CreateHermiteSpline(p1: Vector3, t1: Vector3, p2: Vector3, t2: Vector3, nbPoints: number): Curve3;
  15627. /**
  15628. * Returns a Curve3 object along a CatmullRom Spline curve :
  15629. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  15630. * @param nbPoints (integer) the wanted number of points between each curve control points
  15631. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  15632. */
  15633. static CreateCatmullRomSpline(points: Vector3[], nbPoints: number, closed?: boolean): Curve3;
  15634. /**
  15635. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  15636. * A Curve3 is designed from a series of successive Vector3.
  15637. * Tuto : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#curve3-object
  15638. */
  15639. constructor(points: Vector3[]);
  15640. /**
  15641. * Returns the Curve3 stored array of successive Vector3
  15642. */
  15643. getPoints(): Vector3[];
  15644. /**
  15645. * Returns the computed length (float) of the curve.
  15646. */
  15647. length(): number;
  15648. /**
  15649. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  15650. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  15651. * curveA and curveB keep unchanged.
  15652. */
  15653. continue(curve: Curve3): Curve3;
  15654. private _computeLength(path);
  15655. }
  15656. class PositionNormalVertex {
  15657. position: Vector3;
  15658. normal: Vector3;
  15659. constructor(position?: Vector3, normal?: Vector3);
  15660. clone(): PositionNormalVertex;
  15661. }
  15662. class PositionNormalTextureVertex {
  15663. position: Vector3;
  15664. normal: Vector3;
  15665. uv: Vector2;
  15666. constructor(position?: Vector3, normal?: Vector3, uv?: Vector2);
  15667. clone(): PositionNormalTextureVertex;
  15668. }
  15669. class Tmp {
  15670. static Color3: Color3[];
  15671. static Color4: Color4[];
  15672. static Vector2: Vector2[];
  15673. static Vector3: Vector3[];
  15674. static Vector4: Vector4[];
  15675. static Quaternion: Quaternion[];
  15676. static Matrix: Matrix[];
  15677. }
  15678. }
  15679. declare module BABYLON {
  15680. class SphericalPolynomial {
  15681. x: Vector3;
  15682. y: Vector3;
  15683. z: Vector3;
  15684. xx: Vector3;
  15685. yy: Vector3;
  15686. zz: Vector3;
  15687. xy: Vector3;
  15688. yz: Vector3;
  15689. zx: Vector3;
  15690. addAmbient(color: Color3): void;
  15691. static getSphericalPolynomialFromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  15692. scale(scale: number): void;
  15693. }
  15694. class SphericalHarmonics {
  15695. L00: Vector3;
  15696. L1_1: Vector3;
  15697. L10: Vector3;
  15698. L11: Vector3;
  15699. L2_2: Vector3;
  15700. L2_1: Vector3;
  15701. L20: Vector3;
  15702. L21: Vector3;
  15703. L22: Vector3;
  15704. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  15705. scale(scale: number): void;
  15706. convertIncidentRadianceToIrradiance(): void;
  15707. convertIrradianceToLambertianRadiance(): void;
  15708. static getsphericalHarmonicsFromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  15709. }
  15710. }
  15711. declare module BABYLON {
  15712. /**
  15713. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  15714. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  15715. * 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;
  15716. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  15717. */
  15718. class ColorCurves {
  15719. private _dirty;
  15720. private _tempColor;
  15721. private _globalCurve;
  15722. private _highlightsCurve;
  15723. private _midtonesCurve;
  15724. private _shadowsCurve;
  15725. private _positiveCurve;
  15726. private _negativeCurve;
  15727. private _globalHue;
  15728. private _globalDensity;
  15729. private _globalSaturation;
  15730. private _globalExposure;
  15731. /**
  15732. * Gets the global Hue value.
  15733. * 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).
  15734. */
  15735. /**
  15736. * Sets the global Hue value.
  15737. * 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).
  15738. */
  15739. globalHue: number;
  15740. /**
  15741. * Gets the global Density value.
  15742. * 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.
  15743. * Values less than zero provide a filter of opposite hue.
  15744. */
  15745. /**
  15746. * Sets the global Density value.
  15747. * 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.
  15748. * Values less than zero provide a filter of opposite hue.
  15749. */
  15750. globalDensity: number;
  15751. /**
  15752. * Gets the global Saturation value.
  15753. * 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.
  15754. */
  15755. /**
  15756. * Sets the global Saturation value.
  15757. * 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.
  15758. */
  15759. globalSaturation: number;
  15760. /**
  15761. * Gets the global Exposure value.
  15762. * 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.
  15763. */
  15764. /**
  15765. * Sets the global Exposure value.
  15766. * 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.
  15767. */
  15768. globalExposure: number;
  15769. private _highlightsHue;
  15770. private _highlightsDensity;
  15771. private _highlightsSaturation;
  15772. private _highlightsExposure;
  15773. /**
  15774. * Gets the highlights Hue value.
  15775. * 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).
  15776. */
  15777. /**
  15778. * Sets the highlights Hue value.
  15779. * 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).
  15780. */
  15781. highlightsHue: number;
  15782. /**
  15783. * Gets the highlights Density value.
  15784. * 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.
  15785. * Values less than zero provide a filter of opposite hue.
  15786. */
  15787. /**
  15788. * Sets the highlights Density value.
  15789. * 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.
  15790. * Values less than zero provide a filter of opposite hue.
  15791. */
  15792. highlightsDensity: number;
  15793. /**
  15794. * Gets the highlights Saturation value.
  15795. * 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.
  15796. */
  15797. /**
  15798. * Sets the highlights Saturation value.
  15799. * 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.
  15800. */
  15801. highlightsSaturation: number;
  15802. /**
  15803. * Gets the highlights Exposure value.
  15804. * 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.
  15805. */
  15806. /**
  15807. * Sets the highlights Exposure value.
  15808. * 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.
  15809. */
  15810. highlightsExposure: number;
  15811. private _midtonesHue;
  15812. private _midtonesDensity;
  15813. private _midtonesSaturation;
  15814. private _midtonesExposure;
  15815. /**
  15816. * Gets the midtones Hue value.
  15817. * 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).
  15818. */
  15819. /**
  15820. * Sets the midtones Hue value.
  15821. * 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).
  15822. */
  15823. midtonesHue: number;
  15824. /**
  15825. * Gets the midtones Density value.
  15826. * 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.
  15827. * Values less than zero provide a filter of opposite hue.
  15828. */
  15829. /**
  15830. * Sets the midtones Density value.
  15831. * 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.
  15832. * Values less than zero provide a filter of opposite hue.
  15833. */
  15834. midtonesDensity: number;
  15835. /**
  15836. * Gets the midtones Saturation value.
  15837. * 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.
  15838. */
  15839. /**
  15840. * Sets the midtones Saturation value.
  15841. * 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.
  15842. */
  15843. midtonesSaturation: number;
  15844. /**
  15845. * Gets the midtones Exposure value.
  15846. * 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.
  15847. */
  15848. /**
  15849. * Sets the midtones Exposure value.
  15850. * 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.
  15851. */
  15852. midtonesExposure: number;
  15853. private _shadowsHue;
  15854. private _shadowsDensity;
  15855. private _shadowsSaturation;
  15856. private _shadowsExposure;
  15857. /**
  15858. * Gets the shadows Hue value.
  15859. * 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).
  15860. */
  15861. /**
  15862. * Sets the shadows 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. shadowsHue: number;
  15866. /**
  15867. * Gets the shadows Density value.
  15868. * 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.
  15869. * Values less than zero provide a filter of opposite hue.
  15870. */
  15871. /**
  15872. * Sets the shadows Density value.
  15873. * 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.
  15874. * Values less than zero provide a filter of opposite hue.
  15875. */
  15876. shadowsDensity: number;
  15877. /**
  15878. * Gets the shadows Saturation value.
  15879. * 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.
  15880. */
  15881. /**
  15882. * Sets the shadows 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. shadowsSaturation: number;
  15886. /**
  15887. * Gets the shadows Exposure value.
  15888. * 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.
  15889. */
  15890. /**
  15891. * Sets the shadows 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. shadowsExposure: number;
  15895. getClassName(): string;
  15896. /**
  15897. * Binds the color curves to the shader.
  15898. * @param colorCurves The color curve to bind
  15899. * @param effect The effect to bind to
  15900. */
  15901. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  15902. /**
  15903. * Prepare the list of uniforms associated with the ColorCurves effects.
  15904. * @param uniformsList The list of uniforms used in the effect
  15905. */
  15906. static PrepareUniforms(uniformsList: string[]): void;
  15907. /**
  15908. * Returns color grading data based on a hue, density, saturation and exposure value.
  15909. * @param filterHue The hue of the color filter.
  15910. * @param filterDensity The density of the color filter.
  15911. * @param saturation The saturation.
  15912. * @param exposure The exposure.
  15913. * @param result The result data container.
  15914. */
  15915. private getColorGradingDataToRef(hue, density, saturation, exposure, result);
  15916. /**
  15917. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  15918. * @param value The input slider value in range [-100,100].
  15919. * @returns Adjusted value.
  15920. */
  15921. private static applyColorGradingSliderNonlinear(value);
  15922. /**
  15923. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  15924. * @param hue The hue (H) input.
  15925. * @param saturation The saturation (S) input.
  15926. * @param brightness The brightness (B) input.
  15927. * @result An RGBA color represented as Vector4.
  15928. */
  15929. private static fromHSBToRef(hue, saturation, brightness, result);
  15930. /**
  15931. * Returns a value clamped between min and max
  15932. * @param value The value to clamp
  15933. * @param min The minimum of value
  15934. * @param max The maximum of value
  15935. * @returns The clamped value.
  15936. */
  15937. private static clamp(value, min, max);
  15938. /**
  15939. * Clones the current color curve instance.
  15940. * @return The cloned curves
  15941. */
  15942. clone(): ColorCurves;
  15943. /**
  15944. * Serializes the current color curve instance to a json representation.
  15945. * @return a JSON representation
  15946. */
  15947. serialize(): any;
  15948. /**
  15949. * Parses the color curve from a json representation.
  15950. * @param source the JSON source to parse
  15951. * @return The parsed curves
  15952. */
  15953. static Parse(source: any): ColorCurves;
  15954. }
  15955. }
  15956. declare module BABYLON {
  15957. /**
  15958. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  15959. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  15960. */
  15961. class EffectFallbacks {
  15962. private _defines;
  15963. private _currentRank;
  15964. private _maxRank;
  15965. private _mesh;
  15966. /**
  15967. * Removes the fallback from the bound mesh.
  15968. */
  15969. unBindMesh(): void;
  15970. /**
  15971. * Adds a fallback on the specified property.
  15972. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  15973. * @param define The name of the define in the shader
  15974. */
  15975. addFallback(rank: number, define: string): void;
  15976. /**
  15977. * Sets the mesh to use CPU skinning when needing to fallback.
  15978. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  15979. * @param mesh The mesh to use the fallbacks.
  15980. */
  15981. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  15982. /**
  15983. * Checks to see if more fallbacks are still availible.
  15984. */
  15985. readonly isMoreFallbacks: boolean;
  15986. /**
  15987. * Removes the defines that shoould be removed when falling back.
  15988. * @param currentDefines defines the current define statements for the shader.
  15989. * @param effect defines the current effect we try to compile
  15990. * @returns The resulting defines with defines of the current rank removed.
  15991. */
  15992. reduce(currentDefines: string, effect: Effect): string;
  15993. }
  15994. /**
  15995. * Options to be used when creating an effect.
  15996. */
  15997. class EffectCreationOptions {
  15998. /**
  15999. * Atrributes that will be used in the shader.
  16000. */
  16001. attributes: string[];
  16002. /**
  16003. * Uniform varible names that will be set in the shader.
  16004. */
  16005. uniformsNames: string[];
  16006. /**
  16007. * Uniform buffer varible names that will be set in the shader.
  16008. */
  16009. uniformBuffersNames: string[];
  16010. /**
  16011. * Sampler texture variable names that will be set in the shader.
  16012. */
  16013. samplers: string[];
  16014. /**
  16015. * Define statements that will be set in the shader.
  16016. */
  16017. defines: any;
  16018. /**
  16019. * Possible fallbacks for this effect to improve performance when needed.
  16020. */
  16021. fallbacks: Nullable<EffectFallbacks>;
  16022. /**
  16023. * Callback that will be called when the shader is compiled.
  16024. */
  16025. onCompiled: Nullable<(effect: Effect) => void>;
  16026. /**
  16027. * Callback that will be called if an error occurs during shader compilation.
  16028. */
  16029. onError: Nullable<(effect: Effect, errors: string) => void>;
  16030. /**
  16031. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  16032. */
  16033. indexParameters: any;
  16034. /**
  16035. * Max number of lights that can be used in the shader.
  16036. */
  16037. maxSimultaneousLights: number;
  16038. /**
  16039. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  16040. */
  16041. transformFeedbackVaryings: Nullable<string[]>;
  16042. }
  16043. /**
  16044. * Effect containing vertex and fragment shader that can be executed on an object.
  16045. */
  16046. class Effect {
  16047. /**
  16048. * Name of the effect.
  16049. */
  16050. name: any;
  16051. /**
  16052. * String container all the define statements that should be set on the shader.
  16053. */
  16054. defines: string;
  16055. /**
  16056. * Callback that will be called when the shader is compiled.
  16057. */
  16058. onCompiled: Nullable<(effect: Effect) => void>;
  16059. /**
  16060. * Callback that will be called if an error occurs during shader compilation.
  16061. */
  16062. onError: Nullable<(effect: Effect, errors: string) => void>;
  16063. /**
  16064. * Callback that will be called when effect is bound.
  16065. */
  16066. onBind: Nullable<(effect: Effect) => void>;
  16067. /**
  16068. * Unique ID of the effect.
  16069. */
  16070. uniqueId: number;
  16071. /**
  16072. * Observable that will be called when the shader is compiled.
  16073. */
  16074. onCompileObservable: Observable<Effect>;
  16075. /**
  16076. * Observable that will be called if an error occurs during shader compilation.
  16077. */
  16078. onErrorObservable: Observable<Effect>;
  16079. /**
  16080. * Observable that will be called when effect is bound.
  16081. */
  16082. onBindObservable: Observable<Effect>;
  16083. /** @hidden */
  16084. private static _uniqueIdSeed;
  16085. private _engine;
  16086. private _uniformBuffersNames;
  16087. private _uniformsNames;
  16088. private _samplers;
  16089. private _isReady;
  16090. private _compilationError;
  16091. private _attributesNames;
  16092. private _attributes;
  16093. private _uniforms;
  16094. /**
  16095. * Key for the effect.
  16096. */
  16097. private _indexParameters;
  16098. private _fallbacks;
  16099. private _vertexSourceCode;
  16100. private _fragmentSourceCode;
  16101. private _vertexSourceCodeOverride;
  16102. private _fragmentSourceCodeOverride;
  16103. private _transformFeedbackVaryings;
  16104. /**
  16105. * Compiled shader to webGL program.
  16106. */
  16107. private _valueCache;
  16108. private static _baseCache;
  16109. /**
  16110. * Instantiates an effect.
  16111. * An effect can be used to create/manage/execute vertex and fragment shaders.
  16112. * @param baseName Name of the effect.
  16113. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  16114. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  16115. * @param samplers List of sampler variables that will be passed to the shader.
  16116. * @param engine Engine to be used to render the effect
  16117. * @param defines Define statements to be added to the shader.
  16118. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  16119. * @param onCompiled Callback that will be called when the shader is compiled.
  16120. * @param onError Callback that will be called if an error occurs during shader compilation.
  16121. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  16122. */
  16123. 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);
  16124. /**
  16125. * Unique key for this effect
  16126. */
  16127. readonly key: string;
  16128. /**
  16129. * If the effect has been compiled and prepared.
  16130. * @returns if the effect is compiled and prepared.
  16131. */
  16132. isReady(): boolean;
  16133. /**
  16134. * The engine the effect was initialized with.
  16135. * @returns the engine.
  16136. */
  16137. getEngine(): Engine;
  16138. /**
  16139. * The compiled webGL program for the effect
  16140. * @returns the webGL program.
  16141. */
  16142. getProgram(): WebGLProgram;
  16143. /**
  16144. * The set of names of attribute variables for the shader.
  16145. * @returns An array of attribute names.
  16146. */
  16147. getAttributesNames(): string[];
  16148. /**
  16149. * Returns the attribute at the given index.
  16150. * @param index The index of the attribute.
  16151. * @returns The location of the attribute.
  16152. */
  16153. getAttributeLocation(index: number): number;
  16154. /**
  16155. * Returns the attribute based on the name of the variable.
  16156. * @param name of the attribute to look up.
  16157. * @returns the attribute location.
  16158. */
  16159. getAttributeLocationByName(name: string): number;
  16160. /**
  16161. * The number of attributes.
  16162. * @returns the numnber of attributes.
  16163. */
  16164. getAttributesCount(): number;
  16165. /**
  16166. * Gets the index of a uniform variable.
  16167. * @param uniformName of the uniform to look up.
  16168. * @returns the index.
  16169. */
  16170. getUniformIndex(uniformName: string): number;
  16171. /**
  16172. * Returns the attribute based on the name of the variable.
  16173. * @param uniformName of the uniform to look up.
  16174. * @returns the location of the uniform.
  16175. */
  16176. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  16177. /**
  16178. * Returns an array of sampler variable names
  16179. * @returns The array of sampler variable neames.
  16180. */
  16181. getSamplers(): string[];
  16182. /**
  16183. * The error from the last compilation.
  16184. * @returns the error string.
  16185. */
  16186. getCompilationError(): string;
  16187. /**
  16188. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  16189. * @param func The callback to be used.
  16190. */
  16191. executeWhenCompiled(func: (effect: Effect) => void): void;
  16192. /** @hidden */
  16193. /** @hidden */
  16194. private _dumpShadersSource(vertexCode, fragmentCode, defines);
  16195. private _processShaderConversion(sourceCode, isFragment, callback);
  16196. private _processIncludes(sourceCode, callback);
  16197. private _processPrecision(source);
  16198. /**
  16199. * Recompiles the webGL program
  16200. * @param vertexSourceCode The source code for the vertex shader.
  16201. * @param fragmentSourceCode The source code for the fragment shader.
  16202. * @param onCompiled Callback called when completed.
  16203. * @param onError Callback called on error.
  16204. */
  16205. /**
  16206. * Gets the uniform locations of the the specified variable names
  16207. * @param names THe names of the variables to lookup.
  16208. * @returns Array of locations in the same order as variable names.
  16209. */
  16210. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  16211. /**
  16212. * Prepares the effect
  16213. */
  16214. /**
  16215. * Checks if the effect is supported. (Must be called after compilation)
  16216. */
  16217. readonly isSupported: boolean;
  16218. /**
  16219. * Binds a texture to the engine to be used as output of the shader.
  16220. * @param channel Name of the output variable.
  16221. * @param texture Texture to bind.
  16222. */
  16223. /**
  16224. * Sets a texture on the engine to be used in the shader.
  16225. * @param channel Name of the sampler variable.
  16226. * @param texture Texture to set.
  16227. */
  16228. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  16229. /**
  16230. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  16231. * @param channel Name of the sampler variable.
  16232. * @param texture Texture to set.
  16233. */
  16234. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  16235. /**
  16236. * Sets an array of textures on the engine to be used in the shader.
  16237. * @param channel Name of the variable.
  16238. * @param textures Textures to set.
  16239. */
  16240. setTextureArray(channel: string, textures: BaseTexture[]): void;
  16241. /**
  16242. * 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)
  16243. * @param channel Name of the sampler variable.
  16244. * @param postProcess Post process to get the input texture from.
  16245. */
  16246. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  16247. /**
  16248. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  16249. * 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)
  16250. * @param channel Name of the sampler variable.
  16251. * @param postProcess Post process to get the output texture from.
  16252. */
  16253. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  16254. /** @hidden */
  16255. /** @hidden */
  16256. /** @hidden */
  16257. /** @hidden */
  16258. /**
  16259. * Binds a buffer to a uniform.
  16260. * @param buffer Buffer to bind.
  16261. * @param name Name of the uniform variable to bind to.
  16262. */
  16263. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  16264. /**
  16265. * Binds block to a uniform.
  16266. * @param blockName Name of the block to bind.
  16267. * @param index Index to bind.
  16268. */
  16269. bindUniformBlock(blockName: string, index: number): void;
  16270. /**
  16271. * Sets an interger value on a uniform variable.
  16272. * @param uniformName Name of the variable.
  16273. * @param value Value to be set.
  16274. * @returns this effect.
  16275. */
  16276. setInt(uniformName: string, value: number): Effect;
  16277. /**
  16278. * Sets an int array on a uniform variable.
  16279. * @param uniformName Name of the variable.
  16280. * @param array array to be set.
  16281. * @returns this effect.
  16282. */
  16283. setIntArray(uniformName: string, array: Int32Array): Effect;
  16284. /**
  16285. * 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)
  16286. * @param uniformName Name of the variable.
  16287. * @param array array to be set.
  16288. * @returns this effect.
  16289. */
  16290. setIntArray2(uniformName: string, array: Int32Array): Effect;
  16291. /**
  16292. * 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)
  16293. * @param uniformName Name of the variable.
  16294. * @param array array to be set.
  16295. * @returns this effect.
  16296. */
  16297. setIntArray3(uniformName: string, array: Int32Array): Effect;
  16298. /**
  16299. * 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)
  16300. * @param uniformName Name of the variable.
  16301. * @param array array to be set.
  16302. * @returns this effect.
  16303. */
  16304. setIntArray4(uniformName: string, array: Int32Array): Effect;
  16305. /**
  16306. * Sets an float array on a uniform variable.
  16307. * @param uniformName Name of the variable.
  16308. * @param array array to be set.
  16309. * @returns this effect.
  16310. */
  16311. setFloatArray(uniformName: string, array: Float32Array): Effect;
  16312. /**
  16313. * 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)
  16314. * @param uniformName Name of the variable.
  16315. * @param array array to be set.
  16316. * @returns this effect.
  16317. */
  16318. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  16319. /**
  16320. * 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)
  16321. * @param uniformName Name of the variable.
  16322. * @param array array to be set.
  16323. * @returns this effect.
  16324. */
  16325. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  16326. /**
  16327. * 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)
  16328. * @param uniformName Name of the variable.
  16329. * @param array array to be set.
  16330. * @returns this effect.
  16331. */
  16332. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  16333. /**
  16334. * Sets an array on a uniform variable.
  16335. * @param uniformName Name of the variable.
  16336. * @param array array to be set.
  16337. * @returns this effect.
  16338. */
  16339. setArray(uniformName: string, array: number[]): Effect;
  16340. /**
  16341. * 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)
  16342. * @param uniformName Name of the variable.
  16343. * @param array array to be set.
  16344. * @returns this effect.
  16345. */
  16346. setArray2(uniformName: string, array: number[]): Effect;
  16347. /**
  16348. * 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)
  16349. * @param uniformName Name of the variable.
  16350. * @param array array to be set.
  16351. * @returns this effect.
  16352. */
  16353. setArray3(uniformName: string, array: number[]): Effect;
  16354. /**
  16355. * 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)
  16356. * @param uniformName Name of the variable.
  16357. * @param array array to be set.
  16358. * @returns this effect.
  16359. */
  16360. setArray4(uniformName: string, array: number[]): Effect;
  16361. /**
  16362. * Sets matrices on a uniform variable.
  16363. * @param uniformName Name of the variable.
  16364. * @param matrices matrices to be set.
  16365. * @returns this effect.
  16366. */
  16367. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  16368. /**
  16369. * Sets matrix on a uniform variable.
  16370. * @param uniformName Name of the variable.
  16371. * @param matrix matrix to be set.
  16372. * @returns this effect.
  16373. */
  16374. setMatrix(uniformName: string, matrix: Matrix): Effect;
  16375. /**
  16376. * 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)
  16377. * @param uniformName Name of the variable.
  16378. * @param matrix matrix to be set.
  16379. * @returns this effect.
  16380. */
  16381. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  16382. /**
  16383. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  16384. * @param uniformName Name of the variable.
  16385. * @param matrix matrix to be set.
  16386. * @returns this effect.
  16387. */
  16388. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  16389. /**
  16390. * Sets a float on a uniform variable.
  16391. * @param uniformName Name of the variable.
  16392. * @param value value to be set.
  16393. * @returns this effect.
  16394. */
  16395. setFloat(uniformName: string, value: number): Effect;
  16396. /**
  16397. * Sets a boolean on a uniform variable.
  16398. * @param uniformName Name of the variable.
  16399. * @param bool value to be set.
  16400. * @returns this effect.
  16401. */
  16402. setBool(uniformName: string, bool: boolean): Effect;
  16403. /**
  16404. * Sets a Vector2 on a uniform variable.
  16405. * @param uniformName Name of the variable.
  16406. * @param vector2 vector2 to be set.
  16407. * @returns this effect.
  16408. */
  16409. setVector2(uniformName: string, vector2: Vector2): Effect;
  16410. /**
  16411. * Sets a float2 on a uniform variable.
  16412. * @param uniformName Name of the variable.
  16413. * @param x First float in float2.
  16414. * @param y Second float in float2.
  16415. * @returns this effect.
  16416. */
  16417. setFloat2(uniformName: string, x: number, y: number): Effect;
  16418. /**
  16419. * Sets a Vector3 on a uniform variable.
  16420. * @param uniformName Name of the variable.
  16421. * @param vector3 Value to be set.
  16422. * @returns this effect.
  16423. */
  16424. setVector3(uniformName: string, vector3: Vector3): Effect;
  16425. /**
  16426. * Sets a float3 on a uniform variable.
  16427. * @param uniformName Name of the variable.
  16428. * @param x First float in float3.
  16429. * @param y Second float in float3.
  16430. * @param z Third float in float3.
  16431. * @returns this effect.
  16432. */
  16433. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  16434. /**
  16435. * Sets a Vector4 on a uniform variable.
  16436. * @param uniformName Name of the variable.
  16437. * @param vector4 Value to be set.
  16438. * @returns this effect.
  16439. */
  16440. setVector4(uniformName: string, vector4: Vector4): Effect;
  16441. /**
  16442. * Sets a float4 on a uniform variable.
  16443. * @param uniformName Name of the variable.
  16444. * @param x First float in float4.
  16445. * @param y Second float in float4.
  16446. * @param z Third float in float4.
  16447. * @param w Fourth float in float4.
  16448. * @returns this effect.
  16449. */
  16450. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  16451. /**
  16452. * Sets a Color3 on a uniform variable.
  16453. * @param uniformName Name of the variable.
  16454. * @param color3 Value to be set.
  16455. * @returns this effect.
  16456. */
  16457. setColor3(uniformName: string, color3: Color3): Effect;
  16458. /**
  16459. * Sets a Color4 on a uniform variable.
  16460. * @param uniformName Name of the variable.
  16461. * @param color3 Value to be set.
  16462. * @param alpha Alpha value to be set.
  16463. * @returns this effect.
  16464. */
  16465. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  16466. /**
  16467. * Sets a Color4 on a uniform variable
  16468. * @param uniformName defines the name of the variable
  16469. * @param color4 defines the value to be set
  16470. * @returns this effect.
  16471. */
  16472. setDirectColor4(uniformName: string, color4: Color4): Effect;
  16473. /**
  16474. * Store of each shader (The can be looked up using effect.key)
  16475. */
  16476. static ShadersStore: {
  16477. [key: string]: string;
  16478. };
  16479. /**
  16480. * Store of each included file for a shader (The can be looked up using effect.key)
  16481. */
  16482. static IncludesShadersStore: {
  16483. [key: string]: string;
  16484. };
  16485. /**
  16486. * Resets the cache of effects.
  16487. */
  16488. static ResetCache(): void;
  16489. }
  16490. }
  16491. declare module BABYLON {
  16492. class FresnelParameters {
  16493. private _isEnabled;
  16494. isEnabled: boolean;
  16495. leftColor: Color3;
  16496. rightColor: Color3;
  16497. bias: number;
  16498. power: number;
  16499. clone(): FresnelParameters;
  16500. serialize(): any;
  16501. static Parse(parsedFresnelParameters: any): FresnelParameters;
  16502. }
  16503. }
  16504. declare module BABYLON {
  16505. /**
  16506. * Interface to follow in your material defines to integrate easily the
  16507. * Image proccessing functions.
  16508. * @hidden
  16509. */
  16510. interface IImageProcessingConfigurationDefines {
  16511. IMAGEPROCESSING: boolean;
  16512. VIGNETTE: boolean;
  16513. VIGNETTEBLENDMODEMULTIPLY: boolean;
  16514. VIGNETTEBLENDMODEOPAQUE: boolean;
  16515. TONEMAPPING: boolean;
  16516. CONTRAST: boolean;
  16517. EXPOSURE: boolean;
  16518. COLORCURVES: boolean;
  16519. COLORGRADING: boolean;
  16520. COLORGRADING3D: boolean;
  16521. SAMPLER3DGREENDEPTH: boolean;
  16522. SAMPLER3DBGRMAP: boolean;
  16523. IMAGEPROCESSINGPOSTPROCESS: boolean;
  16524. }
  16525. /**
  16526. * This groups together the common properties used for image processing either in direct forward pass
  16527. * or through post processing effect depending on the use of the image processing pipeline in your scene
  16528. * or not.
  16529. */
  16530. class ImageProcessingConfiguration {
  16531. /**
  16532. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  16533. */
  16534. colorCurves: Nullable<ColorCurves>;
  16535. private _colorCurvesEnabled;
  16536. /**
  16537. * Gets wether the color curves effect is enabled.
  16538. */
  16539. /**
  16540. * Sets wether the color curves effect is enabled.
  16541. */
  16542. colorCurvesEnabled: boolean;
  16543. /**
  16544. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  16545. */
  16546. colorGradingTexture: Nullable<BaseTexture>;
  16547. private _colorGradingEnabled;
  16548. /**
  16549. * Gets wether the color grading effect is enabled.
  16550. */
  16551. /**
  16552. * Sets wether the color grading effect is enabled.
  16553. */
  16554. colorGradingEnabled: boolean;
  16555. private _colorGradingWithGreenDepth;
  16556. /**
  16557. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  16558. */
  16559. /**
  16560. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  16561. */
  16562. colorGradingWithGreenDepth: boolean;
  16563. private _colorGradingBGR;
  16564. /**
  16565. * Gets wether the color grading texture contains BGR values.
  16566. */
  16567. /**
  16568. * Sets wether the color grading texture contains BGR values.
  16569. */
  16570. colorGradingBGR: boolean;
  16571. /**
  16572. * Gets the Exposure used in the effect.
  16573. */
  16574. /**
  16575. * Sets the Exposure used in the effect.
  16576. */
  16577. exposure: number;
  16578. private _toneMappingEnabled;
  16579. /**
  16580. * Gets wether the tone mapping effect is enabled.
  16581. */
  16582. /**
  16583. * Sets wether the tone mapping effect is enabled.
  16584. */
  16585. toneMappingEnabled: boolean;
  16586. protected _contrast: number;
  16587. /**
  16588. * Gets the contrast used in the effect.
  16589. */
  16590. /**
  16591. * Sets the contrast used in the effect.
  16592. */
  16593. contrast: number;
  16594. /**
  16595. * Vignette stretch size.
  16596. */
  16597. vignetteStretch: number;
  16598. /**
  16599. * Vignette centre X Offset.
  16600. */
  16601. vignetteCentreX: number;
  16602. /**
  16603. * Vignette centre Y Offset.
  16604. */
  16605. vignetteCentreY: number;
  16606. /**
  16607. * Vignette weight or intensity of the vignette effect.
  16608. */
  16609. vignetteWeight: number;
  16610. /**
  16611. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  16612. * if vignetteEnabled is set to true.
  16613. */
  16614. vignetteColor: Color4;
  16615. /**
  16616. * Camera field of view used by the Vignette effect.
  16617. */
  16618. vignetteCameraFov: number;
  16619. private _vignetteBlendMode;
  16620. /**
  16621. * Gets the vignette blend mode allowing different kind of effect.
  16622. */
  16623. /**
  16624. * Sets the vignette blend mode allowing different kind of effect.
  16625. */
  16626. vignetteBlendMode: number;
  16627. private _vignetteEnabled;
  16628. /**
  16629. * Gets wether the vignette effect is enabled.
  16630. */
  16631. /**
  16632. * Sets wether the vignette effect is enabled.
  16633. */
  16634. vignetteEnabled: boolean;
  16635. private _applyByPostProcess;
  16636. /**
  16637. * Gets wether the image processing is applied through a post process or not.
  16638. */
  16639. /**
  16640. * Sets wether the image processing is applied through a post process or not.
  16641. */
  16642. applyByPostProcess: boolean;
  16643. private _isEnabled;
  16644. /**
  16645. * Gets wether the image processing is enabled or not.
  16646. */
  16647. /**
  16648. * Sets wether the image processing is enabled or not.
  16649. */
  16650. isEnabled: boolean;
  16651. /**
  16652. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  16653. */
  16654. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  16655. /**
  16656. * Method called each time the image processing information changes requires to recompile the effect.
  16657. */
  16658. protected _updateParameters(): void;
  16659. getClassName(): string;
  16660. /**
  16661. * Prepare the list of uniforms associated with the Image Processing effects.
  16662. * @param uniformsList The list of uniforms used in the effect
  16663. * @param defines the list of defines currently in use
  16664. */
  16665. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  16666. /**
  16667. * Prepare the list of samplers associated with the Image Processing effects.
  16668. * @param uniformsList The list of uniforms used in the effect
  16669. * @param defines the list of defines currently in use
  16670. */
  16671. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  16672. /**
  16673. * Prepare the list of defines associated to the shader.
  16674. * @param defines the list of defines to complete
  16675. */
  16676. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  16677. /**
  16678. * Returns true if all the image processing information are ready.
  16679. */
  16680. isReady(): boolean;
  16681. /**
  16682. * Binds the image processing to the shader.
  16683. * @param effect The effect to bind to
  16684. */
  16685. bind(effect: Effect, aspectRatio?: number): void;
  16686. /**
  16687. * Clones the current image processing instance.
  16688. * @return The cloned image processing
  16689. */
  16690. clone(): ImageProcessingConfiguration;
  16691. /**
  16692. * Serializes the current image processing instance to a json representation.
  16693. * @return a JSON representation
  16694. */
  16695. serialize(): any;
  16696. /**
  16697. * Parses the image processing from a json representation.
  16698. * @param source the JSON source to parse
  16699. * @return The parsed image processing
  16700. */
  16701. static Parse(source: any): ImageProcessingConfiguration;
  16702. private static _VIGNETTEMODE_MULTIPLY;
  16703. private static _VIGNETTEMODE_OPAQUE;
  16704. /**
  16705. * Used to apply the vignette as a mix with the pixel color.
  16706. */
  16707. static readonly VIGNETTEMODE_MULTIPLY: number;
  16708. /**
  16709. * Used to apply the vignette as a replacement of the pixel color.
  16710. */
  16711. static readonly VIGNETTEMODE_OPAQUE: number;
  16712. }
  16713. }
  16714. declare module BABYLON {
  16715. /**
  16716. * Manages the defines for the Material
  16717. */
  16718. class MaterialDefines {
  16719. private _keys;
  16720. private _isDirty;
  16721. /** @hidden */
  16722. /** @hidden */
  16723. /** @hidden */
  16724. /** @hidden */
  16725. /** @hidden */
  16726. /** @hidden */
  16727. /** @hidden */
  16728. /** @hidden */
  16729. /** @hidden */
  16730. /** @hidden */
  16731. /** @hidden */
  16732. /**
  16733. * Specifies if the material needs to be re-calculated
  16734. */
  16735. readonly isDirty: boolean;
  16736. /**
  16737. * Marks the material to indicate that it has been re-calculated
  16738. */
  16739. markAsProcessed(): void;
  16740. /**
  16741. * Marks the material to indicate that it needs to be re-calculated
  16742. */
  16743. markAsUnprocessed(): void;
  16744. /**
  16745. * Marks the material to indicate all of its defines need to be re-calculated
  16746. */
  16747. markAllAsDirty(): void;
  16748. /**
  16749. * Marks the material to indicate that image processing needs to be re-calculated
  16750. */
  16751. markAsImageProcessingDirty(): void;
  16752. /**
  16753. * Marks the material to indicate the lights need to be re-calculated
  16754. */
  16755. markAsLightDirty(): void;
  16756. /**
  16757. * Marks the attribute state as changed
  16758. */
  16759. markAsAttributesDirty(): void;
  16760. /**
  16761. * Marks the texture state as changed
  16762. */
  16763. markAsTexturesDirty(): void;
  16764. /**
  16765. * Marks the fresnel state as changed
  16766. */
  16767. markAsFresnelDirty(): void;
  16768. /**
  16769. * Marks the misc state as changed
  16770. */
  16771. markAsMiscDirty(): void;
  16772. /**
  16773. * Rebuilds the material defines
  16774. */
  16775. rebuild(): void;
  16776. /**
  16777. * Specifies if two material defines are equal
  16778. * @param other - A material define instance to compare to
  16779. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  16780. */
  16781. isEqual(other: MaterialDefines): boolean;
  16782. /**
  16783. * Clones this instance's defines to another instance
  16784. * @param other - material defines to clone values to
  16785. */
  16786. cloneTo(other: MaterialDefines): void;
  16787. /**
  16788. * Resets the material define values
  16789. */
  16790. reset(): void;
  16791. /**
  16792. * Converts the material define values to a string
  16793. * @returns - String of material define information
  16794. */
  16795. toString(): string;
  16796. }
  16797. /**
  16798. * Base class for the main features of a material in Babylon.js
  16799. */
  16800. class Material implements IAnimatable {
  16801. private static _TriangleFillMode;
  16802. private static _WireFrameFillMode;
  16803. private static _PointFillMode;
  16804. private static _PointListDrawMode;
  16805. private static _LineListDrawMode;
  16806. private static _LineLoopDrawMode;
  16807. private static _LineStripDrawMode;
  16808. private static _TriangleStripDrawMode;
  16809. private static _TriangleFanDrawMode;
  16810. /**
  16811. * Returns the triangle fill mode
  16812. */
  16813. static readonly TriangleFillMode: number;
  16814. /**
  16815. * Returns the wireframe mode
  16816. */
  16817. static readonly WireFrameFillMode: number;
  16818. /**
  16819. * Returns the point fill mode
  16820. */
  16821. static readonly PointFillMode: number;
  16822. /**
  16823. * Returns the point list draw mode
  16824. */
  16825. static readonly PointListDrawMode: number;
  16826. /**
  16827. * Returns the line list draw mode
  16828. */
  16829. static readonly LineListDrawMode: number;
  16830. /**
  16831. * Returns the line loop draw mode
  16832. */
  16833. static readonly LineLoopDrawMode: number;
  16834. /**
  16835. * Returns the line strip draw mode
  16836. */
  16837. static readonly LineStripDrawMode: number;
  16838. /**
  16839. * Returns the triangle strip draw mode
  16840. */
  16841. static readonly TriangleStripDrawMode: number;
  16842. /**
  16843. * Returns the triangle fan draw mode
  16844. */
  16845. static readonly TriangleFanDrawMode: number;
  16846. /**
  16847. * Stores the clock-wise side orientation
  16848. */
  16849. private static _ClockWiseSideOrientation;
  16850. /**
  16851. * Stores the counter clock-wise side orientation
  16852. */
  16853. private static _CounterClockWiseSideOrientation;
  16854. /**
  16855. * Returns the clock-wise side orientation
  16856. */
  16857. static readonly ClockWiseSideOrientation: number;
  16858. /**
  16859. * Returns the counter clock-wise side orientation
  16860. */
  16861. static readonly CounterClockWiseSideOrientation: number;
  16862. /**
  16863. * The dirty texture flag value
  16864. */
  16865. private static _TextureDirtyFlag;
  16866. /**
  16867. * The dirty light flag value
  16868. */
  16869. private static _LightDirtyFlag;
  16870. /**
  16871. * The dirty fresnel flag value
  16872. */
  16873. private static _FresnelDirtyFlag;
  16874. /**
  16875. * The dirty attribute flag value
  16876. */
  16877. private static _AttributesDirtyFlag;
  16878. /**
  16879. * The dirty misc flag value
  16880. */
  16881. private static _MiscDirtyFlag;
  16882. /**
  16883. * Returns the dirty texture flag value
  16884. */
  16885. static readonly TextureDirtyFlag: number;
  16886. /**
  16887. * Returns the dirty light flag value
  16888. */
  16889. static readonly LightDirtyFlag: number;
  16890. /**
  16891. * Returns the dirty fresnel flag value
  16892. */
  16893. static readonly FresnelDirtyFlag: number;
  16894. /**
  16895. * Returns the dirty attributes flag value
  16896. */
  16897. static readonly AttributesDirtyFlag: number;
  16898. /**
  16899. * Returns the dirty misc flag value
  16900. */
  16901. static readonly MiscDirtyFlag: number;
  16902. /**
  16903. * The ID of the material
  16904. */
  16905. id: string;
  16906. /**
  16907. * Gets or sets the unique id of the material
  16908. */
  16909. uniqueId: number;
  16910. /**
  16911. * The name of the material
  16912. */
  16913. name: string;
  16914. /**
  16915. * Specifies if the ready state should be checked on each call
  16916. */
  16917. checkReadyOnEveryCall: boolean;
  16918. /**
  16919. * Specifies if the ready state should be checked once
  16920. */
  16921. checkReadyOnlyOnce: boolean;
  16922. /**
  16923. * The state of the material
  16924. */
  16925. state: string;
  16926. /**
  16927. * The alpha value of the material
  16928. */
  16929. protected _alpha: number;
  16930. /**
  16931. * Gets the alpha value of the material
  16932. */
  16933. /**
  16934. * Sets the alpha value of the material
  16935. */
  16936. alpha: number;
  16937. /**
  16938. * Specifies if back face culling is enabled
  16939. */
  16940. protected _backFaceCulling: boolean;
  16941. /**
  16942. * Gets the back-face culling state
  16943. */
  16944. /**
  16945. * Sets the back-face culling state
  16946. */
  16947. backFaceCulling: boolean;
  16948. /**
  16949. * Stores the value for side orientation
  16950. */
  16951. sideOrientation: number;
  16952. /**
  16953. * Callback triggered when the material is compiled
  16954. */
  16955. onCompiled: (effect: Effect) => void;
  16956. /**
  16957. * Callback triggered when an error occurs
  16958. */
  16959. onError: (effect: Effect, errors: string) => void;
  16960. /**
  16961. * Callback triggered to get the render target textures
  16962. */
  16963. getRenderTargetTextures: () => SmartArray<RenderTargetTexture>;
  16964. /**
  16965. * Specifies if the material should be serialized
  16966. */
  16967. doNotSerialize: boolean;
  16968. /**
  16969. * Specifies if the effect should be stored on sub meshes
  16970. */
  16971. storeEffectOnSubMeshes: boolean;
  16972. /**
  16973. * Stores the animations for the material
  16974. */
  16975. animations: Array<Animation>;
  16976. /**
  16977. * An event triggered when the material is disposed
  16978. */
  16979. onDisposeObservable: Observable<Material>;
  16980. /**
  16981. * An observer which watches for dispose events
  16982. */
  16983. private _onDisposeObserver;
  16984. /**
  16985. * Called during a dispose event
  16986. */
  16987. onDispose: () => void;
  16988. /**
  16989. * An event triggered when the material is bound
  16990. */
  16991. onBindObservable: Observable<AbstractMesh>;
  16992. /**
  16993. * An observer which watches for bind events
  16994. */
  16995. private _onBindObserver;
  16996. /**
  16997. * Called during a bind event
  16998. */
  16999. onBind: (Mesh: AbstractMesh) => void;
  17000. /**
  17001. * An event triggered when the material is unbound
  17002. */
  17003. onUnBindObservable: Observable<Material>;
  17004. /**
  17005. * Stores the value of the alpha mode
  17006. */
  17007. private _alphaMode;
  17008. /**
  17009. * Gets the value of the alpha mode
  17010. */
  17011. /**
  17012. * Sets the value of the alpha mode.
  17013. *
  17014. * | Value | Type | Description |
  17015. * | --- | --- | --- |
  17016. * | 0 | ALPHA_DISABLE | |
  17017. * | 1 | ALPHA_ADD | |
  17018. * | 2 | ALPHA_COMBINE | |
  17019. * | 3 | ALPHA_SUBTRACT | |
  17020. * | 4 | ALPHA_MULTIPLY | |
  17021. * | 5 | ALPHA_MAXIMIZED | |
  17022. * | 6 | ALPHA_ONEONE | |
  17023. * | 7 | ALPHA_PREMULTIPLIED | |
  17024. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  17025. * | 9 | ALPHA_INTERPOLATE | |
  17026. * | 10 | ALPHA_SCREENMODE | |
  17027. *
  17028. */
  17029. alphaMode: number;
  17030. /**
  17031. * Stores the state of the need depth pre-pass value
  17032. */
  17033. private _needDepthPrePass;
  17034. /**
  17035. * Gets the depth pre-pass value
  17036. */
  17037. /**
  17038. * Sets the need depth pre-pass value
  17039. */
  17040. needDepthPrePass: boolean;
  17041. /**
  17042. * Specifies if depth writing should be disabled
  17043. */
  17044. disableDepthWrite: boolean;
  17045. /**
  17046. * Specifies if depth writing should be forced
  17047. */
  17048. forceDepthWrite: boolean;
  17049. /**
  17050. * Specifies if there should be a separate pass for culling
  17051. */
  17052. separateCullingPass: boolean;
  17053. /**
  17054. * Stores the state specifing if fog should be enabled
  17055. */
  17056. private _fogEnabled;
  17057. /**
  17058. * Gets the value of the fog enabled state
  17059. */
  17060. /**
  17061. * Sets the state for enabling fog
  17062. */
  17063. fogEnabled: boolean;
  17064. /**
  17065. * Stores the size of points
  17066. */
  17067. pointSize: number;
  17068. /**
  17069. * Stores the z offset value
  17070. */
  17071. zOffset: number;
  17072. /**
  17073. * Gets a value specifying if wireframe mode is enabled
  17074. */
  17075. /**
  17076. * Sets the state of wireframe mode
  17077. */
  17078. wireframe: boolean;
  17079. /**
  17080. * Gets the value specifying if point clouds are enabled
  17081. */
  17082. /**
  17083. * Sets the state of point cloud mode
  17084. */
  17085. pointsCloud: boolean;
  17086. /**
  17087. * Gets the material fill mode
  17088. */
  17089. /**
  17090. * Sets the material fill mode
  17091. */
  17092. fillMode: number;
  17093. /**
  17094. * Stores the effects for the material
  17095. */
  17096. /**
  17097. * Specifies if the material was previously ready
  17098. */
  17099. /**
  17100. * Specifies if uniform buffers should be used
  17101. */
  17102. private _useUBO;
  17103. /**
  17104. * Stores a reference to the scene
  17105. */
  17106. private _scene;
  17107. /**
  17108. * Stores the fill mode state
  17109. */
  17110. private _fillMode;
  17111. /**
  17112. * Specifies if the depth write state should be cached
  17113. */
  17114. private _cachedDepthWriteState;
  17115. /**
  17116. * Stores the uniform buffer
  17117. */
  17118. protected _uniformBuffer: UniformBuffer;
  17119. /**
  17120. * Creates a material instance
  17121. * @param name defines the name of the material
  17122. * @param scene defines the scene to reference
  17123. * @param doNotAdd specifies if the material should be added to the scene
  17124. */
  17125. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  17126. /**
  17127. * Returns a string representation of the current material
  17128. * @param fullDetails defines a boolean indicating which levels of logging is desired
  17129. * @returns a string with material information
  17130. */
  17131. toString(fullDetails?: boolean): string;
  17132. /**
  17133. * Gets the class name of the material
  17134. * @returns a string with the class name of the material
  17135. */
  17136. getClassName(): string;
  17137. /**
  17138. * Specifies if updates for the material been locked
  17139. */
  17140. readonly isFrozen: boolean;
  17141. /**
  17142. * Locks updates for the material
  17143. */
  17144. freeze(): void;
  17145. /**
  17146. * Unlocks updates for the material
  17147. */
  17148. unfreeze(): void;
  17149. /**
  17150. * Specifies if the material is ready to be used
  17151. * @param mesh defines the mesh to check
  17152. * @param useInstances specifies if instances should be used
  17153. * @returns a boolean indicating if the material is ready to be used
  17154. */
  17155. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  17156. /**
  17157. * Specifies that the submesh is ready to be used
  17158. * @param mesh defines the mesh to check
  17159. * @param subMesh defines which submesh to check
  17160. * @param useInstances specifies that instances should be used
  17161. * @returns a boolean indicating that the submesh is ready or not
  17162. */
  17163. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  17164. /**
  17165. * Returns the material effect
  17166. * @returns the effect associated with the material
  17167. */
  17168. getEffect(): Nullable<Effect>;
  17169. /**
  17170. * Returns the current scene
  17171. * @returns a Scene
  17172. */
  17173. getScene(): Scene;
  17174. /**
  17175. * Specifies if the material will require alpha blending
  17176. * @returns a boolean specifying if alpha blending is needed
  17177. */
  17178. needAlphaBlending(): boolean;
  17179. /**
  17180. * Specifies if the mesh will require alpha blending
  17181. * @param mesh defines the mesh to check
  17182. * @returns a boolean specifying if alpha blending is needed for the mesh
  17183. */
  17184. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  17185. /**
  17186. * Specifies if this material should be rendered in alpha test mode
  17187. * @returns a boolean specifying if an alpha test is needed.
  17188. */
  17189. needAlphaTesting(): boolean;
  17190. /**
  17191. * Gets the texture used for the alpha test
  17192. * @returns the texture to use for alpha testing
  17193. */
  17194. getAlphaTestTexture(): Nullable<BaseTexture>;
  17195. /**
  17196. * Marks the material to indicate that it needs to be re-calculated
  17197. */
  17198. markDirty(): void;
  17199. /** @hidden */
  17200. /**
  17201. * Binds the material to the mesh
  17202. * @param world defines the world transformation matrix
  17203. * @param mesh defines the mesh to bind the material to
  17204. */
  17205. bind(world: Matrix, mesh?: Mesh): void;
  17206. /**
  17207. * Binds the submesh to the material
  17208. * @param world defines the world transformation matrix
  17209. * @param mesh defines the mesh containing the submesh
  17210. * @param subMesh defines the submesh to bind the material to
  17211. */
  17212. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  17213. /**
  17214. * Binds the world matrix to the material
  17215. * @param world defines the world transformation matrix
  17216. */
  17217. bindOnlyWorldMatrix(world: Matrix): void;
  17218. /**
  17219. * Binds the scene's uniform buffer to the effect.
  17220. * @param effect defines the effect to bind to the scene uniform buffer
  17221. * @param sceneUbo defines the uniform buffer storing scene data
  17222. */
  17223. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  17224. /**
  17225. * Binds the view matrix to the effect
  17226. * @param effect defines the effect to bind the view matrix to
  17227. */
  17228. bindView(effect: Effect): void;
  17229. /**
  17230. * Binds the view projection matrix to the effect
  17231. * @param effect defines the effect to bind the view projection matrix to
  17232. */
  17233. bindViewProjection(effect: Effect): void;
  17234. /**
  17235. * Specifies if material alpha testing should be turned on for the mesh
  17236. * @param mesh defines the mesh to check
  17237. */
  17238. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  17239. /**
  17240. * Processes to execute after binding the material to a mesh
  17241. * @param mesh defines the rendered mesh
  17242. */
  17243. protected _afterBind(mesh?: Mesh): void;
  17244. /**
  17245. * Unbinds the material from the mesh
  17246. */
  17247. unbind(): void;
  17248. /**
  17249. * Gets the active textures from the material
  17250. * @returns an array of textures
  17251. */
  17252. getActiveTextures(): BaseTexture[];
  17253. /**
  17254. * Specifies if the material uses a texture
  17255. * @param texture defines the texture to check against the material
  17256. * @returns a boolean specifying if the material uses the texture
  17257. */
  17258. hasTexture(texture: BaseTexture): boolean;
  17259. /**
  17260. * Makes a duplicate of the material, and gives it a new name
  17261. * @param name defines the new name for the duplicated material
  17262. * @returns the cloned material
  17263. */
  17264. clone(name: string): Nullable<Material>;
  17265. /**
  17266. * Gets the meshes bound to the material
  17267. * @returns an array of meshes bound to the material
  17268. */
  17269. getBindedMeshes(): AbstractMesh[];
  17270. /**
  17271. * Force shader compilation
  17272. * @param mesh defines the mesh associated with this material
  17273. * @param onCompiled defines a function to execute once the material is compiled
  17274. * @param options defines the options to configure the compilation
  17275. */
  17276. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  17277. clipPlane: boolean;
  17278. }>): void;
  17279. /**
  17280. * Force shader compilation
  17281. * @param mesh defines the mesh that will use this material
  17282. * @param options defines additional options for compiling the shaders
  17283. * @returns a promise that resolves when the compilation completes
  17284. */
  17285. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  17286. clipPlane: boolean;
  17287. }>): Promise<void>;
  17288. /**
  17289. * Marks a define in the material to indicate that it needs to be re-computed
  17290. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  17291. */
  17292. markAsDirty(flag: number): void;
  17293. /**
  17294. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  17295. * @param func defines a function which checks material defines against the submeshes
  17296. */
  17297. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  17298. /**
  17299. * Indicates that image processing needs to be re-calculated for all submeshes
  17300. */
  17301. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  17302. /**
  17303. * Indicates that textures need to be re-calculated for all submeshes
  17304. */
  17305. protected _markAllSubMeshesAsTexturesDirty(): void;
  17306. /**
  17307. * Indicates that fresnel needs to be re-calculated for all submeshes
  17308. */
  17309. protected _markAllSubMeshesAsFresnelDirty(): void;
  17310. /**
  17311. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  17312. */
  17313. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  17314. /**
  17315. * Indicates that lights need to be re-calculated for all submeshes
  17316. */
  17317. protected _markAllSubMeshesAsLightsDirty(): void;
  17318. /**
  17319. * Indicates that attributes need to be re-calculated for all submeshes
  17320. */
  17321. protected _markAllSubMeshesAsAttributesDirty(): void;
  17322. /**
  17323. * Indicates that misc needs to be re-calculated for all submeshes
  17324. */
  17325. protected _markAllSubMeshesAsMiscDirty(): void;
  17326. /**
  17327. * Indicates that textures and misc need to be re-calculated for all submeshes
  17328. */
  17329. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  17330. /**
  17331. * Disposes the material
  17332. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  17333. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  17334. */
  17335. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  17336. /**
  17337. * Serializes this material
  17338. * @returns the serialized material object
  17339. */
  17340. serialize(): any;
  17341. /**
  17342. * Creates a MultiMaterial from parsed MultiMaterial data.
  17343. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  17344. * @param scene defines the hosting scene
  17345. * @returns a new MultiMaterial
  17346. */
  17347. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  17348. /**
  17349. * Creates a material from parsed material data
  17350. * @param parsedMaterial defines parsed material data
  17351. * @param scene defines the hosting scene
  17352. * @param rootUrl defines the root URL to use to load textures
  17353. * @returns a new material
  17354. */
  17355. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): any;
  17356. }
  17357. }
  17358. declare module BABYLON {
  17359. /**
  17360. * "Static Class" containing the most commonly used helper while dealing with material for
  17361. * rendering purpose.
  17362. *
  17363. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  17364. *
  17365. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  17366. */
  17367. class MaterialHelper {
  17368. /**
  17369. * Bind the current view position to an effect.
  17370. * @param effect The effect to be bound
  17371. * @param scene The scene the eyes position is used from
  17372. */
  17373. static BindEyePosition(effect: Effect, scene: Scene): void;
  17374. /**
  17375. * Helps preparing the defines values about the UVs in used in the effect.
  17376. * UVs are shared as much as we can accross chanels in the shaders.
  17377. * @param texture The texture we are preparing the UVs for
  17378. * @param defines The defines to update
  17379. * @param key The chanel key "diffuse", "specular"... used in the shader
  17380. */
  17381. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  17382. /**
  17383. * Binds a texture matrix value to its corrsponding uniform
  17384. * @param texture The texture to bind the matrix for
  17385. * @param uniformBuffer The uniform buffer receivin the data
  17386. * @param key The chanel key "diffuse", "specular"... used in the shader
  17387. */
  17388. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  17389. /**
  17390. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  17391. * @param mesh defines the current mesh
  17392. * @param scene defines the current scene
  17393. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  17394. * @param pointsCloud defines if point cloud rendering has to be turned on
  17395. * @param fogEnabled defines if fog has to be turned on
  17396. * @param alphaTest defines if alpha testing has to be turned on
  17397. * @param defines defines the current list of defines
  17398. */
  17399. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  17400. /**
  17401. * Helper used to prepare the list of defines associated with frame values for shader compilation
  17402. * @param scene defines the current scene
  17403. * @param engine defines the current engine
  17404. * @param defines specifies the list of active defines
  17405. * @param useInstances defines if instances have to be turned on
  17406. * @param useClipPlane defines if clip plane have to be turned on
  17407. */
  17408. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  17409. /**
  17410. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  17411. * @param mesh The mesh containing the geometry data we will draw
  17412. * @param defines The defines to update
  17413. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  17414. * @param useBones Precise whether bones should be used or not (override mesh info)
  17415. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  17416. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  17417. * @returns false if defines are considered not dirty and have not been checked
  17418. */
  17419. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  17420. /**
  17421. * Prepares the defines related to the light information passed in parameter
  17422. * @param scene The scene we are intending to draw
  17423. * @param mesh The mesh the effect is compiling for
  17424. * @param defines The defines to update
  17425. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  17426. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  17427. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  17428. * @returns true if normals will be required for the rest of the effect
  17429. */
  17430. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  17431. /**
  17432. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  17433. * that won t be acctive due to defines being turned off.
  17434. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  17435. * @param samplersList The samplers list
  17436. * @param defines The defines helping in the list generation
  17437. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  17438. */
  17439. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  17440. /**
  17441. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  17442. * @param defines The defines to update while falling back
  17443. * @param fallbacks The authorized effect fallbacks
  17444. * @param maxSimultaneousLights The maximum number of lights allowed
  17445. * @param rank the current rank of the Effect
  17446. * @returns The newly affected rank
  17447. */
  17448. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  17449. /**
  17450. * Prepares the list of attributes required for morph targets according to the effect defines.
  17451. * @param attribs The current list of supported attribs
  17452. * @param mesh The mesh to prepare the morph targets attributes for
  17453. * @param defines The current Defines of the effect
  17454. */
  17455. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  17456. /**
  17457. * Prepares the list of attributes required for bones according to the effect defines.
  17458. * @param attribs The current list of supported attribs
  17459. * @param mesh The mesh to prepare the bones attributes for
  17460. * @param defines The current Defines of the effect
  17461. * @param fallbacks The current efffect fallback strategy
  17462. */
  17463. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  17464. /**
  17465. * Prepares the list of attributes required for instances according to the effect defines.
  17466. * @param attribs The current list of supported attribs
  17467. * @param defines The current Defines of the effect
  17468. */
  17469. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  17470. /**
  17471. * Binds the light shadow information to the effect for the given mesh.
  17472. * @param light The light containing the generator
  17473. * @param scene The scene the lights belongs to
  17474. * @param mesh The mesh we are binding the information to render
  17475. * @param lightIndex The light index in the effect used to render the mesh
  17476. * @param effect The effect we are binding the data to
  17477. */
  17478. static BindLightShadow(light: Light, scene: Scene, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  17479. /**
  17480. * Binds the light information to the effect.
  17481. * @param light The light containing the generator
  17482. * @param effect The effect we are binding the data to
  17483. * @param lightIndex The light index in the effect used to render
  17484. */
  17485. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  17486. /**
  17487. * Binds the lights information from the scene to the effect for the given mesh.
  17488. * @param scene The scene the lights belongs to
  17489. * @param mesh The mesh we are binding the information to render
  17490. * @param effect The effect we are binding the data to
  17491. * @param defines The generated defines for the effect
  17492. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  17493. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  17494. */
  17495. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  17496. /**
  17497. * Binds the fog information from the scene to the effect for the given mesh.
  17498. * @param scene The scene the lights belongs to
  17499. * @param mesh The mesh we are binding the information to render
  17500. * @param effect The effect we are binding the data to
  17501. */
  17502. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect): void;
  17503. /**
  17504. * Binds the bones information from the mesh to the effect.
  17505. * @param mesh The mesh we are binding the information to render
  17506. * @param effect The effect we are binding the data to
  17507. */
  17508. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  17509. /**
  17510. * Binds the morph targets information from the mesh to the effect.
  17511. * @param abstractMesh The mesh we are binding the information to render
  17512. * @param effect The effect we are binding the data to
  17513. */
  17514. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  17515. /**
  17516. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  17517. * @param defines The generated defines used in the effect
  17518. * @param effect The effect we are binding the data to
  17519. * @param scene The scene we are willing to render with logarithmic scale for
  17520. */
  17521. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  17522. /**
  17523. * Binds the clip plane information from the scene to the effect.
  17524. * @param scene The scene the clip plane information are extracted from
  17525. * @param effect The effect we are binding the data to
  17526. */
  17527. static BindClipPlane(effect: Effect, scene: Scene): void;
  17528. }
  17529. }
  17530. declare module BABYLON {
  17531. class MultiMaterial extends Material {
  17532. private _subMaterials;
  17533. subMaterials: Nullable<Material>[];
  17534. constructor(name: string, scene: Scene);
  17535. private _hookArray(array);
  17536. getSubMaterial(index: number): Nullable<Material>;
  17537. getActiveTextures(): BaseTexture[];
  17538. getClassName(): string;
  17539. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  17540. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  17541. serialize(): any;
  17542. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  17543. }
  17544. }
  17545. declare module BABYLON {
  17546. class PushMaterial extends Material {
  17547. protected _activeEffect: Effect;
  17548. protected _normalMatrix: Matrix;
  17549. constructor(name: string, scene: Scene);
  17550. getEffect(): Effect;
  17551. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  17552. /**
  17553. * Binds the given world matrix to the active effect
  17554. *
  17555. * @param world the matrix to bind
  17556. */
  17557. bindOnlyWorldMatrix(world: Matrix): void;
  17558. /**
  17559. * Binds the given normal matrix to the active effect
  17560. *
  17561. * @param normalMatrix the matrix to bind
  17562. */
  17563. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  17564. bind(world: Matrix, mesh?: Mesh): void;
  17565. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  17566. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  17567. }
  17568. }
  17569. declare module BABYLON {
  17570. class ShaderMaterial extends Material {
  17571. private _shaderPath;
  17572. private _options;
  17573. private _textures;
  17574. private _textureArrays;
  17575. private _floats;
  17576. private _ints;
  17577. private _floatsArrays;
  17578. private _colors3;
  17579. private _colors3Arrays;
  17580. private _colors4;
  17581. private _vectors2;
  17582. private _vectors3;
  17583. private _vectors4;
  17584. private _matrices;
  17585. private _matrices3x3;
  17586. private _matrices2x2;
  17587. private _vectors2Arrays;
  17588. private _vectors3Arrays;
  17589. private _cachedWorldViewMatrix;
  17590. private _renderId;
  17591. constructor(name: string, scene: Scene, shaderPath: any, options: any);
  17592. getClassName(): string;
  17593. needAlphaBlending(): boolean;
  17594. needAlphaTesting(): boolean;
  17595. private _checkUniform(uniformName);
  17596. setTexture(name: string, texture: Texture): ShaderMaterial;
  17597. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  17598. setFloat(name: string, value: number): ShaderMaterial;
  17599. setInt(name: string, value: number): ShaderMaterial;
  17600. setFloats(name: string, value: number[]): ShaderMaterial;
  17601. setColor3(name: string, value: Color3): ShaderMaterial;
  17602. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  17603. setColor4(name: string, value: Color4): ShaderMaterial;
  17604. setVector2(name: string, value: Vector2): ShaderMaterial;
  17605. setVector3(name: string, value: Vector3): ShaderMaterial;
  17606. setVector4(name: string, value: Vector4): ShaderMaterial;
  17607. setMatrix(name: string, value: Matrix): ShaderMaterial;
  17608. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  17609. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  17610. setArray2(name: string, value: number[]): ShaderMaterial;
  17611. setArray3(name: string, value: number[]): ShaderMaterial;
  17612. private _checkCache(scene, mesh?, useInstances?);
  17613. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  17614. bindOnlyWorldMatrix(world: Matrix): void;
  17615. bind(world: Matrix, mesh?: Mesh): void;
  17616. getActiveTextures(): BaseTexture[];
  17617. hasTexture(texture: BaseTexture): boolean;
  17618. clone(name: string): ShaderMaterial;
  17619. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  17620. serialize(): any;
  17621. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  17622. }
  17623. }
  17624. declare module BABYLON {
  17625. /** @hidden */
  17626. class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  17627. MAINUV1: boolean;
  17628. MAINUV2: boolean;
  17629. DIFFUSE: boolean;
  17630. DIFFUSEDIRECTUV: number;
  17631. AMBIENT: boolean;
  17632. AMBIENTDIRECTUV: number;
  17633. OPACITY: boolean;
  17634. OPACITYDIRECTUV: number;
  17635. OPACITYRGB: boolean;
  17636. REFLECTION: boolean;
  17637. EMISSIVE: boolean;
  17638. EMISSIVEDIRECTUV: number;
  17639. SPECULAR: boolean;
  17640. SPECULARDIRECTUV: number;
  17641. BUMP: boolean;
  17642. BUMPDIRECTUV: number;
  17643. PARALLAX: boolean;
  17644. PARALLAXOCCLUSION: boolean;
  17645. SPECULAROVERALPHA: boolean;
  17646. CLIPPLANE: boolean;
  17647. ALPHATEST: boolean;
  17648. DEPTHPREPASS: boolean;
  17649. ALPHAFROMDIFFUSE: boolean;
  17650. POINTSIZE: boolean;
  17651. FOG: boolean;
  17652. SPECULARTERM: boolean;
  17653. DIFFUSEFRESNEL: boolean;
  17654. OPACITYFRESNEL: boolean;
  17655. REFLECTIONFRESNEL: boolean;
  17656. REFRACTIONFRESNEL: boolean;
  17657. EMISSIVEFRESNEL: boolean;
  17658. FRESNEL: boolean;
  17659. NORMAL: boolean;
  17660. UV1: boolean;
  17661. UV2: boolean;
  17662. VERTEXCOLOR: boolean;
  17663. VERTEXALPHA: boolean;
  17664. NUM_BONE_INFLUENCERS: number;
  17665. BonesPerMesh: number;
  17666. INSTANCES: boolean;
  17667. GLOSSINESS: boolean;
  17668. ROUGHNESS: boolean;
  17669. EMISSIVEASILLUMINATION: boolean;
  17670. LINKEMISSIVEWITHDIFFUSE: boolean;
  17671. REFLECTIONFRESNELFROMSPECULAR: boolean;
  17672. LIGHTMAP: boolean;
  17673. LIGHTMAPDIRECTUV: number;
  17674. OBJECTSPACE_NORMALMAP: boolean;
  17675. USELIGHTMAPASSHADOWMAP: boolean;
  17676. REFLECTIONMAP_3D: boolean;
  17677. REFLECTIONMAP_SPHERICAL: boolean;
  17678. REFLECTIONMAP_PLANAR: boolean;
  17679. REFLECTIONMAP_CUBIC: boolean;
  17680. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  17681. REFLECTIONMAP_PROJECTION: boolean;
  17682. REFLECTIONMAP_SKYBOX: boolean;
  17683. REFLECTIONMAP_EXPLICIT: boolean;
  17684. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  17685. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  17686. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  17687. INVERTCUBICMAP: boolean;
  17688. LOGARITHMICDEPTH: boolean;
  17689. REFRACTION: boolean;
  17690. REFRACTIONMAP_3D: boolean;
  17691. REFLECTIONOVERALPHA: boolean;
  17692. TWOSIDEDLIGHTING: boolean;
  17693. SHADOWFLOAT: boolean;
  17694. MORPHTARGETS: boolean;
  17695. MORPHTARGETS_NORMAL: boolean;
  17696. MORPHTARGETS_TANGENT: boolean;
  17697. NUM_MORPH_INFLUENCERS: number;
  17698. NONUNIFORMSCALING: boolean;
  17699. PREMULTIPLYALPHA: boolean;
  17700. IMAGEPROCESSING: boolean;
  17701. VIGNETTE: boolean;
  17702. VIGNETTEBLENDMODEMULTIPLY: boolean;
  17703. VIGNETTEBLENDMODEOPAQUE: boolean;
  17704. TONEMAPPING: boolean;
  17705. CONTRAST: boolean;
  17706. COLORCURVES: boolean;
  17707. COLORGRADING: boolean;
  17708. COLORGRADING3D: boolean;
  17709. SAMPLER3DGREENDEPTH: boolean;
  17710. SAMPLER3DBGRMAP: boolean;
  17711. IMAGEPROCESSINGPOSTPROCESS: boolean;
  17712. /**
  17713. * If the reflection texture on this material is in linear color space
  17714. * @hidden
  17715. */
  17716. IS_REFLECTION_LINEAR: boolean;
  17717. /**
  17718. * If the refraction texture on this material is in linear color space
  17719. * @hidden
  17720. */
  17721. IS_REFRACTION_LINEAR: boolean;
  17722. EXPOSURE: boolean;
  17723. constructor();
  17724. setReflectionMode(modeToEnable: string): void;
  17725. }
  17726. class StandardMaterial extends PushMaterial {
  17727. private _diffuseTexture;
  17728. diffuseTexture: Nullable<BaseTexture>;
  17729. private _ambientTexture;
  17730. ambientTexture: Nullable<BaseTexture>;
  17731. private _opacityTexture;
  17732. opacityTexture: Nullable<BaseTexture>;
  17733. private _reflectionTexture;
  17734. reflectionTexture: Nullable<BaseTexture>;
  17735. private _emissiveTexture;
  17736. emissiveTexture: Nullable<BaseTexture>;
  17737. private _specularTexture;
  17738. specularTexture: Nullable<BaseTexture>;
  17739. private _bumpTexture;
  17740. bumpTexture: Nullable<BaseTexture>;
  17741. private _lightmapTexture;
  17742. lightmapTexture: Nullable<BaseTexture>;
  17743. private _refractionTexture;
  17744. refractionTexture: Nullable<BaseTexture>;
  17745. ambientColor: Color3;
  17746. diffuseColor: Color3;
  17747. specularColor: Color3;
  17748. emissiveColor: Color3;
  17749. specularPower: number;
  17750. private _useAlphaFromDiffuseTexture;
  17751. useAlphaFromDiffuseTexture: boolean;
  17752. private _useEmissiveAsIllumination;
  17753. useEmissiveAsIllumination: boolean;
  17754. private _linkEmissiveWithDiffuse;
  17755. linkEmissiveWithDiffuse: boolean;
  17756. private _useSpecularOverAlpha;
  17757. useSpecularOverAlpha: boolean;
  17758. private _useReflectionOverAlpha;
  17759. useReflectionOverAlpha: boolean;
  17760. private _disableLighting;
  17761. disableLighting: boolean;
  17762. private _useObjectSpaceNormalMap;
  17763. /**
  17764. * Allows using an object space normal map (instead of tangent space).
  17765. */
  17766. useObjectSpaceNormalMap: boolean;
  17767. private _useParallax;
  17768. useParallax: boolean;
  17769. private _useParallaxOcclusion;
  17770. useParallaxOcclusion: boolean;
  17771. parallaxScaleBias: number;
  17772. private _roughness;
  17773. roughness: number;
  17774. indexOfRefraction: number;
  17775. invertRefractionY: boolean;
  17776. /**
  17777. * Defines the alpha limits in alpha test mode
  17778. */
  17779. alphaCutOff: number;
  17780. private _useLightmapAsShadowmap;
  17781. useLightmapAsShadowmap: boolean;
  17782. private _diffuseFresnelParameters;
  17783. diffuseFresnelParameters: FresnelParameters;
  17784. private _opacityFresnelParameters;
  17785. opacityFresnelParameters: FresnelParameters;
  17786. private _reflectionFresnelParameters;
  17787. reflectionFresnelParameters: FresnelParameters;
  17788. private _refractionFresnelParameters;
  17789. refractionFresnelParameters: FresnelParameters;
  17790. private _emissiveFresnelParameters;
  17791. emissiveFresnelParameters: FresnelParameters;
  17792. private _useReflectionFresnelFromSpecular;
  17793. useReflectionFresnelFromSpecular: boolean;
  17794. private _useGlossinessFromSpecularMapAlpha;
  17795. useGlossinessFromSpecularMapAlpha: boolean;
  17796. private _maxSimultaneousLights;
  17797. maxSimultaneousLights: number;
  17798. /**
  17799. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  17800. */
  17801. private _invertNormalMapX;
  17802. invertNormalMapX: boolean;
  17803. /**
  17804. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  17805. */
  17806. private _invertNormalMapY;
  17807. invertNormalMapY: boolean;
  17808. /**
  17809. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  17810. */
  17811. private _twoSidedLighting;
  17812. twoSidedLighting: boolean;
  17813. /**
  17814. * Default configuration related to image processing available in the standard Material.
  17815. */
  17816. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  17817. /**
  17818. * Gets the image processing configuration used either in this material.
  17819. */
  17820. /**
  17821. * Sets the Default image processing configuration used either in the this material.
  17822. *
  17823. * If sets to null, the scene one is in use.
  17824. */
  17825. imageProcessingConfiguration: ImageProcessingConfiguration;
  17826. /**
  17827. * Keep track of the image processing observer to allow dispose and replace.
  17828. */
  17829. private _imageProcessingObserver;
  17830. /**
  17831. * Attaches a new image processing configuration to the Standard Material.
  17832. * @param configuration
  17833. */
  17834. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  17835. /**
  17836. * Gets wether the color curves effect is enabled.
  17837. */
  17838. /**
  17839. * Sets wether the color curves effect is enabled.
  17840. */
  17841. cameraColorCurvesEnabled: boolean;
  17842. /**
  17843. * Gets wether the color grading effect is enabled.
  17844. */
  17845. /**
  17846. * Gets wether the color grading effect is enabled.
  17847. */
  17848. cameraColorGradingEnabled: boolean;
  17849. /**
  17850. * Gets wether tonemapping is enabled or not.
  17851. */
  17852. /**
  17853. * Sets wether tonemapping is enabled or not
  17854. */
  17855. cameraToneMappingEnabled: boolean;
  17856. /**
  17857. * The camera exposure used on this material.
  17858. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  17859. * This corresponds to a photographic exposure.
  17860. */
  17861. /**
  17862. * The camera exposure used on this material.
  17863. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  17864. * This corresponds to a photographic exposure.
  17865. */
  17866. cameraExposure: number;
  17867. /**
  17868. * Gets The camera contrast used on this material.
  17869. */
  17870. /**
  17871. * Sets The camera contrast used on this material.
  17872. */
  17873. cameraContrast: number;
  17874. /**
  17875. * Gets the Color Grading 2D Lookup Texture.
  17876. */
  17877. /**
  17878. * Sets the Color Grading 2D Lookup Texture.
  17879. */
  17880. cameraColorGradingTexture: Nullable<BaseTexture>;
  17881. /**
  17882. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  17883. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  17884. * 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;
  17885. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  17886. */
  17887. /**
  17888. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  17889. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  17890. * 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;
  17891. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  17892. */
  17893. cameraColorCurves: Nullable<ColorCurves>;
  17894. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  17895. protected _renderTargets: SmartArray<RenderTargetTexture>;
  17896. protected _worldViewProjectionMatrix: Matrix;
  17897. protected _globalAmbientColor: Color3;
  17898. protected _useLogarithmicDepth: boolean;
  17899. constructor(name: string, scene: Scene);
  17900. getClassName(): string;
  17901. useLogarithmicDepth: boolean;
  17902. needAlphaBlending(): boolean;
  17903. needAlphaTesting(): boolean;
  17904. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  17905. getAlphaTestTexture(): Nullable<BaseTexture>;
  17906. /**
  17907. * Child classes can use it to update shaders
  17908. */
  17909. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  17910. buildUniformLayout(): void;
  17911. unbind(): void;
  17912. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  17913. getAnimatables(): IAnimatable[];
  17914. getActiveTextures(): BaseTexture[];
  17915. hasTexture(texture: BaseTexture): boolean;
  17916. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  17917. clone(name: string): StandardMaterial;
  17918. serialize(): any;
  17919. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  17920. private static _DiffuseTextureEnabled: boolean;
  17921. static DiffuseTextureEnabled: boolean;
  17922. private static _AmbientTextureEnabled: boolean;
  17923. static AmbientTextureEnabled: boolean;
  17924. private static _OpacityTextureEnabled: boolean;
  17925. static OpacityTextureEnabled: boolean;
  17926. private static _ReflectionTextureEnabled: boolean;
  17927. static ReflectionTextureEnabled: boolean;
  17928. private static _EmissiveTextureEnabled: boolean;
  17929. static EmissiveTextureEnabled: boolean;
  17930. private static _SpecularTextureEnabled: boolean;
  17931. static SpecularTextureEnabled: boolean;
  17932. private static _BumpTextureEnabled: boolean;
  17933. static BumpTextureEnabled: boolean;
  17934. private static _LightmapTextureEnabled: boolean;
  17935. static LightmapTextureEnabled: boolean;
  17936. private static _RefractionTextureEnabled: boolean;
  17937. static RefractionTextureEnabled: boolean;
  17938. private static _ColorGradingTextureEnabled: boolean;
  17939. static ColorGradingTextureEnabled: boolean;
  17940. private static _FresnelEnabled: boolean;
  17941. static FresnelEnabled: boolean;
  17942. }
  17943. }
  17944. declare module BABYLON {
  17945. class UniformBuffer {
  17946. private _engine;
  17947. private _buffer;
  17948. private _data;
  17949. private _bufferData;
  17950. private _dynamic?;
  17951. private _uniformLocations;
  17952. private _uniformSizes;
  17953. private _uniformLocationPointer;
  17954. private _needSync;
  17955. private _noUBO;
  17956. private _currentEffect;
  17957. private static _MAX_UNIFORM_SIZE;
  17958. private static _tempBuffer;
  17959. /**
  17960. * Wrapper for updateUniform.
  17961. * @method updateMatrix3x3
  17962. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  17963. * @param {Float32Array} matrix
  17964. */
  17965. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  17966. /**
  17967. * Wrapper for updateUniform.
  17968. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  17969. * @param {Float32Array} matrix
  17970. */
  17971. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  17972. /**
  17973. * Wrapper for updateUniform.
  17974. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  17975. * @param {number} x
  17976. */
  17977. updateFloat: (name: string, x: number) => void;
  17978. /**
  17979. * Wrapper for updateUniform.
  17980. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  17981. * @param {number} x
  17982. * @param {number} y
  17983. * @param {string} [suffix] Suffix to add to the uniform name.
  17984. */
  17985. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  17986. /**
  17987. * Wrapper for updateUniform.
  17988. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  17989. * @param {number} x
  17990. * @param {number} y
  17991. * @param {number} z
  17992. * @param {string} [suffix] Suffix to add to the uniform name.
  17993. */
  17994. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  17995. /**
  17996. * Wrapper for updateUniform.
  17997. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  17998. * @param {number} x
  17999. * @param {number} y
  18000. * @param {number} z
  18001. * @param {number} w
  18002. * @param {string} [suffix] Suffix to add to the uniform name.
  18003. */
  18004. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  18005. /**
  18006. * Wrapper for updateUniform.
  18007. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  18008. * @param {Matrix} A 4x4 matrix.
  18009. */
  18010. updateMatrix: (name: string, mat: Matrix) => void;
  18011. /**
  18012. * Wrapper for updateUniform.
  18013. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  18014. * @param {Vector3} vector
  18015. */
  18016. updateVector3: (name: string, vector: Vector3) => void;
  18017. /**
  18018. * Wrapper for updateUniform.
  18019. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  18020. * @param {Vector4} vector
  18021. */
  18022. updateVector4: (name: string, vector: Vector4) => void;
  18023. /**
  18024. * Wrapper for updateUniform.
  18025. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  18026. * @param {Color3} color
  18027. * @param {string} [suffix] Suffix to add to the uniform name.
  18028. */
  18029. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  18030. /**
  18031. * Wrapper for updateUniform.
  18032. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  18033. * @param {Color3} color
  18034. * @param {number} alpha
  18035. * @param {string} [suffix] Suffix to add to the uniform name.
  18036. */
  18037. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  18038. /**
  18039. * Uniform buffer objects.
  18040. *
  18041. * Handles blocks of uniform on the GPU.
  18042. *
  18043. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  18044. *
  18045. * For more information, please refer to :
  18046. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  18047. */
  18048. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  18049. /**
  18050. * Indicates if the buffer is using the WebGL2 UBO implementation,
  18051. * or just falling back on setUniformXXX calls.
  18052. */
  18053. readonly useUbo: boolean;
  18054. /**
  18055. * Indicates if the WebGL underlying uniform buffer is in sync
  18056. * with the javascript cache data.
  18057. */
  18058. readonly isSync: boolean;
  18059. /**
  18060. * Indicates if the WebGL underlying uniform buffer is dynamic.
  18061. * Also, a dynamic UniformBuffer will disable cache verification and always
  18062. * update the underlying WebGL uniform buffer to the GPU.
  18063. */
  18064. isDynamic(): boolean;
  18065. /**
  18066. * The data cache on JS side.
  18067. */
  18068. getData(): Float32Array;
  18069. /**
  18070. * The underlying WebGL Uniform buffer.
  18071. */
  18072. getBuffer(): Nullable<WebGLBuffer>;
  18073. /**
  18074. * std140 layout specifies how to align data within an UBO structure.
  18075. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  18076. * for specs.
  18077. */
  18078. private _fillAlignment(size);
  18079. /**
  18080. * Adds an uniform in the buffer.
  18081. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  18082. * for the layout to be correct !
  18083. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  18084. * @param {number|number[]} size Data size, or data directly.
  18085. */
  18086. addUniform(name: string, size: number | number[]): void;
  18087. /**
  18088. * Wrapper for addUniform.
  18089. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  18090. * @param {Matrix} mat A 4x4 matrix.
  18091. */
  18092. addMatrix(name: string, mat: Matrix): void;
  18093. /**
  18094. * Wrapper for addUniform.
  18095. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  18096. * @param {number} x
  18097. * @param {number} y
  18098. */
  18099. addFloat2(name: string, x: number, y: number): void;
  18100. /**
  18101. * Wrapper for addUniform.
  18102. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  18103. * @param {number} x
  18104. * @param {number} y
  18105. * @param {number} z
  18106. */
  18107. addFloat3(name: string, x: number, y: number, z: number): void;
  18108. /**
  18109. * Wrapper for addUniform.
  18110. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  18111. * @param {Color3} color
  18112. */
  18113. addColor3(name: string, color: Color3): void;
  18114. /**
  18115. * Wrapper for addUniform.
  18116. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  18117. * @param {Color3} color
  18118. * @param {number} alpha
  18119. */
  18120. addColor4(name: string, color: Color3, alpha: number): void;
  18121. /**
  18122. * Wrapper for addUniform.
  18123. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  18124. * @param {Vector3} vector
  18125. */
  18126. addVector3(name: string, vector: Vector3): void;
  18127. /**
  18128. * Wrapper for addUniform.
  18129. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  18130. */
  18131. addMatrix3x3(name: string): void;
  18132. /**
  18133. * Wrapper for addUniform.
  18134. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  18135. */
  18136. addMatrix2x2(name: string): void;
  18137. /**
  18138. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  18139. */
  18140. create(): void;
  18141. /**
  18142. * Updates the WebGL Uniform Buffer on the GPU.
  18143. * If the `dynamic` flag is set to true, no cache comparison is done.
  18144. * Otherwise, the buffer will be updated only if the cache differs.
  18145. */
  18146. update(): void;
  18147. /**
  18148. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  18149. * @param {string} uniformName Name of the uniform, as used in the uniform block in the shader.
  18150. * @param {number[]|Float32Array} data Flattened data
  18151. * @param {number} size Size of the data.
  18152. */
  18153. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  18154. private _updateMatrix3x3ForUniform(name, matrix);
  18155. private _updateMatrix3x3ForEffect(name, matrix);
  18156. private _updateMatrix2x2ForEffect(name, matrix);
  18157. private _updateMatrix2x2ForUniform(name, matrix);
  18158. private _updateFloatForEffect(name, x);
  18159. private _updateFloatForUniform(name, x);
  18160. private _updateFloat2ForEffect(name, x, y, suffix?);
  18161. private _updateFloat2ForUniform(name, x, y, suffix?);
  18162. private _updateFloat3ForEffect(name, x, y, z, suffix?);
  18163. private _updateFloat3ForUniform(name, x, y, z, suffix?);
  18164. private _updateFloat4ForEffect(name, x, y, z, w, suffix?);
  18165. private _updateFloat4ForUniform(name, x, y, z, w, suffix?);
  18166. private _updateMatrixForEffect(name, mat);
  18167. private _updateMatrixForUniform(name, mat);
  18168. private _updateVector3ForEffect(name, vector);
  18169. private _updateVector3ForUniform(name, vector);
  18170. private _updateVector4ForEffect(name, vector);
  18171. private _updateVector4ForUniform(name, vector);
  18172. private _updateColor3ForEffect(name, color, suffix?);
  18173. private _updateColor3ForUniform(name, color, suffix?);
  18174. private _updateColor4ForEffect(name, color, alpha, suffix?);
  18175. private _updateColor4ForUniform(name, color, alpha, suffix?);
  18176. /**
  18177. * Sets a sampler uniform on the effect.
  18178. * @param {string} name Name of the sampler.
  18179. * @param {Texture} texture
  18180. */
  18181. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  18182. /**
  18183. * Directly updates the value of the uniform in the cache AND on the GPU.
  18184. * @param {string} uniformName Name of the uniform, as used in the uniform block in the shader.
  18185. * @param {number[]|Float32Array} data Flattened data
  18186. */
  18187. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  18188. /**
  18189. * Binds this uniform buffer to an effect.
  18190. * @param {Effect} effect
  18191. * @param {string} name Name of the uniform block in the shader.
  18192. */
  18193. bindToEffect(effect: Effect, name: string): void;
  18194. /**
  18195. * Disposes the uniform buffer.
  18196. */
  18197. dispose(): void;
  18198. }
  18199. }
  18200. declare module BABYLON {
  18201. /**
  18202. * Defines a target to use with MorphTargetManager
  18203. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  18204. */
  18205. class MorphTarget implements IAnimatable {
  18206. /** defines the name of the target */
  18207. name: string;
  18208. /**
  18209. * Gets or sets the list of animations
  18210. */
  18211. animations: Animation[];
  18212. private _scene;
  18213. private _positions;
  18214. private _normals;
  18215. private _tangents;
  18216. private _influence;
  18217. /**
  18218. * Observable raised when the influence changes
  18219. */
  18220. onInfluenceChanged: Observable<boolean>;
  18221. /**
  18222. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  18223. */
  18224. influence: number;
  18225. private _animationPropertiesOverride;
  18226. /**
  18227. * Gets or sets the animation properties override
  18228. */
  18229. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  18230. /**
  18231. * Creates a new MorphTarget
  18232. * @param name defines the name of the target
  18233. * @param influence defines the influence to use
  18234. */
  18235. constructor(
  18236. /** defines the name of the target */
  18237. name: string, influence?: number, scene?: Nullable<Scene>);
  18238. /**
  18239. * Gets a boolean defining if the target contains position data
  18240. */
  18241. readonly hasPositions: boolean;
  18242. /**
  18243. * Gets a boolean defining if the target contains normal data
  18244. */
  18245. readonly hasNormals: boolean;
  18246. /**
  18247. * Gets a boolean defining if the target contains tangent data
  18248. */
  18249. readonly hasTangents: boolean;
  18250. /**
  18251. * Affects position data to this target
  18252. * @param data defines the position data to use
  18253. */
  18254. setPositions(data: Nullable<FloatArray>): void;
  18255. /**
  18256. * Gets the position data stored in this target
  18257. * @returns a FloatArray containing the position data (or null if not present)
  18258. */
  18259. getPositions(): Nullable<FloatArray>;
  18260. /**
  18261. * Affects normal data to this target
  18262. * @param data defines the normal data to use
  18263. */
  18264. setNormals(data: Nullable<FloatArray>): void;
  18265. /**
  18266. * Gets the normal data stored in this target
  18267. * @returns a FloatArray containing the normal data (or null if not present)
  18268. */
  18269. getNormals(): Nullable<FloatArray>;
  18270. /**
  18271. * Affects tangent data to this target
  18272. * @param data defines the tangent data to use
  18273. */
  18274. setTangents(data: Nullable<FloatArray>): void;
  18275. /**
  18276. * Gets the tangent data stored in this target
  18277. * @returns a FloatArray containing the tangent data (or null if not present)
  18278. */
  18279. getTangents(): Nullable<FloatArray>;
  18280. /**
  18281. * Serializes the current target into a Serialization object
  18282. * @returns the serialized object
  18283. */
  18284. serialize(): any;
  18285. /**
  18286. * Creates a new target from serialized data
  18287. * @param serializationObject defines the serialized data to use
  18288. * @returns a new MorphTarget
  18289. */
  18290. static Parse(serializationObject: any): MorphTarget;
  18291. /**
  18292. * Creates a MorphTarget from mesh data
  18293. * @param mesh defines the source mesh
  18294. * @param name defines the name to use for the new target
  18295. * @param influence defines the influence to attach to the target
  18296. * @returns a new MorphTarget
  18297. */
  18298. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  18299. }
  18300. }
  18301. declare module BABYLON {
  18302. /**
  18303. * This class is used to deform meshes using morphing between different targets
  18304. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  18305. */
  18306. class MorphTargetManager {
  18307. private _targets;
  18308. private _targetObservable;
  18309. private _activeTargets;
  18310. private _scene;
  18311. private _influences;
  18312. private _supportsNormals;
  18313. private _supportsTangents;
  18314. private _vertexCount;
  18315. private _uniqueId;
  18316. private _tempInfluences;
  18317. /**
  18318. * Creates a new MorphTargetManager
  18319. * @param scene defines the current scene
  18320. */
  18321. constructor(scene?: Nullable<Scene>);
  18322. /**
  18323. * Gets the unique ID of this manager
  18324. */
  18325. readonly uniqueId: number;
  18326. /**
  18327. * Gets the number of vertices handled by this manager
  18328. */
  18329. readonly vertexCount: number;
  18330. /**
  18331. * Gets a boolean indicating if this manager supports morphing of normals
  18332. */
  18333. readonly supportsNormals: boolean;
  18334. /**
  18335. * Gets a boolean indicating if this manager supports morphing of tangents
  18336. */
  18337. readonly supportsTangents: boolean;
  18338. /**
  18339. * Gets the number of targets stored in this manager
  18340. */
  18341. readonly numTargets: number;
  18342. /**
  18343. * Gets the number of influencers (ie. the number of targets with influences > 0)
  18344. */
  18345. readonly numInfluencers: number;
  18346. /**
  18347. * Gets the list of influences (one per target)
  18348. */
  18349. readonly influences: Float32Array;
  18350. /**
  18351. * Gets the active target at specified index. An active target is a target with an influence > 0
  18352. * @param index defines the index to check
  18353. * @returns the requested target
  18354. */
  18355. getActiveTarget(index: number): MorphTarget;
  18356. /**
  18357. * Gets the target at specified index
  18358. * @param index defines the index to check
  18359. * @returns the requested target
  18360. */
  18361. getTarget(index: number): MorphTarget;
  18362. /**
  18363. * Add a new target to this manager
  18364. * @param target defines the target to add
  18365. */
  18366. addTarget(target: MorphTarget): void;
  18367. /**
  18368. * Removes a target from the manager
  18369. * @param target defines the target to remove
  18370. */
  18371. removeTarget(target: MorphTarget): void;
  18372. /**
  18373. * Serializes the current manager into a Serialization object
  18374. * @returns the serialized object
  18375. */
  18376. serialize(): any;
  18377. private _syncActiveTargets(needUpdate);
  18378. /**
  18379. * Syncrhonize the targets with all the meshes using this morph target manager
  18380. */
  18381. synchronize(): void;
  18382. /**
  18383. * Creates a new MorphTargetManager from serialized data
  18384. * @param serializationObject defines the serialized data
  18385. * @param scene defines the hosting scene
  18386. * @returns the new MorphTargetManager
  18387. */
  18388. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  18389. }
  18390. }
  18391. declare module BABYLON {
  18392. /**
  18393. * This represents a GPU particle system in Babylon
  18394. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  18395. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  18396. */
  18397. class GPUParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  18398. /**
  18399. * The id of the Particle system.
  18400. */
  18401. id: string;
  18402. /**
  18403. * The friendly name of the Particle system.
  18404. */
  18405. name: string;
  18406. /**
  18407. * The emitter represents the Mesh or position we are attaching the particle system to.
  18408. */
  18409. emitter: Nullable<AbstractMesh | Vector3>;
  18410. /**
  18411. * The rendering group used by the Particle system to chose when to render.
  18412. */
  18413. renderingGroupId: number;
  18414. /**
  18415. * The layer mask we are rendering the particles through.
  18416. */
  18417. layerMask: number;
  18418. private _capacity;
  18419. private _activeCount;
  18420. private _currentActiveCount;
  18421. private _accumulatedCount;
  18422. private _renderEffect;
  18423. private _updateEffect;
  18424. private _buffer0;
  18425. private _buffer1;
  18426. private _spriteBuffer;
  18427. private _updateVAO;
  18428. private _renderVAO;
  18429. private _targetIndex;
  18430. private _sourceBuffer;
  18431. private _targetBuffer;
  18432. private _scene;
  18433. private _engine;
  18434. private _currentRenderId;
  18435. private _started;
  18436. private _stopped;
  18437. private _timeDelta;
  18438. private _randomTexture;
  18439. private _randomTexture2;
  18440. private _attributesStrideSize;
  18441. private _updateEffectOptions;
  18442. private _randomTextureSize;
  18443. private _actualFrame;
  18444. /**
  18445. * List of animations used by the particle system.
  18446. */
  18447. animations: Animation[];
  18448. /**
  18449. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  18450. */
  18451. static readonly IsSupported: boolean;
  18452. /**
  18453. * An event triggered when the system is disposed.
  18454. */
  18455. onDisposeObservable: Observable<GPUParticleSystem>;
  18456. /**
  18457. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  18458. */
  18459. updateSpeed: number;
  18460. /**
  18461. * The amount of time the particle system is running (depends of the overall update speed).
  18462. */
  18463. targetStopDuration: number;
  18464. /**
  18465. * The texture used to render each particle. (this can be a spritesheet)
  18466. */
  18467. particleTexture: Nullable<Texture>;
  18468. /**
  18469. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  18470. */
  18471. blendMode: number;
  18472. /**
  18473. * Minimum life time of emitting particles.
  18474. */
  18475. minLifeTime: number;
  18476. /**
  18477. * Maximum life time of emitting particles.
  18478. */
  18479. maxLifeTime: number;
  18480. /**
  18481. * Minimum Size of emitting particles.
  18482. */
  18483. minSize: number;
  18484. /**
  18485. * Maximum Size of emitting particles.
  18486. */
  18487. maxSize: number;
  18488. /**
  18489. * Minimum scale of emitting particles on X axis.
  18490. */
  18491. minScaleX: number;
  18492. /**
  18493. * Maximum scale of emitting particles on X axis.
  18494. */
  18495. maxScaleX: number;
  18496. /**
  18497. * Minimum scale of emitting particles on Y axis.
  18498. */
  18499. minScaleY: number;
  18500. /**
  18501. * Maximum scale of emitting particles on Y axis.
  18502. */
  18503. maxScaleY: number;
  18504. /**
  18505. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18506. */
  18507. color1: Color4;
  18508. /**
  18509. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18510. */
  18511. color2: Color4;
  18512. /**
  18513. * Color the particle will have at the end of its lifetime.
  18514. */
  18515. colorDead: Color4;
  18516. /**
  18517. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  18518. */
  18519. emitRate: number;
  18520. /**
  18521. * You can use gravity if you want to give an orientation to your particles.
  18522. */
  18523. gravity: Vector3;
  18524. /**
  18525. * Minimum power of emitting particles.
  18526. */
  18527. minEmitPower: number;
  18528. /**
  18529. * Maximum power of emitting particles.
  18530. */
  18531. maxEmitPower: number;
  18532. /**
  18533. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  18534. */
  18535. minAngularSpeed: number;
  18536. /**
  18537. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  18538. */
  18539. maxAngularSpeed: number;
  18540. /**
  18541. * The particle emitter type defines the emitter used by the particle system.
  18542. * It can be for example box, sphere, or cone...
  18543. */
  18544. particleEmitterType: Nullable<IParticleEmitterType>;
  18545. /**
  18546. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18547. * This only works when particleEmitterTyps is a BoxParticleEmitter
  18548. */
  18549. direction1: Vector3;
  18550. /**
  18551. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18552. * This only works when particleEmitterTyps is a BoxParticleEmitter
  18553. */
  18554. direction2: Vector3;
  18555. /**
  18556. * 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.
  18557. * This only works when particleEmitterTyps is a BoxParticleEmitter
  18558. */
  18559. minEmitBox: Vector3;
  18560. /**
  18561. * 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.
  18562. * This only works when particleEmitterTyps is a BoxParticleEmitter
  18563. */
  18564. maxEmitBox: Vector3;
  18565. /**
  18566. * Gets the maximum number of particles active at the same time.
  18567. * @returns The max number of active particles.
  18568. */
  18569. getCapacity(): number;
  18570. /**
  18571. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  18572. * to override the particles.
  18573. */
  18574. forceDepthWrite: boolean;
  18575. /**
  18576. * Gets or set the number of active particles
  18577. */
  18578. activeParticleCount: number;
  18579. private _preWarmDone;
  18580. /** 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 */
  18581. preWarmCycles: number;
  18582. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  18583. preWarmStepOffset: number;
  18584. /**
  18585. * Gets or sets the minimal initial rotation in radians.
  18586. */
  18587. minInitialRotation: number;
  18588. /**
  18589. * Gets or sets the maximal initial rotation in radians.
  18590. */
  18591. maxInitialRotation: number;
  18592. /**
  18593. * Is this system ready to be used/rendered
  18594. * @return true if the system is ready
  18595. */
  18596. isReady(): boolean;
  18597. /**
  18598. * Gets Wether the system has been started.
  18599. * @returns True if it has been started, otherwise false.
  18600. */
  18601. isStarted(): boolean;
  18602. /**
  18603. * Starts the particle system and begins to emit.
  18604. */
  18605. start(): void;
  18606. /**
  18607. * Stops the particle system.
  18608. */
  18609. stop(): void;
  18610. /**
  18611. * Remove all active particles
  18612. */
  18613. reset(): void;
  18614. /**
  18615. * Returns the string "GPUParticleSystem"
  18616. * @returns a string containing the class name
  18617. */
  18618. getClassName(): string;
  18619. private _isBillboardBased;
  18620. /**
  18621. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  18622. */
  18623. isBillboardBased: boolean;
  18624. private _colorGradients;
  18625. private _colorGradientsTexture;
  18626. /**
  18627. * Gets the current list of color gradients.
  18628. * You must use addColorGradient and removeColorGradient to udpate this list
  18629. * @returns the list of color gradients
  18630. */
  18631. getColorGradients(): Nullable<Array<ColorGradient>>;
  18632. /**
  18633. * Gets the current list of size gradients.
  18634. * You must use addSizeGradient and removeSizeGradient to udpate this list
  18635. * @returns the list of size gradients
  18636. */
  18637. getSizeGradients(): Nullable<Array<FactorGradient>>;
  18638. /**
  18639. * Adds a new color gradient
  18640. * @param gradient defines the gradient to use (between 0 and 1)
  18641. * @param color defines the color to affect to the specified gradient
  18642. */
  18643. addColorGradient(gradient: number, color: Color4): GPUParticleSystem;
  18644. /**
  18645. * Remove a specific color gradient
  18646. * @param gradient defines the gradient to remove
  18647. */
  18648. removeColorGradient(gradient: number): GPUParticleSystem;
  18649. private _sizeGradients;
  18650. private _sizeGradientsTexture;
  18651. /**
  18652. * Adds a new size gradient
  18653. * @param gradient defines the gradient to use (between 0 and 1)
  18654. * @param factor defines the size factor to affect to the specified gradient
  18655. */
  18656. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  18657. /**
  18658. * Remove a specific size gradient
  18659. * @param gradient defines the gradient to remove
  18660. */
  18661. removeSizeGradient(gradient: number): GPUParticleSystem;
  18662. /**
  18663. * Instantiates a GPU particle system.
  18664. * 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.
  18665. * @param name The name of the particle system
  18666. * @param capacity The max number of particles alive at the same time
  18667. * @param scene The scene the particle system belongs to
  18668. */
  18669. constructor(name: string, options: Partial<{
  18670. capacity: number;
  18671. randomTextureSize: number;
  18672. }>, scene: Scene);
  18673. private _createUpdateVAO(source);
  18674. private _createRenderVAO(source, spriteSource);
  18675. private _initialize(force?);
  18676. /** @hidden */
  18677. /** @hidden */
  18678. /**
  18679. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  18680. * @param preWarm defines if we are in the pre-warmimg phase
  18681. */
  18682. animate(preWarm?: boolean): void;
  18683. private _createSizeGradientTexture();
  18684. private _createColorGradientTexture();
  18685. /**
  18686. * Renders the particle system in its current state
  18687. * @param preWarm defines if the system should only update the particles but not render them
  18688. * @returns the current number of particles
  18689. */
  18690. render(preWarm?: boolean): number;
  18691. /**
  18692. * Rebuilds the particle system
  18693. */
  18694. rebuild(): void;
  18695. private _releaseBuffers();
  18696. private _releaseVAOs();
  18697. /**
  18698. * Disposes the particle system and free the associated resources
  18699. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  18700. */
  18701. dispose(disposeTexture?: boolean): void;
  18702. /**
  18703. * Clones the particle system.
  18704. * @param name The name of the cloned object
  18705. * @param newEmitter The new emitter to use
  18706. * @returns the cloned particle system
  18707. */
  18708. clone(name: string, newEmitter: any): Nullable<GPUParticleSystem>;
  18709. /**
  18710. * Serializes the particle system to a JSON object.
  18711. * @returns the JSON object
  18712. */
  18713. serialize(): any;
  18714. /**
  18715. * Parses a JSON object to create a GPU particle system.
  18716. * @param parsedParticleSystem The JSON object to parse
  18717. * @param scene The scene to create the particle system in
  18718. * @param rootUrl The root url to use to load external dependencies like texture
  18719. * @returns the parsed GPU particle system
  18720. */
  18721. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string): GPUParticleSystem;
  18722. }
  18723. }
  18724. declare module BABYLON {
  18725. /**
  18726. * Interface representing a particle system in Babylon.
  18727. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  18728. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  18729. */
  18730. interface IParticleSystem {
  18731. /**
  18732. * List of animations used by the particle system.
  18733. */
  18734. animations: Animation[];
  18735. /**
  18736. * The id of the Particle system.
  18737. */
  18738. id: string;
  18739. /**
  18740. * The name of the Particle system.
  18741. */
  18742. name: string;
  18743. /**
  18744. * The emitter represents the Mesh or position we are attaching the particle system to.
  18745. */
  18746. emitter: Nullable<AbstractMesh | Vector3>;
  18747. /**
  18748. * The rendering group used by the Particle system to chose when to render.
  18749. */
  18750. renderingGroupId: number;
  18751. /**
  18752. * The layer mask we are rendering the particles through.
  18753. */
  18754. layerMask: number;
  18755. /**
  18756. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  18757. */
  18758. updateSpeed: number;
  18759. /**
  18760. * The amount of time the particle system is running (depends of the overall update speed).
  18761. */
  18762. targetStopDuration: number;
  18763. /**
  18764. * The texture used to render each particle. (this can be a spritesheet)
  18765. */
  18766. particleTexture: Nullable<Texture>;
  18767. /**
  18768. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  18769. */
  18770. blendMode: number;
  18771. /**
  18772. * Minimum life time of emitting particles.
  18773. */
  18774. minLifeTime: number;
  18775. /**
  18776. * Maximum life time of emitting particles.
  18777. */
  18778. maxLifeTime: number;
  18779. /**
  18780. * Minimum Size of emitting particles.
  18781. */
  18782. minSize: number;
  18783. /**
  18784. * Maximum Size of emitting particles.
  18785. */
  18786. maxSize: number;
  18787. /**
  18788. * Minimum scale of emitting particles on X axis.
  18789. */
  18790. minScaleX: number;
  18791. /**
  18792. * Maximum scale of emitting particles on X axis.
  18793. */
  18794. maxScaleX: number;
  18795. /**
  18796. * Minimum scale of emitting particles on Y axis.
  18797. */
  18798. minScaleY: number;
  18799. /**
  18800. * Maximum scale of emitting particles on Y axis.
  18801. */
  18802. maxScaleY: number;
  18803. /**
  18804. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18805. */
  18806. color1: Color4;
  18807. /**
  18808. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18809. */
  18810. color2: Color4;
  18811. /**
  18812. * Color the particle will have at the end of its lifetime.
  18813. */
  18814. colorDead: Color4;
  18815. /**
  18816. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  18817. */
  18818. emitRate: number;
  18819. /**
  18820. * You can use gravity if you want to give an orientation to your particles.
  18821. */
  18822. gravity: Vector3;
  18823. /**
  18824. * Minimum power of emitting particles.
  18825. */
  18826. minEmitPower: number;
  18827. /**
  18828. * Maximum power of emitting particles.
  18829. */
  18830. maxEmitPower: number;
  18831. /**
  18832. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  18833. */
  18834. minAngularSpeed: number;
  18835. /**
  18836. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  18837. */
  18838. maxAngularSpeed: number;
  18839. /**
  18840. * Gets or sets the minimal initial rotation in radians.
  18841. */
  18842. minInitialRotation: number;
  18843. /**
  18844. * Gets or sets the maximal initial rotation in radians.
  18845. */
  18846. maxInitialRotation: number;
  18847. /**
  18848. * The particle emitter type defines the emitter used by the particle system.
  18849. * It can be for example box, sphere, or cone...
  18850. */
  18851. particleEmitterType: Nullable<IParticleEmitterType>;
  18852. /**
  18853. * 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
  18854. */
  18855. preWarmCycles: number;
  18856. /**
  18857. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  18858. */
  18859. preWarmStepOffset: number;
  18860. /**
  18861. * Gets the maximum number of particles active at the same time.
  18862. * @returns The max number of active particles.
  18863. */
  18864. getCapacity(): number;
  18865. /**
  18866. * Gets Wether the system has been started.
  18867. * @returns True if it has been started, otherwise false.
  18868. */
  18869. isStarted(): boolean;
  18870. /**
  18871. * Gets if the particle system has been started.
  18872. * @return true if the system has been started, otherwise false.
  18873. */
  18874. isStarted(): boolean;
  18875. /**
  18876. * Animates the particle system for this frame.
  18877. */
  18878. animate(): void;
  18879. /**
  18880. * Renders the particle system in its current state.
  18881. * @returns the current number of particles
  18882. */
  18883. render(): number;
  18884. /**
  18885. * Dispose the particle system and frees its associated resources.
  18886. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  18887. */
  18888. dispose(disposeTexture?: boolean): void;
  18889. /**
  18890. * Clones the particle system.
  18891. * @param name The name of the cloned object
  18892. * @param newEmitter The new emitter to use
  18893. * @returns the cloned particle system
  18894. */
  18895. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  18896. /**
  18897. * Serializes the particle system to a JSON object.
  18898. * @returns the JSON object
  18899. */
  18900. serialize(): any;
  18901. /**
  18902. * Rebuild the particle system
  18903. */
  18904. rebuild(): void;
  18905. /**
  18906. * Starts the particle system and begins to emit.
  18907. */
  18908. start(): void;
  18909. /**
  18910. * Stops the particle system.
  18911. */
  18912. stop(): void;
  18913. /**
  18914. * Remove all active particles
  18915. */
  18916. reset(): void;
  18917. /**
  18918. * Is this system ready to be used/rendered
  18919. * @return true if the system is ready
  18920. */
  18921. isReady(): boolean;
  18922. /**
  18923. * Adds a new color gradient
  18924. * @param gradient defines the gradient to use (between 0 and 1)
  18925. * @param color defines the color to affect to the specified gradient
  18926. */
  18927. addColorGradient(gradient: number, color: Color4): IParticleSystem;
  18928. /**
  18929. * Remove a specific color gradient
  18930. * @param gradient defines the gradient to remove
  18931. */
  18932. removeColorGradient(gradient: number): IParticleSystem;
  18933. /**
  18934. * Adds a new size gradient
  18935. * @param gradient defines the gradient to use (between 0 and 1)
  18936. * @param factor defines the size factor to affect to the specified gradient
  18937. */
  18938. addSizeGradient(gradient: number, factor: number): IParticleSystem;
  18939. /**
  18940. * Remove a specific size gradient
  18941. * @param gradient defines the gradient to remove
  18942. */
  18943. removeSizeGradient(gradient: number): IParticleSystem;
  18944. /**
  18945. * Gets the current list of color gradients.
  18946. * You must use addColorGradient and removeColorGradient to udpate this list
  18947. * @returns the list of color gradients
  18948. */
  18949. getColorGradients(): Nullable<Array<ColorGradient>>;
  18950. /**
  18951. * Gets the current list of size gradients.
  18952. * You must use addSizeGradient and removeSizeGradient to udpate this list
  18953. * @returns the list of size gradients
  18954. */
  18955. getSizeGradients(): Nullable<Array<FactorGradient>>;
  18956. }
  18957. }
  18958. declare module BABYLON {
  18959. /**
  18960. * A particle represents one of the element emitted by a particle system.
  18961. * This is mainly define by its coordinates, direction, velocity and age.
  18962. */
  18963. class Particle {
  18964. /**
  18965. * particleSystem the particle system the particle belongs to.
  18966. */
  18967. particleSystem: ParticleSystem;
  18968. /**
  18969. * The world position of the particle in the scene.
  18970. */
  18971. position: Vector3;
  18972. /**
  18973. * The world direction of the particle in the scene.
  18974. */
  18975. direction: Vector3;
  18976. /**
  18977. * The color of the particle.
  18978. */
  18979. color: Color4;
  18980. /**
  18981. * The color change of the particle per step.
  18982. */
  18983. colorStep: Color4;
  18984. /**
  18985. * Defines how long will the life of the particle be.
  18986. */
  18987. lifeTime: number;
  18988. /**
  18989. * The current age of the particle.
  18990. */
  18991. age: number;
  18992. /**
  18993. * The current size of the particle.
  18994. */
  18995. size: number;
  18996. /**
  18997. * The current scale of the particle.
  18998. */
  18999. scale: Vector2;
  19000. /**
  19001. * The current angle of the particle.
  19002. */
  19003. angle: number;
  19004. /**
  19005. * Defines how fast is the angle changing.
  19006. */
  19007. angularSpeed: number;
  19008. /**
  19009. * Defines the cell index used by the particle to be rendered from a sprite.
  19010. */
  19011. cellIndex: number;
  19012. private _currentFrameCounter;
  19013. /** @hidden */
  19014. /** @hidden */
  19015. /**
  19016. * Creates a new instance Particle
  19017. * @param particleSystem the particle system the particle belongs to
  19018. */
  19019. constructor(
  19020. /**
  19021. * particleSystem the particle system the particle belongs to.
  19022. */
  19023. particleSystem: ParticleSystem);
  19024. private updateCellInfoFromSystem();
  19025. /**
  19026. * Defines how the sprite cell index is updated for the particle. This is
  19027. * defined as a callback.
  19028. */
  19029. updateCellIndex: (scaledUpdateSpeed: number) => void;
  19030. private _updateCellIndexWithSpeedCalculated(scaledUpdateSpeed);
  19031. private _updateCellIndexWithCustomSpeed();
  19032. /**
  19033. * Copy the properties of particle to another one.
  19034. * @param other the particle to copy the information to.
  19035. */
  19036. copyTo(other: Particle): void;
  19037. }
  19038. }
  19039. declare module BABYLON {
  19040. /**
  19041. * This represents a particle system in Babylon.
  19042. * 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.
  19043. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  19044. * @example https://doc.babylonjs.com/babylon101/particles
  19045. */
  19046. class ParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  19047. /**
  19048. * Source color is added to the destination color without alpha affecting the result.
  19049. */
  19050. static BLENDMODE_ONEONE: number;
  19051. /**
  19052. * Blend current color and particle color using particle’s alpha.
  19053. */
  19054. static BLENDMODE_STANDARD: number;
  19055. /**
  19056. * Add current color and particle color multiplied by particle’s alpha.
  19057. */
  19058. static BLENDMODE_ADD: number;
  19059. /**
  19060. * List of animations used by the particle system.
  19061. */
  19062. animations: Animation[];
  19063. /**
  19064. * The id of the Particle system.
  19065. */
  19066. id: string;
  19067. /**
  19068. * The friendly name of the Particle system.
  19069. */
  19070. name: string;
  19071. /**
  19072. * The rendering group used by the Particle system to chose when to render.
  19073. */
  19074. renderingGroupId: number;
  19075. /**
  19076. * The emitter represents the Mesh or position we are attaching the particle system to.
  19077. */
  19078. emitter: Nullable<AbstractMesh | Vector3>;
  19079. /**
  19080. * The maximum number of particles to emit per frame
  19081. */
  19082. emitRate: number;
  19083. /**
  19084. * If you want to launch only a few particles at once, that can be done, as well.
  19085. */
  19086. manualEmitCount: number;
  19087. /**
  19088. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  19089. */
  19090. updateSpeed: number;
  19091. /**
  19092. * The amount of time the particle system is running (depends of the overall update speed).
  19093. */
  19094. targetStopDuration: number;
  19095. /**
  19096. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  19097. */
  19098. disposeOnStop: boolean;
  19099. /**
  19100. * Minimum power of emitting particles.
  19101. */
  19102. minEmitPower: number;
  19103. /**
  19104. * Maximum power of emitting particles.
  19105. */
  19106. maxEmitPower: number;
  19107. /**
  19108. * Minimum life time of emitting particles.
  19109. */
  19110. minLifeTime: number;
  19111. /**
  19112. * Maximum life time of emitting particles.
  19113. */
  19114. maxLifeTime: number;
  19115. /**
  19116. * Minimum Size of emitting particles.
  19117. */
  19118. minSize: number;
  19119. /**
  19120. * Maximum Size of emitting particles.
  19121. */
  19122. maxSize: number;
  19123. /**
  19124. * Minimum scale of emitting particles on X axis.
  19125. */
  19126. minScaleX: number;
  19127. /**
  19128. * Maximum scale of emitting particles on X axis.
  19129. */
  19130. maxScaleX: number;
  19131. /**
  19132. * Minimum scale of emitting particles on Y axis.
  19133. */
  19134. minScaleY: number;
  19135. /**
  19136. * Maximum scale of emitting particles on Y axis.
  19137. */
  19138. maxScaleY: number;
  19139. /**
  19140. * Gets or sets the minimal initial rotation in radians.
  19141. */
  19142. minInitialRotation: number;
  19143. /**
  19144. * Gets or sets the maximal initial rotation in radians.
  19145. */
  19146. maxInitialRotation: number;
  19147. /**
  19148. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  19149. */
  19150. minAngularSpeed: number;
  19151. /**
  19152. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  19153. */
  19154. maxAngularSpeed: number;
  19155. /**
  19156. * The texture used to render each particle. (this can be a spritesheet)
  19157. */
  19158. particleTexture: Nullable<Texture>;
  19159. /**
  19160. * The layer mask we are rendering the particles through.
  19161. */
  19162. layerMask: number;
  19163. /**
  19164. * This can help using your own shader to render the particle system.
  19165. * The according effect will be created
  19166. */
  19167. customShader: any;
  19168. /**
  19169. * By default particle system starts as soon as they are created. This prevents the
  19170. * automatic start to happen and let you decide when to start emitting particles.
  19171. */
  19172. preventAutoStart: boolean;
  19173. /**
  19174. * This function can be defined to provide custom update for active particles.
  19175. * This function will be called instead of regular update (age, position, color, etc.).
  19176. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  19177. */
  19178. updateFunction: (particles: Particle[]) => void;
  19179. /**
  19180. * Callback triggered when the particle animation is ending.
  19181. */
  19182. onAnimationEnd: Nullable<() => void>;
  19183. /**
  19184. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  19185. */
  19186. blendMode: number;
  19187. /**
  19188. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  19189. * to override the particles.
  19190. */
  19191. forceDepthWrite: boolean;
  19192. /**
  19193. * You can use gravity if you want to give an orientation to your particles.
  19194. */
  19195. gravity: Vector3;
  19196. private _colorGradients;
  19197. private _sizeGradients;
  19198. /**
  19199. * Gets the current list of color gradients.
  19200. * You must use addColorGradient and removeColorGradient to udpate this list
  19201. * @returns the list of color gradients
  19202. */
  19203. getColorGradients(): Nullable<Array<ColorGradient>>;
  19204. /**
  19205. * Gets the current list of size gradients.
  19206. * You must use addSizeGradient and removeSizeGradient to udpate this list
  19207. * @returns the list of size gradients
  19208. */
  19209. getSizeGradients(): Nullable<Array<FactorGradient>>;
  19210. /**
  19211. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  19212. * This only works when particleEmitterTyps is a BoxParticleEmitter
  19213. */
  19214. direction1: Vector3;
  19215. /**
  19216. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  19217. * This only works when particleEmitterTyps is a BoxParticleEmitter
  19218. */
  19219. direction2: Vector3;
  19220. /**
  19221. * 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.
  19222. * This only works when particleEmitterTyps is a BoxParticleEmitter
  19223. */
  19224. minEmitBox: Vector3;
  19225. /**
  19226. * 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.
  19227. * This only works when particleEmitterTyps is a BoxParticleEmitter
  19228. */
  19229. maxEmitBox: Vector3;
  19230. /**
  19231. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  19232. */
  19233. color1: Color4;
  19234. /**
  19235. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  19236. */
  19237. color2: Color4;
  19238. /**
  19239. * Color the particle will have at the end of its lifetime
  19240. */
  19241. colorDead: Color4;
  19242. /**
  19243. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  19244. */
  19245. textureMask: Color4;
  19246. /**
  19247. * The particle emitter type defines the emitter used by the particle system.
  19248. * It can be for example box, sphere, or cone...
  19249. */
  19250. particleEmitterType: IParticleEmitterType;
  19251. /**
  19252. * This function can be defined to specify initial direction for every new particle.
  19253. * It by default use the emitterType defined function
  19254. */
  19255. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  19256. /**
  19257. * This function can be defined to specify initial position for every new particle.
  19258. * It by default use the emitterType defined function
  19259. */
  19260. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  19261. /**
  19262. * If using a spritesheet (isAnimationSheetEnabled), defines if the sprite animation should loop between startSpriteCellID and endSpriteCellID or not
  19263. */
  19264. spriteCellLoop: boolean;
  19265. /**
  19266. * If using a spritesheet (isAnimationSheetEnabled) and spriteCellLoop defines the speed of the sprite loop
  19267. */
  19268. spriteCellChangeSpeed: number;
  19269. /**
  19270. * If using a spritesheet (isAnimationSheetEnabled) and spriteCellLoop defines the first sprite cell to display
  19271. */
  19272. startSpriteCellID: number;
  19273. /**
  19274. * If using a spritesheet (isAnimationSheetEnabled) and spriteCellLoop defines the last sprite cell to display
  19275. */
  19276. endSpriteCellID: number;
  19277. /**
  19278. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  19279. */
  19280. spriteCellWidth: number;
  19281. /**
  19282. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  19283. */
  19284. spriteCellHeight: number;
  19285. /** 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 */
  19286. preWarmCycles: number;
  19287. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  19288. preWarmStepOffset: number;
  19289. /**
  19290. * An event triggered when the system is disposed
  19291. */
  19292. onDisposeObservable: Observable<ParticleSystem>;
  19293. private _onDisposeObserver;
  19294. /**
  19295. * Sets a callback that will be triggered when the system is disposed
  19296. */
  19297. onDispose: () => void;
  19298. /**
  19299. * Gets whether an animation sprite sheet is enabled or not on the particle system
  19300. */
  19301. readonly isAnimationSheetEnabled: boolean;
  19302. /**
  19303. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  19304. */
  19305. isBillboardBased: boolean;
  19306. private _particles;
  19307. private _epsilon;
  19308. private _capacity;
  19309. private _scene;
  19310. private _stockParticles;
  19311. private _newPartsExcess;
  19312. private _vertexData;
  19313. private _vertexBuffer;
  19314. private _vertexBuffers;
  19315. private _spriteBuffer;
  19316. private _indexBuffer;
  19317. private _effect;
  19318. private _customEffect;
  19319. private _cachedDefines;
  19320. private _scaledColorStep;
  19321. private _colorDiff;
  19322. private _scaledDirection;
  19323. private _scaledGravity;
  19324. private _currentRenderId;
  19325. private _alive;
  19326. private _useInstancing;
  19327. private _started;
  19328. private _stopped;
  19329. private _actualFrame;
  19330. private _scaledUpdateSpeed;
  19331. private _vertexBufferSize;
  19332. private _isAnimationSheetEnabled;
  19333. private _isBillboardBased;
  19334. /**
  19335. * this is the Sub-emitters templates that will be used to generate particle system when the particle dies, this property is used by the root particle system only.
  19336. */
  19337. subEmitters: ParticleSystem[];
  19338. /**
  19339. * The current active Sub-systems, this property is used by the root particle system only.
  19340. */
  19341. activeSubSystems: Array<ParticleSystem>;
  19342. private _rootParticleSystem;
  19343. /**
  19344. * Gets the current list of active particles
  19345. */
  19346. readonly particles: Particle[];
  19347. /**
  19348. * Returns the string "ParticleSystem"
  19349. * @returns a string containing the class name
  19350. */
  19351. getClassName(): string;
  19352. /**
  19353. * Instantiates a particle system.
  19354. * 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.
  19355. * @param name The name of the particle system
  19356. * @param capacity The max number of particles alive at the same time
  19357. * @param scene The scene the particle system belongs to
  19358. * @param customEffect a custom effect used to change the way particles are rendered by default
  19359. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  19360. * @param epsilon Offset used to render the particles
  19361. */
  19362. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  19363. /**
  19364. * Adds a new size gradient
  19365. * @param gradient defines the gradient to use (between 0 and 1)
  19366. * @param factor defines the size factor to affect to the specified gradient
  19367. */
  19368. addSizeGradient(gradient: number, factor: number): ParticleSystem;
  19369. /**
  19370. * Remove a specific size gradient
  19371. * @param gradient defines the gradient to remove
  19372. */
  19373. removeSizeGradient(gradient: number): ParticleSystem;
  19374. /**
  19375. * Adds a new color gradient
  19376. * @param gradient defines the gradient to use (between 0 and 1)
  19377. * @param color defines the color to affect to the specified gradient
  19378. */
  19379. addColorGradient(gradient: number, color: Color4): ParticleSystem;
  19380. /**
  19381. * Remove a specific color gradient
  19382. * @param gradient defines the gradient to remove
  19383. */
  19384. removeColorGradient(gradient: number): ParticleSystem;
  19385. private _resetEffect();
  19386. private _createVertexBuffers();
  19387. private _createIndexBuffer();
  19388. /**
  19389. * Gets the maximum number of particles active at the same time.
  19390. * @returns The max number of active particles.
  19391. */
  19392. getCapacity(): number;
  19393. /**
  19394. * Gets Wether there are still active particles in the system.
  19395. * @returns True if it is alive, otherwise false.
  19396. */
  19397. isAlive(): boolean;
  19398. /**
  19399. * Gets Wether the system has been started.
  19400. * @returns True if it has been started, otherwise false.
  19401. */
  19402. isStarted(): boolean;
  19403. /**
  19404. * Starts the particle system and begins to emit.
  19405. */
  19406. start(): void;
  19407. /**
  19408. * Stops the particle system.
  19409. * @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.
  19410. */
  19411. stop(stopSubEmitters?: boolean): void;
  19412. /**
  19413. * Remove all active particles
  19414. */
  19415. reset(): void;
  19416. /**
  19417. * @hidden (for internal use only)
  19418. */
  19419. /**
  19420. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  19421. * Its lifetime will start back at 0.
  19422. */
  19423. recycleParticle: (particle: Particle) => void;
  19424. private _stopSubEmitters();
  19425. private _createParticle;
  19426. private _removeFromRoot();
  19427. private _emitFromParticle;
  19428. private _update(newParticles);
  19429. private _getEffect();
  19430. /**
  19431. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  19432. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  19433. */
  19434. animate(preWarmOnly?: boolean): void;
  19435. private _appendParticleVertices(offset, particle);
  19436. /**
  19437. * Rebuilds the particle system.
  19438. */
  19439. rebuild(): void;
  19440. /**
  19441. * Is this system ready to be used/rendered
  19442. * @return true if the system is ready
  19443. */
  19444. isReady(): boolean;
  19445. /**
  19446. * Renders the particle system in its current state.
  19447. * @returns the current number of particles
  19448. */
  19449. render(): number;
  19450. /**
  19451. * Disposes the particle system and free the associated resources
  19452. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  19453. */
  19454. dispose(disposeTexture?: boolean): void;
  19455. /**
  19456. * Creates a Sphere Emitter for the particle system. (emits along the sphere radius)
  19457. * @param radius The radius of the sphere to emit from
  19458. * @returns the emitter
  19459. */
  19460. createSphereEmitter(radius?: number): SphereParticleEmitter;
  19461. /**
  19462. * Creates a Directed Sphere Emitter for the particle system. (emits between direction1 and direction2)
  19463. * @param radius The radius of the sphere to emit from
  19464. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  19465. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  19466. * @returns the emitter
  19467. */
  19468. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  19469. /**
  19470. * Creates a Cone Emitter for the particle system. (emits from the cone to the particle position)
  19471. * @param radius The radius of the cone to emit from
  19472. * @param angle The base angle of the cone
  19473. * @returns the emitter
  19474. */
  19475. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  19476. /**
  19477. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  19478. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19479. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19480. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19481. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19482. * @returns the emitter
  19483. */
  19484. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  19485. /**
  19486. * Clones the particle system.
  19487. * @param name The name of the cloned object
  19488. * @param newEmitter The new emitter to use
  19489. * @returns the cloned particle system
  19490. */
  19491. clone(name: string, newEmitter: any): ParticleSystem;
  19492. /**
  19493. * Serializes the particle system to a JSON object.
  19494. * @returns the JSON object
  19495. */
  19496. serialize(): any;
  19497. /** @hidden */
  19498. private static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  19499. /** @hidden */
  19500. private static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  19501. /**
  19502. * Parses a JSON object to create a particle system.
  19503. * @param parsedParticleSystem The JSON object to parse
  19504. * @param scene The scene to create the particle system in
  19505. * @param rootUrl The root url to use to load external dependencies like texture
  19506. * @returns the Parsed particle system
  19507. */
  19508. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string): ParticleSystem;
  19509. }
  19510. }
  19511. declare module BABYLON {
  19512. /**
  19513. * Represents one particle of a solid particle system.
  19514. */
  19515. class SolidParticle {
  19516. /**
  19517. * particle global index
  19518. */
  19519. idx: number;
  19520. /**
  19521. * The color of the particle
  19522. */
  19523. color: Nullable<Color4>;
  19524. /**
  19525. * The world space position of the particle.
  19526. */
  19527. position: Vector3;
  19528. /**
  19529. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  19530. */
  19531. rotation: Vector3;
  19532. /**
  19533. * The world space rotation quaternion of the particle.
  19534. */
  19535. rotationQuaternion: Nullable<Quaternion>;
  19536. /**
  19537. * The scaling of the particle.
  19538. */
  19539. scaling: Vector3;
  19540. /**
  19541. * The uvs of the particle.
  19542. */
  19543. uvs: Vector4;
  19544. /**
  19545. * The current speed of the particle.
  19546. */
  19547. velocity: Vector3;
  19548. /**
  19549. * The pivot point in the particle local space.
  19550. */
  19551. pivot: Vector3;
  19552. /**
  19553. * Must the particle be translated from its pivot point in its local space ?
  19554. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  19555. * Default : false
  19556. */
  19557. translateFromPivot: boolean;
  19558. /**
  19559. * Is the particle active or not ?
  19560. */
  19561. alive: boolean;
  19562. /**
  19563. * Is the particle visible or not ?
  19564. */
  19565. isVisible: boolean;
  19566. /**
  19567. * Index of this particle in the global "positions" array (Internal use)
  19568. */
  19569. /**
  19570. * Index of this particle in the global "indices" array (Internal use)
  19571. */
  19572. /**
  19573. * ModelShape of this particle (Internal use)
  19574. */
  19575. /**
  19576. * ModelShape id of this particle
  19577. */
  19578. shapeId: number;
  19579. /**
  19580. * Index of the particle in its shape id (Internal use)
  19581. */
  19582. idxInShape: number;
  19583. /**
  19584. * Reference to the shape model BoundingInfo object (Internal use)
  19585. */
  19586. /**
  19587. * Particle BoundingInfo object (Internal use)
  19588. */
  19589. /**
  19590. * Reference to the SPS what the particle belongs to (Internal use)
  19591. */
  19592. /**
  19593. * Still set as invisible in order to skip useless computations (Internal use)
  19594. */
  19595. /**
  19596. * Last computed particle rotation matrix
  19597. */
  19598. /**
  19599. * Parent particle Id, if any.
  19600. * Default null.
  19601. */
  19602. parentId: Nullable<number>;
  19603. /**
  19604. * Internal global position in the SPS.
  19605. */
  19606. /**
  19607. * Creates a Solid Particle object.
  19608. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  19609. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  19610. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  19611. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  19612. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  19613. * @param shapeId (integer) is the model shape identifier in the SPS.
  19614. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  19615. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  19616. */
  19617. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  19618. /**
  19619. * Legacy support, changed scale to scaling
  19620. */
  19621. /**
  19622. * Legacy support, changed scale to scaling
  19623. */
  19624. scale: Vector3;
  19625. /**
  19626. * Legacy support, changed quaternion to rotationQuaternion
  19627. */
  19628. /**
  19629. * Legacy support, changed quaternion to rotationQuaternion
  19630. */
  19631. quaternion: Nullable<Quaternion>;
  19632. /**
  19633. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  19634. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  19635. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  19636. * @returns true if it intersects
  19637. */
  19638. intersectsMesh(target: Mesh | SolidParticle): boolean;
  19639. }
  19640. /**
  19641. * Represents the shape of the model used by one particle of a solid particle system.
  19642. * SPS internal tool, don't use it manually.
  19643. */
  19644. class ModelShape {
  19645. /**
  19646. * The shape id.
  19647. */
  19648. shapeID: number;
  19649. /**
  19650. * flat array of model positions (internal use)
  19651. */
  19652. /**
  19653. * flat array of model UVs (internal use)
  19654. */
  19655. /**
  19656. * length of the shape in the model indices array (internal use)
  19657. */
  19658. /**
  19659. * Custom position function (internal use)
  19660. */
  19661. /**
  19662. * Custom vertex function (internal use)
  19663. */
  19664. /**
  19665. * 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.
  19666. * SPS internal tool, don't use it manually.
  19667. * @hidden
  19668. */
  19669. 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>);
  19670. }
  19671. /**
  19672. * Represents a Depth Sorted Particle in the solid particle system.
  19673. */
  19674. class DepthSortedParticle {
  19675. /**
  19676. * Index of the particle in the "indices" array
  19677. */
  19678. ind: number;
  19679. /**
  19680. * Length of the particle shape in the "indices" array
  19681. */
  19682. indicesLength: number;
  19683. /**
  19684. * Squared distance from the particle to the camera
  19685. */
  19686. sqDistance: number;
  19687. }
  19688. }
  19689. declare module BABYLON {
  19690. /**
  19691. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  19692. *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.
  19693. * The SPS is also a particle system. It provides some methods to manage the particles.
  19694. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  19695. *
  19696. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  19697. */
  19698. class SolidParticleSystem implements IDisposable {
  19699. /**
  19700. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  19701. * Example : var p = SPS.particles[i];
  19702. */
  19703. particles: SolidParticle[];
  19704. /**
  19705. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  19706. */
  19707. nbParticles: number;
  19708. /**
  19709. * If the particles must ever face the camera (default false). Useful for planar particles.
  19710. */
  19711. billboard: boolean;
  19712. /**
  19713. * Recompute normals when adding a shape
  19714. */
  19715. recomputeNormals: boolean;
  19716. /**
  19717. * This a counter ofr your own usage. It's not set by any SPS functions.
  19718. */
  19719. counter: number;
  19720. /**
  19721. * The SPS name. This name is also given to the underlying mesh.
  19722. */
  19723. name: string;
  19724. /**
  19725. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  19726. */
  19727. mesh: Mesh;
  19728. /**
  19729. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  19730. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  19731. */
  19732. vars: any;
  19733. /**
  19734. * This array is populated when the SPS is set as 'pickable'.
  19735. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  19736. * Each element of this array is an object `{idx: int, faceId: int}`.
  19737. * `idx` is the picked particle index in the `SPS.particles` array
  19738. * `faceId` is the picked face index counted within this particle.
  19739. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  19740. */
  19741. pickedParticles: {
  19742. idx: number;
  19743. faceId: number;
  19744. }[];
  19745. /**
  19746. * This array is populated when `enableDepthSort` is set to true.
  19747. * Each element of this array is an instance of the class DepthSortedParticle.
  19748. */
  19749. depthSortedParticles: DepthSortedParticle[];
  19750. /**
  19751. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  19752. */
  19753. /**
  19754. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  19755. */
  19756. private _scene;
  19757. private _positions;
  19758. private _indices;
  19759. private _normals;
  19760. private _colors;
  19761. private _uvs;
  19762. private _indices32;
  19763. private _positions32;
  19764. private _normals32;
  19765. private _fixedNormal32;
  19766. private _colors32;
  19767. private _uvs32;
  19768. private _index;
  19769. private _updatable;
  19770. private _pickable;
  19771. private _isVisibilityBoxLocked;
  19772. private _alwaysVisible;
  19773. private _depthSort;
  19774. private _shapeCounter;
  19775. private _copy;
  19776. private _shape;
  19777. private _shapeUV;
  19778. private _color;
  19779. private _computeParticleColor;
  19780. private _computeParticleTexture;
  19781. private _computeParticleRotation;
  19782. private _computeParticleVertex;
  19783. private _computeBoundingBox;
  19784. private _depthSortParticles;
  19785. private _cam_axisZ;
  19786. private _cam_axisY;
  19787. private _cam_axisX;
  19788. private _axisZ;
  19789. private _camera;
  19790. private _particle;
  19791. private _camDir;
  19792. private _camInvertedPosition;
  19793. private _rotMatrix;
  19794. private _invertMatrix;
  19795. private _rotated;
  19796. private _quaternion;
  19797. private _vertex;
  19798. private _normal;
  19799. private _yaw;
  19800. private _pitch;
  19801. private _roll;
  19802. private _halfroll;
  19803. private _halfpitch;
  19804. private _halfyaw;
  19805. private _sinRoll;
  19806. private _cosRoll;
  19807. private _sinPitch;
  19808. private _cosPitch;
  19809. private _sinYaw;
  19810. private _cosYaw;
  19811. private _mustUnrotateFixedNormals;
  19812. private _minimum;
  19813. private _maximum;
  19814. private _minBbox;
  19815. private _maxBbox;
  19816. private _particlesIntersect;
  19817. private _depthSortFunction;
  19818. private _needs32Bits;
  19819. private _pivotBackTranslation;
  19820. private _scaledPivot;
  19821. private _particleHasParent;
  19822. private _parent;
  19823. /**
  19824. * Creates a SPS (Solid Particle System) object.
  19825. * @param name (String) is the SPS name, this will be the underlying mesh name.
  19826. * @param scene (Scene) is the scene in which the SPS is added.
  19827. * @param updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  19828. * @param isPickable (optional boolean, default false) : if the solid particles must be pickable.
  19829. * @param enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  19830. * @param particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  19831. * @param boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  19832. * @param bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  19833. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  19834. */
  19835. constructor(name: string, scene: Scene, options?: {
  19836. updatable?: boolean;
  19837. isPickable?: boolean;
  19838. enableDepthSort?: boolean;
  19839. particleIntersection?: boolean;
  19840. boundingSphereOnly?: boolean;
  19841. bSphereRadiusFactor?: number;
  19842. });
  19843. /**
  19844. * Builds the SPS underlying mesh. Returns a standard Mesh.
  19845. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  19846. * @returns the created mesh
  19847. */
  19848. buildMesh(): Mesh;
  19849. /**
  19850. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  19851. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  19852. * Thus the particles generated from `digest()` have their property `position` set yet.
  19853. * @param mesh ( Mesh ) is the mesh to be digested
  19854. * @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
  19855. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  19856. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  19857. * @returns the current SPS
  19858. */
  19859. digest(mesh: Mesh, options?: {
  19860. facetNb?: number;
  19861. number?: number;
  19862. delta?: number;
  19863. }): SolidParticleSystem;
  19864. private _unrotateFixedNormals();
  19865. private _resetCopy();
  19866. private _meshBuilder(p, shape, positions, meshInd, indices, meshUV, uvs, meshCol, colors, meshNor, normals, idx, idxInShape, options);
  19867. private _posToShape(positions);
  19868. private _uvsToShapeUV(uvs);
  19869. private _addParticle(idx, idxpos, idxind, model, shapeId, idxInShape, bInfo?);
  19870. /**
  19871. * Adds some particles to the SPS from the model shape. Returns the shape id.
  19872. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  19873. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  19874. * @param nb (positive integer) the number of particles to be created from this model
  19875. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  19876. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  19877. * @returns the number of shapes in the system
  19878. */
  19879. addShape(mesh: Mesh, nb: number, options?: {
  19880. positionFunction?: any;
  19881. vertexFunction?: any;
  19882. }): number;
  19883. private _rebuildParticle(particle);
  19884. /**
  19885. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  19886. * @returns the SPS.
  19887. */
  19888. rebuildMesh(): SolidParticleSystem;
  19889. /**
  19890. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  19891. * This method calls `updateParticle()` for each particle of the SPS.
  19892. * For an animated SPS, it is usually called within the render loop.
  19893. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  19894. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  19895. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  19896. * @returns the SPS.
  19897. */
  19898. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  19899. private _quaternionRotationYPR();
  19900. private _quaternionToRotationMatrix();
  19901. /**
  19902. * Disposes the SPS.
  19903. */
  19904. dispose(): void;
  19905. /**
  19906. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  19907. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  19908. * @returns the SPS.
  19909. */
  19910. refreshVisibleSize(): SolidParticleSystem;
  19911. /**
  19912. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  19913. * @param size the size (float) of the visibility box
  19914. * note : this doesn't lock the SPS mesh bounding box.
  19915. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  19916. */
  19917. setVisibilityBox(size: number): void;
  19918. /**
  19919. * Gets whether the SPS as always visible or not
  19920. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  19921. */
  19922. /**
  19923. * Sets the SPS as always visible or not
  19924. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  19925. */
  19926. isAlwaysVisible: boolean;
  19927. /**
  19928. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  19929. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  19930. */
  19931. /**
  19932. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  19933. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  19934. */
  19935. isVisibilityBoxLocked: boolean;
  19936. /**
  19937. * Gets if `setParticles()` computes the particle rotations or not.
  19938. * Default value : true. The SPS is faster when it's set to false.
  19939. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  19940. */
  19941. /**
  19942. * Tells to `setParticles()` to compute the particle rotations or not.
  19943. * Default value : true. The SPS is faster when it's set to false.
  19944. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  19945. */
  19946. computeParticleRotation: boolean;
  19947. /**
  19948. * Gets if `setParticles()` computes the particle colors or not.
  19949. * Default value : true. The SPS is faster when it's set to false.
  19950. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  19951. */
  19952. /**
  19953. * Tells to `setParticles()` to compute the particle colors or not.
  19954. * Default value : true. The SPS is faster when it's set to false.
  19955. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  19956. */
  19957. computeParticleColor: boolean;
  19958. /**
  19959. * Gets if `setParticles()` computes the particle textures or not.
  19960. * Default value : true. The SPS is faster when it's set to false.
  19961. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  19962. */
  19963. computeParticleTexture: boolean;
  19964. /**
  19965. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  19966. * Default value : false. The SPS is faster when it's set to false.
  19967. * Note : the particle custom vertex positions aren't stored values.
  19968. */
  19969. /**
  19970. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  19971. * Default value : false. The SPS is faster when it's set to false.
  19972. * Note : the particle custom vertex positions aren't stored values.
  19973. */
  19974. computeParticleVertex: boolean;
  19975. /**
  19976. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  19977. */
  19978. /**
  19979. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  19980. */
  19981. computeBoundingBox: boolean;
  19982. /**
  19983. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  19984. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  19985. * Default : `true`
  19986. */
  19987. /**
  19988. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  19989. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  19990. * Default : `true`
  19991. */
  19992. depthSortParticles: boolean;
  19993. /**
  19994. * This function does nothing. It may be overwritten to set all the particle first values.
  19995. * The SPS doesn't call this function, you may have to call it by your own.
  19996. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  19997. */
  19998. initParticles(): void;
  19999. /**
  20000. * This function does nothing. It may be overwritten to recycle a particle.
  20001. * The SPS doesn't call this function, you may have to call it by your own.
  20002. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  20003. * @param particle The particle to recycle
  20004. * @returns the recycled particle
  20005. */
  20006. recycleParticle(particle: SolidParticle): SolidParticle;
  20007. /**
  20008. * Updates a particle : this function should be overwritten by the user.
  20009. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  20010. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  20011. * @example : just set a particle position or velocity and recycle conditions
  20012. * @param particle The particle to update
  20013. * @returns the updated particle
  20014. */
  20015. updateParticle(particle: SolidParticle): SolidParticle;
  20016. /**
  20017. * Updates a vertex of a particle : it can be overwritten by the user.
  20018. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  20019. * @param particle the current particle
  20020. * @param vertex the current index of the current particle
  20021. * @param pt the index of the current vertex in the particle shape
  20022. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  20023. * @example : just set a vertex particle position
  20024. * @returns the updated vertex
  20025. */
  20026. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  20027. /**
  20028. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  20029. * This does nothing and may be overwritten by the user.
  20030. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  20031. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  20032. * @param update the boolean update value actually passed to setParticles()
  20033. */
  20034. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  20035. /**
  20036. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  20037. * This will be passed three parameters.
  20038. * This does nothing and may be overwritten by the user.
  20039. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  20040. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  20041. * @param update the boolean update value actually passed to setParticles()
  20042. */
  20043. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  20044. }
  20045. }
  20046. declare module BABYLON {
  20047. /**
  20048. * Class used to store all common mesh properties
  20049. */
  20050. class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  20051. /** No occlusion */
  20052. static OCCLUSION_TYPE_NONE: number;
  20053. /** Occlusion set to optimisitic */
  20054. static OCCLUSION_TYPE_OPTIMISTIC: number;
  20055. /** Occlusion set to strict */
  20056. static OCCLUSION_TYPE_STRICT: number;
  20057. /** Use an accurante occlusion algorithm */
  20058. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  20059. /** Use a conservative occlusion algorithm */
  20060. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  20061. /**
  20062. * No billboard
  20063. */
  20064. static readonly BILLBOARDMODE_NONE: number;
  20065. /** Billboard on X axis */
  20066. static readonly BILLBOARDMODE_X: number;
  20067. /** Billboard on Y axis */
  20068. static readonly BILLBOARDMODE_Y: number;
  20069. /** Billboard on Z axis */
  20070. static readonly BILLBOARDMODE_Z: number;
  20071. /** Billboard on all axes */
  20072. static readonly BILLBOARDMODE_ALL: number;
  20073. private _facetPositions;
  20074. private _facetNormals;
  20075. private _facetPartitioning;
  20076. private _facetNb;
  20077. private _partitioningSubdivisions;
  20078. private _partitioningBBoxRatio;
  20079. private _facetDataEnabled;
  20080. private _facetParameters;
  20081. private _bbSize;
  20082. private _subDiv;
  20083. private _facetDepthSort;
  20084. private _facetDepthSortEnabled;
  20085. private _depthSortedIndices;
  20086. private _depthSortedFacets;
  20087. private _facetDepthSortFunction;
  20088. private _facetDepthSortFrom;
  20089. private _facetDepthSortOrigin;
  20090. private _invertedMatrix;
  20091. /**
  20092. * Gets the number of facets in the mesh
  20093. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  20094. */
  20095. readonly facetNb: number;
  20096. /**
  20097. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  20098. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  20099. */
  20100. partitioningSubdivisions: number;
  20101. /**
  20102. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  20103. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  20104. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  20105. */
  20106. partitioningBBoxRatio: number;
  20107. /**
  20108. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  20109. * Works only for updatable meshes.
  20110. * Doesn't work with multi-materials
  20111. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  20112. */
  20113. mustDepthSortFacets: boolean;
  20114. /**
  20115. * The location (Vector3) where the facet depth sort must be computed from.
  20116. * By default, the active camera position.
  20117. * Used only when facet depth sort is enabled
  20118. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  20119. */
  20120. facetDepthSortFrom: Vector3;
  20121. /**
  20122. * gets a boolean indicating if facetData is enabled
  20123. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  20124. */
  20125. readonly isFacetDataEnabled: boolean;
  20126. /** @hidden */
  20127. /**
  20128. * An event triggered when this mesh collides with another one
  20129. */
  20130. onCollideObservable: Observable<AbstractMesh>;
  20131. private _onCollideObserver;
  20132. /** Set a function to call when this mesh collides with another one */
  20133. onCollide: () => void;
  20134. /**
  20135. * An event triggered when the collision's position changes
  20136. */
  20137. onCollisionPositionChangeObservable: Observable<Vector3>;
  20138. private _onCollisionPositionChangeObserver;
  20139. /** Set a function to call when the collision's position changes */
  20140. onCollisionPositionChange: () => void;
  20141. /**
  20142. * An event triggered when material is changed
  20143. */
  20144. onMaterialChangedObservable: Observable<AbstractMesh>;
  20145. /**
  20146. * Gets or sets the orientation for POV movement & rotation
  20147. */
  20148. definedFacingForward: boolean;
  20149. /**
  20150. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  20151. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  20152. * * 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.
  20153. * @see http://doc.babylonjs.com/features/occlusionquery
  20154. */
  20155. occlusionQueryAlgorithmType: number;
  20156. /**
  20157. * 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:
  20158. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  20159. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  20160. * * 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.
  20161. * @see http://doc.babylonjs.com/features/occlusionquery
  20162. */
  20163. occlusionType: number;
  20164. /**
  20165. * 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.
  20166. * The default value is -1 which means don't break the query and wait till the result
  20167. * @see http://doc.babylonjs.com/features/occlusionquery
  20168. */
  20169. occlusionRetryCount: number;
  20170. private _occlusionInternalRetryCounter;
  20171. protected _isOccluded: boolean;
  20172. /**
  20173. * 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
  20174. * @see http://doc.babylonjs.com/features/occlusionquery
  20175. */
  20176. isOccluded: boolean;
  20177. private _isOcclusionQueryInProgress;
  20178. /**
  20179. * Flag to check the progress status of the query
  20180. * @see http://doc.babylonjs.com/features/occlusionquery
  20181. */
  20182. readonly isOcclusionQueryInProgress: boolean;
  20183. private _occlusionQuery;
  20184. private _visibility;
  20185. /**
  20186. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  20187. */
  20188. /**
  20189. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  20190. */
  20191. visibility: number;
  20192. /** Gets or sets the alpha index used to sort transparent meshes
  20193. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  20194. */
  20195. alphaIndex: number;
  20196. /**
  20197. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  20198. */
  20199. isVisible: boolean;
  20200. /**
  20201. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  20202. */
  20203. isPickable: boolean;
  20204. /**
  20205. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  20206. */
  20207. showBoundingBox: boolean;
  20208. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  20209. showSubMeshesBoundingBox: boolean;
  20210. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  20211. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  20212. */
  20213. isBlocker: boolean;
  20214. /**
  20215. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  20216. */
  20217. enablePointerMoveEvents: boolean;
  20218. /**
  20219. * Specifies the rendering group id for this mesh (0 by default)
  20220. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  20221. */
  20222. renderingGroupId: number;
  20223. private _material;
  20224. /** Gets or sets current material */
  20225. material: Nullable<Material>;
  20226. private _receiveShadows;
  20227. /**
  20228. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  20229. * @see http://doc.babylonjs.com/babylon101/shadows
  20230. */
  20231. receiveShadows: boolean;
  20232. /**
  20233. * Gets or sets a boolean indicating if the outline must be rendered as well
  20234. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  20235. */
  20236. renderOutline: boolean;
  20237. /** Defines color to use when rendering outline */
  20238. outlineColor: Color3;
  20239. /** Define width to use when rendering outline */
  20240. outlineWidth: number;
  20241. /**
  20242. * Gets or sets a boolean indicating if the overlay must be rendered as well
  20243. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  20244. */
  20245. renderOverlay: boolean;
  20246. /** Defines color to use when rendering overlay */
  20247. overlayColor: Color3;
  20248. /** Defines alpha to use when rendering overlay */
  20249. overlayAlpha: number;
  20250. private _hasVertexAlpha;
  20251. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  20252. hasVertexAlpha: boolean;
  20253. private _useVertexColors;
  20254. /** 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) */
  20255. useVertexColors: boolean;
  20256. private _computeBonesUsingShaders;
  20257. /**
  20258. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  20259. */
  20260. computeBonesUsingShaders: boolean;
  20261. private _numBoneInfluencers;
  20262. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  20263. numBoneInfluencers: number;
  20264. private _applyFog;
  20265. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  20266. applyFog: boolean;
  20267. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  20268. useOctreeForRenderingSelection: boolean;
  20269. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  20270. useOctreeForPicking: boolean;
  20271. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  20272. useOctreeForCollisions: boolean;
  20273. private _layerMask;
  20274. /**
  20275. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  20276. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  20277. */
  20278. layerMask: number;
  20279. /**
  20280. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  20281. */
  20282. alwaysSelectAsActiveMesh: boolean;
  20283. /**
  20284. * Gets or sets the current action manager
  20285. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  20286. */
  20287. actionManager: Nullable<ActionManager>;
  20288. /**
  20289. * Gets or sets impostor used for physic simulation
  20290. * @see http://doc.babylonjs.com/features/physics_engine
  20291. */
  20292. physicsImpostor: Nullable<PhysicsImpostor>;
  20293. private _checkCollisions;
  20294. private _collisionMask;
  20295. private _collisionGroup;
  20296. /**
  20297. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  20298. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  20299. */
  20300. ellipsoid: Vector3;
  20301. /**
  20302. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  20303. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  20304. */
  20305. ellipsoidOffset: Vector3;
  20306. private _collider;
  20307. private _oldPositionForCollisions;
  20308. private _diffPositionForCollisions;
  20309. /**
  20310. * Gets or sets a collision mask used to mask collisions (default is -1).
  20311. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  20312. */
  20313. collisionMask: number;
  20314. /**
  20315. * Gets or sets the current collision group mask (-1 by default).
  20316. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  20317. */
  20318. collisionGroup: number;
  20319. /**
  20320. * Defines edge width used when edgesRenderer is enabled
  20321. * @see https://www.babylonjs-playground.com/#10OJSG#13
  20322. */
  20323. edgesWidth: number;
  20324. /**
  20325. * Defines edge color used when edgesRenderer is enabled
  20326. * @see https://www.babylonjs-playground.com/#10OJSG#13
  20327. */
  20328. edgesColor: Color4;
  20329. /** @hidden */
  20330. private _collisionsTransformMatrix;
  20331. private _collisionsScalingMatrix;
  20332. /** @hidden */
  20333. /** @hidden */
  20334. /** @hidden */
  20335. /**
  20336. * Gets or sets the list of subMeshes
  20337. * @see http://doc.babylonjs.com/how_to/multi_materials
  20338. */
  20339. subMeshes: SubMesh[];
  20340. /** @hidden */
  20341. /** @hidden */
  20342. /** @hidden */
  20343. /** @hidden */
  20344. /** @hidden */
  20345. protected readonly _positions: Nullable<Vector3[]>;
  20346. /** @hidden */
  20347. /** @hidden */
  20348. private _skeleton;
  20349. /** @hidden */
  20350. /**
  20351. * Gets or sets a skeleton to apply skining transformations
  20352. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  20353. */
  20354. skeleton: Nullable<Skeleton>;
  20355. /**
  20356. * Creates a new AbstractMesh
  20357. * @param name defines the name of the mesh
  20358. * @param scene defines the hosting scene
  20359. */
  20360. constructor(name: string, scene?: Nullable<Scene>);
  20361. /**
  20362. * Returns the string "AbstractMesh"
  20363. * @returns "AbstractMesh"
  20364. */
  20365. getClassName(): string;
  20366. /**
  20367. * Gets a string representation of the current mesh
  20368. * @param fullDetails defines a boolean indicating if full details must be included
  20369. * @returns a string representation of the current mesh
  20370. */
  20371. toString(fullDetails?: boolean): string;
  20372. /** @hidden */
  20373. /** @hidden */
  20374. /** @hidden */
  20375. /** @hidden */
  20376. /** @hidden */
  20377. private _markSubMeshesAsDirty(func);
  20378. /** @hidden */
  20379. /** @hidden */
  20380. /** @hidden */
  20381. /**
  20382. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  20383. */
  20384. scaling: Vector3;
  20385. /**
  20386. * Disables the mesh edge rendering mode
  20387. * @returns the currentAbstractMesh
  20388. */
  20389. disableEdgesRendering(): AbstractMesh;
  20390. /**
  20391. * Enables the edge rendering mode on the mesh.
  20392. * This mode makes the mesh edges visible
  20393. * @param epsilon defines the maximal distance between two angles to detect a face
  20394. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  20395. * @returns the currentAbstractMesh
  20396. * @see https://www.babylonjs-playground.com/#19O9TU#0
  20397. */
  20398. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  20399. /**
  20400. * Gets the edgesRenderer associated with the mesh
  20401. */
  20402. readonly edgesRenderer: Nullable<EdgesRenderer>;
  20403. /**
  20404. * Returns true if the mesh is blocked. Implemented by child classes
  20405. */
  20406. readonly isBlocked: boolean;
  20407. /**
  20408. * Returns the mesh itself by default. Implemented by child classes
  20409. * @param camera defines the camera to use to pick the right LOD level
  20410. * @returns the currentAbstractMesh
  20411. */
  20412. getLOD(camera: Camera): Nullable<AbstractMesh>;
  20413. /**
  20414. * Returns 0 by default. Implemented by child classes
  20415. * @returns an integer
  20416. */
  20417. getTotalVertices(): number;
  20418. /**
  20419. * Returns null by default. Implemented by child classes
  20420. * @returns null
  20421. */
  20422. getIndices(): Nullable<IndicesArray>;
  20423. /**
  20424. * Returns the array of the requested vertex data kind. Implemented by child classes
  20425. * @param kind defines the vertex data kind to use
  20426. * @returns null
  20427. */
  20428. getVerticesData(kind: string): Nullable<FloatArray>;
  20429. /**
  20430. * Sets the vertex data of the mesh geometry for the requested `kind`.
  20431. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  20432. * Note that a new underlying VertexBuffer object is created each call.
  20433. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  20434. * @param kind defines vertex data kind:
  20435. * * BABYLON.VertexBuffer.PositionKind
  20436. * * BABYLON.VertexBuffer.UVKind
  20437. * * BABYLON.VertexBuffer.UV2Kind
  20438. * * BABYLON.VertexBuffer.UV3Kind
  20439. * * BABYLON.VertexBuffer.UV4Kind
  20440. * * BABYLON.VertexBuffer.UV5Kind
  20441. * * BABYLON.VertexBuffer.UV6Kind
  20442. * * BABYLON.VertexBuffer.ColorKind
  20443. * * BABYLON.VertexBuffer.MatricesIndicesKind
  20444. * * BABYLON.VertexBuffer.MatricesIndicesExtraKind
  20445. * * BABYLON.VertexBuffer.MatricesWeightsKind
  20446. * * BABYLON.VertexBuffer.MatricesWeightsExtraKind
  20447. * @param data defines the data source
  20448. * @param updatable defines if the data must be flagged as updatable (or static)
  20449. * @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
  20450. * @returns the current mesh
  20451. */
  20452. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  20453. /**
  20454. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  20455. * If the mesh has no geometry, it is simply returned as it is.
  20456. * @param kind defines vertex data kind:
  20457. * * BABYLON.VertexBuffer.PositionKind
  20458. * * BABYLON.VertexBuffer.UVKind
  20459. * * BABYLON.VertexBuffer.UV2Kind
  20460. * * BABYLON.VertexBuffer.UV3Kind
  20461. * * BABYLON.VertexBuffer.UV4Kind
  20462. * * BABYLON.VertexBuffer.UV5Kind
  20463. * * BABYLON.VertexBuffer.UV6Kind
  20464. * * BABYLON.VertexBuffer.ColorKind
  20465. * * BABYLON.VertexBuffer.MatricesIndicesKind
  20466. * * BABYLON.VertexBuffer.MatricesIndicesExtraKind
  20467. * * BABYLON.VertexBuffer.MatricesWeightsKind
  20468. * * BABYLON.VertexBuffer.MatricesWeightsExtraKind
  20469. * @param data defines the data source
  20470. * @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
  20471. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  20472. * @returns the current mesh
  20473. */
  20474. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  20475. /**
  20476. * Sets the mesh indices,
  20477. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  20478. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  20479. * @param totalVertices Defines the total number of vertices
  20480. * @returns the current mesh
  20481. */
  20482. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  20483. /**
  20484. * Gets a boolean indicating if specific vertex data is present
  20485. * @param kind defines the vertex data kind to use
  20486. * @returns true is data kind is present
  20487. */
  20488. isVerticesDataPresent(kind: string): boolean;
  20489. /**
  20490. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  20491. * @returns a BoundingInfo
  20492. */
  20493. getBoundingInfo(): BoundingInfo;
  20494. /**
  20495. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  20496. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box
  20497. * @returns the current mesh
  20498. */
  20499. normalizeToUnitCube(includeDescendants?: boolean): AbstractMesh;
  20500. /**
  20501. * Overwrite the current bounding info
  20502. * @param boundingInfo defines the new bounding info
  20503. * @returns the current mesh
  20504. */
  20505. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  20506. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  20507. readonly useBones: boolean;
  20508. /** @hidden */
  20509. /** @hidden */
  20510. /** @hidden */
  20511. /**
  20512. * Gets the current world matrix
  20513. * @returns a Matrix
  20514. */
  20515. getWorldMatrix(): Matrix;
  20516. /** @hidden */
  20517. /**
  20518. * Perform relative position change from the point of view of behind the front of the mesh.
  20519. * This is performed taking into account the meshes current rotation, so you do not have to care.
  20520. * Supports definition of mesh facing forward or backward
  20521. * @param amountRight defines the distance on the right axis
  20522. * @param amountUp defines the distance on the up axis
  20523. * @param amountForward defines the distance on the forward axis
  20524. * @returns the current mesh
  20525. */
  20526. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  20527. /**
  20528. * Calculate relative position change from the point of view of behind the front of the mesh.
  20529. * This is performed taking into account the meshes current rotation, so you do not have to care.
  20530. * Supports definition of mesh facing forward or backward
  20531. * @param amountRight defines the distance on the right axis
  20532. * @param amountUp defines the distance on the up axis
  20533. * @param amountForward defines the distance on the forward axis
  20534. * @returns the new displacement vector
  20535. */
  20536. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  20537. /**
  20538. * Perform relative rotation change from the point of view of behind the front of the mesh.
  20539. * Supports definition of mesh facing forward or backward
  20540. * @param flipBack defines the flip
  20541. * @param twirlClockwise defines the twirl
  20542. * @param tiltRight defines the tilt
  20543. * @returns the current mesh
  20544. */
  20545. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  20546. /**
  20547. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  20548. * Supports definition of mesh facing forward or backward.
  20549. * @param flipBack defines the flip
  20550. * @param twirlClockwise defines the twirl
  20551. * @param tiltRight defines the tilt
  20552. * @returns the new rotation vector
  20553. */
  20554. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  20555. /**
  20556. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  20557. * @param includeDescendants Include bounding info from descendants as well (true by default)
  20558. * @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
  20559. * @returns the new bounding vectors
  20560. */
  20561. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  20562. min: Vector3;
  20563. max: Vector3;
  20564. };
  20565. /** @hidden */
  20566. /** @hidden */
  20567. /** @hidden */
  20568. protected _afterComputeWorldMatrix(): void;
  20569. /**
  20570. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  20571. * A mesh is in the frustum if its bounding box intersects the frustum
  20572. * @param frustumPlanes defines the frustum to test
  20573. * @returns true if the mesh is in the frustum planes
  20574. */
  20575. isInFrustum(frustumPlanes: Plane[]): boolean;
  20576. /**
  20577. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  20578. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  20579. * @param frustumPlanes defines the frustum to test
  20580. * @returns true if the mesh is completely in the frustum planes
  20581. */
  20582. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  20583. /**
  20584. * True if the mesh intersects another mesh or a SolidParticle object
  20585. * @param mesh defines a target mesh or SolidParticle to test
  20586. * @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)
  20587. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  20588. * @returns true if there is an intersection
  20589. */
  20590. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  20591. /**
  20592. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  20593. * @param point defines the point to test
  20594. * @returns true if there is an intersection
  20595. */
  20596. intersectsPoint(point: Vector3): boolean;
  20597. /**
  20598. * Gets the current physics impostor
  20599. * @see http://doc.babylonjs.com/features/physics_engine
  20600. * @returns a physics impostor or null
  20601. */
  20602. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  20603. /**
  20604. * Gets the position of the current mesh in camera space
  20605. * @param camera defines the camera to use
  20606. * @returns a position
  20607. */
  20608. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  20609. /**
  20610. * Returns the distance from the mesh to the active camera
  20611. * @param camera defines the camera to use
  20612. * @returns the distance
  20613. */
  20614. getDistanceToCamera(camera?: Nullable<Camera>): number;
  20615. /**
  20616. * Apply a physic impulse to the mesh
  20617. * @param force defines the force to apply
  20618. * @param contactPoint defines where to apply the force
  20619. * @returns the current mesh
  20620. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  20621. */
  20622. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  20623. /**
  20624. * Creates a physic joint between two meshes
  20625. * @param otherMesh defines the other mesh to use
  20626. * @param pivot1 defines the pivot to use on this mesh
  20627. * @param pivot2 defines the pivot to use on the other mesh
  20628. * @param options defines additional options (can be plugin dependent)
  20629. * @returns the current mesh
  20630. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  20631. */
  20632. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  20633. /**
  20634. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  20635. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  20636. */
  20637. checkCollisions: boolean;
  20638. /**
  20639. * Gets Collider object used to compute collisions (not physics)
  20640. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  20641. */
  20642. readonly collider: Collider;
  20643. /**
  20644. * Move the mesh using collision engine
  20645. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  20646. * @param displacement defines the requested displacement vector
  20647. * @returns the current mesh
  20648. */
  20649. moveWithCollisions(displacement: Vector3): AbstractMesh;
  20650. private _onCollisionPositionChange;
  20651. /**
  20652. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  20653. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  20654. * @param maxCapacity defines the maximum size of each block (64 by default)
  20655. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  20656. * @returns the new octree
  20657. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  20658. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  20659. */
  20660. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  20661. /** @hidden */
  20662. /** @hidden */
  20663. /** @hidden */
  20664. /** @hidden */
  20665. /**
  20666. * Checks if the passed Ray intersects with the mesh
  20667. * @param ray defines the ray to use
  20668. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  20669. * @returns the picking info
  20670. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  20671. */
  20672. intersects(ray: Ray, fastCheck?: boolean): PickingInfo;
  20673. /**
  20674. * Clones the current mesh
  20675. * @param name defines the mesh name
  20676. * @param newParent defines the new mesh parent
  20677. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  20678. * @returns the new mesh
  20679. */
  20680. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  20681. /**
  20682. * Disposes all the submeshes of the current meshnp
  20683. * @returns the current mesh
  20684. */
  20685. releaseSubMeshes(): AbstractMesh;
  20686. /**
  20687. * Releases resources associated with this abstract mesh.
  20688. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  20689. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  20690. */
  20691. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  20692. /**
  20693. * Adds the passed mesh as a child to the current mesh
  20694. * @param mesh defines the child mesh
  20695. * @returns the current mesh
  20696. */
  20697. addChild(mesh: AbstractMesh): AbstractMesh;
  20698. /**
  20699. * Removes the passed mesh from the current mesh children list
  20700. * @param mesh defines the child mesh
  20701. * @returns the current mesh
  20702. */
  20703. removeChild(mesh: AbstractMesh): AbstractMesh;
  20704. /** @hidden */
  20705. private _initFacetData();
  20706. /**
  20707. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  20708. * This method can be called within the render loop.
  20709. * 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
  20710. * @returns the current mesh
  20711. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  20712. */
  20713. updateFacetData(): AbstractMesh;
  20714. /**
  20715. * Returns the facetLocalNormals array.
  20716. * The normals are expressed in the mesh local spac
  20717. * @returns an array of Vector3
  20718. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  20719. */
  20720. getFacetLocalNormals(): Vector3[];
  20721. /**
  20722. * Returns the facetLocalPositions array.
  20723. * The facet positions are expressed in the mesh local space
  20724. * @returns an array of Vector3
  20725. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  20726. */
  20727. getFacetLocalPositions(): Vector3[];
  20728. /**
  20729. * Returns the facetLocalPartioning array
  20730. * @returns an array of array of numbers
  20731. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  20732. */
  20733. getFacetLocalPartitioning(): number[][];
  20734. /**
  20735. * Returns the i-th facet position in the world system.
  20736. * This method allocates a new Vector3 per call
  20737. * @param i defines the facet index
  20738. * @returns a new Vector3
  20739. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  20740. */
  20741. getFacetPosition(i: number): Vector3;
  20742. /**
  20743. * Sets the reference Vector3 with the i-th facet position in the world system
  20744. * @param i defines the facet index
  20745. * @param ref defines the target vector
  20746. * @returns the current mesh
  20747. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  20748. */
  20749. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  20750. /**
  20751. * Returns the i-th facet normal in the world system.
  20752. * This method allocates a new Vector3 per call
  20753. * @param i defines the facet index
  20754. * @returns a new Vector3
  20755. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  20756. */
  20757. getFacetNormal(i: number): Vector3;
  20758. /**
  20759. * Sets the reference Vector3 with the i-th facet normal in the world system
  20760. * @param i defines the facet index
  20761. * @param ref defines the target vector
  20762. * @returns the current mesh
  20763. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  20764. */
  20765. getFacetNormalToRef(i: number, ref: Vector3): this;
  20766. /**
  20767. * 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)
  20768. * @param x defines x coordinate
  20769. * @param y defines y coordinate
  20770. * @param z defines z coordinate
  20771. * @returns the array of facet indexes
  20772. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  20773. */
  20774. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  20775. /**
  20776. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  20777. * @param projected sets as the (x,y,z) world projection on the facet
  20778. * @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
  20779. * @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
  20780. * @param x defines x coordinate
  20781. * @param y defines y coordinate
  20782. * @param z defines z coordinate
  20783. * @returns the face index if found (or null instead)
  20784. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  20785. */
  20786. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  20787. /**
  20788. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  20789. * @param projected sets as the (x,y,z) local projection on the facet
  20790. * @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
  20791. * @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
  20792. * @param x defines x coordinate
  20793. * @param y defines y coordinate
  20794. * @param z defines z coordinate
  20795. * @returns the face index if found (or null instead)
  20796. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  20797. */
  20798. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  20799. /**
  20800. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  20801. * @returns the parameters
  20802. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  20803. */
  20804. getFacetDataParameters(): any;
  20805. /**
  20806. * Disables the feature FacetData and frees the related memory
  20807. * @returns the current mesh
  20808. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  20809. */
  20810. disableFacetData(): AbstractMesh;
  20811. /**
  20812. * Updates the AbstractMesh indices array
  20813. * @param indices defines the data source
  20814. * @returns the current mesh
  20815. */
  20816. updateIndices(indices: IndicesArray): AbstractMesh;
  20817. /**
  20818. * Creates new normals data for the mesh
  20819. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  20820. * @returns the current mesh
  20821. */
  20822. createNormals(updatable: boolean): AbstractMesh;
  20823. /**
  20824. * Align the mesh with a normal
  20825. * @param normal defines the normal to use
  20826. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  20827. * @returns the current mesh
  20828. */
  20829. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  20830. /** @hidden */
  20831. protected _checkOcclusionQuery(): void;
  20832. }
  20833. }
  20834. declare module BABYLON {
  20835. class Buffer {
  20836. private _engine;
  20837. private _buffer;
  20838. /** @hidden */
  20839. private _updatable;
  20840. private _instanced;
  20841. /**
  20842. * Gets the byte stride.
  20843. */
  20844. readonly byteStride: number;
  20845. /**
  20846. * Constructor
  20847. * @param engine the engine
  20848. * @param data the data to use for this buffer
  20849. * @param updatable whether the data is updatable
  20850. * @param stride the stride (optional)
  20851. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  20852. * @param instanced whether the buffer is instanced (optional)
  20853. * @param useBytes set to true if the stride in in bytes (optional)
  20854. */
  20855. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  20856. /**
  20857. * Create a new {BABYLON.VertexBuffer} based on the current buffer
  20858. * @param kind defines the vertex buffer kind (position, normal, etc.)
  20859. * @param offset defines offset in the buffer (0 by default)
  20860. * @param size defines the size in floats of attributes (position is 3 for instance)
  20861. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  20862. * @param instanced defines if the vertex buffer contains indexed data
  20863. * @param useBytes defines if the offset and stride are in bytes
  20864. * @returns the new vertex buffer
  20865. */
  20866. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  20867. isUpdatable(): boolean;
  20868. getData(): Nullable<DataArray>;
  20869. getBuffer(): Nullable<WebGLBuffer>;
  20870. /**
  20871. * Gets the stride in float32 units (i.e. byte stride / 4).
  20872. * May not be an integer if the byte stride is not divisible by 4.
  20873. * DEPRECATED. Use byteStride instead.
  20874. * @returns the stride in float32 units
  20875. */
  20876. getStrideSize(): number;
  20877. create(data?: Nullable<DataArray>): void;
  20878. update(data: DataArray): void;
  20879. /**
  20880. * Updates the data directly.
  20881. * @param data the new data
  20882. * @param offset the new offset
  20883. * @param vertexCount the vertex count (optional)
  20884. * @param useBytes set to true if the offset is in bytes
  20885. */
  20886. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  20887. dispose(): void;
  20888. }
  20889. }
  20890. declare module BABYLON {
  20891. class CSG {
  20892. private polygons;
  20893. matrix: Matrix;
  20894. position: Vector3;
  20895. rotation: Vector3;
  20896. rotationQuaternion: Nullable<Quaternion>;
  20897. scaling: Vector3;
  20898. static FromMesh(mesh: Mesh): CSG;
  20899. private static FromPolygons(polygons);
  20900. clone(): CSG;
  20901. union(csg: CSG): CSG;
  20902. unionInPlace(csg: CSG): void;
  20903. subtract(csg: CSG): CSG;
  20904. subtractInPlace(csg: CSG): void;
  20905. intersect(csg: CSG): CSG;
  20906. intersectInPlace(csg: CSG): void;
  20907. inverse(): CSG;
  20908. inverseInPlace(): void;
  20909. copyTransformAttributes(csg: CSG): CSG;
  20910. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  20911. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  20912. }
  20913. }
  20914. declare module BABYLON {
  20915. /**
  20916. * Class used to store geometry data (vertex buffers + index buffer)
  20917. */
  20918. class Geometry implements IGetSetVerticesData {
  20919. /**
  20920. * Gets or sets the unique ID of the geometry
  20921. */
  20922. id: string;
  20923. /**
  20924. * Gets the delay loading state of the geometry (none by default which means not delayed)
  20925. */
  20926. delayLoadState: number;
  20927. /**
  20928. * Gets the file containing the data to load when running in delay load state
  20929. */
  20930. delayLoadingFile: Nullable<string>;
  20931. /**
  20932. * Callback called when the geometry is updated
  20933. */
  20934. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  20935. private _scene;
  20936. private _engine;
  20937. private _meshes;
  20938. private _totalVertices;
  20939. /** @hidden */
  20940. /** @hidden */
  20941. ;
  20942. private _isDisposed;
  20943. private _extend;
  20944. private _boundingBias;
  20945. /** @hidden */
  20946. private _indexBuffer;
  20947. private _indexBufferIsUpdatable;
  20948. /** @hidden */
  20949. /** @hidden */
  20950. /** @hidden */
  20951. private _vertexArrayObjects;
  20952. private _updatable;
  20953. /** @hidden */
  20954. /**
  20955. * 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
  20956. */
  20957. /**
  20958. * 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
  20959. */
  20960. boundingBias: Vector2;
  20961. /**
  20962. * Static function used to attach a new empty geometry to a mesh
  20963. * @param mesh defines the mesh to attach the geometry to
  20964. * @returns the new {BABYLON.Geometry}
  20965. */
  20966. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  20967. /**
  20968. * Creates a new geometry
  20969. * @param id defines the unique ID
  20970. * @param scene defines the hosting scene
  20971. * @param vertexData defines the {BABYLON.VertexData} used to get geometry data
  20972. * @param updatable defines if geometry must be updatable (false by default)
  20973. * @param mesh defines the mesh that will be associated with the geometry
  20974. */
  20975. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  20976. /**
  20977. * Gets the current extend of the geometry
  20978. */
  20979. readonly extend: {
  20980. minimum: Vector3;
  20981. maximum: Vector3;
  20982. };
  20983. /**
  20984. * Gets the hosting scene
  20985. * @returns the hosting {BABYLON.Scene}
  20986. */
  20987. getScene(): Scene;
  20988. /**
  20989. * Gets the hosting engine
  20990. * @returns the hosting {BABYLON.Engine}
  20991. */
  20992. getEngine(): Engine;
  20993. /**
  20994. * Defines if the geometry is ready to use
  20995. * @returns true if the geometry is ready to be used
  20996. */
  20997. isReady(): boolean;
  20998. /**
  20999. * Gets a value indicating that the geometry should not be serialized
  21000. */
  21001. readonly doNotSerialize: boolean;
  21002. /** @hidden */
  21003. /**
  21004. * Affects all geometry data in one call
  21005. * @param vertexData defines the geometry data
  21006. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  21007. */
  21008. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  21009. /**
  21010. * Set specific vertex data
  21011. * @param kind defines the data kind (Position, normal, etc...)
  21012. * @param data defines the vertex data to use
  21013. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21014. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21015. */
  21016. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  21017. /**
  21018. * Removes a specific vertex data
  21019. * @param kind defines the data kind (Position, normal, etc...)
  21020. */
  21021. removeVerticesData(kind: string): void;
  21022. /**
  21023. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  21024. * @param buffer defines the vertex buffer to use
  21025. * @param totalVertices defines the total number of vertices for position kind (could be null)
  21026. */
  21027. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  21028. /**
  21029. * Update a specific vertex buffer
  21030. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  21031. * It will do nothing if the buffer is not updatable
  21032. * @param kind defines the data kind (Position, normal, etc...)
  21033. * @param data defines the data to use
  21034. * @param offset defines the offset in the target buffer where to store the data
  21035. * @param useBytes set to true if the offset is in bytes
  21036. */
  21037. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  21038. /**
  21039. * Update a specific vertex buffer
  21040. * This function will create a new buffer if the current one is not updatable
  21041. * @param kind defines the data kind (Position, normal, etc...)
  21042. * @param data defines the data to use
  21043. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  21044. */
  21045. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  21046. private _updateBoundingInfo(updateExtends, data);
  21047. /** @hidden */
  21048. /**
  21049. * Gets total number of vertices
  21050. * @returns the total number of vertices
  21051. */
  21052. getTotalVertices(): number;
  21053. /**
  21054. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21055. * @param kind defines the data kind (Position, normal, etc...)
  21056. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21057. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21058. * @returns a float array containing vertex data
  21059. */
  21060. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21061. /**
  21062. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  21063. * @param kind defines the data kind (Position, normal, etc...)
  21064. * @returns true if the vertex buffer with the specified kind is updatable
  21065. */
  21066. isVertexBufferUpdatable(kind: string): boolean;
  21067. /**
  21068. * Gets a specific vertex buffer
  21069. * @param kind defines the data kind (Position, normal, etc...)
  21070. * @returns a {BABYLON.VertexBuffer}
  21071. */
  21072. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21073. /**
  21074. * Returns all vertex buffers
  21075. * @return an object holding all vertex buffers indexed by kind
  21076. */
  21077. getVertexBuffers(): Nullable<{
  21078. [key: string]: VertexBuffer;
  21079. }>;
  21080. /**
  21081. * Gets a boolean indicating if specific vertex buffer is present
  21082. * @param kind defines the data kind (Position, normal, etc...)
  21083. * @returns true if data is present
  21084. */
  21085. isVerticesDataPresent(kind: string): boolean;
  21086. /**
  21087. * Gets a list of all attached data kinds (Position, normal, etc...)
  21088. * @returns a list of string containing all kinds
  21089. */
  21090. getVerticesDataKinds(): string[];
  21091. /**
  21092. * Update index buffer
  21093. * @param indices defines the indices to store in the index buffer
  21094. * @param offset defines the offset in the target buffer where to store the data
  21095. */
  21096. updateIndices(indices: IndicesArray, offset?: number): void;
  21097. /**
  21098. * Creates a new index buffer
  21099. * @param indices defines the indices to store in the index buffer
  21100. * @param totalVertices defines the total number of vertices (could be null)
  21101. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21102. */
  21103. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  21104. /**
  21105. * Return the total number of indices
  21106. * @returns the total number of indices
  21107. */
  21108. getTotalIndices(): number;
  21109. /**
  21110. * Gets the index buffer array
  21111. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21112. * @returns the index buffer array
  21113. */
  21114. getIndices(copyWhenShared?: boolean): Nullable<IndicesArray>;
  21115. /**
  21116. * Gets the index buffer
  21117. * @return the index buffer
  21118. */
  21119. getIndexBuffer(): Nullable<WebGLBuffer>;
  21120. /** @hidden */
  21121. /**
  21122. * Release the associated resources for a specific mesh
  21123. * @param mesh defines the source mesh
  21124. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  21125. */
  21126. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  21127. /**
  21128. * Apply current geometry to a given mesh
  21129. * @param mesh defines the mesh to apply geometry to
  21130. */
  21131. applyToMesh(mesh: Mesh): void;
  21132. private _updateExtend(data?);
  21133. private _applyToMesh(mesh);
  21134. private notifyUpdate(kind?);
  21135. /**
  21136. * Load the geometry if it was flagged as delay loaded
  21137. * @param scene defines the hosting scene
  21138. * @param onLoaded defines a callback called when the geometry is loaded
  21139. */
  21140. load(scene: Scene, onLoaded?: () => void): void;
  21141. private _queueLoad(scene, onLoaded?);
  21142. /**
  21143. * Invert the geometry to move from a right handed system to a left handed one.
  21144. */
  21145. toLeftHanded(): void;
  21146. /** @hidden */
  21147. /** @hidden */
  21148. /**
  21149. * Gets a value indicating if the geometry is disposed
  21150. * @returns true if the geometry was disposed
  21151. */
  21152. isDisposed(): boolean;
  21153. private _disposeVertexArrayObjects();
  21154. /**
  21155. * Free all associated resources
  21156. */
  21157. dispose(): void;
  21158. /**
  21159. * Clone the current geometry into a new geometry
  21160. * @param id defines the unique ID of the new geometry
  21161. * @returns a new geometry object
  21162. */
  21163. copy(id: string): Geometry;
  21164. /**
  21165. * Serialize the current geometry info (and not the vertices data) into a JSON object
  21166. * @return a JSON representation of the current geometry data (without the vertices data)
  21167. */
  21168. serialize(): any;
  21169. private toNumberArray(origin);
  21170. /**
  21171. * Serialize all vertices data into a JSON oject
  21172. * @returns a JSON representation of the current geometry data
  21173. */
  21174. serializeVerticeData(): any;
  21175. /**
  21176. * Extracts a clone of a mesh geometry
  21177. * @param mesh defines the source mesh
  21178. * @param id defines the unique ID of the new geometry object
  21179. * @returns the new geometry object
  21180. */
  21181. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  21182. /**
  21183. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  21184. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  21185. * Be aware Math.random() could cause collisions, but:
  21186. * "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"
  21187. * @returns a string containing a new GUID
  21188. */
  21189. static RandomId(): string;
  21190. /** @hidden */
  21191. private static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  21192. private static _CleanMatricesWeights(parsedGeometry, mesh);
  21193. /**
  21194. * Create a new geometry from persisted data (Using .babylon file format)
  21195. * @param parsedVertexData defines the persisted data
  21196. * @param scene defines the hosting scene
  21197. * @param rootUrl defines the root url to use to load assets (like delayed data)
  21198. * @returns the new geometry object
  21199. */
  21200. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  21201. }
  21202. /**
  21203. * Abstract class used to provide common services for all typed geometries
  21204. * @hidden
  21205. */
  21206. class _PrimitiveGeometry extends Geometry {
  21207. private _canBeRegenerated;
  21208. private _beingRegenerated;
  21209. /**
  21210. * Creates a new typed geometry
  21211. * @param id defines the unique ID of the geometry
  21212. * @param scene defines the hosting scene
  21213. * @param _canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  21214. * @param mesh defines the hosting mesh (can be null)
  21215. */
  21216. constructor(id: string, scene: Scene, _canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  21217. /**
  21218. * Gets a value indicating if the geometry supports being regenerated with new parameters (false by default)
  21219. * @returns true if the geometry can be regenerated
  21220. */
  21221. canBeRegenerated(): boolean;
  21222. /**
  21223. * If the geometry supports regeneration, the function will recreates the geometry with updated parameter values
  21224. */
  21225. regenerate(): void;
  21226. /**
  21227. * Clone the geometry
  21228. * @param id defines the unique ID of the new geometry
  21229. * @returns the new geometry
  21230. */
  21231. asNewGeometry(id: string): Geometry;
  21232. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  21233. setVerticesData(kind: string, data: FloatArray, updatable?: boolean): void;
  21234. /** @hidden */
  21235. copy(id: string): Geometry;
  21236. serialize(): any;
  21237. }
  21238. /**
  21239. * Creates a ribbon geometry
  21240. * @description See http://doc.babylonjs.com/how_to/ribbon_tutorial, http://doc.babylonjs.com/resources/maths_make_ribbons
  21241. */
  21242. class RibbonGeometry extends _PrimitiveGeometry {
  21243. /**
  21244. * Defines the array of paths to use
  21245. */
  21246. pathArray: Vector3[][];
  21247. /**
  21248. * Defines if the last and first points of each path in your pathArray must be joined
  21249. */
  21250. closeArray: boolean;
  21251. /**
  21252. * Defines if the last and first points of each path in your pathArray must be joined
  21253. */
  21254. closePath: boolean;
  21255. /**
  21256. * Defines the offset between points
  21257. */
  21258. offset: number;
  21259. /**
  21260. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  21261. */
  21262. side: number;
  21263. /**
  21264. * Creates a ribbon geometry
  21265. * @param id defines the unique ID of the geometry
  21266. * @param scene defines the hosting scene
  21267. * @param pathArray defines the array of paths to use
  21268. * @param closeArray defines if the last path and the first path must be joined
  21269. * @param closePath defines if the last and first points of each path in your pathArray must be joined
  21270. * @param offset defines the offset between points
  21271. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  21272. * @param mesh defines the hosting mesh (can be null)
  21273. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  21274. */
  21275. constructor(id: string, scene: Scene,
  21276. /**
  21277. * Defines the array of paths to use
  21278. */
  21279. pathArray: Vector3[][],
  21280. /**
  21281. * Defines if the last and first points of each path in your pathArray must be joined
  21282. */
  21283. closeArray: boolean,
  21284. /**
  21285. * Defines if the last and first points of each path in your pathArray must be joined
  21286. */
  21287. closePath: boolean,
  21288. /**
  21289. * Defines the offset between points
  21290. */
  21291. offset: number, canBeRegenerated?: boolean, mesh?: Mesh,
  21292. /**
  21293. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  21294. */
  21295. side?: number);
  21296. /** @hidden */
  21297. copy(id: string): Geometry;
  21298. }
  21299. /**
  21300. * Creates a box geometry
  21301. * @description see http://doc.babylonjs.com/how_to/set_shapes#box
  21302. */
  21303. class BoxGeometry extends _PrimitiveGeometry {
  21304. /**
  21305. * Defines the zise of the box (width, height and depth are the same)
  21306. */
  21307. size: number;
  21308. /**
  21309. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  21310. */
  21311. side: number;
  21312. /**
  21313. * Creates a box geometry
  21314. * @param id defines the unique ID of the geometry
  21315. * @param scene defines the hosting scene
  21316. * @param size defines the zise of the box (width, height and depth are the same)
  21317. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  21318. * @param mesh defines the hosting mesh (can be null)
  21319. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  21320. */
  21321. constructor(id: string, scene: Scene,
  21322. /**
  21323. * Defines the zise of the box (width, height and depth are the same)
  21324. */
  21325. size: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  21326. /**
  21327. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  21328. */
  21329. side?: number);
  21330. copy(id: string): Geometry;
  21331. serialize(): any;
  21332. static Parse(parsedBox: any, scene: Scene): Nullable<BoxGeometry>;
  21333. }
  21334. /**
  21335. * Creates a sphere geometry
  21336. * @description see http://doc.babylonjs.com/how_to/set_shapes#sphere
  21337. */
  21338. class SphereGeometry extends _PrimitiveGeometry {
  21339. /**
  21340. * Defines the number of segments to use to create the sphere
  21341. */
  21342. segments: number;
  21343. /**
  21344. * Defines the diameter of the sphere
  21345. */
  21346. diameter: number;
  21347. /**
  21348. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  21349. */
  21350. side: number;
  21351. /**
  21352. * Create a new sphere geometry
  21353. * @param id defines the unique ID of the geometry
  21354. * @param scene defines the hosting scene
  21355. * @param segments defines the number of segments to use to create the sphere
  21356. * @param diameter defines the diameter of the sphere
  21357. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  21358. * @param mesh defines the hosting mesh (can be null)
  21359. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  21360. */
  21361. constructor(id: string, scene: Scene,
  21362. /**
  21363. * Defines the number of segments to use to create the sphere
  21364. */
  21365. segments: number,
  21366. /**
  21367. * Defines the diameter of the sphere
  21368. */
  21369. diameter: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  21370. /**
  21371. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  21372. */
  21373. side?: number);
  21374. copy(id: string): Geometry;
  21375. serialize(): any;
  21376. static Parse(parsedSphere: any, scene: Scene): Nullable<SphereGeometry>;
  21377. }
  21378. /**
  21379. * Creates a disc geometry
  21380. * @description see http://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  21381. */
  21382. class DiscGeometry extends _PrimitiveGeometry {
  21383. /**
  21384. * Defines the radius of the disc
  21385. */
  21386. radius: number;
  21387. /**
  21388. * Defines the tesselation factor to apply to the disc
  21389. */
  21390. tessellation: number;
  21391. /**
  21392. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  21393. */
  21394. side: number;
  21395. /**
  21396. * Creates a new disc geometry
  21397. * @param id defines the unique ID of the geometry
  21398. * @param scene defines the hosting scene
  21399. * @param radius defines the radius of the disc
  21400. * @param tessellation defines the tesselation factor to apply to the disc
  21401. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  21402. * @param mesh defines the hosting mesh (can be null)
  21403. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  21404. */
  21405. constructor(id: string, scene: Scene,
  21406. /**
  21407. * Defines the radius of the disc
  21408. */
  21409. radius: number,
  21410. /**
  21411. * Defines the tesselation factor to apply to the disc
  21412. */
  21413. tessellation: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  21414. /**
  21415. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  21416. */
  21417. side?: number);
  21418. copy(id: string): Geometry;
  21419. }
  21420. /**
  21421. * Creates a new cylinder geometry
  21422. * @description see http://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  21423. */
  21424. class CylinderGeometry extends _PrimitiveGeometry {
  21425. /**
  21426. * Defines the height of the cylinder
  21427. */
  21428. height: number;
  21429. /**
  21430. * Defines the diameter of the cylinder's top cap
  21431. */
  21432. diameterTop: number;
  21433. /**
  21434. * Defines the diameter of the cylinder's bottom cap
  21435. */
  21436. diameterBottom: number;
  21437. /**
  21438. * Defines the tessellation factor to apply to the cylinder
  21439. */
  21440. tessellation: number;
  21441. /**
  21442. * Defines the number of subdivisions to apply to the cylinder (1 by default)
  21443. */
  21444. subdivisions: number;
  21445. /**
  21446. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  21447. */
  21448. side: number;
  21449. /**
  21450. * Creates a new cylinder geometry
  21451. * @param id defines the unique ID of the geometry
  21452. * @param scene defines the hosting scene
  21453. * @param height defines the height of the cylinder
  21454. * @param diameterTop defines the diameter of the cylinder's top cap
  21455. * @param diameterBottom defines the diameter of the cylinder's bottom cap
  21456. * @param tessellation defines the tessellation factor to apply to the cylinder (number of radial sides)
  21457. * @param subdivisions defines the number of subdivisions to apply to the cylinder (number of rings) (1 by default)
  21458. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  21459. * @param mesh defines the hosting mesh (can be null)
  21460. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  21461. */
  21462. constructor(id: string, scene: Scene,
  21463. /**
  21464. * Defines the height of the cylinder
  21465. */
  21466. height: number,
  21467. /**
  21468. * Defines the diameter of the cylinder's top cap
  21469. */
  21470. diameterTop: number,
  21471. /**
  21472. * Defines the diameter of the cylinder's bottom cap
  21473. */
  21474. diameterBottom: number,
  21475. /**
  21476. * Defines the tessellation factor to apply to the cylinder
  21477. */
  21478. tessellation: number,
  21479. /**
  21480. * Defines the number of subdivisions to apply to the cylinder (1 by default)
  21481. */
  21482. subdivisions?: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  21483. /**
  21484. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  21485. */
  21486. side?: number);
  21487. copy(id: string): Geometry;
  21488. serialize(): any;
  21489. static Parse(parsedCylinder: any, scene: Scene): Nullable<CylinderGeometry>;
  21490. }
  21491. /**
  21492. * Creates a new torus geometry
  21493. * @description see http://doc.babylonjs.com/how_to/set_shapes#torus
  21494. */
  21495. class TorusGeometry extends _PrimitiveGeometry {
  21496. /**
  21497. * Defines the diameter of the torus
  21498. */
  21499. diameter: number;
  21500. /**
  21501. * Defines the thickness of the torus (ie. internal diameter)
  21502. */
  21503. thickness: number;
  21504. /**
  21505. * Defines the tesselation factor to apply to the torus
  21506. */
  21507. tessellation: number;
  21508. /**
  21509. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  21510. */
  21511. side: number;
  21512. /**
  21513. * Creates a new torus geometry
  21514. * @param id defines the unique ID of the geometry
  21515. * @param scene defines the hosting scene
  21516. * @param diameter defines the diameter of the torus
  21517. * @param thickness defines the thickness of the torus (ie. internal diameter)
  21518. * @param tessellation defines the tesselation factor to apply to the torus (number of segments along the circle)
  21519. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  21520. * @param mesh defines the hosting mesh (can be null)
  21521. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  21522. */
  21523. constructor(id: string, scene: Scene,
  21524. /**
  21525. * Defines the diameter of the torus
  21526. */
  21527. diameter: number,
  21528. /**
  21529. * Defines the thickness of the torus (ie. internal diameter)
  21530. */
  21531. thickness: number,
  21532. /**
  21533. * Defines the tesselation factor to apply to the torus
  21534. */
  21535. tessellation: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  21536. /**
  21537. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  21538. */
  21539. side?: number);
  21540. copy(id: string): Geometry;
  21541. serialize(): any;
  21542. static Parse(parsedTorus: any, scene: Scene): Nullable<TorusGeometry>;
  21543. }
  21544. /**
  21545. * Creates a new ground geometry
  21546. * @description see http://doc.babylonjs.com/how_to/set_shapes#ground
  21547. */
  21548. class GroundGeometry extends _PrimitiveGeometry {
  21549. /**
  21550. * Defines the width of the ground
  21551. */
  21552. width: number;
  21553. /**
  21554. * Defines the height of the ground
  21555. */
  21556. height: number;
  21557. /**
  21558. * Defines the subdivisions to apply to the ground
  21559. */
  21560. subdivisions: number;
  21561. /**
  21562. * Creates a new ground geometry
  21563. * @param id defines the unique ID of the geometry
  21564. * @param scene defines the hosting scene
  21565. * @param width defines the width of the ground
  21566. * @param height defines the height of the ground
  21567. * @param subdivisions defines the subdivisions to apply to the ground
  21568. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  21569. * @param mesh defines the hosting mesh (can be null)
  21570. */
  21571. constructor(id: string, scene: Scene,
  21572. /**
  21573. * Defines the width of the ground
  21574. */
  21575. width: number,
  21576. /**
  21577. * Defines the height of the ground
  21578. */
  21579. height: number,
  21580. /**
  21581. * Defines the subdivisions to apply to the ground
  21582. */
  21583. subdivisions: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  21584. copy(id: string): Geometry;
  21585. serialize(): any;
  21586. static Parse(parsedGround: any, scene: Scene): Nullable<GroundGeometry>;
  21587. }
  21588. /**
  21589. * Creates a tiled ground geometry
  21590. * @description see http://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  21591. */
  21592. class TiledGroundGeometry extends _PrimitiveGeometry {
  21593. /**
  21594. * Defines the minimum value on X axis
  21595. */
  21596. xmin: number;
  21597. /**
  21598. * Defines the minimum value on Z axis
  21599. */
  21600. zmin: number;
  21601. /**
  21602. * Defines the maximum value on X axis
  21603. */
  21604. xmax: number;
  21605. /**
  21606. * Defines the maximum value on Z axis
  21607. */
  21608. zmax: number;
  21609. /**
  21610. * Defines the subdivisions to apply to the ground
  21611. */
  21612. subdivisions: {
  21613. w: number;
  21614. h: number;
  21615. };
  21616. /**
  21617. * Defines the precision to use when computing the tiles
  21618. */
  21619. precision: {
  21620. w: number;
  21621. h: number;
  21622. };
  21623. /**
  21624. * Creates a tiled ground geometry
  21625. * @param id defines the unique ID of the geometry
  21626. * @param scene defines the hosting scene
  21627. * @param xmin defines the minimum value on X axis
  21628. * @param zmin defines the minimum value on Z axis
  21629. * @param xmax defines the maximum value on X axis
  21630. * @param zmax defines the maximum value on Z axis
  21631. * @param subdivisions defines the subdivisions to apply to the ground (number of subdivisions (tiles) on the height and the width of the map)
  21632. * @param precision defines the precision to use when computing the tiles
  21633. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  21634. * @param mesh defines the hosting mesh (can be null)
  21635. */
  21636. constructor(id: string, scene: Scene,
  21637. /**
  21638. * Defines the minimum value on X axis
  21639. */
  21640. xmin: number,
  21641. /**
  21642. * Defines the minimum value on Z axis
  21643. */
  21644. zmin: number,
  21645. /**
  21646. * Defines the maximum value on X axis
  21647. */
  21648. xmax: number,
  21649. /**
  21650. * Defines the maximum value on Z axis
  21651. */
  21652. zmax: number,
  21653. /**
  21654. * Defines the subdivisions to apply to the ground
  21655. */
  21656. subdivisions: {
  21657. w: number;
  21658. h: number;
  21659. },
  21660. /**
  21661. * Defines the precision to use when computing the tiles
  21662. */
  21663. precision: {
  21664. w: number;
  21665. h: number;
  21666. }, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  21667. copy(id: string): Geometry;
  21668. }
  21669. /**
  21670. * Creates a plane geometry
  21671. * @description see http://doc.babylonjs.com/how_to/set_shapes#plane
  21672. */
  21673. class PlaneGeometry extends _PrimitiveGeometry {
  21674. /**
  21675. * Defines the size of the plane (width === height)
  21676. */
  21677. size: number;
  21678. /**
  21679. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  21680. */
  21681. side: number;
  21682. /**
  21683. * Creates a plane geometry
  21684. * @param id defines the unique ID of the geometry
  21685. * @param scene defines the hosting scene
  21686. * @param size defines the size of the plane (width === height)
  21687. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  21688. * @param mesh defines the hosting mesh (can be null)
  21689. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  21690. */
  21691. constructor(id: string, scene: Scene,
  21692. /**
  21693. * Defines the size of the plane (width === height)
  21694. */
  21695. size: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  21696. /**
  21697. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  21698. */
  21699. side?: number);
  21700. copy(id: string): Geometry;
  21701. serialize(): any;
  21702. static Parse(parsedPlane: any, scene: Scene): Nullable<PlaneGeometry>;
  21703. }
  21704. /**
  21705. * Creates a torus knot geometry
  21706. * @description see http://doc.babylonjs.com/how_to/set_shapes#torus-knot
  21707. */
  21708. class TorusKnotGeometry extends _PrimitiveGeometry {
  21709. /**
  21710. * Defines the radius of the torus knot
  21711. */
  21712. radius: number;
  21713. /**
  21714. * Defines the thickness of the torus knot tube
  21715. */
  21716. tube: number;
  21717. /**
  21718. * Defines the number of radial segments
  21719. */
  21720. radialSegments: number;
  21721. /**
  21722. * Defines the number of tubular segments
  21723. */
  21724. tubularSegments: number;
  21725. /**
  21726. * Defines the first number of windings
  21727. */
  21728. p: number;
  21729. /**
  21730. * Defines the second number of windings
  21731. */
  21732. q: number;
  21733. /**
  21734. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  21735. */
  21736. side: number;
  21737. /**
  21738. * Creates a torus knot geometry
  21739. * @param id defines the unique ID of the geometry
  21740. * @param scene defines the hosting scene
  21741. * @param radius defines the radius of the torus knot
  21742. * @param tube defines the thickness of the torus knot tube
  21743. * @param radialSegments defines the number of radial segments
  21744. * @param tubularSegments defines the number of tubular segments
  21745. * @param p defines the first number of windings
  21746. * @param q defines the second number of windings
  21747. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  21748. * @param mesh defines the hosting mesh (can be null)
  21749. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  21750. */
  21751. constructor(id: string, scene: Scene,
  21752. /**
  21753. * Defines the radius of the torus knot
  21754. */
  21755. radius: number,
  21756. /**
  21757. * Defines the thickness of the torus knot tube
  21758. */
  21759. tube: number,
  21760. /**
  21761. * Defines the number of radial segments
  21762. */
  21763. radialSegments: number,
  21764. /**
  21765. * Defines the number of tubular segments
  21766. */
  21767. tubularSegments: number,
  21768. /**
  21769. * Defines the first number of windings
  21770. */
  21771. p: number,
  21772. /**
  21773. * Defines the second number of windings
  21774. */
  21775. q: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  21776. /**
  21777. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  21778. */
  21779. side?: number);
  21780. copy(id: string): Geometry;
  21781. serialize(): any;
  21782. static Parse(parsedTorusKnot: any, scene: Scene): Nullable<TorusKnotGeometry>;
  21783. }
  21784. }
  21785. declare module BABYLON {
  21786. class GroundMesh extends Mesh {
  21787. generateOctree: boolean;
  21788. private _heightQuads;
  21789. constructor(name: string, scene: Scene);
  21790. getClassName(): string;
  21791. readonly subdivisions: number;
  21792. readonly subdivisionsX: number;
  21793. readonly subdivisionsY: number;
  21794. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  21795. /**
  21796. * Returns a height (y) value in the Worl system :
  21797. * the ground altitude at the coordinates (x, z) expressed in the World system.
  21798. * Returns the ground y position if (x, z) are outside the ground surface.
  21799. */
  21800. getHeightAtCoordinates(x: number, z: number): number;
  21801. /**
  21802. * Returns a normalized vector (Vector3) orthogonal to the ground
  21803. * at the ground coordinates (x, z) expressed in the World system.
  21804. * Returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  21805. */
  21806. getNormalAtCoordinates(x: number, z: number): Vector3;
  21807. /**
  21808. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  21809. * at the ground coordinates (x, z) expressed in the World system.
  21810. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  21811. * Returns the GroundMesh.
  21812. */
  21813. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  21814. /**
  21815. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  21816. * if the ground has been updated.
  21817. * This can be used in the render loop.
  21818. * Returns the GroundMesh.
  21819. */
  21820. updateCoordinateHeights(): GroundMesh;
  21821. private _getFacetAt(x, z);
  21822. private _initHeightQuads();
  21823. private _computeHeightQuads();
  21824. serialize(serializationObject: any): void;
  21825. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  21826. }
  21827. }
  21828. declare module BABYLON {
  21829. /**
  21830. * Creates an instance based on a source mesh.
  21831. */
  21832. class InstancedMesh extends AbstractMesh {
  21833. private _sourceMesh;
  21834. private _currentLOD;
  21835. constructor(name: string, source: Mesh);
  21836. /**
  21837. * Returns the string "InstancedMesh".
  21838. */
  21839. getClassName(): string;
  21840. readonly receiveShadows: boolean;
  21841. readonly material: Nullable<Material>;
  21842. readonly visibility: number;
  21843. readonly skeleton: Nullable<Skeleton>;
  21844. renderingGroupId: number;
  21845. /**
  21846. * Returns the total number of vertices (integer).
  21847. */
  21848. getTotalVertices(): number;
  21849. readonly sourceMesh: Mesh;
  21850. /**
  21851. * Is this node ready to be used/rendered
  21852. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  21853. * @return {boolean} is it ready
  21854. */
  21855. isReady(completeCheck?: boolean): boolean;
  21856. /**
  21857. * Returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  21858. */
  21859. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  21860. /**
  21861. * Sets the vertex data of the mesh geometry for the requested `kind`.
  21862. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  21863. * The `data` are either a numeric array either a Float32Array.
  21864. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  21865. * 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).
  21866. * Note that a new underlying VertexBuffer object is created each call.
  21867. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  21868. *
  21869. * Possible `kind` values :
  21870. * - BABYLON.VertexBuffer.PositionKind
  21871. * - BABYLON.VertexBuffer.UVKind
  21872. * - BABYLON.VertexBuffer.UV2Kind
  21873. * - BABYLON.VertexBuffer.UV3Kind
  21874. * - BABYLON.VertexBuffer.UV4Kind
  21875. * - BABYLON.VertexBuffer.UV5Kind
  21876. * - BABYLON.VertexBuffer.UV6Kind
  21877. * - BABYLON.VertexBuffer.ColorKind
  21878. * - BABYLON.VertexBuffer.MatricesIndicesKind
  21879. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  21880. * - BABYLON.VertexBuffer.MatricesWeightsKind
  21881. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  21882. *
  21883. * Returns the Mesh.
  21884. */
  21885. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  21886. /**
  21887. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  21888. * If the mesh has no geometry, it is simply returned as it is.
  21889. * The `data` are either a numeric array either a Float32Array.
  21890. * No new underlying VertexBuffer object is created.
  21891. * 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.
  21892. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  21893. *
  21894. * Possible `kind` values :
  21895. * - BABYLON.VertexBuffer.PositionKind
  21896. * - BABYLON.VertexBuffer.UVKind
  21897. * - BABYLON.VertexBuffer.UV2Kind
  21898. * - BABYLON.VertexBuffer.UV3Kind
  21899. * - BABYLON.VertexBuffer.UV4Kind
  21900. * - BABYLON.VertexBuffer.UV5Kind
  21901. * - BABYLON.VertexBuffer.UV6Kind
  21902. * - BABYLON.VertexBuffer.ColorKind
  21903. * - BABYLON.VertexBuffer.MatricesIndicesKind
  21904. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  21905. * - BABYLON.VertexBuffer.MatricesWeightsKind
  21906. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  21907. *
  21908. * Returns the Mesh.
  21909. */
  21910. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  21911. /**
  21912. * Sets the mesh indices.
  21913. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  21914. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  21915. * This method creates a new index buffer each call.
  21916. * Returns the Mesh.
  21917. */
  21918. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  21919. /**
  21920. * Boolean : True if the mesh owns the requested kind of data.
  21921. */
  21922. isVerticesDataPresent(kind: string): boolean;
  21923. /**
  21924. * Returns an array of indices (IndicesArray).
  21925. */
  21926. getIndices(): Nullable<IndicesArray>;
  21927. protected readonly _positions: Nullable<Vector3[]>;
  21928. /**
  21929. * Sets a new updated BoundingInfo to the mesh.
  21930. * Returns the mesh.
  21931. */
  21932. refreshBoundingInfo(): InstancedMesh;
  21933. /**
  21934. * Returns the current associated LOD AbstractMesh.
  21935. */
  21936. getLOD(camera: Camera): AbstractMesh;
  21937. /**
  21938. * Creates a new InstancedMesh from the current mesh.
  21939. * - name (string) : the cloned mesh name
  21940. * - newParent (optional Node) : the optional Node to parent the clone to.
  21941. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  21942. *
  21943. * Returns the clone.
  21944. */
  21945. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  21946. /**
  21947. * Disposes the InstancedMesh.
  21948. * Returns nothing.
  21949. */
  21950. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  21951. }
  21952. }
  21953. declare module BABYLON {
  21954. class LinesMesh extends Mesh {
  21955. useVertexColor: boolean | undefined;
  21956. useVertexAlpha: boolean | undefined;
  21957. color: Color3;
  21958. alpha: number;
  21959. /**
  21960. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  21961. * This margin is expressed in world space coordinates, so its value may vary.
  21962. * Default value is 0.1
  21963. * @returns the intersection Threshold value.
  21964. */
  21965. /**
  21966. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  21967. * This margin is expressed in world space coordinates, so its value may vary.
  21968. * @param value the new threshold to apply
  21969. */
  21970. intersectionThreshold: number;
  21971. private _intersectionThreshold;
  21972. private _colorShader;
  21973. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean, useVertexColor?: boolean | undefined, useVertexAlpha?: boolean | undefined);
  21974. /**
  21975. * Returns the string "LineMesh"
  21976. */
  21977. getClassName(): string;
  21978. material: Material;
  21979. readonly checkCollisions: boolean;
  21980. createInstance(name: string): InstancedMesh;
  21981. dispose(doNotRecurse?: boolean): void;
  21982. /**
  21983. * Returns a new LineMesh object cloned from the current one.
  21984. */
  21985. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  21986. }
  21987. }
  21988. declare module BABYLON {
  21989. /**
  21990. * @hidden
  21991. **/
  21992. class _InstancesBatch {
  21993. mustReturn: boolean;
  21994. visibleInstances: Nullable<InstancedMesh[]>[];
  21995. renderSelf: boolean[];
  21996. }
  21997. class Mesh extends AbstractMesh implements IGetSetVerticesData {
  21998. private static _FRONTSIDE: number;
  21999. private static _BACKSIDE: number;
  22000. private static _DOUBLESIDE: number;
  22001. private static _DEFAULTSIDE: number;
  22002. private static _NO_CAP: number;
  22003. private static _CAP_START: number;
  22004. private static _CAP_END: number;
  22005. private static _CAP_ALL: number;
  22006. /**
  22007. * Mesh side orientation : usually the external or front surface
  22008. */
  22009. static readonly FRONTSIDE: number;
  22010. /**
  22011. * Mesh side orientation : usually the internal or back surface
  22012. */
  22013. static readonly BACKSIDE: number;
  22014. /**
  22015. * Mesh side orientation : both internal and external or front and back surfaces
  22016. */
  22017. static readonly DOUBLESIDE: number;
  22018. /**
  22019. * Mesh side orientation : by default, `FRONTSIDE`
  22020. */
  22021. static readonly DEFAULTSIDE: number;
  22022. /**
  22023. * Mesh cap setting : no cap
  22024. */
  22025. static readonly NO_CAP: number;
  22026. /**
  22027. * Mesh cap setting : one cap at the beginning of the mesh
  22028. */
  22029. static readonly CAP_START: number;
  22030. /**
  22031. * Mesh cap setting : one cap at the end of the mesh
  22032. */
  22033. static readonly CAP_END: number;
  22034. /**
  22035. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  22036. */
  22037. static readonly CAP_ALL: number;
  22038. /**
  22039. * An event triggered before rendering the mesh
  22040. */
  22041. onBeforeRenderObservable: Observable<Mesh>;
  22042. /**
  22043. * An event triggered after rendering the mesh
  22044. */
  22045. onAfterRenderObservable: Observable<Mesh>;
  22046. /**
  22047. * An event triggered before drawing the mesh
  22048. */
  22049. onBeforeDrawObservable: Observable<Mesh>;
  22050. private _onBeforeDrawObserver;
  22051. onBeforeDraw: () => void;
  22052. delayLoadState: number;
  22053. instances: InstancedMesh[];
  22054. delayLoadingFile: string;
  22055. private _LODLevels;
  22056. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  22057. private _morphTargetManager;
  22058. morphTargetManager: Nullable<MorphTargetManager>;
  22059. private _renderIdForInstances;
  22060. private _batchCache;
  22061. private _instancesBufferSize;
  22062. private _instancesBuffer;
  22063. private _instancesData;
  22064. private _overridenInstanceCount;
  22065. private _effectiveMaterial;
  22066. private _preActivateId;
  22067. overrideMaterialSideOrientation: Nullable<number>;
  22068. private _areNormalsFrozen;
  22069. private _sourcePositions;
  22070. private _sourceNormals;
  22071. private _source;
  22072. readonly source: Nullable<Mesh>;
  22073. isUnIndexed: boolean;
  22074. /**
  22075. * @constructor
  22076. * @param {string} name The value used by scene.getMeshByName() to do a lookup.
  22077. * @param {Scene} scene The scene to add this mesh to.
  22078. * @param {Node} parent The parent of this mesh, if it has one
  22079. * @param {Mesh} source An optional Mesh from which geometry is shared, cloned.
  22080. * @param {boolean} doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  22081. * When false, achieved by calling a clone(), also passing False.
  22082. * This will make creation of children, recursive.
  22083. * @param {boolean} clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  22084. */
  22085. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  22086. /**
  22087. * Returns the string "Mesh".
  22088. */
  22089. getClassName(): string;
  22090. /**
  22091. * Returns a string.
  22092. * @param {boolean} fullDetails - support for multiple levels of logging within scene loading
  22093. */
  22094. toString(fullDetails?: boolean): string;
  22095. /**
  22096. * True if the mesh has some Levels Of Details (LOD).
  22097. * Returns a boolean.
  22098. */
  22099. readonly hasLODLevels: boolean;
  22100. /**
  22101. * Gets the list of {BABYLON.MeshLODLevel} associated with the current mesh
  22102. * @returns an array of {BABYLON.MeshLODLevel}
  22103. */
  22104. getLODLevels(): MeshLODLevel[];
  22105. private _sortLODLevels();
  22106. /**
  22107. * Add a mesh as LOD level triggered at the given distance.
  22108. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_LOD
  22109. * @param distance The distance from the center of the object to show this level
  22110. * @param mesh The mesh to be added as LOD level (can be null)
  22111. * @return This mesh (for chaining)
  22112. */
  22113. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  22114. /**
  22115. * Returns the LOD level mesh at the passed distance or null if not found.
  22116. * It is related to the method `addLODLevel(distance, mesh)`.
  22117. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_LOD
  22118. * Returns an object Mesh or `null`.
  22119. */
  22120. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  22121. /**
  22122. * Remove a mesh from the LOD array
  22123. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_LOD
  22124. * @param {Mesh} mesh The mesh to be removed.
  22125. * @return {Mesh} This mesh (for chaining)
  22126. */
  22127. removeLODLevel(mesh: Mesh): Mesh;
  22128. /**
  22129. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  22130. * tuto : http://doc.babylonjs.com/how_to/how_to_use_lod
  22131. */
  22132. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  22133. /**
  22134. * Returns the mesh internal Geometry object.
  22135. */
  22136. readonly geometry: Nullable<Geometry>;
  22137. /**
  22138. * Returns a positive integer : the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  22139. */
  22140. getTotalVertices(): number;
  22141. /**
  22142. * Returns an array of integers or floats, or a Float32Array, depending on the requested `kind` (positions, indices, normals, etc).
  22143. * If `copywhenShared` is true (default false) and if the mesh geometry is shared among some other meshes, the returned array is a copy of the internal one.
  22144. * You can force the copy with forceCopy === true
  22145. * Returns null if the mesh has no geometry or no vertex buffer.
  22146. * Possible `kind` values :
  22147. * - BABYLON.VertexBuffer.PositionKind
  22148. * - BABYLON.VertexBuffer.UVKind
  22149. * - BABYLON.VertexBuffer.UV2Kind
  22150. * - BABYLON.VertexBuffer.UV3Kind
  22151. * - BABYLON.VertexBuffer.UV4Kind
  22152. * - BABYLON.VertexBuffer.UV5Kind
  22153. * - BABYLON.VertexBuffer.UV6Kind
  22154. * - BABYLON.VertexBuffer.ColorKind
  22155. * - BABYLON.VertexBuffer.MatricesIndicesKind
  22156. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  22157. * - BABYLON.VertexBuffer.MatricesWeightsKind
  22158. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  22159. */
  22160. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22161. /**
  22162. * Returns the mesh VertexBuffer object from the requested `kind` : positions, indices, normals, etc.
  22163. * Returns `null` if the mesh has no geometry.
  22164. * Possible `kind` values :
  22165. * - BABYLON.VertexBuffer.PositionKind
  22166. * - BABYLON.VertexBuffer.UVKind
  22167. * - BABYLON.VertexBuffer.UV2Kind
  22168. * - BABYLON.VertexBuffer.UV3Kind
  22169. * - BABYLON.VertexBuffer.UV4Kind
  22170. * - BABYLON.VertexBuffer.UV5Kind
  22171. * - BABYLON.VertexBuffer.UV6Kind
  22172. * - BABYLON.VertexBuffer.ColorKind
  22173. * - BABYLON.VertexBuffer.MatricesIndicesKind
  22174. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  22175. * - BABYLON.VertexBuffer.MatricesWeightsKind
  22176. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  22177. */
  22178. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  22179. isVerticesDataPresent(kind: string): boolean;
  22180. /**
  22181. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  22182. * Possible `kind` values :
  22183. * - BABYLON.VertexBuffer.PositionKind
  22184. * - BABYLON.VertexBuffer.UVKind
  22185. * - BABYLON.VertexBuffer.UV2Kind
  22186. * - BABYLON.VertexBuffer.UV3Kind
  22187. * - BABYLON.VertexBuffer.UV4Kind
  22188. * - BABYLON.VertexBuffer.UV5Kind
  22189. * - BABYLON.VertexBuffer.UV6Kind
  22190. * - BABYLON.VertexBuffer.ColorKind
  22191. * - BABYLON.VertexBuffer.MatricesIndicesKind
  22192. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  22193. * - BABYLON.VertexBuffer.MatricesWeightsKind
  22194. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  22195. */
  22196. isVertexBufferUpdatable(kind: string): boolean;
  22197. /**
  22198. * Returns a string : the list of existing `kinds` of Vertex Data for this mesh.
  22199. * Possible `kind` values :
  22200. * - BABYLON.VertexBuffer.PositionKind
  22201. * - BABYLON.VertexBuffer.UVKind
  22202. * - BABYLON.VertexBuffer.UV2Kind
  22203. * - BABYLON.VertexBuffer.UV3Kind
  22204. * - BABYLON.VertexBuffer.UV4Kind
  22205. * - BABYLON.VertexBuffer.UV5Kind
  22206. * - BABYLON.VertexBuffer.UV6Kind
  22207. * - BABYLON.VertexBuffer.ColorKind
  22208. * - BABYLON.VertexBuffer.MatricesIndicesKind
  22209. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  22210. * - BABYLON.VertexBuffer.MatricesWeightsKind
  22211. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  22212. */
  22213. getVerticesDataKinds(): string[];
  22214. /**
  22215. * Returns a positive integer : the total number of indices in this mesh geometry.
  22216. * Returns zero if the mesh has no geometry.
  22217. */
  22218. getTotalIndices(): number;
  22219. /**
  22220. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  22221. * If the parameter `copyWhenShared` is 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.
  22222. * Returns an empty array if the mesh has no geometry.
  22223. */
  22224. getIndices(copyWhenShared?: boolean): Nullable<IndicesArray>;
  22225. readonly isBlocked: boolean;
  22226. /**
  22227. * Determine if the current mesh is ready to be rendered
  22228. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  22229. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  22230. * @returns true if all associated assets are ready (material, textures, shaders)
  22231. */
  22232. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  22233. /**
  22234. * Boolean : true if the normals aren't to be recomputed on next mesh `positions` array update.
  22235. * This property is pertinent only for updatable parametric shapes.
  22236. */
  22237. readonly areNormalsFrozen: boolean;
  22238. /**
  22239. * This function affects parametric shapes on vertex position update only : ribbons, tubes, etc.
  22240. * It has no effect at all on other shapes.
  22241. * It prevents the mesh normals from being recomputed on next `positions` array update.
  22242. * Returns the Mesh.
  22243. */
  22244. freezeNormals(): Mesh;
  22245. /**
  22246. * This function affects parametric shapes on vertex position update only : ribbons, tubes, etc.
  22247. * It has no effect at all on other shapes.
  22248. * It reactivates the mesh normals computation if it was previously frozen.
  22249. * Returns the Mesh.
  22250. */
  22251. unfreezeNormals(): Mesh;
  22252. /**
  22253. * Overrides instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  22254. */
  22255. overridenInstanceCount: number;
  22256. /**
  22257. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  22258. * This means the mesh underlying bounding box and sphere are recomputed.
  22259. * Returns the Mesh.
  22260. */
  22261. refreshBoundingInfo(): Mesh;
  22262. private _getPositionData(applySkeleton);
  22263. subdivide(count: number): void;
  22264. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  22265. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  22266. /**
  22267. * Sets the mesh VertexBuffer.
  22268. * Returns the Mesh.
  22269. */
  22270. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  22271. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  22272. /**
  22273. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  22274. * tuto : http://doc.babylonjs.com/tutorials/How_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  22275. * The parameter `positionFunction` is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything.
  22276. * The parameter `computeNormals` is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update.
  22277. * Returns the Mesh.
  22278. */
  22279. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  22280. /**
  22281. * Creates a un-shared specific occurence of the geometry for the mesh.
  22282. * Returns the Mesh.
  22283. */
  22284. makeGeometryUnique(): Mesh;
  22285. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  22286. /**
  22287. * Update the current index buffer
  22288. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  22289. * Returns the Mesh.
  22290. */
  22291. updateIndices(indices: IndicesArray, offset?: number): Mesh;
  22292. /**
  22293. * Invert the geometry to move from a right handed system to a left handed one.
  22294. * Returns the Mesh.
  22295. */
  22296. toLeftHanded(): Mesh;
  22297. /**
  22298. * Registers for this mesh a javascript function called just before the rendering process.
  22299. * This function is passed the current mesh.
  22300. * Return the Mesh.
  22301. */
  22302. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  22303. /**
  22304. * Disposes a previously registered javascript function called before the rendering.
  22305. * This function is passed the current mesh.
  22306. * Returns the Mesh.
  22307. */
  22308. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  22309. /**
  22310. * Registers for this mesh a javascript function called just after the rendering is complete.
  22311. * This function is passed the current mesh.
  22312. * Returns the Mesh.
  22313. */
  22314. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  22315. /**
  22316. * Disposes a previously registered javascript function called after the rendering.
  22317. * This function is passed the current mesh.
  22318. * Return the Mesh.
  22319. */
  22320. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  22321. /**
  22322. * Triggers the draw call for the mesh.
  22323. * Usually, you don't need to call this method by your own because the mesh rendering is handled by the scene rendering manager.
  22324. * Returns the Mesh.
  22325. */
  22326. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  22327. private _onBeforeDraw(isInstance, world, effectiveMaterial?);
  22328. /**
  22329. * Returns an array populated with ParticleSystem objects whose the mesh is the emitter.
  22330. */
  22331. getEmittedParticleSystems(): IParticleSystem[];
  22332. /**
  22333. * Returns an array populated with ParticleSystem objects whose the mesh or its children are the emitter.
  22334. */
  22335. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  22336. /**
  22337. * Normalize matrix weights so that all vertices have a total weight set to 1
  22338. */
  22339. cleanMatrixWeights(): void;
  22340. private _queueLoad(scene);
  22341. /**
  22342. * Boolean, true is the mesh in the frustum defined by the Plane objects from the `frustumPlanes` array parameter.
  22343. */
  22344. isInFrustum(frustumPlanes: Plane[]): boolean;
  22345. /**
  22346. * Sets the mesh material by the material or multiMaterial `id` property.
  22347. * The material `id` is a string identifying the material or the multiMaterial.
  22348. * This method returns the Mesh.
  22349. */
  22350. setMaterialByID(id: string): Mesh;
  22351. /**
  22352. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  22353. */
  22354. getAnimatables(): IAnimatable[];
  22355. /**
  22356. * Modifies the mesh geometry according to the passed transformation matrix.
  22357. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  22358. * The mesh normals are modified accordingly the same transformation.
  22359. * tuto : http://doc.babylonjs.com/resources/baking_transformations
  22360. * Note that, under the hood, this method sets a new VertexBuffer each call.
  22361. * Returns the Mesh.
  22362. */
  22363. bakeTransformIntoVertices(transform: Matrix): Mesh;
  22364. /**
  22365. * Modifies the mesh geometry according to its own current World Matrix.
  22366. * The mesh World Matrix is then reset.
  22367. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  22368. * tuto : tuto : http://doc.babylonjs.com/resources/baking_transformations
  22369. * Note that, under the hood, this method sets a new VertexBuffer each call.
  22370. * Returns the Mesh.
  22371. */
  22372. bakeCurrentTransformIntoVertices(): Mesh;
  22373. protected readonly _positions: Nullable<Vector3[]>;
  22374. /**
  22375. * Returns a new Mesh object generated from the current mesh properties.
  22376. * This method must not get confused with createInstance().
  22377. * The parameter `name` is a string, the name given to the new mesh.
  22378. * The optional parameter `newParent` can be any Node object (default `null`).
  22379. * The optional parameter `doNotCloneChildren` (default `false`) allows/denies the recursive cloning of the original mesh children if any.
  22380. * The parameter `clonePhysicsImpostor` (default `true`) allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any.
  22381. */
  22382. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  22383. /**
  22384. * Releases resources associated with this mesh.
  22385. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  22386. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  22387. */
  22388. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  22389. /**
  22390. * Modifies the mesh geometry according to a displacement map.
  22391. * 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.
  22392. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  22393. * This method returns nothing.
  22394. * The parameter `url` is a string, the URL from the image file is to be downloaded.
  22395. * The parameters `minHeight` and `maxHeight` are the lower and upper limits of the displacement.
  22396. * The parameter `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.
  22397. * The parameter `uvOffset` is an optional vector2 used to offset UV.
  22398. * The parameter `uvScale` is an optional vector2 used to scale UV.
  22399. *
  22400. * Returns the Mesh.
  22401. */
  22402. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2): Mesh;
  22403. /**
  22404. * Modifies the mesh geometry according to a displacementMap buffer.
  22405. * 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.
  22406. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  22407. * This method returns nothing.
  22408. * The parameter `buffer` is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  22409. * The parameters `heightMapWidth` and `heightMapHeight` are positive integers to set the width and height of the buffer image.
  22410. * The parameters `minHeight` and `maxHeight` are the lower and upper limits of the displacement.
  22411. * The parameter `uvOffset` is an optional vector2 used to offset UV.
  22412. * The parameter `uvScale` is an optional vector2 used to scale UV.
  22413. *
  22414. * Returns the Mesh.
  22415. */
  22416. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2): Mesh;
  22417. /**
  22418. * Modify the mesh to get a flat shading rendering.
  22419. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  22420. * This method returns the Mesh.
  22421. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  22422. */
  22423. convertToFlatShadedMesh(): Mesh;
  22424. /**
  22425. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  22426. * In other words, more vertices, no more indices and a single bigger VBO.
  22427. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  22428. * Returns the Mesh.
  22429. */
  22430. convertToUnIndexedMesh(): Mesh;
  22431. /**
  22432. * Inverses facet orientations and inverts also the normals with `flipNormals` (default `false`) if true.
  22433. * This method returns the Mesh.
  22434. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  22435. */
  22436. flipFaces(flipNormals?: boolean): Mesh;
  22437. /**
  22438. * Creates a new InstancedMesh object from the mesh model.
  22439. * An instance shares the same properties and the same material than its model.
  22440. * Only these properties of each instance can then be set individually :
  22441. * - position
  22442. * - rotation
  22443. * - rotationQuaternion
  22444. * - setPivotMatrix
  22445. * - scaling
  22446. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_Instances
  22447. * Warning : this method is not supported for Line mesh and LineSystem
  22448. */
  22449. createInstance(name: string): InstancedMesh;
  22450. /**
  22451. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  22452. * After this call, all the mesh instances have the same submeshes than the current mesh.
  22453. * This method returns the Mesh.
  22454. */
  22455. synchronizeInstances(): Mesh;
  22456. /**
  22457. * Simplify the mesh according to the given array of settings.
  22458. * Function will return immediately and will simplify async. It returns the Mesh.
  22459. * @param settings a collection of simplification settings.
  22460. * @param parallelProcessing should all levels calculate parallel or one after the other.
  22461. * @param type the type of simplification to run.
  22462. * @param successCallback optional success callback to be called after the simplification finished processing all settings.
  22463. */
  22464. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  22465. /**
  22466. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  22467. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  22468. * This should be used together with the simplification to avoid disappearing triangles.
  22469. * Returns the Mesh.
  22470. * @param successCallback an optional success callback to be called after the optimization finished.
  22471. */
  22472. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  22473. serialize(serializationObject: any): void;
  22474. /**
  22475. * Returns a new Mesh object parsed from the source provided.
  22476. * The parameter `parsedMesh` is the source.
  22477. * The parameter `rootUrl` is a string, it's the root URL to prefix the `delayLoadingFile` property with
  22478. */
  22479. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  22480. /**
  22481. * Creates a ribbon mesh.
  22482. * Please consider using the same method from the MeshBuilder class instead.
  22483. * The ribbon is a parametric shape : http://doc.babylonjs.com/tutorials/Parametric_Shapes. It has no predefined shape. Its final shape will depend on the input parameters.
  22484. *
  22485. * Please read this full tutorial to understand how to design a ribbon : http://doc.babylonjs.com/tutorials/Ribbon_Tutorial
  22486. * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  22487. * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array.
  22488. * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array.
  22489. * 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.
  22490. * It's the offset to join together the points from the same path. Ex : offset = 10 means the point 1 is joined to the point 11.
  22491. * 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
  22492. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22493. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  22494. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22495. */
  22496. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean | undefined, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  22497. /**
  22498. * Creates a plane polygonal mesh. By default, this is a disc.
  22499. * Please consider using the same method from the MeshBuilder class instead.
  22500. * The parameter `radius` sets the radius size (float) of the polygon (default 0.5).
  22501. * 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.
  22502. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22503. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  22504. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22505. */
  22506. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  22507. /**
  22508. * Creates a box mesh.
  22509. * Please consider using the same method from the MeshBuilder class instead.
  22510. * The parameter `size` sets the size (float) of each box side (default 1).
  22511. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22512. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  22513. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22514. */
  22515. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  22516. /**
  22517. * Creates a sphere mesh.
  22518. * Please consider using the same method from the MeshBuilder class instead.
  22519. * The parameter `diameter` sets the diameter size (float) of the sphere (default 1).
  22520. * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32).
  22521. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22522. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  22523. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22524. */
  22525. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  22526. /**
  22527. * Creates a cylinder or a cone mesh.
  22528. * Please consider using the same method from the MeshBuilder class instead.
  22529. * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  22530. * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  22531. * 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.
  22532. * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  22533. * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  22534. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22535. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  22536. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22537. */
  22538. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  22539. /**
  22540. * Creates a torus mesh.
  22541. * Please consider using the same method from the MeshBuilder class instead.
  22542. * The parameter `diameter` sets the diameter size (float) of the torus (default 1).
  22543. * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5).
  22544. * The parameter `tessellation` sets the number of torus sides (postive integer, default 16).
  22545. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22546. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  22547. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22548. */
  22549. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  22550. /**
  22551. * Creates a torus knot mesh.
  22552. * Please consider using the same method from the MeshBuilder class instead.
  22553. * The parameter `radius` sets the global radius size (float) of the torus knot (default 2).
  22554. * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32).
  22555. * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32).
  22556. * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3).
  22557. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22558. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  22559. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22560. */
  22561. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  22562. /**
  22563. * Creates a line mesh.
  22564. * Please consider using the same method from the MeshBuilder class instead.
  22565. * 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.
  22566. * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function.
  22567. * The parameter `points` is an array successive Vector3.
  22568. * 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
  22569. * When updating an instance, remember that only point positions can change, not the number of points.
  22570. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22571. */
  22572. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  22573. /**
  22574. * Creates a dashed line mesh.
  22575. * Please consider using the same method from the MeshBuilder class instead.
  22576. * 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.
  22577. * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function.
  22578. * The parameter `points` is an array successive Vector3.
  22579. * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200).
  22580. * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3).
  22581. * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1).
  22582. * 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
  22583. * When updating an instance, remember that only point positions can change, not the number of points.
  22584. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22585. */
  22586. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  22587. /**
  22588. * Creates a polygon mesh.
  22589. * Please consider using the same method from the MeshBuilder class instead.
  22590. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  22591. * 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.
  22592. * You can set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22593. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22594. * Remember you can only change the shape positions, not their number when updating a polygon.
  22595. */
  22596. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number): Mesh;
  22597. /**
  22598. * Creates an extruded polygon mesh, with depth in the Y direction.
  22599. * Please consider using the same method from the MeshBuilder class instead.
  22600. */
  22601. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number): Mesh;
  22602. /**
  22603. * Creates an extruded shape mesh.
  22604. * The extrusion is a parametric shape : http://doc.babylonjs.com/tutorials/Parametric_Shapes. It has no predefined shape. Its final shape will depend on the input parameters.
  22605. * Please consider using the same method from the MeshBuilder class instead.
  22606. *
  22607. * Please read this full tutorial to understand how to design an extruded shape : http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  22608. * 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
  22609. * extruded along the Z axis.
  22610. * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  22611. * 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.
  22612. * The parameter `scale` (float, default 1) is the value to scale the shape.
  22613. * 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
  22614. * 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
  22615. * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  22616. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22617. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  22618. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22619. */
  22620. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  22621. /**
  22622. * Creates an custom extruded shape mesh.
  22623. * The custom extrusion is a parametric shape : http://doc.babylonjs.com/tutorials/Parametric_Shapes. It has no predefined shape. Its final shape will depend on the input parameters.
  22624. * Please consider using the same method from the MeshBuilder class instead.
  22625. *
  22626. * Please read this full tutorial to understand how to design a custom extruded shape : http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  22627. * 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
  22628. * extruded along the Z axis.
  22629. * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  22630. * 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
  22631. * and the distance of this point from the begining of the path :
  22632. * ```javascript
  22633. * var rotationFunction = function(i, distance) {
  22634. * // do things
  22635. * return rotationValue; }
  22636. * ```
  22637. * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  22638. * 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
  22639. * and the distance of this point from the begining of the path :
  22640. * ```javascript
  22641. * var scaleFunction = function(i, distance) {
  22642. * // do things
  22643. * return scaleValue;}
  22644. * ```
  22645. * It must returns a float value that will be the scale value applied to the shape on each path point.
  22646. * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`.
  22647. * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`.
  22648. * 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
  22649. * 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
  22650. * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  22651. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22652. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  22653. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22654. */
  22655. 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;
  22656. /**
  22657. * Creates lathe mesh.
  22658. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  22659. * Please consider using the same method from the MeshBuilder class instead.
  22660. * 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
  22661. * rotated around the Y axis. It's usually a 2D shape, so the Vector3 z coordinates are often set to zero.
  22662. * The parameter `radius` (positive float, default 1) is the radius value of the lathe.
  22663. * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe.
  22664. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22665. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  22666. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22667. */
  22668. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  22669. /**
  22670. * Creates a plane mesh.
  22671. * Please consider using the same method from the MeshBuilder class instead.
  22672. * The parameter `size` sets the size (float) of both sides of the plane at once (default 1).
  22673. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22674. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  22675. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22676. */
  22677. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  22678. /**
  22679. * Creates a ground mesh.
  22680. * Please consider using the same method from the MeshBuilder class instead.
  22681. * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground.
  22682. * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side.
  22683. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22684. */
  22685. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  22686. /**
  22687. * Creates a tiled ground mesh.
  22688. * Please consider using the same method from the MeshBuilder class instead.
  22689. * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates.
  22690. * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates.
  22691. * The parameter `subdivisions` is a javascript object `{w: positive integer, h: positive integer}` (default `{w: 6, h: 6}`). `w` and `h` are the
  22692. * numbers of subdivisions on the ground width and height. Each subdivision is called a tile.
  22693. * The parameter `precision` is a javascript object `{w: positive integer, h: positive integer}` (default `{w: 2, h: 2}`). `w` and `h` are the
  22694. * numbers of subdivisions on the ground width and height of each tile.
  22695. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22696. */
  22697. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  22698. w: number;
  22699. h: number;
  22700. }, precision: {
  22701. w: number;
  22702. h: number;
  22703. }, scene: Scene, updatable?: boolean): Mesh;
  22704. /**
  22705. * Creates a ground mesh from a height map.
  22706. * tuto : http://doc.babylonjs.com/babylon101/height_map
  22707. * Please consider using the same method from the MeshBuilder class instead.
  22708. * The parameter `url` sets the URL of the height map image resource.
  22709. * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  22710. * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  22711. * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  22712. * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  22713. * 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).
  22714. * This function is passed the newly built mesh :
  22715. * ```javascript
  22716. * function(mesh) { // do things
  22717. * return; }
  22718. * ```
  22719. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22720. */
  22721. static CreateGroundFromHeightMap(name: string, url: string, width: number, height: number, subdivisions: number, minHeight: number, maxHeight: number, scene: Scene, updatable?: boolean, onReady?: (mesh: GroundMesh) => void): GroundMesh;
  22722. /**
  22723. * Creates a tube mesh.
  22724. * The tube is a parametric shape : http://doc.babylonjs.com/tutorials/Parametric_Shapes. It has no predefined shape. Its final shape will depend on the input parameters.
  22725. * Please consider using the same method from the MeshBuilder class instead.
  22726. * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube.
  22727. * The parameter `radius` (positive float, default 1) sets the tube radius size.
  22728. * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface.
  22729. * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`.
  22730. * 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.
  22731. * It must return a radius value (positive float) :
  22732. * ```javascript
  22733. * var radiusFunction = function(i, distance) {
  22734. * // do things
  22735. * return radius; }
  22736. * ```
  22737. * 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
  22738. * 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
  22739. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22740. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  22741. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22742. */
  22743. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  22744. (i: number, distance: number): number;
  22745. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  22746. /**
  22747. * Creates a polyhedron mesh.
  22748. * Please consider using the same method from the MeshBuilder class instead.
  22749. * 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
  22750. * to choose the wanted type.
  22751. * The parameter `size` (positive float, default 1) sets the polygon size.
  22752. * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value).
  22753. * 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`.
  22754. * 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
  22755. * 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)`).
  22756. * 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
  22757. * 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.
  22758. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22759. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  22760. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22761. */
  22762. static CreatePolyhedron(name: string, options: {
  22763. type?: number;
  22764. size?: number;
  22765. sizeX?: number;
  22766. sizeY?: number;
  22767. sizeZ?: number;
  22768. custom?: any;
  22769. faceUV?: Vector4[];
  22770. faceColors?: Color4[];
  22771. updatable?: boolean;
  22772. sideOrientation?: number;
  22773. }, scene: Scene): Mesh;
  22774. /**
  22775. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided.
  22776. * Please consider using the same method from the MeshBuilder class instead.
  22777. * The parameter `radius` sets the radius size (float) of the icosphere (default 1).
  22778. * 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`).
  22779. * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size.
  22780. * 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.
  22781. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22782. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  22783. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22784. */
  22785. static CreateIcoSphere(name: string, options: {
  22786. radius?: number;
  22787. flat?: boolean;
  22788. subdivisions?: number;
  22789. sideOrientation?: number;
  22790. updatable?: boolean;
  22791. }, scene: Scene): Mesh;
  22792. /**
  22793. * Creates a decal mesh.
  22794. * Please consider using the same method from the MeshBuilder class instead.
  22795. * 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.
  22796. * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates.
  22797. * The parameter `normal` (Vector3, default Vector3.Up) sets the normal of the mesh where the decal is applied onto in World coordinates.
  22798. * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling.
  22799. * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal.
  22800. */
  22801. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  22802. /**
  22803. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  22804. */
  22805. setPositionsForCPUSkinning(): Float32Array;
  22806. /**
  22807. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  22808. */
  22809. setNormalsForCPUSkinning(): Float32Array;
  22810. /**
  22811. * Updates the vertex buffer by applying transformation from the bones.
  22812. * Returns the Mesh.
  22813. *
  22814. * @param {skeleton} skeleton to apply
  22815. */
  22816. applySkeleton(skeleton: Skeleton): Mesh;
  22817. /**
  22818. * Returns an object `{min:` Vector3`, max:` Vector3`}`
  22819. * This min and max Vector3 are the minimum and maximum vectors of each mesh bounding box from the passed array, in the World system
  22820. */
  22821. static MinMax(meshes: AbstractMesh[]): {
  22822. min: Vector3;
  22823. max: Vector3;
  22824. };
  22825. /**
  22826. * Returns a Vector3, the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array.
  22827. */
  22828. static Center(meshesOrMinMaxVector: {
  22829. min: Vector3;
  22830. max: Vector3;
  22831. } | AbstractMesh[]): Vector3;
  22832. /**
  22833. * Merge the array of meshes into a single mesh for performance reasons.
  22834. * @param {Array<Mesh>} meshes - The vertices source. They should all be of the same material. Entries can empty
  22835. * @param {boolean} disposeSource - When true (default), dispose of the vertices from the source meshes
  22836. * @param {boolean} allow32BitsIndices - When the sum of the vertices > 64k, this must be set to true.
  22837. * @param {Mesh} meshSubclass - When set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  22838. * @param {boolean} subdivideWithSubMeshes - When true (false default), subdivide mesh to his subMesh array with meshes source.
  22839. */
  22840. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean): Nullable<Mesh>;
  22841. }
  22842. }
  22843. declare module BABYLON {
  22844. /**
  22845. * Define an interface for all classes that will get and set the data on vertices
  22846. */
  22847. interface IGetSetVerticesData {
  22848. isVerticesDataPresent(kind: string): boolean;
  22849. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22850. getIndices(copyWhenShared?: boolean): Nullable<IndicesArray>;
  22851. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  22852. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  22853. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  22854. }
  22855. /**
  22856. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  22857. */
  22858. class VertexData {
  22859. /**
  22860. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  22861. */
  22862. positions: Nullable<FloatArray>;
  22863. /**
  22864. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22865. */
  22866. normals: Nullable<FloatArray>;
  22867. /**
  22868. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  22869. */
  22870. tangents: Nullable<FloatArray>;
  22871. /**
  22872. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22873. */
  22874. uvs: Nullable<FloatArray>;
  22875. /**
  22876. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22877. */
  22878. uvs2: Nullable<FloatArray>;
  22879. /**
  22880. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22881. */
  22882. uvs3: Nullable<FloatArray>;
  22883. /**
  22884. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22885. */
  22886. uvs4: Nullable<FloatArray>;
  22887. /**
  22888. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22889. */
  22890. uvs5: Nullable<FloatArray>;
  22891. /**
  22892. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22893. */
  22894. uvs6: Nullable<FloatArray>;
  22895. /**
  22896. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  22897. */
  22898. colors: Nullable<FloatArray>;
  22899. /**
  22900. * 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).
  22901. */
  22902. matricesIndices: Nullable<FloatArray>;
  22903. /**
  22904. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  22905. */
  22906. matricesWeights: Nullable<FloatArray>;
  22907. /**
  22908. * An array extending the number of possible indices
  22909. */
  22910. matricesIndicesExtra: Nullable<FloatArray>;
  22911. /**
  22912. * An array extending the number of possible weights when the number of indices is extended
  22913. */
  22914. matricesWeightsExtra: Nullable<FloatArray>;
  22915. /**
  22916. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22917. */
  22918. indices: Nullable<IndicesArray>;
  22919. /**
  22920. * Uses the passed data array to set the set the values for the specified kind of data
  22921. * @param data a linear array of floating numbers
  22922. * @param kind the type of data that is being set, eg positions, colors etc
  22923. */
  22924. set(data: FloatArray, kind: string): void;
  22925. /**
  22926. * Associates the vertexData to the passed Mesh.
  22927. * Sets it as updatable or not (default `false`)
  22928. * @param mesh the mesh the vertexData is applied to
  22929. * @param updatable when used and having the value true allows new data to update the vertexData
  22930. * @returns the VertexData
  22931. */
  22932. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22933. /**
  22934. * Associates the vertexData to the passed Geometry.
  22935. * Sets it as updatable or not (default `false`)
  22936. * @param geometry the geometry the vertexData is applied to
  22937. * @param updatable when used and having the value true allows new data to update the vertexData
  22938. * @returns VertexData
  22939. */
  22940. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22941. /**
  22942. * Updates the associated mesh
  22943. * @param mesh the mesh to be updated
  22944. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22945. * @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
  22946. * @returns VertexData
  22947. */
  22948. updateMesh(mesh: Mesh, updateExtends?: boolean, makeItUnique?: boolean): VertexData;
  22949. /**
  22950. * Updates the associated geometry
  22951. * @param geometry the geometry to be updated
  22952. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22953. * @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
  22954. * @returns VertexData.
  22955. */
  22956. updateGeometry(geometry: Geometry, updateExtends?: boolean, makeItUnique?: boolean): VertexData;
  22957. private _applyTo(meshOrGeometry, updatable?);
  22958. private _update(meshOrGeometry, updateExtends?, makeItUnique?);
  22959. /**
  22960. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22961. * @param matrix the transforming matrix
  22962. * @returns the VertexData
  22963. */
  22964. transform(matrix: Matrix): VertexData;
  22965. /**
  22966. * Merges the passed VertexData into the current one
  22967. * @param other the VertexData to be merged into the current one
  22968. * @returns the modified VertexData
  22969. */
  22970. merge(other: VertexData): VertexData;
  22971. private _mergeElement(source, other);
  22972. private _validate();
  22973. /**
  22974. * Serializes the VertexData
  22975. * @returns a serialized object
  22976. */
  22977. serialize(): any;
  22978. /**
  22979. * Extracts the vertexData from a mesh
  22980. * @param mesh the mesh from which to extract the VertexData
  22981. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22982. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22983. * @returns the object VertexData associated to the passed mesh
  22984. */
  22985. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22986. /**
  22987. * Extracts the vertexData from the geometry
  22988. * @param geometry the geometry from which to extract the VertexData
  22989. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22990. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22991. * @returns the object VertexData associated to the passed mesh
  22992. */
  22993. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22994. private static _ExtractFrom(meshOrGeometry, copyWhenShared?, forceCopy?);
  22995. /**
  22996. * Creates the VertexData for a Ribbon
  22997. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22998. * * pathArray array of paths, each of which an array of successive Vector3
  22999. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  23000. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  23001. * * 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
  23002. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23003. * * 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)
  23004. * * 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)
  23005. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  23006. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  23007. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  23008. * @returns the VertexData of the ribbon
  23009. */
  23010. static CreateRibbon(options: {
  23011. pathArray: Vector3[][];
  23012. closeArray?: boolean;
  23013. closePath?: boolean;
  23014. offset?: number;
  23015. sideOrientation?: number;
  23016. frontUVs?: Vector4;
  23017. backUVs?: Vector4;
  23018. invertUV?: boolean;
  23019. uvs?: Vector2[];
  23020. colors?: Color4[];
  23021. }): VertexData;
  23022. /**
  23023. * Creates the VertexData for a box
  23024. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23025. * * size sets the width, height and depth of the box to the value of size, optional default 1
  23026. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  23027. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  23028. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  23029. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  23030. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  23031. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23032. * * 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)
  23033. * * 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)
  23034. * @returns the VertexData of the box
  23035. */
  23036. static CreateBox(options: {
  23037. size?: number;
  23038. width?: number;
  23039. height?: number;
  23040. depth?: number;
  23041. faceUV?: Vector4[];
  23042. faceColors?: Color4[];
  23043. sideOrientation?: number;
  23044. frontUVs?: Vector4;
  23045. backUVs?: Vector4;
  23046. }): VertexData;
  23047. /**
  23048. * Creates the VertexData for an ellipsoid, defaults to a sphere
  23049. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23050. * * segments sets the number of horizontal strips optional, default 32
  23051. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  23052. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  23053. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  23054. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  23055. * * 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
  23056. * * 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
  23057. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23058. * * 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)
  23059. * * 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)
  23060. * @returns the VertexData of the ellipsoid
  23061. */
  23062. static CreateSphere(options: {
  23063. segments?: number;
  23064. diameter?: number;
  23065. diameterX?: number;
  23066. diameterY?: number;
  23067. diameterZ?: number;
  23068. arc?: number;
  23069. slice?: number;
  23070. sideOrientation?: number;
  23071. frontUVs?: Vector4;
  23072. backUVs?: Vector4;
  23073. }): VertexData;
  23074. /**
  23075. * Creates the VertexData for a cylinder, cone or prism
  23076. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23077. * * height sets the height (y direction) of the cylinder, optional, default 2
  23078. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  23079. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  23080. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  23081. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23082. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  23083. * * 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
  23084. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23085. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23086. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  23087. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  23088. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23089. * * 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)
  23090. * * 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)
  23091. * @returns the VertexData of the cylinder, cone or prism
  23092. */
  23093. static CreateCylinder(options: {
  23094. height?: number;
  23095. diameterTop?: number;
  23096. diameterBottom?: number;
  23097. diameter?: number;
  23098. tessellation?: number;
  23099. subdivisions?: number;
  23100. arc?: number;
  23101. faceColors?: Color4[];
  23102. faceUV?: Vector4[];
  23103. hasRings?: boolean;
  23104. enclose?: boolean;
  23105. sideOrientation?: number;
  23106. frontUVs?: Vector4;
  23107. backUVs?: Vector4;
  23108. }): VertexData;
  23109. /**
  23110. * Creates the VertexData for a torus
  23111. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23112. * * diameter the diameter of the torus, optional default 1
  23113. * * thickness the diameter of the tube forming the torus, optional default 0.5
  23114. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23115. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23116. * * 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)
  23117. * * 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)
  23118. * @returns the VertexData of the torus
  23119. */
  23120. static CreateTorus(options: {
  23121. diameter?: number;
  23122. thickness?: number;
  23123. tessellation?: number;
  23124. sideOrientation?: number;
  23125. frontUVs?: Vector4;
  23126. backUVs?: Vector4;
  23127. }): VertexData;
  23128. /**
  23129. * Creates the VertexData of the LineSystem
  23130. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  23131. * - lines an array of lines, each line being an array of successive Vector3
  23132. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  23133. * @returns the VertexData of the LineSystem
  23134. */
  23135. static CreateLineSystem(options: {
  23136. lines: Vector3[][];
  23137. colors?: Nullable<Color4[][]>;
  23138. }): VertexData;
  23139. /**
  23140. * Create the VertexData for a DashedLines
  23141. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  23142. * - points an array successive Vector3
  23143. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  23144. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  23145. * - dashNb the intended total number of dashes, optional, default 200
  23146. * @returns the VertexData for the DashedLines
  23147. */
  23148. static CreateDashedLines(options: {
  23149. points: Vector3[];
  23150. dashSize?: number;
  23151. gapSize?: number;
  23152. dashNb?: number;
  23153. }): VertexData;
  23154. /**
  23155. * Creates the VertexData for a Ground
  23156. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23157. * - width the width (x direction) of the ground, optional, default 1
  23158. * - height the height (z direction) of the ground, optional, default 1
  23159. * - subdivisions the number of subdivisions per side, optional, default 1
  23160. * @returns the VertexData of the Ground
  23161. */
  23162. static CreateGround(options: {
  23163. width?: number;
  23164. height?: number;
  23165. subdivisions?: number;
  23166. subdivisionsX?: number;
  23167. subdivisionsY?: number;
  23168. }): VertexData;
  23169. /**
  23170. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  23171. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23172. * * xmin the ground minimum X coordinate, optional, default -1
  23173. * * zmin the ground minimum Z coordinate, optional, default -1
  23174. * * xmax the ground maximum X coordinate, optional, default 1
  23175. * * zmax the ground maximum Z coordinate, optional, default 1
  23176. * * 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}
  23177. * * 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}
  23178. * @returns the VertexData of the TiledGround
  23179. */
  23180. static CreateTiledGround(options: {
  23181. xmin: number;
  23182. zmin: number;
  23183. xmax: number;
  23184. zmax: number;
  23185. subdivisions?: {
  23186. w: number;
  23187. h: number;
  23188. };
  23189. precision?: {
  23190. w: number;
  23191. h: number;
  23192. };
  23193. }): VertexData;
  23194. /**
  23195. * Creates the VertexData of the Ground designed from a heightmap
  23196. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  23197. * * width the width (x direction) of the ground
  23198. * * height the height (z direction) of the ground
  23199. * * subdivisions the number of subdivisions per side
  23200. * * minHeight the minimum altitude on the ground, optional, default 0
  23201. * * maxHeight the maximum altitude on the ground, optional default 1
  23202. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  23203. * * buffer the array holding the image color data
  23204. * * bufferWidth the width of image
  23205. * * bufferHeight the height of image
  23206. * @returns the VertexData of the Ground designed from a heightmap
  23207. */
  23208. static CreateGroundFromHeightMap(options: {
  23209. width: number;
  23210. height: number;
  23211. subdivisions: number;
  23212. minHeight: number;
  23213. maxHeight: number;
  23214. colorFilter: Color3;
  23215. buffer: Uint8Array;
  23216. bufferWidth: number;
  23217. bufferHeight: number;
  23218. }): VertexData;
  23219. /**
  23220. * Creates the VertexData for a Plane
  23221. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  23222. * * size sets the width and height of the plane to the value of size, optional default 1
  23223. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  23224. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  23225. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23226. * * 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)
  23227. * * 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)
  23228. * @returns the VertexData of the box
  23229. */
  23230. static CreatePlane(options: {
  23231. size?: number;
  23232. width?: number;
  23233. height?: number;
  23234. sideOrientation?: number;
  23235. frontUVs?: Vector4;
  23236. backUVs?: Vector4;
  23237. }): VertexData;
  23238. /**
  23239. * Creates the VertexData of the Disc or regular Polygon
  23240. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  23241. * * radius the radius of the disc, optional default 0.5
  23242. * * tessellation the number of polygon sides, optional, default 64
  23243. * * 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
  23244. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23245. * * 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)
  23246. * * 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)
  23247. * @returns the VertexData of the box
  23248. */
  23249. static CreateDisc(options: {
  23250. radius?: number;
  23251. tessellation?: number;
  23252. arc?: number;
  23253. sideOrientation?: number;
  23254. frontUVs?: Vector4;
  23255. backUVs?: Vector4;
  23256. }): VertexData;
  23257. /**
  23258. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  23259. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  23260. * @param polygon a mesh built from polygonTriangulation.build()
  23261. * @param sideOrientation takes the values BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23262. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23263. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23264. * @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)
  23265. * @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)
  23266. * @returns the VertexData of the Polygon
  23267. */
  23268. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  23269. /**
  23270. * Creates the VertexData of the IcoSphere
  23271. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  23272. * * radius the radius of the IcoSphere, optional default 1
  23273. * * radiusX allows stretching in the x direction, optional, default radius
  23274. * * radiusY allows stretching in the y direction, optional, default radius
  23275. * * radiusZ allows stretching in the z direction, optional, default radius
  23276. * * flat when true creates a flat shaded mesh, optional, default true
  23277. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23278. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23279. * * 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)
  23280. * * 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)
  23281. * @returns the VertexData of the IcoSphere
  23282. */
  23283. static CreateIcoSphere(options: {
  23284. radius?: number;
  23285. radiusX?: number;
  23286. radiusY?: number;
  23287. radiusZ?: number;
  23288. flat?: boolean;
  23289. subdivisions?: number;
  23290. sideOrientation?: number;
  23291. frontUVs?: Vector4;
  23292. backUVs?: Vector4;
  23293. }): VertexData;
  23294. /**
  23295. * Creates the VertexData for a Polyhedron
  23296. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  23297. * * type provided types are:
  23298. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  23299. * * 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)
  23300. * * size the size of the IcoSphere, optional default 1
  23301. * * sizeX allows stretching in the x direction, optional, default size
  23302. * * sizeY allows stretching in the y direction, optional, default size
  23303. * * sizeZ allows stretching in the z direction, optional, default size
  23304. * * 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
  23305. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23306. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23307. * * flat when true creates a flat shaded mesh, optional, default true
  23308. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23309. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23310. * * 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)
  23311. * * 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)
  23312. * @returns the VertexData of the Polyhedron
  23313. */
  23314. static CreatePolyhedron(options: {
  23315. type?: number;
  23316. size?: number;
  23317. sizeX?: number;
  23318. sizeY?: number;
  23319. sizeZ?: number;
  23320. custom?: any;
  23321. faceUV?: Vector4[];
  23322. faceColors?: Color4[];
  23323. flat?: boolean;
  23324. sideOrientation?: number;
  23325. frontUVs?: Vector4;
  23326. backUVs?: Vector4;
  23327. }): VertexData;
  23328. /**
  23329. * Creates the VertexData for a TorusKnot
  23330. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  23331. * * radius the radius of the torus knot, optional, default 2
  23332. * * tube the thickness of the tube, optional, default 0.5
  23333. * * radialSegments the number of sides on each tube segments, optional, default 32
  23334. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  23335. * * p the number of windings around the z axis, optional, default 2
  23336. * * q the number of windings around the x axis, optional, default 3
  23337. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23338. * * 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)
  23339. * * 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)
  23340. * @returns the VertexData of the Torus Knot
  23341. */
  23342. static CreateTorusKnot(options: {
  23343. radius?: number;
  23344. tube?: number;
  23345. radialSegments?: number;
  23346. tubularSegments?: number;
  23347. p?: number;
  23348. q?: number;
  23349. sideOrientation?: number;
  23350. frontUVs?: Vector4;
  23351. backUVs?: Vector4;
  23352. }): VertexData;
  23353. /**
  23354. * Compute normals for given positions and indices
  23355. * @param positions an array of vertex positions, [...., x, y, z, ......]
  23356. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  23357. * @param normals an array of vertex normals, [...., x, y, z, ......]
  23358. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  23359. * * facetNormals : optional array of facet normals (vector3)
  23360. * * facetPositions : optional array of facet positions (vector3)
  23361. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  23362. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  23363. * * bInfo : optional bounding info, required for facetPartitioning computation
  23364. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  23365. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  23366. * * useRightHandedSystem: optional boolean to for right handed system computation
  23367. * * depthSort : optional boolean to enable the facet depth sort computation
  23368. * * distanceTo : optional Vector3 to compute the facet depth from this location
  23369. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  23370. */
  23371. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  23372. facetNormals?: any;
  23373. facetPositions?: any;
  23374. facetPartitioning?: any;
  23375. ratio?: number;
  23376. bInfo?: any;
  23377. bbSize?: Vector3;
  23378. subDiv?: any;
  23379. useRightHandedSystem?: boolean;
  23380. depthSort?: boolean;
  23381. distanceTo?: Vector3;
  23382. depthSortedFacets?: any;
  23383. }): void;
  23384. private static _ComputeSides(sideOrientation, positions, indices, normals, uvs, frontUVs?, backUVs?);
  23385. /**
  23386. * Applies VertexData created from the imported parameters to the geometry
  23387. * @param parsedVertexData the parsed data from an imported file
  23388. * @param geometry the geometry to apply the VertexData to
  23389. */
  23390. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  23391. }
  23392. }
  23393. declare module BABYLON {
  23394. /**
  23395. * Class containing static functions to help procedurally build meshes
  23396. */
  23397. class MeshBuilder {
  23398. private static updateSideOrientation(orientation?);
  23399. /**
  23400. * Creates a box mesh
  23401. * * The parameter `size` sets the size (float) of each box side (default 1)
  23402. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value than `size`)
  23403. * * 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)
  23404. * * Please read this tutorial : http://doc.babylonjs.com/tutorials/CreateBox_Per_Face_Textures_And_Colors
  23405. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23406. * * 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
  23407. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23408. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#box
  23409. * @param name defines the name of the mesh
  23410. * @param options defines the options used to create the mesh
  23411. * @param scene defines the hosting scene
  23412. * @returns the box mesh
  23413. */
  23414. static CreateBox(name: string, options: {
  23415. size?: number;
  23416. width?: number;
  23417. height?: number;
  23418. depth?: number;
  23419. faceUV?: Vector4[];
  23420. faceColors?: Color4[];
  23421. sideOrientation?: number;
  23422. frontUVs?: Vector4;
  23423. backUVs?: Vector4;
  23424. updatable?: boolean;
  23425. }, scene?: Nullable<Scene>): Mesh;
  23426. /**
  23427. * Creates a sphere mesh
  23428. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  23429. * * 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 than `diameter`)
  23430. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  23431. * * 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
  23432. * * 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)
  23433. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23434. * * 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
  23435. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23436. * @param name defines the name of the mesh
  23437. * @param options defines the options used to create the mesh
  23438. * @param scene defines the hosting scene
  23439. * @returns the sphere mesh
  23440. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#sphere
  23441. */
  23442. static CreateSphere(name: string, options: {
  23443. segments?: number;
  23444. diameter?: number;
  23445. diameterX?: number;
  23446. diameterY?: number;
  23447. diameterZ?: number;
  23448. arc?: number;
  23449. slice?: number;
  23450. sideOrientation?: number;
  23451. frontUVs?: Vector4;
  23452. backUVs?: Vector4;
  23453. updatable?: boolean;
  23454. }, scene: any): Mesh;
  23455. /**
  23456. * Creates a plane polygonal mesh. By default, this is a disc
  23457. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  23458. * * 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
  23459. * * 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
  23460. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23461. * * 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
  23462. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23463. * @param name defines the name of the mesh
  23464. * @param options defines the options used to create the mesh
  23465. * @param scene defines the hosting scene
  23466. * @returns the plane polygonal mesh
  23467. * @see http://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  23468. */
  23469. static CreateDisc(name: string, options: {
  23470. radius?: number;
  23471. tessellation?: number;
  23472. arc?: number;
  23473. updatable?: boolean;
  23474. sideOrientation?: number;
  23475. frontUVs?: Vector4;
  23476. backUVs?: Vector4;
  23477. }, scene?: Nullable<Scene>): Mesh;
  23478. /**
  23479. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  23480. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  23481. * * 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`)
  23482. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  23483. * * 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
  23484. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23485. * * 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
  23486. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23487. * @param name defines the name of the mesh
  23488. * @param options defines the options used to create the mesh
  23489. * @param scene defines the hosting scene
  23490. * @returns the icosahedron mesh
  23491. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  23492. */
  23493. static CreateIcoSphere(name: string, options: {
  23494. radius?: number;
  23495. radiusX?: number;
  23496. radiusY?: number;
  23497. radiusZ?: number;
  23498. flat?: boolean;
  23499. subdivisions?: number;
  23500. sideOrientation?: number;
  23501. frontUVs?: Vector4;
  23502. backUVs?: Vector4;
  23503. updatable?: boolean;
  23504. }, scene: Scene): Mesh;
  23505. /**
  23506. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  23507. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  23508. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  23509. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  23510. * * 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
  23511. * * 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
  23512. * * 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
  23513. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23514. * * 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
  23515. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  23516. * * 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
  23517. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  23518. * * 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
  23519. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  23520. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23521. * @param name defines the name of the mesh
  23522. * @param options defines the options used to create the mesh
  23523. * @param scene defines the hosting scene
  23524. * @returns the ribbon mesh
  23525. * @see http://doc.babylonjs.com/tutorials/Ribbon_Tutorial
  23526. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  23527. */
  23528. static CreateRibbon(name: string, options: {
  23529. pathArray: Vector3[][];
  23530. closeArray?: boolean;
  23531. closePath?: boolean;
  23532. offset?: number;
  23533. updatable?: boolean;
  23534. sideOrientation?: number;
  23535. frontUVs?: Vector4;
  23536. backUVs?: Vector4;
  23537. instance?: Mesh;
  23538. invertUV?: boolean;
  23539. uvs?: Vector2[];
  23540. colors?: Color4[];
  23541. }, scene?: Nullable<Scene>): Mesh;
  23542. /**
  23543. * Creates a cylinder or a cone mesh
  23544. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  23545. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  23546. * * 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.
  23547. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  23548. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  23549. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  23550. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  23551. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  23552. * * 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).
  23553. * * 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
  23554. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  23555. * * 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
  23556. * * 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.
  23557. * * If `enclose` is false, a ring surface is one element.
  23558. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  23559. * * 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
  23560. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23561. * * 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
  23562. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  23563. * @param name defines the name of the mesh
  23564. * @param options defines the options used to create the mesh
  23565. * @param scene defines the hosting scene
  23566. * @returns the cylinder mesh
  23567. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#cylinder-or-cone
  23568. */
  23569. static CreateCylinder(name: string, options: {
  23570. height?: number;
  23571. diameterTop?: number;
  23572. diameterBottom?: number;
  23573. diameter?: number;
  23574. tessellation?: number;
  23575. subdivisions?: number;
  23576. arc?: number;
  23577. faceColors?: Color4[];
  23578. faceUV?: Vector4[];
  23579. updatable?: boolean;
  23580. hasRings?: boolean;
  23581. enclose?: boolean;
  23582. sideOrientation?: number;
  23583. frontUVs?: Vector4;
  23584. backUVs?: Vector4;
  23585. }, scene: any): Mesh;
  23586. /**
  23587. * Creates a torus mesh
  23588. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  23589. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  23590. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  23591. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23592. * * 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
  23593. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  23594. * @param name defines the name of the mesh
  23595. * @param options defines the options used to create the mesh
  23596. * @param scene defines the hosting scene
  23597. * @returns the torus mesh
  23598. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#torus
  23599. */
  23600. static CreateTorus(name: string, options: {
  23601. diameter?: number;
  23602. thickness?: number;
  23603. tessellation?: number;
  23604. updatable?: boolean;
  23605. sideOrientation?: number;
  23606. frontUVs?: Vector4;
  23607. backUVs?: Vector4;
  23608. }, scene: any): Mesh;
  23609. /**
  23610. * Creates a torus knot mesh
  23611. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  23612. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  23613. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  23614. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  23615. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23616. * * 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
  23617. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  23618. * @param name defines the name of the mesh
  23619. * @param options defines the options used to create the mesh
  23620. * @param scene defines the hosting scene
  23621. * @returns the torus knot mesh
  23622. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#torus-knot
  23623. */
  23624. static CreateTorusKnot(name: string, options: {
  23625. radius?: number;
  23626. tube?: number;
  23627. radialSegments?: number;
  23628. tubularSegments?: number;
  23629. p?: number;
  23630. q?: number;
  23631. updatable?: boolean;
  23632. sideOrientation?: number;
  23633. frontUVs?: Vector4;
  23634. backUVs?: Vector4;
  23635. }, scene: any): Mesh;
  23636. /**
  23637. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  23638. * * 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
  23639. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  23640. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  23641. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  23642. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  23643. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  23644. * * 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
  23645. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  23646. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23647. * @see http://doc.babylonjs.com/how_to/parametric_shapes#line-system
  23648. * @param name defines the name of the new line system
  23649. * @param options defines the options used to create the line system
  23650. * @param scene defines the hosting scene
  23651. * @returns a new line system mesh
  23652. */
  23653. static CreateLineSystem(name: string, options: {
  23654. lines: Vector3[][];
  23655. updatable?: boolean;
  23656. instance?: Nullable<LinesMesh>;
  23657. colors?: Nullable<Color4[][]>;
  23658. useVertexAlpha?: boolean;
  23659. }, scene: Nullable<Scene>): LinesMesh;
  23660. /**
  23661. * Creates a line mesh
  23662. * 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
  23663. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  23664. * * The parameter `points` is an array successive Vector3
  23665. * * 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
  23666. * * The optional parameter `colors` is an array of successive Color4, one per line point
  23667. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  23668. * * When updating an instance, remember that only point positions can change, not the number of points
  23669. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23670. * @see http://doc.babylonjs.com/how_to/parametric_shapes#lines
  23671. * @param name defines the name of the new line system
  23672. * @param options defines the options used to create the line system
  23673. * @param scene defines the hosting scene
  23674. * @returns a new line mesh
  23675. */
  23676. static CreateLines(name: string, options: {
  23677. points: Vector3[];
  23678. updatable?: boolean;
  23679. instance?: Nullable<LinesMesh>;
  23680. colors?: Color4[];
  23681. useVertexAlpha?: boolean;
  23682. }, scene?: Nullable<Scene>): LinesMesh;
  23683. /**
  23684. * Creates a dashed line mesh
  23685. * * 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
  23686. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  23687. * * The parameter `points` is an array successive Vector3
  23688. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  23689. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  23690. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  23691. * * 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
  23692. * * When updating an instance, remember that only point positions can change, not the number of points
  23693. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23694. * @param name defines the name of the mesh
  23695. * @param options defines the options used to create the mesh
  23696. * @param scene defines the hosting scene
  23697. * @returns the dashed line mesh
  23698. * @see http://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  23699. */
  23700. static CreateDashedLines(name: string, options: {
  23701. points: Vector3[];
  23702. dashSize?: number;
  23703. gapSize?: number;
  23704. dashNb?: number;
  23705. updatable?: boolean;
  23706. instance?: LinesMesh;
  23707. }, scene?: Nullable<Scene>): LinesMesh;
  23708. /**
  23709. * 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.
  23710. * * 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.
  23711. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  23712. * * 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.
  23713. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  23714. * * 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
  23715. * * 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
  23716. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  23717. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23718. * * 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
  23719. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  23720. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  23721. * @param name defines the name of the mesh
  23722. * @param options defines the options used to create the mesh
  23723. * @param scene defines the hosting scene
  23724. * @returns the extruded shape mesh
  23725. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  23726. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  23727. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  23728. */
  23729. static ExtrudeShape(name: string, options: {
  23730. shape: Vector3[];
  23731. path: Vector3[];
  23732. scale?: number;
  23733. rotation?: number;
  23734. cap?: number;
  23735. updatable?: boolean;
  23736. sideOrientation?: number;
  23737. frontUVs?: Vector4;
  23738. backUVs?: Vector4;
  23739. instance?: Mesh;
  23740. invertUV?: boolean;
  23741. }, scene?: Nullable<Scene>): Mesh;
  23742. /**
  23743. * Creates an custom extruded shape mesh.
  23744. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  23745. * * 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.
  23746. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  23747. * * 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
  23748. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  23749. * * 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
  23750. * * It must returns a float value that will be the scale value applied to the shape on each path point
  23751. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  23752. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  23753. * * 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
  23754. * * 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
  23755. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  23756. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23757. * * 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
  23758. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  23759. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23760. * @param name defines the name of the mesh
  23761. * @param options defines the options used to create the mesh
  23762. * @param scene defines the hosting scene
  23763. * @returns the custom extruded shape mesh
  23764. * @see http://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  23765. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  23766. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  23767. */
  23768. static ExtrudeShapeCustom(name: string, options: {
  23769. shape: Vector3[];
  23770. path: Vector3[];
  23771. scaleFunction?: any;
  23772. rotationFunction?: any;
  23773. ribbonCloseArray?: boolean;
  23774. ribbonClosePath?: boolean;
  23775. cap?: number;
  23776. updatable?: boolean;
  23777. sideOrientation?: number;
  23778. frontUVs?: Vector4;
  23779. backUVs?: Vector4;
  23780. instance?: Mesh;
  23781. invertUV?: boolean;
  23782. }, scene: Scene): Mesh;
  23783. /**
  23784. * Creates lathe mesh.
  23785. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  23786. * * 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
  23787. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  23788. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  23789. * * 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
  23790. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  23791. * * 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
  23792. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23793. * * 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
  23794. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  23795. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23796. * @param name defines the name of the mesh
  23797. * @param options defines the options used to create the mesh
  23798. * @param scene defines the hosting scene
  23799. * @returns the lathe mesh
  23800. * @see http://doc.babylonjs.com/how_to/parametric_shapes#lathe
  23801. */
  23802. static CreateLathe(name: string, options: {
  23803. shape: Vector3[];
  23804. radius?: number;
  23805. tessellation?: number;
  23806. arc?: number;
  23807. closed?: boolean;
  23808. updatable?: boolean;
  23809. sideOrientation?: number;
  23810. frontUVs?: Vector4;
  23811. backUVs?: Vector4;
  23812. cap?: number;
  23813. invertUV?: boolean;
  23814. }, scene: Scene): Mesh;
  23815. /**
  23816. * Creates a plane mesh
  23817. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  23818. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value than `size`)
  23819. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  23820. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23821. * * 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
  23822. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23823. * @param name defines the name of the mesh
  23824. * @param options defines the options used to create the mesh
  23825. * @param scene defines the hosting scene
  23826. * @returns the plane mesh
  23827. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#plane
  23828. */
  23829. static CreatePlane(name: string, options: {
  23830. size?: number;
  23831. width?: number;
  23832. height?: number;
  23833. sideOrientation?: number;
  23834. frontUVs?: Vector4;
  23835. backUVs?: Vector4;
  23836. updatable?: boolean;
  23837. sourcePlane?: Plane;
  23838. }, scene: Scene): Mesh;
  23839. /**
  23840. * Creates a ground mesh
  23841. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  23842. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  23843. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23844. * @param name defines the name of the mesh
  23845. * @param options defines the options used to create the mesh
  23846. * @param scene defines the hosting scene
  23847. * @returns the ground mesh
  23848. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#plane
  23849. */
  23850. static CreateGround(name: string, options: {
  23851. width?: number;
  23852. height?: number;
  23853. subdivisions?: number;
  23854. subdivisionsX?: number;
  23855. subdivisionsY?: number;
  23856. updatable?: boolean;
  23857. }, scene: any): Mesh;
  23858. /**
  23859. * Creates a tiled ground mesh
  23860. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  23861. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  23862. * * 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
  23863. * * 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
  23864. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  23865. * @param name defines the name of the mesh
  23866. * @param options defines the options used to create the mesh
  23867. * @param scene defines the hosting scene
  23868. * @returns the tiled ground mesh
  23869. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#tiled-ground
  23870. */
  23871. static CreateTiledGround(name: string, options: {
  23872. xmin: number;
  23873. zmin: number;
  23874. xmax: number;
  23875. zmax: number;
  23876. subdivisions?: {
  23877. w: number;
  23878. h: number;
  23879. };
  23880. precision?: {
  23881. w: number;
  23882. h: number;
  23883. };
  23884. updatable?: boolean;
  23885. }, scene: Scene): Mesh;
  23886. /**
  23887. * Creates a ground mesh from a height map
  23888. * * The parameter `url` sets the URL of the height map image resource.
  23889. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  23890. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  23891. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  23892. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  23893. * * 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.
  23894. * * 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).
  23895. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  23896. * @param name defines the name of the mesh
  23897. * @param url defines the url to the height map
  23898. * @param options defines the options used to create the mesh
  23899. * @param scene defines the hosting scene
  23900. * @returns the ground mesh
  23901. * @see http://doc.babylonjs.com/babylon101/height_map
  23902. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#ground-from-a-height-map
  23903. */
  23904. static CreateGroundFromHeightMap(name: string, url: string, options: {
  23905. width?: number;
  23906. height?: number;
  23907. subdivisions?: number;
  23908. minHeight?: number;
  23909. maxHeight?: number;
  23910. colorFilter?: Color3;
  23911. updatable?: boolean;
  23912. onReady?: (mesh: GroundMesh) => void;
  23913. }, scene: Scene): GroundMesh;
  23914. /**
  23915. * Creates a polygon mesh
  23916. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  23917. * * 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
  23918. * * You can set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23919. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23920. * * 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)
  23921. * * Remember you can only change the shape positions, not their number when updating a polygon
  23922. * @param name defines the name of the mesh
  23923. * @param options defines the options used to create the mesh
  23924. * @param scene defines the hosting scene
  23925. * @returns the polygon mesh
  23926. */
  23927. static CreatePolygon(name: string, options: {
  23928. shape: Vector3[];
  23929. holes?: Vector3[][];
  23930. depth?: number;
  23931. faceUV?: Vector4[];
  23932. faceColors?: Color4[];
  23933. updatable?: boolean;
  23934. sideOrientation?: number;
  23935. frontUVs?: Vector4;
  23936. backUVs?: Vector4;
  23937. }, scene: Scene): Mesh;
  23938. /**
  23939. * Creates an extruded polygon mesh, with depth in the Y direction.
  23940. * * 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)
  23941. * @see http://doc.babylonjs.com/tutorials/CreateBox_Per_Face_Textures_And_Colors
  23942. * @param name defines the name of the mesh
  23943. * @param options defines the options used to create the mesh
  23944. * @param scene defines the hosting scene
  23945. * @returns the polygon mesh
  23946. */
  23947. static ExtrudePolygon(name: string, options: {
  23948. shape: Vector3[];
  23949. holes?: Vector3[][];
  23950. depth?: number;
  23951. faceUV?: Vector4[];
  23952. faceColors?: Color4[];
  23953. updatable?: boolean;
  23954. sideOrientation?: number;
  23955. frontUVs?: Vector4;
  23956. backUVs?: Vector4;
  23957. }, scene: Scene): Mesh;
  23958. /**
  23959. * Creates a tube mesh.
  23960. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  23961. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  23962. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  23963. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  23964. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  23965. * * 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)
  23966. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  23967. * * 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
  23968. * * 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
  23969. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23970. * * 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
  23971. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  23972. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23973. * @param name defines the name of the mesh
  23974. * @param options defines the options used to create the mesh
  23975. * @param scene defines the hosting scene
  23976. * @returns the tube mesh
  23977. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  23978. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#tube
  23979. */
  23980. static CreateTube(name: string, options: {
  23981. path: Vector3[];
  23982. radius?: number;
  23983. tessellation?: number;
  23984. radiusFunction?: {
  23985. (i: number, distance: number): number;
  23986. };
  23987. cap?: number;
  23988. arc?: number;
  23989. updatable?: boolean;
  23990. sideOrientation?: number;
  23991. frontUVs?: Vector4;
  23992. backUVs?: Vector4;
  23993. instance?: Mesh;
  23994. invertUV?: boolean;
  23995. }, scene: Scene): Mesh;
  23996. /**
  23997. * Creates a polyhedron mesh
  23998. * * 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
  23999. * * The parameter `size` (positive float, default 1) sets the polygon size
  24000. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  24001. * * 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`
  24002. * * 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
  24003. * * 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)`)
  24004. * * 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
  24005. * * 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
  24006. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  24007. * * 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
  24008. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24009. * @param name defines the name of the mesh
  24010. * @param options defines the options used to create the mesh
  24011. * @param scene defines the hosting scene
  24012. * @returns the polyhedron mesh
  24013. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes
  24014. */
  24015. static CreatePolyhedron(name: string, options: {
  24016. type?: number;
  24017. size?: number;
  24018. sizeX?: number;
  24019. sizeY?: number;
  24020. sizeZ?: number;
  24021. custom?: any;
  24022. faceUV?: Vector4[];
  24023. faceColors?: Color4[];
  24024. flat?: boolean;
  24025. updatable?: boolean;
  24026. sideOrientation?: number;
  24027. frontUVs?: Vector4;
  24028. backUVs?: Vector4;
  24029. }, scene: Scene): Mesh;
  24030. /**
  24031. * Creates a decal mesh.
  24032. * 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
  24033. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  24034. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  24035. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  24036. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  24037. * @param name defines the name of the mesh
  24038. * @param sourceMesh defines the mesh where the decal must be applied
  24039. * @param options defines the options used to create the mesh
  24040. * @param scene defines the hosting scene
  24041. * @returns the decal mesh
  24042. * @see http://doc.babylonjs.com/how_to/decals
  24043. */
  24044. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  24045. position?: Vector3;
  24046. normal?: Vector3;
  24047. size?: Vector3;
  24048. angle?: number;
  24049. }): Mesh;
  24050. private static _ExtrudeShapeGeneric(name, shape, curve, scale, rotation, scaleFunction, rotateFunction, rbCA, rbCP, cap, custom, scene, updtbl, side, instance, invertUV, frontUVs, backUVs);
  24051. }
  24052. }
  24053. declare module BABYLON {
  24054. class MeshLODLevel {
  24055. distance: number;
  24056. mesh: Nullable<Mesh>;
  24057. constructor(distance: number, mesh: Nullable<Mesh>);
  24058. }
  24059. }
  24060. declare module BABYLON {
  24061. /**
  24062. * A simplifier interface for future simplification implementations.
  24063. */
  24064. interface ISimplifier {
  24065. /**
  24066. * Simplification of a given mesh according to the given settings.
  24067. * Since this requires computation, it is assumed that the function runs async.
  24068. * @param settings The settings of the simplification, including quality and distance
  24069. * @param successCallback A callback that will be called after the mesh was simplified.
  24070. * @param errorCallback in case of an error, this callback will be called. optional.
  24071. */
  24072. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  24073. }
  24074. /**
  24075. * Expected simplification settings.
  24076. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%);
  24077. */
  24078. interface ISimplificationSettings {
  24079. quality: number;
  24080. distance: number;
  24081. optimizeMesh?: boolean;
  24082. }
  24083. class SimplificationSettings implements ISimplificationSettings {
  24084. quality: number;
  24085. distance: number;
  24086. optimizeMesh: boolean | undefined;
  24087. constructor(quality: number, distance: number, optimizeMesh?: boolean | undefined);
  24088. }
  24089. interface ISimplificationTask {
  24090. settings: Array<ISimplificationSettings>;
  24091. simplificationType: SimplificationType;
  24092. mesh: Mesh;
  24093. successCallback?: () => void;
  24094. parallelProcessing: boolean;
  24095. }
  24096. class SimplificationQueue {
  24097. private _simplificationArray;
  24098. running: boolean;
  24099. constructor();
  24100. addTask(task: ISimplificationTask): void;
  24101. executeNext(): void;
  24102. runSimplification(task: ISimplificationTask): void;
  24103. private getSimplifier(task);
  24104. }
  24105. /**
  24106. * The implemented types of simplification
  24107. * At the moment only Quadratic Error Decimation is implemented
  24108. */
  24109. enum SimplificationType {
  24110. /** Quadratic error decimation */
  24111. QUADRATIC = 0,
  24112. }
  24113. class DecimationTriangle {
  24114. vertices: Array<DecimationVertex>;
  24115. normal: Vector3;
  24116. error: Array<number>;
  24117. deleted: boolean;
  24118. isDirty: boolean;
  24119. borderFactor: number;
  24120. deletePending: boolean;
  24121. originalOffset: number;
  24122. constructor(vertices: Array<DecimationVertex>);
  24123. }
  24124. class DecimationVertex {
  24125. position: Vector3;
  24126. id: number;
  24127. q: QuadraticMatrix;
  24128. isBorder: boolean;
  24129. triangleStart: number;
  24130. triangleCount: number;
  24131. originalOffsets: Array<number>;
  24132. constructor(position: Vector3, id: number);
  24133. updatePosition(newPosition: Vector3): void;
  24134. }
  24135. class QuadraticMatrix {
  24136. data: Array<number>;
  24137. constructor(data?: Array<number>);
  24138. det(a11: number, a12: number, a13: number, a21: number, a22: number, a23: number, a31: number, a32: number, a33: number): number;
  24139. addInPlace(matrix: QuadraticMatrix): void;
  24140. addArrayInPlace(data: Array<number>): void;
  24141. add(matrix: QuadraticMatrix): QuadraticMatrix;
  24142. static FromData(a: number, b: number, c: number, d: number): QuadraticMatrix;
  24143. static DataFromNumbers(a: number, b: number, c: number, d: number): number[];
  24144. }
  24145. class Reference {
  24146. vertexId: number;
  24147. triangleId: number;
  24148. constructor(vertexId: number, triangleId: number);
  24149. }
  24150. /**
  24151. * An implementation of the Quadratic Error simplification algorithm.
  24152. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  24153. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  24154. * @author RaananW
  24155. */
  24156. class QuadraticErrorSimplification implements ISimplifier {
  24157. private _mesh;
  24158. private triangles;
  24159. private vertices;
  24160. private references;
  24161. private _reconstructedMesh;
  24162. syncIterations: number;
  24163. aggressiveness: number;
  24164. decimationIterations: number;
  24165. boundingBoxEpsilon: number;
  24166. constructor(_mesh: Mesh);
  24167. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  24168. private runDecimation(settings, submeshIndex, successCallback);
  24169. private initWithMesh(submeshIndex, callback, optimizeMesh?);
  24170. private init(callback);
  24171. private reconstructMesh(submeshIndex);
  24172. private initDecimatedMesh();
  24173. private isFlipped(vertex1, vertex2, point, deletedArray, borderFactor, delTr);
  24174. private updateTriangles(origVertex, vertex, deletedArray, deletedTriangles);
  24175. private identifyBorder();
  24176. private updateMesh(identifyBorders?);
  24177. private vertexError(q, point);
  24178. private calculateError(vertex1, vertex2, pointResult?, normalResult?, uvResult?, colorResult?);
  24179. }
  24180. }
  24181. declare module BABYLON {
  24182. class Polygon {
  24183. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  24184. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  24185. static Parse(input: string): Vector2[];
  24186. static StartingAt(x: number, y: number): Path2;
  24187. }
  24188. class PolygonMeshBuilder {
  24189. private _points;
  24190. private _outlinepoints;
  24191. private _holes;
  24192. private _name;
  24193. private _scene;
  24194. private _epoints;
  24195. private _eholes;
  24196. private _addToepoint(points);
  24197. constructor(name: string, contours: Path2, scene: Scene);
  24198. constructor(name: string, contours: Vector2[], scene: Scene);
  24199. addHole(hole: Vector2[]): PolygonMeshBuilder;
  24200. build(updatable?: boolean, depth?: number): Mesh;
  24201. private addSide(positions, normals, uvs, indices, bounds, points, depth, flip);
  24202. }
  24203. }
  24204. declare module BABYLON {
  24205. class BaseSubMesh {
  24206. readonly effect: Nullable<Effect>;
  24207. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  24208. }
  24209. class SubMesh extends BaseSubMesh implements ICullable {
  24210. materialIndex: number;
  24211. verticesStart: number;
  24212. verticesCount: number;
  24213. indexStart: number;
  24214. indexCount: number;
  24215. linesIndexCount: number;
  24216. private _mesh;
  24217. private _renderingMesh;
  24218. private _boundingInfo;
  24219. private _linesIndexBuffer;
  24220. private _currentMaterial;
  24221. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  24222. constructor(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  24223. readonly IsGlobal: boolean;
  24224. /**
  24225. * Returns the submesh BoudingInfo object.
  24226. */
  24227. getBoundingInfo(): BoundingInfo;
  24228. /**
  24229. * Sets the submesh BoundingInfo.
  24230. * Return the SubMesh.
  24231. */
  24232. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  24233. /**
  24234. * Returns the mesh of the current submesh.
  24235. */
  24236. getMesh(): AbstractMesh;
  24237. /**
  24238. * Returns the rendering mesh of the submesh.
  24239. */
  24240. getRenderingMesh(): Mesh;
  24241. /**
  24242. * Returns the submesh material.
  24243. */
  24244. getMaterial(): Nullable<Material>;
  24245. /**
  24246. * Sets a new updated BoundingInfo object to the submesh.
  24247. * Returns the SubMesh.
  24248. */
  24249. refreshBoundingInfo(): SubMesh;
  24250. /**
  24251. * Updates the submesh BoundingInfo.
  24252. * Returns the Submesh.
  24253. */
  24254. updateBoundingInfo(world: Matrix): SubMesh;
  24255. /**
  24256. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  24257. * Boolean returned.
  24258. */
  24259. isInFrustum(frustumPlanes: Plane[]): boolean;
  24260. /**
  24261. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes.
  24262. * Boolean returned.
  24263. */
  24264. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  24265. /**
  24266. * Renders the submesh.
  24267. * Returns it.
  24268. */
  24269. render(enableAlphaMode: boolean): SubMesh;
  24270. /**
  24271. * Returns a new Index Buffer.
  24272. * Type returned : WebGLBuffer.
  24273. */
  24274. getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  24275. /**
  24276. * True is the passed Ray intersects the submesh bounding box.
  24277. * Boolean returned.
  24278. */
  24279. canIntersects(ray: Ray): boolean;
  24280. /**
  24281. * Returns an object IntersectionInfo.
  24282. */
  24283. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean): Nullable<IntersectionInfo>;
  24284. /**
  24285. * Creates a new Submesh from the passed Mesh.
  24286. */
  24287. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  24288. /**
  24289. * Disposes the Submesh.
  24290. * Returns nothing.
  24291. */
  24292. dispose(): void;
  24293. /**
  24294. * Creates a new Submesh from the passed parameters :
  24295. * - materialIndex (integer) : the index of the main mesh material.
  24296. * - startIndex (integer) : the index where to start the copy in the mesh indices array.
  24297. * - indexCount (integer) : the number of indices to copy then from the startIndex.
  24298. * - mesh (Mesh) : the main mesh to create the submesh from.
  24299. * - renderingMesh (optional Mesh) : rendering mesh.
  24300. */
  24301. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  24302. }
  24303. }
  24304. declare module BABYLON {
  24305. class TransformNode extends Node {
  24306. static BILLBOARDMODE_NONE: number;
  24307. static BILLBOARDMODE_X: number;
  24308. static BILLBOARDMODE_Y: number;
  24309. static BILLBOARDMODE_Z: number;
  24310. static BILLBOARDMODE_ALL: number;
  24311. private _forward;
  24312. private _forwardInverted;
  24313. private _up;
  24314. private _right;
  24315. private _rightInverted;
  24316. private _rotation;
  24317. private _rotationQuaternion;
  24318. protected _scaling: Vector3;
  24319. protected _isDirty: boolean;
  24320. private _transformToBoneReferal;
  24321. /**
  24322. * Set the billboard mode. Default is 0.
  24323. *
  24324. * | Value | Type | Description |
  24325. * | --- | --- | --- |
  24326. * | 0 | BILLBOARDMODE_NONE | |
  24327. * | 1 | BILLBOARDMODE_X | |
  24328. * | 2 | BILLBOARDMODE_Y | |
  24329. * | 4 | BILLBOARDMODE_Z | |
  24330. * | 7 | BILLBOARDMODE_ALL | |
  24331. *
  24332. */
  24333. billboardMode: number;
  24334. scalingDeterminant: number;
  24335. infiniteDistance: boolean;
  24336. /**
  24337. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  24338. * By default the system will update normals to compensate
  24339. */
  24340. ignoreNonUniformScaling: boolean;
  24341. position: Vector3;
  24342. private _localWorld;
  24343. private _absolutePosition;
  24344. private _pivotMatrix;
  24345. private _pivotMatrixInverse;
  24346. private _postMultiplyPivotMatrix;
  24347. protected _isWorldMatrixFrozen: boolean;
  24348. /**
  24349. * An event triggered after the world matrix is updated
  24350. */
  24351. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  24352. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  24353. /**
  24354. * Gets a string idenfifying the name of the class
  24355. * @returns "TransformNode" string
  24356. */
  24357. getClassName(): string;
  24358. /**
  24359. * Rotation property : a Vector3 depicting the rotation value in radians around each local axis X, Y, Z.
  24360. * If rotation quaternion is set, this Vector3 will (almost always) be the Zero vector!
  24361. * Default : (0.0, 0.0, 0.0)
  24362. */
  24363. rotation: Vector3;
  24364. /**
  24365. * Scaling property : a Vector3 depicting the mesh scaling along each local axis X, Y, Z.
  24366. * Default : (1.0, 1.0, 1.0)
  24367. */
  24368. /**
  24369. * Scaling property : a Vector3 depicting the mesh scaling along each local axis X, Y, Z.
  24370. * Default : (1.0, 1.0, 1.0)
  24371. */
  24372. scaling: Vector3;
  24373. /**
  24374. * Rotation Quaternion property : this a Quaternion object depicting the mesh rotation by using a unit quaternion.
  24375. * It's null by default.
  24376. * If set, only the rotationQuaternion is then used to compute the mesh rotation and its property `.rotation\ is then ignored and set to (0.0, 0.0, 0.0)
  24377. */
  24378. rotationQuaternion: Nullable<Quaternion>;
  24379. /**
  24380. * The forward direction of that transform in world space.
  24381. */
  24382. readonly forward: Vector3;
  24383. /**
  24384. * The up direction of that transform in world space.
  24385. */
  24386. readonly up: Vector3;
  24387. /**
  24388. * The right direction of that transform in world space.
  24389. */
  24390. readonly right: Vector3;
  24391. /**
  24392. * Returns the latest update of the World matrix
  24393. * Returns a Matrix.
  24394. */
  24395. getWorldMatrix(): Matrix;
  24396. /** @hidden */
  24397. /**
  24398. * Returns directly the latest state of the mesh World matrix.
  24399. * A Matrix is returned.
  24400. */
  24401. readonly worldMatrixFromCache: Matrix;
  24402. /**
  24403. * Copies the paramater passed Matrix into the mesh Pose matrix.
  24404. * Returns the TransformNode.
  24405. */
  24406. updatePoseMatrix(matrix: Matrix): TransformNode;
  24407. /**
  24408. * Returns the mesh Pose matrix.
  24409. * Returned object : Matrix
  24410. */
  24411. getPoseMatrix(): Matrix;
  24412. markAsDirty(property: string): TransformNode;
  24413. /**
  24414. * Returns the current mesh absolute position.
  24415. * Retuns a Vector3.
  24416. */
  24417. readonly absolutePosition: Vector3;
  24418. /**
  24419. * Sets a new matrix to apply before all other transformation
  24420. * @param matrix defines the transform matrix
  24421. * @returns the current TransformNode
  24422. */
  24423. setPreTransformMatrix(matrix: Matrix): TransformNode;
  24424. /**
  24425. * Sets a new pivot matrix to the current node
  24426. * @param matrix defines the new pivot matrix to use
  24427. * @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
  24428. * @returns the current TransformNode
  24429. */
  24430. setPivotMatrix(matrix: Matrix, postMultiplyPivotMatrix?: boolean): TransformNode;
  24431. /**
  24432. * Returns the mesh pivot matrix.
  24433. * Default : Identity.
  24434. * A Matrix is returned.
  24435. */
  24436. getPivotMatrix(): Matrix;
  24437. /**
  24438. * Prevents the World matrix to be computed any longer.
  24439. * Returns the TransformNode.
  24440. */
  24441. freezeWorldMatrix(): TransformNode;
  24442. /**
  24443. * Allows back the World matrix computation.
  24444. * Returns the TransformNode.
  24445. */
  24446. unfreezeWorldMatrix(): this;
  24447. /**
  24448. * True if the World matrix has been frozen.
  24449. * Returns a boolean.
  24450. */
  24451. readonly isWorldMatrixFrozen: boolean;
  24452. /**
  24453. * Retuns the mesh absolute position in the World.
  24454. * Returns a Vector3.
  24455. */
  24456. getAbsolutePosition(): Vector3;
  24457. /**
  24458. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  24459. * Returns the TransformNode.
  24460. */
  24461. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  24462. /**
  24463. * Sets the mesh position in its local space.
  24464. * Returns the TransformNode.
  24465. */
  24466. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  24467. /**
  24468. * Returns the mesh position in the local space from the current World matrix values.
  24469. * Returns a new Vector3.
  24470. */
  24471. getPositionExpressedInLocalSpace(): Vector3;
  24472. /**
  24473. * Translates the mesh along the passed Vector3 in its local space.
  24474. * Returns the TransformNode.
  24475. */
  24476. locallyTranslate(vector3: Vector3): TransformNode;
  24477. private static _lookAtVectorCache;
  24478. /**
  24479. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  24480. * @param targetPoint the position (must be in same space as current mesh) to look at
  24481. * @param yawCor optional yaw (y-axis) correction in radians
  24482. * @param pitchCor optional pitch (x-axis) correction in radians
  24483. * @param rollCor optional roll (z-axis) correction in radians
  24484. * @param space the choosen space of the target
  24485. * @returns the TransformNode.
  24486. */
  24487. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  24488. /**
  24489. * Returns a new Vector3 what is the localAxis, expressed in the mesh local space, rotated like the mesh.
  24490. * This Vector3 is expressed in the World space.
  24491. */
  24492. getDirection(localAxis: Vector3): Vector3;
  24493. /**
  24494. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  24495. * localAxis is expressed in the mesh local space.
  24496. * result is computed in the Wordl space from the mesh World matrix.
  24497. * Returns the TransformNode.
  24498. */
  24499. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  24500. /**
  24501. * Sets a new pivot point to the current node
  24502. * @param point defines the new pivot point to use
  24503. * @param space defines if the point is in world or local space (local by default)
  24504. * @returns the current TransformNode
  24505. */
  24506. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  24507. /**
  24508. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  24509. */
  24510. getPivotPoint(): Vector3;
  24511. /**
  24512. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  24513. * Returns the TransformNode.
  24514. */
  24515. getPivotPointToRef(result: Vector3): TransformNode;
  24516. /**
  24517. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  24518. */
  24519. getAbsolutePivotPoint(): Vector3;
  24520. /**
  24521. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  24522. * Returns the TransformNode.
  24523. */
  24524. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  24525. /**
  24526. * Defines the passed node as the parent of the current node.
  24527. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  24528. * Returns the TransformNode.
  24529. */
  24530. setParent(node: Nullable<Node>): TransformNode;
  24531. private _nonUniformScaling;
  24532. readonly nonUniformScaling: boolean;
  24533. /**
  24534. * Attach the current TransformNode to another TransformNode associated with a bone
  24535. * @param bone Bone affecting the TransformNode
  24536. * @param affectedTransformNode TransformNode associated with the bone
  24537. */
  24538. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  24539. detachFromBone(): TransformNode;
  24540. private static _rotationAxisCache;
  24541. /**
  24542. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  24543. * space (default LOCAL) can be either BABYLON.Space.LOCAL, either BABYLON.Space.WORLD.
  24544. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  24545. * The passed axis is also normalized.
  24546. * Returns the TransformNode.
  24547. */
  24548. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  24549. /**
  24550. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  24551. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  24552. * The passed axis is also normalized.
  24553. * Returns the TransformNode.
  24554. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  24555. */
  24556. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  24557. /**
  24558. * Translates the mesh along the axis vector for the passed distance in the given space.
  24559. * space (default LOCAL) can be either BABYLON.Space.LOCAL, either BABYLON.Space.WORLD.
  24560. * Returns the TransformNode.
  24561. */
  24562. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  24563. /**
  24564. * Adds a rotation step to the mesh current rotation.
  24565. * x, y, z are Euler angles expressed in radians.
  24566. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  24567. * This means this rotation is made in the mesh local space only.
  24568. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  24569. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  24570. * ```javascript
  24571. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  24572. * ```
  24573. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  24574. * 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.
  24575. * Returns the TransformNode.
  24576. */
  24577. addRotation(x: number, y: number, z: number): TransformNode;
  24578. /**
  24579. * Computes the mesh World matrix and returns it.
  24580. * If the mesh world matrix is frozen, this computation does nothing more than returning the last frozen values.
  24581. * If the parameter `force` is let to `false` (default), the current cached World matrix is returned.
  24582. * If the parameter `force`is set to `true`, the actual computation is done.
  24583. * Returns the mesh World Matrix.
  24584. */
  24585. computeWorldMatrix(force?: boolean): Matrix;
  24586. protected _afterComputeWorldMatrix(): void;
  24587. /**
  24588. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  24589. * @param func: callback function to add
  24590. *
  24591. * Returns the TransformNode.
  24592. */
  24593. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  24594. /**
  24595. * Removes a registered callback function.
  24596. * Returns the TransformNode.
  24597. */
  24598. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  24599. /**
  24600. * Clone the current transform node
  24601. * Returns the new transform node
  24602. * @param name Name of the new clone
  24603. * @param newParent New parent for the clone
  24604. * @param doNotCloneChildren Do not clone children hierarchy
  24605. */
  24606. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  24607. serialize(currentSerializationObject?: any): any;
  24608. /**
  24609. * Returns a new TransformNode object parsed from the source provided.
  24610. * The parameter `parsedMesh` is the source.
  24611. * The parameter `rootUrl` is a string, it's the root URL to prefix the `delayLoadingFile` property with
  24612. */
  24613. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  24614. /**
  24615. * Releases resources associated with this transform node.
  24616. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24617. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24618. */
  24619. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24620. }
  24621. }
  24622. declare module BABYLON {
  24623. class VertexBuffer {
  24624. /** @hidden */
  24625. private _kind;
  24626. private _size;
  24627. private _ownsBuffer;
  24628. private _instanced;
  24629. private _instanceDivisor;
  24630. /**
  24631. * The byte type.
  24632. */
  24633. static readonly BYTE: number;
  24634. /**
  24635. * The unsigned byte type.
  24636. */
  24637. static readonly UNSIGNED_BYTE: number;
  24638. /**
  24639. * The short type.
  24640. */
  24641. static readonly SHORT: number;
  24642. /**
  24643. * The unsigned short type.
  24644. */
  24645. static readonly UNSIGNED_SHORT: number;
  24646. /**
  24647. * The integer type.
  24648. */
  24649. static readonly INT: number;
  24650. /**
  24651. * The unsigned integer type.
  24652. */
  24653. static readonly UNSIGNED_INT: number;
  24654. /**
  24655. * The float type.
  24656. */
  24657. static readonly FLOAT: number;
  24658. /**
  24659. * Gets or sets the instance divisor when in instanced mode
  24660. */
  24661. instanceDivisor: number;
  24662. /**
  24663. * Gets the byte stride.
  24664. */
  24665. readonly byteStride: number;
  24666. /**
  24667. * Gets the byte offset.
  24668. */
  24669. readonly byteOffset: number;
  24670. /**
  24671. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  24672. */
  24673. readonly normalized: boolean;
  24674. /**
  24675. * Gets the data type of each component in the array.
  24676. */
  24677. readonly type: number;
  24678. /**
  24679. * Constructor
  24680. * @param engine the engine
  24681. * @param data the data to use for this vertex buffer
  24682. * @param kind the vertex buffer kind
  24683. * @param updatable whether the data is updatable
  24684. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  24685. * @param stride the stride (optional)
  24686. * @param instanced whether the buffer is instanced (optional)
  24687. * @param offset the offset of the data (optional)
  24688. * @param size the number of components (optional)
  24689. * @param type the type of the component (optional)
  24690. * @param normalized whether the data contains normalized data (optional)
  24691. * @param useBytes set to true if stride and offset are in bytes (optional)
  24692. */
  24693. 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);
  24694. /**
  24695. * Returns the kind of the VertexBuffer (string).
  24696. */
  24697. getKind(): string;
  24698. /**
  24699. * Boolean : is the VertexBuffer updatable ?
  24700. */
  24701. isUpdatable(): boolean;
  24702. /**
  24703. * Returns an array of numbers or a typed array containing the VertexBuffer data.
  24704. */
  24705. getData(): Nullable<DataArray>;
  24706. /**
  24707. * Returns the WebGLBuffer associated to the VertexBuffer.
  24708. */
  24709. getBuffer(): Nullable<WebGLBuffer>;
  24710. /**
  24711. * Returns the stride as a multiple of the type byte length.
  24712. * DEPRECATED. Use byteStride instead.
  24713. */
  24714. getStrideSize(): number;
  24715. /**
  24716. * Returns the offset as a multiple of the type byte length.
  24717. * DEPRECATED. Use byteOffset instead.
  24718. */
  24719. getOffset(): number;
  24720. /**
  24721. * Returns the number of components per vertex attribute (integer).
  24722. */
  24723. getSize(): number;
  24724. /**
  24725. * Boolean : is the WebGLBuffer of the VertexBuffer instanced now ?
  24726. */
  24727. getIsInstanced(): boolean;
  24728. /**
  24729. * Returns the instancing divisor, zero for non-instanced (integer).
  24730. */
  24731. getInstanceDivisor(): number;
  24732. /**
  24733. * Creates the underlying WebGLBuffer from the passed numeric array or Float32Array.
  24734. * Returns the created WebGLBuffer.
  24735. */
  24736. create(data?: DataArray): void;
  24737. /**
  24738. * Updates the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  24739. * This function will create a new buffer if the current one is not updatable
  24740. * Returns the updated WebGLBuffer.
  24741. */
  24742. update(data: DataArray): void;
  24743. /**
  24744. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  24745. * Returns the directly updated WebGLBuffer.
  24746. * @param data the new data
  24747. * @param offset the new offset
  24748. * @param useBytes set to true if the offset is in bytes
  24749. */
  24750. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  24751. /**
  24752. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  24753. */
  24754. dispose(): void;
  24755. /**
  24756. * Enumerates each value of this vertex buffer as numbers.
  24757. * @param count the number of values to enumerate
  24758. * @param callback the callback function called for each value
  24759. */
  24760. forEach(count: number, callback: (value: number, index: number) => void): void;
  24761. private static _PositionKind;
  24762. private static _NormalKind;
  24763. private static _TangentKind;
  24764. private static _UVKind;
  24765. private static _UV2Kind;
  24766. private static _UV3Kind;
  24767. private static _UV4Kind;
  24768. private static _UV5Kind;
  24769. private static _UV6Kind;
  24770. private static _ColorKind;
  24771. private static _MatricesIndicesKind;
  24772. private static _MatricesWeightsKind;
  24773. private static _MatricesIndicesExtraKind;
  24774. private static _MatricesWeightsExtraKind;
  24775. static readonly PositionKind: string;
  24776. static readonly NormalKind: string;
  24777. static readonly TangentKind: string;
  24778. static readonly UVKind: string;
  24779. static readonly UV2Kind: string;
  24780. static readonly UV3Kind: string;
  24781. static readonly UV4Kind: string;
  24782. static readonly UV5Kind: string;
  24783. static readonly UV6Kind: string;
  24784. static readonly ColorKind: string;
  24785. static readonly MatricesIndicesKind: string;
  24786. static readonly MatricesWeightsKind: string;
  24787. static readonly MatricesIndicesExtraKind: string;
  24788. static readonly MatricesWeightsExtraKind: string;
  24789. /**
  24790. * Deduces the stride given a kind.
  24791. * @param kind The kind string to deduce
  24792. * @returns The deduced stride
  24793. */
  24794. static DeduceStride(kind: string): number;
  24795. /**
  24796. * Gets the byte length of the given type.
  24797. * @param type the type
  24798. * @returns the number of bytes
  24799. */
  24800. static GetTypeByteLength(type: number): number;
  24801. /**
  24802. * Enumerates each value of the given parameters as numbers.
  24803. * @param data the data to enumerate
  24804. * @param byteOffset the byte offset of the data
  24805. * @param byteStride the byte stride of the data
  24806. * @param componentCount the number of components per element
  24807. * @param componentType the type of the component
  24808. * @param count the total number of components
  24809. * @param normalized whether the data is normalized
  24810. * @param callback the callback function called for each value
  24811. */
  24812. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  24813. private static _GetFloatValue(dataView, type, byteOffset, normalized);
  24814. }
  24815. }
  24816. declare module BABYLON {
  24817. interface PhysicsImpostorJoint {
  24818. mainImpostor: PhysicsImpostor;
  24819. connectedImpostor: PhysicsImpostor;
  24820. joint: PhysicsJoint;
  24821. }
  24822. class PhysicsEngine {
  24823. private _physicsPlugin;
  24824. gravity: Vector3;
  24825. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  24826. setGravity(gravity: Vector3): void;
  24827. /**
  24828. * Set the time step of the physics engine.
  24829. * default is 1/60.
  24830. * To slow it down, enter 1/600 for example.
  24831. * To speed it up, 1/30
  24832. * @param {number} newTimeStep the new timestep to apply to this world.
  24833. */
  24834. setTimeStep(newTimeStep?: number): void;
  24835. /**
  24836. * Get the time step of the physics engine.
  24837. */
  24838. getTimeStep(): number;
  24839. dispose(): void;
  24840. getPhysicsPluginName(): string;
  24841. static Epsilon: number;
  24842. private _impostors;
  24843. private _joints;
  24844. /**
  24845. * Adding a new impostor for the impostor tracking.
  24846. * This will be done by the impostor itself.
  24847. * @param {PhysicsImpostor} impostor the impostor to add
  24848. */
  24849. addImpostor(impostor: PhysicsImpostor): void;
  24850. /**
  24851. * Remove an impostor from the engine.
  24852. * This impostor and its mesh will not longer be updated by the physics engine.
  24853. * @param {PhysicsImpostor} impostor the impostor to remove
  24854. */
  24855. removeImpostor(impostor: PhysicsImpostor): void;
  24856. /**
  24857. * Add a joint to the physics engine
  24858. * @param {PhysicsImpostor} mainImpostor the main impostor to which the joint is added.
  24859. * @param {PhysicsImpostor} connectedImpostor the impostor that is connected to the main impostor using this joint
  24860. * @param {PhysicsJoint} the joint that will connect both impostors.
  24861. */
  24862. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  24863. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  24864. /**
  24865. * Called by the scene. no need to call it.
  24866. */
  24867. getPhysicsPlugin(): IPhysicsEnginePlugin;
  24868. getImpostors(): Array<PhysicsImpostor>;
  24869. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  24870. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  24871. }
  24872. interface IPhysicsEnginePlugin {
  24873. world: any;
  24874. name: string;
  24875. setGravity(gravity: Vector3): void;
  24876. setTimeStep(timeStep: number): void;
  24877. getTimeStep(): number;
  24878. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  24879. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  24880. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  24881. generatePhysicsBody(impostor: PhysicsImpostor): void;
  24882. removePhysicsBody(impostor: PhysicsImpostor): void;
  24883. generateJoint(joint: PhysicsImpostorJoint): void;
  24884. removeJoint(joint: PhysicsImpostorJoint): void;
  24885. isSupported(): boolean;
  24886. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  24887. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  24888. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  24889. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  24890. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  24891. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  24892. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  24893. getBodyMass(impostor: PhysicsImpostor): number;
  24894. getBodyFriction(impostor: PhysicsImpostor): number;
  24895. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  24896. getBodyRestitution(impostor: PhysicsImpostor): number;
  24897. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  24898. sleepBody(impostor: PhysicsImpostor): void;
  24899. wakeUpBody(impostor: PhysicsImpostor): void;
  24900. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  24901. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  24902. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  24903. getRadius(impostor: PhysicsImpostor): number;
  24904. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  24905. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  24906. dispose(): void;
  24907. }
  24908. }
  24909. declare module BABYLON {
  24910. class PhysicsHelper {
  24911. private _scene;
  24912. private _physicsEngine;
  24913. constructor(scene: Scene);
  24914. /**
  24915. * @param {Vector3} origin the origin of the explosion
  24916. * @param {number} radius the explosion radius
  24917. * @param {number} strength the explosion strength
  24918. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear. Defaults to Constant
  24919. */
  24920. applyRadialExplosionImpulse(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  24921. /**
  24922. * @param {Vector3} origin the origin of the explosion
  24923. * @param {number} radius the explosion radius
  24924. * @param {number} strength the explosion strength
  24925. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear. Defaults to Constant
  24926. */
  24927. applyRadialExplosionForce(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  24928. /**
  24929. * @param {Vector3} origin the origin of the explosion
  24930. * @param {number} radius the explosion radius
  24931. * @param {number} strength the explosion strength
  24932. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear. Defaults to Constant
  24933. */
  24934. gravitationalField(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  24935. /**
  24936. * @param {Vector3} origin the origin of the updraft
  24937. * @param {number} radius the radius of the updraft
  24938. * @param {number} strength the strength of the updraft
  24939. * @param {number} height the height of the updraft
  24940. * @param {PhysicsUpdraftMode} updraftMode possible options: Center & Perpendicular. Defaults to Center
  24941. */
  24942. updraft(origin: Vector3, radius: number, strength: number, height: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  24943. /**
  24944. * @param {Vector3} origin the of the vortex
  24945. * @param {number} radius the radius of the vortex
  24946. * @param {number} strength the strength of the vortex
  24947. * @param {number} height the height of the vortex
  24948. */
  24949. vortex(origin: Vector3, radius: number, strength: number, height: number): Nullable<PhysicsVortexEvent>;
  24950. }
  24951. /***** Radial explosion *****/
  24952. class PhysicsRadialExplosionEvent {
  24953. private _scene;
  24954. private _sphere;
  24955. private _sphereOptions;
  24956. private _rays;
  24957. private _dataFetched;
  24958. constructor(scene: Scene);
  24959. /**
  24960. * Returns the data related to the radial explosion event (sphere & rays).
  24961. * @returns {PhysicsRadialExplosionEventData}
  24962. */
  24963. getData(): PhysicsRadialExplosionEventData;
  24964. /**
  24965. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  24966. * @param impostor
  24967. * @param {Vector3} origin the origin of the explosion
  24968. * @param {number} radius the explosion radius
  24969. * @param {number} strength the explosion strength
  24970. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear
  24971. * @returns {Nullable<PhysicsForceAndContactPoint>}
  24972. */
  24973. getImpostorForceAndContactPoint(impostor: PhysicsImpostor, origin: Vector3, radius: number, strength: number, falloff: PhysicsRadialImpulseFalloff): Nullable<PhysicsForceAndContactPoint>;
  24974. /**
  24975. * Disposes the sphere.
  24976. * @param {bolean} force
  24977. */
  24978. dispose(force?: boolean): void;
  24979. /*** Helpers ***/
  24980. private _prepareSphere();
  24981. private _intersectsWithSphere(impostor, origin, radius);
  24982. }
  24983. /***** Gravitational Field *****/
  24984. class PhysicsGravitationalFieldEvent {
  24985. private _physicsHelper;
  24986. private _scene;
  24987. private _origin;
  24988. private _radius;
  24989. private _strength;
  24990. private _falloff;
  24991. private _tickCallback;
  24992. private _sphere;
  24993. private _dataFetched;
  24994. constructor(physicsHelper: PhysicsHelper, scene: Scene, origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff);
  24995. /**
  24996. * Returns the data related to the gravitational field event (sphere).
  24997. * @returns {PhysicsGravitationalFieldEventData}
  24998. */
  24999. getData(): PhysicsGravitationalFieldEventData;
  25000. /**
  25001. * Enables the gravitational field.
  25002. */
  25003. enable(): void;
  25004. /**
  25005. * Disables the gravitational field.
  25006. */
  25007. disable(): void;
  25008. /**
  25009. * Disposes the sphere.
  25010. * @param {bolean} force
  25011. */
  25012. dispose(force?: boolean): void;
  25013. private _tick();
  25014. }
  25015. /***** Updraft *****/
  25016. class PhysicsUpdraftEvent {
  25017. private _scene;
  25018. private _origin;
  25019. private _radius;
  25020. private _strength;
  25021. private _height;
  25022. private _updraftMode;
  25023. private _physicsEngine;
  25024. private _originTop;
  25025. private _originDirection;
  25026. private _tickCallback;
  25027. private _cylinder;
  25028. private _cylinderPosition;
  25029. private _dataFetched;
  25030. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number, _updraftMode: PhysicsUpdraftMode);
  25031. /**
  25032. * Returns the data related to the updraft event (cylinder).
  25033. * @returns {PhysicsUpdraftEventData}
  25034. */
  25035. getData(): PhysicsUpdraftEventData;
  25036. /**
  25037. * Enables the updraft.
  25038. */
  25039. enable(): void;
  25040. /**
  25041. * Disables the cortex.
  25042. */
  25043. disable(): void;
  25044. /**
  25045. * Disposes the sphere.
  25046. * @param {bolean} force
  25047. */
  25048. dispose(force?: boolean): void;
  25049. private getImpostorForceAndContactPoint(impostor);
  25050. private _tick();
  25051. /*** Helpers ***/
  25052. private _prepareCylinder();
  25053. private _intersectsWithCylinder(impostor);
  25054. }
  25055. /***** Vortex *****/
  25056. class PhysicsVortexEvent {
  25057. private _scene;
  25058. private _origin;
  25059. private _radius;
  25060. private _strength;
  25061. private _height;
  25062. private _physicsEngine;
  25063. private _originTop;
  25064. private _centripetalForceThreshold;
  25065. private _updraftMultiplier;
  25066. private _tickCallback;
  25067. private _cylinder;
  25068. private _cylinderPosition;
  25069. private _dataFetched;
  25070. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number);
  25071. /**
  25072. * Returns the data related to the vortex event (cylinder).
  25073. * @returns {PhysicsVortexEventData}
  25074. */
  25075. getData(): PhysicsVortexEventData;
  25076. /**
  25077. * Enables the vortex.
  25078. */
  25079. enable(): void;
  25080. /**
  25081. * Disables the cortex.
  25082. */
  25083. disable(): void;
  25084. /**
  25085. * Disposes the sphere.
  25086. * @param {bolean} force
  25087. */
  25088. dispose(force?: boolean): void;
  25089. private getImpostorForceAndContactPoint(impostor);
  25090. private _tick();
  25091. /*** Helpers ***/
  25092. private _prepareCylinder();
  25093. private _intersectsWithCylinder(impostor);
  25094. }
  25095. /***** Enums *****/
  25096. /**
  25097. * The strenght of the force in correspondence to the distance of the affected object
  25098. */
  25099. enum PhysicsRadialImpulseFalloff {
  25100. /** Defines that impulse is constant in strength across it's whole radius */
  25101. Constant = 0,
  25102. /** DEfines that impulse gets weaker if it's further from the origin */
  25103. Linear = 1,
  25104. }
  25105. /**
  25106. * The strenght of the force in correspondence to the distance of the affected object
  25107. */
  25108. enum PhysicsUpdraftMode {
  25109. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  25110. Center = 0,
  25111. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  25112. Perpendicular = 1,
  25113. }
  25114. /***** Data interfaces *****/
  25115. interface PhysicsForceAndContactPoint {
  25116. force: Vector3;
  25117. contactPoint: Vector3;
  25118. }
  25119. interface PhysicsRadialExplosionEventData {
  25120. sphere: Mesh;
  25121. rays: Array<Ray>;
  25122. }
  25123. interface PhysicsGravitationalFieldEventData {
  25124. sphere: Mesh;
  25125. }
  25126. interface PhysicsUpdraftEventData {
  25127. cylinder: Mesh;
  25128. }
  25129. interface PhysicsVortexEventData {
  25130. cylinder: Mesh;
  25131. }
  25132. }
  25133. declare module BABYLON {
  25134. interface PhysicsImpostorParameters {
  25135. mass: number;
  25136. friction?: number;
  25137. restitution?: number;
  25138. nativeOptions?: any;
  25139. ignoreParent?: boolean;
  25140. disableBidirectionalTransformation?: boolean;
  25141. }
  25142. interface IPhysicsEnabledObject {
  25143. position: Vector3;
  25144. rotationQuaternion: Nullable<Quaternion>;
  25145. scaling: Vector3;
  25146. rotation?: Vector3;
  25147. parent?: any;
  25148. getBoundingInfo(): BoundingInfo;
  25149. computeWorldMatrix(force: boolean): Matrix;
  25150. getWorldMatrix?(): Matrix;
  25151. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  25152. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  25153. getIndices?(): Nullable<IndicesArray>;
  25154. getScene?(): Scene;
  25155. getAbsolutePosition(): Vector3;
  25156. getAbsolutePivotPoint(): Vector3;
  25157. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  25158. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  25159. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  25160. getClassName(): string;
  25161. }
  25162. class PhysicsImpostor {
  25163. object: IPhysicsEnabledObject;
  25164. type: number;
  25165. private _options;
  25166. private _scene;
  25167. static DEFAULT_OBJECT_SIZE: Vector3;
  25168. static IDENTITY_QUATERNION: Quaternion;
  25169. private _physicsEngine;
  25170. private _physicsBody;
  25171. private _bodyUpdateRequired;
  25172. private _onBeforePhysicsStepCallbacks;
  25173. private _onAfterPhysicsStepCallbacks;
  25174. private _onPhysicsCollideCallbacks;
  25175. private _deltaPosition;
  25176. private _deltaRotation;
  25177. private _deltaRotationConjugated;
  25178. private _parent;
  25179. private _isDisposed;
  25180. private static _tmpVecs;
  25181. private static _tmpQuat;
  25182. readonly isDisposed: boolean;
  25183. mass: number;
  25184. friction: number;
  25185. restitution: number;
  25186. uniqueId: number;
  25187. private _joints;
  25188. constructor(object: IPhysicsEnabledObject, type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  25189. /**
  25190. * This function will completly initialize this impostor.
  25191. * It will create a new body - but only if this mesh has no parent.
  25192. * If it has, this impostor will not be used other than to define the impostor
  25193. * of the child mesh.
  25194. */
  25195. private _getPhysicsParent();
  25196. /**
  25197. * Should a new body be generated.
  25198. */
  25199. isBodyInitRequired(): boolean;
  25200. setScalingUpdated(updated: boolean): void;
  25201. /**
  25202. * Force a regeneration of this or the parent's impostor's body.
  25203. * Use under cautious - This will remove all joints already implemented.
  25204. */
  25205. forceUpdate(): void;
  25206. /**
  25207. * Gets the body that holds this impostor. Either its own, or its parent.
  25208. */
  25209. /**
  25210. * Set the physics body. Used mainly by the physics engine/plugin
  25211. */
  25212. physicsBody: any;
  25213. parent: Nullable<PhysicsImpostor>;
  25214. resetUpdateFlags(): void;
  25215. getObjectExtendSize(): Vector3;
  25216. getObjectCenter(): Vector3;
  25217. /**
  25218. * Get a specific parametes from the options parameter.
  25219. */
  25220. getParam(paramName: string): any;
  25221. /**
  25222. * Sets a specific parameter in the options given to the physics plugin
  25223. */
  25224. setParam(paramName: string, value: number): void;
  25225. /**
  25226. * Specifically change the body's mass option. Won't recreate the physics body object
  25227. */
  25228. setMass(mass: number): void;
  25229. getLinearVelocity(): Nullable<Vector3>;
  25230. setLinearVelocity(velocity: Nullable<Vector3>): void;
  25231. getAngularVelocity(): Nullable<Vector3>;
  25232. setAngularVelocity(velocity: Nullable<Vector3>): void;
  25233. /**
  25234. * Execute a function with the physics plugin native code.
  25235. * Provide a function the will have two variables - the world object and the physics body object.
  25236. */
  25237. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  25238. /**
  25239. * Register a function that will be executed before the physics world is stepping forward.
  25240. */
  25241. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  25242. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  25243. /**
  25244. * Register a function that will be executed after the physics step
  25245. */
  25246. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  25247. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  25248. /**
  25249. * register a function that will be executed when this impostor collides against a different body.
  25250. */
  25251. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  25252. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  25253. private _tmpQuat;
  25254. private _tmpQuat2;
  25255. getParentsRotation(): Quaternion;
  25256. /**
  25257. * this function is executed by the physics engine.
  25258. */
  25259. beforeStep: () => void;
  25260. /**
  25261. * this function is executed by the physics engine.
  25262. */
  25263. afterStep: () => void;
  25264. /**
  25265. * Legacy collision detection event support
  25266. */
  25267. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  25268. onCollide: (e: {
  25269. body: any;
  25270. }) => void;
  25271. /**
  25272. * Apply a force
  25273. */
  25274. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  25275. /**
  25276. * Apply an impulse
  25277. */
  25278. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  25279. /**
  25280. * A help function to create a joint.
  25281. */
  25282. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  25283. /**
  25284. * Add a joint to this impostor with a different impostor.
  25285. */
  25286. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  25287. /**
  25288. * Will keep this body still, in a sleep mode.
  25289. */
  25290. sleep(): PhysicsImpostor;
  25291. /**
  25292. * Wake the body up.
  25293. */
  25294. wakeUp(): PhysicsImpostor;
  25295. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  25296. dispose(): void;
  25297. setDeltaPosition(position: Vector3): void;
  25298. setDeltaRotation(rotation: Quaternion): void;
  25299. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  25300. getRadius(): number;
  25301. /**
  25302. * Sync a bone with this impostor
  25303. * @param bone The bone to sync to the impostor.
  25304. * @param boneMesh The mesh that the bone is influencing.
  25305. * @param jointPivot The pivot of the joint / bone in local space.
  25306. * @param distToJoint Optional distance from the impostor to the joint.
  25307. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  25308. */
  25309. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  25310. /**
  25311. * Sync impostor to a bone
  25312. * @param bone The bone that the impostor will be synced to.
  25313. * @param boneMesh The mesh that the bone is influencing.
  25314. * @param jointPivot The pivot of the joint / bone in local space.
  25315. * @param distToJoint Optional distance from the impostor to the joint.
  25316. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  25317. * @param boneAxis Optional vector3 axis the bone is aligned with
  25318. */
  25319. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  25320. static NoImpostor: number;
  25321. static SphereImpostor: number;
  25322. static BoxImpostor: number;
  25323. static PlaneImpostor: number;
  25324. static MeshImpostor: number;
  25325. static CylinderImpostor: number;
  25326. static ParticleImpostor: number;
  25327. static HeightmapImpostor: number;
  25328. }
  25329. }
  25330. declare module BABYLON {
  25331. interface PhysicsJointData {
  25332. mainPivot?: Vector3;
  25333. connectedPivot?: Vector3;
  25334. mainAxis?: Vector3;
  25335. connectedAxis?: Vector3;
  25336. collision?: boolean;
  25337. nativeParams?: any;
  25338. }
  25339. /**
  25340. * This is a holder class for the physics joint created by the physics plugin.
  25341. * It holds a set of functions to control the underlying joint.
  25342. */
  25343. class PhysicsJoint {
  25344. type: number;
  25345. jointData: PhysicsJointData;
  25346. private _physicsJoint;
  25347. protected _physicsPlugin: IPhysicsEnginePlugin;
  25348. constructor(type: number, jointData: PhysicsJointData);
  25349. physicsJoint: any;
  25350. physicsPlugin: IPhysicsEnginePlugin;
  25351. /**
  25352. * Execute a function that is physics-plugin specific.
  25353. * @param {Function} func the function that will be executed.
  25354. * It accepts two parameters: the physics world and the physics joint.
  25355. */
  25356. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  25357. static DistanceJoint: number;
  25358. static HingeJoint: number;
  25359. static BallAndSocketJoint: number;
  25360. static WheelJoint: number;
  25361. static SliderJoint: number;
  25362. static PrismaticJoint: number;
  25363. static UniversalJoint: number;
  25364. static Hinge2Joint: number;
  25365. static PointToPointJoint: number;
  25366. static SpringJoint: number;
  25367. static LockJoint: number;
  25368. }
  25369. /**
  25370. * A class representing a physics distance joint.
  25371. */
  25372. class DistanceJoint extends PhysicsJoint {
  25373. constructor(jointData: DistanceJointData);
  25374. /**
  25375. * Update the predefined distance.
  25376. */
  25377. updateDistance(maxDistance: number, minDistance?: number): void;
  25378. }
  25379. class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  25380. constructor(type: number, jointData: PhysicsJointData);
  25381. /**
  25382. * Set the motor values.
  25383. * Attention, this function is plugin specific. Engines won't react 100% the same.
  25384. * @param {number} force the force to apply
  25385. * @param {number} maxForce max force for this motor.
  25386. */
  25387. setMotor(force?: number, maxForce?: number): void;
  25388. /**
  25389. * Set the motor's limits.
  25390. * Attention, this function is plugin specific. Engines won't react 100% the same.
  25391. */
  25392. setLimit(upperLimit: number, lowerLimit?: number): void;
  25393. }
  25394. /**
  25395. * This class represents a single hinge physics joint
  25396. */
  25397. class HingeJoint extends MotorEnabledJoint {
  25398. constructor(jointData: PhysicsJointData);
  25399. /**
  25400. * Set the motor values.
  25401. * Attention, this function is plugin specific. Engines won't react 100% the same.
  25402. * @param {number} force the force to apply
  25403. * @param {number} maxForce max force for this motor.
  25404. */
  25405. setMotor(force?: number, maxForce?: number): void;
  25406. /**
  25407. * Set the motor's limits.
  25408. * Attention, this function is plugin specific. Engines won't react 100% the same.
  25409. */
  25410. setLimit(upperLimit: number, lowerLimit?: number): void;
  25411. }
  25412. /**
  25413. * This class represents a dual hinge physics joint (same as wheel joint)
  25414. */
  25415. class Hinge2Joint extends MotorEnabledJoint {
  25416. constructor(jointData: PhysicsJointData);
  25417. /**
  25418. * Set the motor values.
  25419. * Attention, this function is plugin specific. Engines won't react 100% the same.
  25420. * @param {number} force the force to apply
  25421. * @param {number} maxForce max force for this motor.
  25422. * @param {motorIndex} the motor's index, 0 or 1.
  25423. */
  25424. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  25425. /**
  25426. * Set the motor limits.
  25427. * Attention, this function is plugin specific. Engines won't react 100% the same.
  25428. * @param {number} upperLimit the upper limit
  25429. * @param {number} lowerLimit lower limit
  25430. * @param {motorIndex} the motor's index, 0 or 1.
  25431. */
  25432. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  25433. }
  25434. interface IMotorEnabledJoint {
  25435. physicsJoint: any;
  25436. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  25437. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  25438. }
  25439. interface DistanceJointData extends PhysicsJointData {
  25440. maxDistance: number;
  25441. }
  25442. interface SpringJointData extends PhysicsJointData {
  25443. length: number;
  25444. stiffness: number;
  25445. damping: number;
  25446. }
  25447. }
  25448. declare module BABYLON {
  25449. class ReflectionProbe {
  25450. name: string;
  25451. private _scene;
  25452. private _renderTargetTexture;
  25453. private _projectionMatrix;
  25454. private _viewMatrix;
  25455. private _target;
  25456. private _add;
  25457. private _attachedMesh;
  25458. private _invertYAxis;
  25459. position: Vector3;
  25460. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  25461. samples: number;
  25462. refreshRate: number;
  25463. getScene(): Scene;
  25464. readonly cubeTexture: RenderTargetTexture;
  25465. readonly renderList: Nullable<AbstractMesh[]>;
  25466. attachToMesh(mesh: AbstractMesh): void;
  25467. /**
  25468. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  25469. *
  25470. * @param renderingGroupId The rendering group id corresponding to its index
  25471. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  25472. */
  25473. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  25474. dispose(): void;
  25475. }
  25476. }
  25477. declare module BABYLON {
  25478. class BoundingBoxRenderer {
  25479. frontColor: Color3;
  25480. backColor: Color3;
  25481. showBackLines: boolean;
  25482. renderList: SmartArray<BoundingBox>;
  25483. private _scene;
  25484. private _colorShader;
  25485. private _vertexBuffers;
  25486. private _indexBuffer;
  25487. constructor(scene: Scene);
  25488. private _prepareRessources();
  25489. private _createIndexBuffer();
  25490. reset(): void;
  25491. render(): void;
  25492. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  25493. dispose(): void;
  25494. }
  25495. }
  25496. declare module BABYLON {
  25497. /**
  25498. * This represents a depth renderer in Babylon.
  25499. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  25500. */
  25501. class DepthRenderer {
  25502. private _scene;
  25503. private _depthMap;
  25504. private _effect;
  25505. private _cachedDefines;
  25506. private _camera;
  25507. /**
  25508. * Instantiates a depth renderer
  25509. * @param scene The scene the renderer belongs to
  25510. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  25511. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  25512. */
  25513. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  25514. /**
  25515. * Creates the depth rendering effect and checks if the effect is ready.
  25516. * @param subMesh The submesh to be used to render the depth map of
  25517. * @param useInstances If multiple world instances should be used
  25518. * @returns if the depth renderer is ready to render the depth map
  25519. */
  25520. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  25521. /**
  25522. * Gets the texture which the depth map will be written to.
  25523. * @returns The depth map texture
  25524. */
  25525. getDepthMap(): RenderTargetTexture;
  25526. /**
  25527. * Disposes of the depth renderer.
  25528. */
  25529. dispose(): void;
  25530. }
  25531. }
  25532. declare module BABYLON {
  25533. class EdgesRenderer {
  25534. edgesWidthScalerForOrthographic: number;
  25535. edgesWidthScalerForPerspective: number;
  25536. private _source;
  25537. private _linesPositions;
  25538. private _linesNormals;
  25539. private _linesIndices;
  25540. private _epsilon;
  25541. private _indicesCount;
  25542. private _lineShader;
  25543. private _ib;
  25544. private _buffers;
  25545. private _checkVerticesInsteadOfIndices;
  25546. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  25547. isEnabled: boolean;
  25548. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  25549. private _prepareRessources();
  25550. dispose(): void;
  25551. private _processEdgeForAdjacencies(pa, pb, p0, p1, p2);
  25552. private _processEdgeForAdjacenciesWithVertices(pa, pb, p0, p1, p2);
  25553. private _checkEdge(faceIndex, edge, faceNormals, p0, p1);
  25554. render(): void;
  25555. }
  25556. }
  25557. declare module BABYLON {
  25558. /**
  25559. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  25560. */
  25561. class GeometryBufferRenderer {
  25562. private _scene;
  25563. private _multiRenderTarget;
  25564. private _ratio;
  25565. private _enablePosition;
  25566. protected _effect: Effect;
  25567. protected _cachedDefines: string;
  25568. /**
  25569. * Set the render list (meshes to be rendered) used in the G buffer.
  25570. */
  25571. renderList: Mesh[];
  25572. /**
  25573. * Gets wether or not G buffer are supported by the running hardware.
  25574. * This requires draw buffer supports
  25575. */
  25576. readonly isSupported: boolean;
  25577. /**
  25578. * Gets wether or not position are enabled for the G buffer.
  25579. */
  25580. /**
  25581. * Sets wether or not position are enabled for the G buffer.
  25582. */
  25583. enablePosition: boolean;
  25584. /**
  25585. * Gets the scene associated with the buffer.
  25586. */
  25587. readonly scene: Scene;
  25588. /**
  25589. * Gets the ratio used by the buffer during its creation.
  25590. * How big is the buffer related to the main canvas.
  25591. */
  25592. readonly ratio: number;
  25593. /**
  25594. * Creates a new G Buffer for the scene
  25595. * @param scene The scene the buffer belongs to
  25596. * @param ratio How big is the buffer related to the main canvas.
  25597. */
  25598. constructor(scene: Scene, ratio?: number);
  25599. /**
  25600. * Checks wether everything is ready to render a submesh to the G buffer.
  25601. * @param subMesh the submesh to check readiness for
  25602. * @param useInstances is the mesh drawn using instance or not
  25603. * @returns true if ready otherwise false
  25604. */
  25605. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  25606. /**
  25607. * Gets the current underlying G Buffer.
  25608. * @returns the buffer
  25609. */
  25610. getGBuffer(): MultiRenderTarget;
  25611. /**
  25612. * Gets the number of samples used to render the buffer (anti aliasing).
  25613. */
  25614. /**
  25615. * Sets the number of samples used to render the buffer (anti aliasing).
  25616. */
  25617. samples: number;
  25618. /**
  25619. * Disposes the renderer and frees up associated resources.
  25620. */
  25621. dispose(): void;
  25622. protected _createRenderTargets(): void;
  25623. }
  25624. }
  25625. declare module BABYLON {
  25626. class OutlineRenderer {
  25627. private _scene;
  25628. private _effect;
  25629. private _cachedDefines;
  25630. zOffset: number;
  25631. constructor(scene: Scene);
  25632. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  25633. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  25634. }
  25635. }
  25636. declare module BABYLON {
  25637. class RenderingGroup {
  25638. index: number;
  25639. private _scene;
  25640. private _opaqueSubMeshes;
  25641. private _transparentSubMeshes;
  25642. private _alphaTestSubMeshes;
  25643. private _depthOnlySubMeshes;
  25644. private _particleSystems;
  25645. private _spriteManagers;
  25646. private _opaqueSortCompareFn;
  25647. private _alphaTestSortCompareFn;
  25648. private _transparentSortCompareFn;
  25649. private _renderOpaque;
  25650. private _renderAlphaTest;
  25651. private _renderTransparent;
  25652. private _edgesRenderers;
  25653. onBeforeTransparentRendering: () => void;
  25654. /**
  25655. * Set the opaque sort comparison function.
  25656. * If null the sub meshes will be render in the order they were created
  25657. */
  25658. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  25659. /**
  25660. * Set the alpha test sort comparison function.
  25661. * If null the sub meshes will be render in the order they were created
  25662. */
  25663. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  25664. /**
  25665. * Set the transparent sort comparison function.
  25666. * If null the sub meshes will be render in the order they were created
  25667. */
  25668. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  25669. /**
  25670. * Creates a new rendering group.
  25671. * @param index The rendering group index
  25672. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  25673. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  25674. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  25675. */
  25676. 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>);
  25677. /**
  25678. * Render all the sub meshes contained in the group.
  25679. * @param customRenderFunction Used to override the default render behaviour of the group.
  25680. * @returns true if rendered some submeshes.
  25681. */
  25682. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  25683. /**
  25684. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  25685. * @param subMeshes The submeshes to render
  25686. */
  25687. private renderOpaqueSorted(subMeshes);
  25688. /**
  25689. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  25690. * @param subMeshes The submeshes to render
  25691. */
  25692. private renderAlphaTestSorted(subMeshes);
  25693. /**
  25694. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  25695. * @param subMeshes The submeshes to render
  25696. */
  25697. private renderTransparentSorted(subMeshes);
  25698. /**
  25699. * Renders the submeshes in a specified order.
  25700. * @param subMeshes The submeshes to sort before render
  25701. * @param sortCompareFn The comparison function use to sort
  25702. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  25703. * @param transparent Specifies to activate blending if true
  25704. */
  25705. private static renderSorted(subMeshes, sortCompareFn, camera, transparent);
  25706. /**
  25707. * Renders the submeshes in the order they were dispatched (no sort applied).
  25708. * @param subMeshes The submeshes to render
  25709. */
  25710. private static renderUnsorted(subMeshes);
  25711. /**
  25712. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  25713. * are rendered back to front if in the same alpha index.
  25714. *
  25715. * @param a The first submesh
  25716. * @param b The second submesh
  25717. * @returns The result of the comparison
  25718. */
  25719. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  25720. /**
  25721. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  25722. * are rendered back to front.
  25723. *
  25724. * @param a The first submesh
  25725. * @param b The second submesh
  25726. * @returns The result of the comparison
  25727. */
  25728. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  25729. /**
  25730. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  25731. * are rendered front to back (prevent overdraw).
  25732. *
  25733. * @param a The first submesh
  25734. * @param b The second submesh
  25735. * @returns The result of the comparison
  25736. */
  25737. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  25738. /**
  25739. * Resets the different lists of submeshes to prepare a new frame.
  25740. */
  25741. prepare(): void;
  25742. dispose(): void;
  25743. /**
  25744. * Inserts the submesh in its correct queue depending on its material.
  25745. * @param subMesh The submesh to dispatch
  25746. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  25747. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  25748. */
  25749. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  25750. dispatchSprites(spriteManager: SpriteManager): void;
  25751. dispatchParticles(particleSystem: IParticleSystem): void;
  25752. private _renderParticles(activeMeshes);
  25753. private _renderSprites();
  25754. }
  25755. }
  25756. declare module BABYLON {
  25757. class RenderingManager {
  25758. /**
  25759. * The max id used for rendering groups (not included)
  25760. */
  25761. static MAX_RENDERINGGROUPS: number;
  25762. /**
  25763. * The min id used for rendering groups (included)
  25764. */
  25765. static MIN_RENDERINGGROUPS: number;
  25766. /**
  25767. * Used to globally prevent autoclearing scenes.
  25768. */
  25769. static AUTOCLEAR: boolean;
  25770. private _scene;
  25771. private _renderingGroups;
  25772. private _depthStencilBufferAlreadyCleaned;
  25773. private _autoClearDepthStencil;
  25774. private _customOpaqueSortCompareFn;
  25775. private _customAlphaTestSortCompareFn;
  25776. private _customTransparentSortCompareFn;
  25777. private _renderinGroupInfo;
  25778. constructor(scene: Scene);
  25779. private _clearDepthStencilBuffer(depth?, stencil?);
  25780. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  25781. reset(): void;
  25782. dispose(): void;
  25783. /**
  25784. * Clear the info related to rendering groups preventing retention points during dispose.
  25785. */
  25786. freeRenderingGroups(): void;
  25787. private _prepareRenderingGroup(renderingGroupId);
  25788. dispatchSprites(spriteManager: SpriteManager): void;
  25789. dispatchParticles(particleSystem: IParticleSystem): void;
  25790. /**
  25791. * @param subMesh The submesh to dispatch
  25792. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  25793. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  25794. */
  25795. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  25796. /**
  25797. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  25798. * This allowed control for front to back rendering or reversly depending of the special needs.
  25799. *
  25800. * @param renderingGroupId The rendering group id corresponding to its index
  25801. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  25802. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  25803. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  25804. */
  25805. 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;
  25806. /**
  25807. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  25808. *
  25809. * @param renderingGroupId The rendering group id corresponding to its index
  25810. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  25811. * @param depth Automatically clears depth between groups if true and autoClear is true.
  25812. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  25813. */
  25814. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  25815. }
  25816. }
  25817. declare module BABYLON {
  25818. /**
  25819. * Renders a layer on top of an existing scene
  25820. */
  25821. class UtilityLayerRenderer implements IDisposable {
  25822. /** the original scene that will be rendered on top of */ originalScene: Scene;
  25823. private _pointerCaptures;
  25824. private _lastPointerEvents;
  25825. /**
  25826. * The scene that is rendered on top of the original scene
  25827. */
  25828. utilityLayerScene: Scene;
  25829. /**
  25830. * If the utility layer should automatically be rendered on top of existing scene
  25831. */
  25832. shouldRender: boolean;
  25833. /**
  25834. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  25835. */
  25836. onlyCheckPointerDownEvents: boolean;
  25837. /**
  25838. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  25839. */
  25840. processAllEvents: boolean;
  25841. /**
  25842. * Observable raised when the pointer move from the utility layer scene to the main scene
  25843. */
  25844. onPointerOutObservable: Observable<number>;
  25845. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  25846. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  25847. private _afterRenderObserver;
  25848. private _sceneDisposeObserver;
  25849. private _originalPointerObserver;
  25850. /**
  25851. * Instantiates a UtilityLayerRenderer
  25852. * @param originalScene the original scene that will be rendered on top of
  25853. */
  25854. constructor(/** the original scene that will be rendered on top of */ originalScene: Scene);
  25855. private _notifyObservers(prePointerInfo, pickInfo, pointerEvent);
  25856. /**
  25857. * Renders the utility layers scene on top of the original scene
  25858. */
  25859. render(): void;
  25860. /**
  25861. * Disposes of the renderer
  25862. */
  25863. dispose(): void;
  25864. private _updateCamera();
  25865. }
  25866. }
  25867. declare module BABYLON {
  25868. class Sprite {
  25869. name: string;
  25870. position: Vector3;
  25871. color: Color4;
  25872. width: number;
  25873. height: number;
  25874. angle: number;
  25875. cellIndex: number;
  25876. invertU: number;
  25877. invertV: number;
  25878. disposeWhenFinishedAnimating: boolean;
  25879. animations: Animation[];
  25880. isPickable: boolean;
  25881. actionManager: ActionManager;
  25882. private _animationStarted;
  25883. private _loopAnimation;
  25884. private _fromIndex;
  25885. private _toIndex;
  25886. private _delay;
  25887. private _direction;
  25888. private _manager;
  25889. private _time;
  25890. private _onAnimationEnd;
  25891. /**
  25892. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  25893. */
  25894. isVisible: boolean;
  25895. size: number;
  25896. constructor(name: string, manager: SpriteManager);
  25897. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  25898. stopAnimation(): void;
  25899. dispose(): void;
  25900. }
  25901. }
  25902. declare module BABYLON {
  25903. class SpriteManager {
  25904. name: string;
  25905. sprites: Sprite[];
  25906. renderingGroupId: number;
  25907. layerMask: number;
  25908. fogEnabled: boolean;
  25909. isPickable: boolean;
  25910. cellWidth: number;
  25911. cellHeight: number;
  25912. /**
  25913. * An event triggered when the manager is disposed.
  25914. */
  25915. onDisposeObservable: Observable<SpriteManager>;
  25916. private _onDisposeObserver;
  25917. onDispose: () => void;
  25918. private _capacity;
  25919. private _spriteTexture;
  25920. private _epsilon;
  25921. private _scene;
  25922. private _vertexData;
  25923. private _buffer;
  25924. private _vertexBuffers;
  25925. private _indexBuffer;
  25926. private _effectBase;
  25927. private _effectFog;
  25928. texture: Texture;
  25929. constructor(name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  25930. private _appendSpriteVertex(index, sprite, offsetX, offsetY, rowSize);
  25931. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  25932. render(): void;
  25933. dispose(): void;
  25934. }
  25935. }
  25936. declare module BABYLON {
  25937. /**
  25938. * @hidden
  25939. **/
  25940. class _AlphaState {
  25941. private _isAlphaBlendDirty;
  25942. private _isBlendFunctionParametersDirty;
  25943. private _isBlendEquationParametersDirty;
  25944. private _isBlendConstantsDirty;
  25945. private _alphaBlend;
  25946. private _blendFunctionParameters;
  25947. private _blendEquationParameters;
  25948. private _blendConstants;
  25949. /**
  25950. * Initializes the state.
  25951. */
  25952. constructor();
  25953. readonly isDirty: boolean;
  25954. alphaBlend: boolean;
  25955. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  25956. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  25957. setAlphaEquationParameters(rgb: number, alpha: number): void;
  25958. reset(): void;
  25959. apply(gl: WebGLRenderingContext): void;
  25960. }
  25961. }
  25962. declare module BABYLON {
  25963. /**
  25964. * @hidden
  25965. **/
  25966. class _DepthCullingState {
  25967. private _isDepthTestDirty;
  25968. private _isDepthMaskDirty;
  25969. private _isDepthFuncDirty;
  25970. private _isCullFaceDirty;
  25971. private _isCullDirty;
  25972. private _isZOffsetDirty;
  25973. private _isFrontFaceDirty;
  25974. private _depthTest;
  25975. private _depthMask;
  25976. private _depthFunc;
  25977. private _cull;
  25978. private _cullFace;
  25979. private _zOffset;
  25980. private _frontFace;
  25981. /**
  25982. * Initializes the state.
  25983. */
  25984. constructor();
  25985. readonly isDirty: boolean;
  25986. zOffset: number;
  25987. cullFace: Nullable<number>;
  25988. cull: Nullable<boolean>;
  25989. depthFunc: Nullable<number>;
  25990. depthMask: boolean;
  25991. depthTest: boolean;
  25992. frontFace: Nullable<number>;
  25993. reset(): void;
  25994. apply(gl: WebGLRenderingContext): void;
  25995. }
  25996. }
  25997. declare module BABYLON {
  25998. /**
  25999. * @hidden
  26000. **/
  26001. class _StencilState {
  26002. private _isStencilTestDirty;
  26003. private _isStencilMaskDirty;
  26004. private _isStencilFuncDirty;
  26005. private _isStencilOpDirty;
  26006. private _stencilTest;
  26007. private _stencilMask;
  26008. private _stencilFunc;
  26009. private _stencilFuncRef;
  26010. private _stencilFuncMask;
  26011. private _stencilOpStencilFail;
  26012. private _stencilOpDepthFail;
  26013. private _stencilOpStencilDepthPass;
  26014. readonly isDirty: boolean;
  26015. stencilFunc: number;
  26016. stencilFuncRef: number;
  26017. stencilFuncMask: number;
  26018. stencilOpStencilFail: number;
  26019. stencilOpDepthFail: number;
  26020. stencilOpStencilDepthPass: number;
  26021. stencilMask: number;
  26022. stencilTest: boolean;
  26023. constructor();
  26024. reset(): void;
  26025. apply(gl: WebGLRenderingContext): void;
  26026. }
  26027. }
  26028. declare module BABYLON {
  26029. /**
  26030. * Postprocess used to generate anaglyphic rendering
  26031. */
  26032. class AnaglyphPostProcess extends PostProcess {
  26033. private _passedProcess;
  26034. /**
  26035. * Creates a new AnaglyphPostProcess
  26036. * @param name defines postprocess name
  26037. * @param options defines creation options or target ratio scale
  26038. * @param rigCameras defines cameras using this postprocess
  26039. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  26040. * @param engine defines hosting engine
  26041. * @param reusable defines if the postprocess will be reused multiple times per frame
  26042. */
  26043. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  26044. }
  26045. }
  26046. declare module BABYLON {
  26047. class BlackAndWhitePostProcess extends PostProcess {
  26048. degree: number;
  26049. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  26050. }
  26051. }
  26052. declare module BABYLON {
  26053. /**
  26054. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  26055. */
  26056. class BloomEffect extends PostProcessRenderEffect {
  26057. private bloomScale;
  26058. /**
  26059. * Internal
  26060. */
  26061. /**
  26062. * Internal
  26063. */
  26064. private _blurX;
  26065. private _blurY;
  26066. private _merge;
  26067. /**
  26068. * The luminance threshold to find bright areas of the image to bloom.
  26069. */
  26070. threshold: number;
  26071. /**
  26072. * The strength of the bloom.
  26073. */
  26074. weight: number;
  26075. /**
  26076. * Specifies the size of the bloom blur kernel, relative to the final output size
  26077. */
  26078. kernel: number;
  26079. /**
  26080. * Creates a new instance of @see BloomEffect
  26081. * @param scene The scene the effect belongs to.
  26082. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  26083. * @param bloomKernel The size of the kernel to be used when applying the blur.
  26084. * @param bloomWeight The the strength of bloom.
  26085. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  26086. * @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)
  26087. */
  26088. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  26089. /**
  26090. * Disposes each of the internal effects for a given camera.
  26091. * @param camera The camera to dispose the effect on.
  26092. */
  26093. disposeEffects(camera: Camera): void;
  26094. /**
  26095. * Internal
  26096. */
  26097. /**
  26098. * Internal
  26099. * @returns if all the contained post processes are ready.
  26100. */
  26101. }
  26102. }
  26103. declare module BABYLON {
  26104. /**
  26105. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  26106. */
  26107. class BloomMergePostProcess extends PostProcess {
  26108. /** Weight of the bloom to be added to the original input. */ weight: number;
  26109. /**
  26110. * Creates a new instance of @see BloomMergePostProcess
  26111. * @param name The name of the effect.
  26112. * @param originalFromInput Post process which's input will be used for the merge.
  26113. * @param blurred Blurred highlights post process which's output will be used.
  26114. * @param weight Weight of the bloom to be added to the original input.
  26115. * @param options The required width/height ratio to downsize to before computing the render pass.
  26116. * @param camera The camera to apply the render pass to.
  26117. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  26118. * @param engine The engine which the post process will be applied. (default: current engine)
  26119. * @param reusable If the post process can be reused on the same frame. (default: false)
  26120. * @param textureType Type of textures used when performing the post process. (default: 0)
  26121. * @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)
  26122. */
  26123. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess, /** Weight of the bloom to be added to the original input. */ weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  26124. }
  26125. }
  26126. declare module BABYLON {
  26127. /**
  26128. * The Blur Post Process which blurs an image based on a kernel and direction.
  26129. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  26130. */
  26131. class BlurPostProcess extends PostProcess {
  26132. /** The direction in which to blur the image. */ direction: Vector2;
  26133. private blockCompilation;
  26134. protected _kernel: number;
  26135. protected _idealKernel: number;
  26136. protected _packedFloat: boolean;
  26137. private _staticDefines;
  26138. /**
  26139. * Gets the length in pixels of the blur sample region
  26140. */
  26141. /**
  26142. * Sets the length in pixels of the blur sample region
  26143. */
  26144. kernel: number;
  26145. /**
  26146. * Gets wether or not the blur is unpacking/repacking floats
  26147. */
  26148. /**
  26149. * Sets wether or not the blur needs to unpack/repack floats
  26150. */
  26151. packedFloat: boolean;
  26152. /**
  26153. * Creates a new instance BlurPostProcess
  26154. * @param name The name of the effect.
  26155. * @param direction The direction in which to blur the image.
  26156. * @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.
  26157. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  26158. * @param camera The camera to apply the render pass to.
  26159. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  26160. * @param engine The engine which the post process will be applied. (default: current engine)
  26161. * @param reusable If the post process can be reused on the same frame. (default: false)
  26162. * @param textureType Type of textures used when performing the post process. (default: 0)
  26163. * @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)
  26164. */
  26165. constructor(name: string, /** The direction in which to blur the image. */ direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  26166. /**
  26167. * Updates the effect with the current post process compile time values and recompiles the shader.
  26168. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  26169. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  26170. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  26171. * @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
  26172. * @param onCompiled Called when the shader has been compiled.
  26173. * @param onError Called if there is an error when compiling a shader.
  26174. */
  26175. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  26176. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  26177. /**
  26178. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  26179. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  26180. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  26181. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  26182. * The gaps between physical kernels are compensated for in the weighting of the samples
  26183. * @param idealKernel Ideal blur kernel.
  26184. * @return Nearest best kernel.
  26185. */
  26186. protected _nearestBestKernel(idealKernel: number): number;
  26187. /**
  26188. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  26189. * @param x The point on the Gaussian distribution to sample.
  26190. * @return the value of the Gaussian function at x.
  26191. */
  26192. protected _gaussianWeight(x: number): number;
  26193. /**
  26194. * Generates a string that can be used as a floating point number in GLSL.
  26195. * @param x Value to print.
  26196. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  26197. * @return GLSL float string.
  26198. */
  26199. protected _glslFloat(x: number, decimalFigures?: number): string;
  26200. }
  26201. }
  26202. declare module BABYLON {
  26203. /**
  26204. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  26205. */
  26206. class ChromaticAberrationPostProcess extends PostProcess {
  26207. /**
  26208. * The amount of seperation of rgb channels (default: 30)
  26209. */
  26210. aberrationAmount: number;
  26211. /**
  26212. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  26213. */
  26214. radialIntensity: number;
  26215. /**
  26216. * 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))
  26217. */
  26218. direction: Vector2;
  26219. /**
  26220. * 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))
  26221. */
  26222. centerPosition: Vector2;
  26223. /**
  26224. * Creates a new instance ChromaticAberrationPostProcess
  26225. * @param name The name of the effect.
  26226. * @param screenWidth The width of the screen to apply the effect on.
  26227. * @param screenHeight The height of the screen to apply the effect on.
  26228. * @param options The required width/height ratio to downsize to before computing the render pass.
  26229. * @param camera The camera to apply the render pass to.
  26230. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  26231. * @param engine The engine which the post process will be applied. (default: current engine)
  26232. * @param reusable If the post process can be reused on the same frame. (default: false)
  26233. * @param textureType Type of textures used when performing the post process. (default: 0)
  26234. * @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)
  26235. */
  26236. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  26237. }
  26238. }
  26239. declare module BABYLON {
  26240. /**
  26241. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  26242. */
  26243. class CircleOfConfusionPostProcess extends PostProcess {
  26244. /**
  26245. * 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.
  26246. */
  26247. lensSize: number;
  26248. /**
  26249. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  26250. */
  26251. fStop: number;
  26252. /**
  26253. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  26254. */
  26255. focusDistance: number;
  26256. /**
  26257. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  26258. */
  26259. focalLength: number;
  26260. private _depthTexture;
  26261. /**
  26262. * Creates a new instance CircleOfConfusionPostProcess
  26263. * @param name The name of the effect.
  26264. * @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.
  26265. * @param options The required width/height ratio to downsize to before computing the render pass.
  26266. * @param camera The camera to apply the render pass to.
  26267. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  26268. * @param engine The engine which the post process will be applied. (default: current engine)
  26269. * @param reusable If the post process can be reused on the same frame. (default: false)
  26270. * @param textureType Type of textures used when performing the post process. (default: 0)
  26271. * @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)
  26272. */
  26273. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  26274. /**
  26275. * 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.
  26276. */
  26277. depthTexture: RenderTargetTexture;
  26278. }
  26279. }
  26280. declare module BABYLON {
  26281. class ColorCorrectionPostProcess extends PostProcess {
  26282. private _colorTableTexture;
  26283. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  26284. }
  26285. }
  26286. declare module BABYLON {
  26287. /**
  26288. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  26289. * input texture to perform effects such as edge detection or sharpening
  26290. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  26291. */
  26292. class ConvolutionPostProcess extends PostProcess {
  26293. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */ kernel: number[];
  26294. /**
  26295. * Creates a new instance ConvolutionPostProcess
  26296. * @param name The name of the effect.
  26297. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  26298. * @param options The required width/height ratio to downsize to before computing the render pass.
  26299. * @param camera The camera to apply the render pass to.
  26300. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  26301. * @param engine The engine which the post process will be applied. (default: current engine)
  26302. * @param reusable If the post process can be reused on the same frame. (default: false)
  26303. * @param textureType Type of textures used when performing the post process. (default: 0)
  26304. */
  26305. constructor(name: string, /** Array of 9 values corrisponding to the 3x3 kernel to be applied */ kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  26306. /**
  26307. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  26308. */
  26309. static EdgeDetect0Kernel: number[];
  26310. /**
  26311. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  26312. */
  26313. static EdgeDetect1Kernel: number[];
  26314. /**
  26315. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  26316. */
  26317. static EdgeDetect2Kernel: number[];
  26318. /**
  26319. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  26320. */
  26321. static SharpenKernel: number[];
  26322. /**
  26323. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  26324. */
  26325. static EmbossKernel: number[];
  26326. /**
  26327. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  26328. */
  26329. static GaussianKernel: number[];
  26330. }
  26331. }
  26332. declare module BABYLON {
  26333. /**
  26334. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  26335. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  26336. * based on samples that have a large difference in distance than the center pixel.
  26337. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  26338. */
  26339. class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  26340. direction: Vector2;
  26341. /**
  26342. * Creates a new instance CircleOfConfusionPostProcess
  26343. * @param name The name of the effect.
  26344. * @param scene The scene the effect belongs to.
  26345. * @param direction The direction the blur should be applied.
  26346. * @param kernel The size of the kernel used to blur.
  26347. * @param options The required width/height ratio to downsize to before computing the render pass.
  26348. * @param camera The camera to apply the render pass to.
  26349. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  26350. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  26351. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  26352. * @param engine The engine which the post process will be applied. (default: current engine)
  26353. * @param reusable If the post process can be reused on the same frame. (default: false)
  26354. * @param textureType Type of textures used when performing the post process. (default: 0)
  26355. * @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)
  26356. */
  26357. 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);
  26358. }
  26359. }
  26360. declare module BABYLON {
  26361. /**
  26362. * Specifies the level of max blur that should be applied when using the depth of field effect
  26363. */
  26364. enum DepthOfFieldEffectBlurLevel {
  26365. /**
  26366. * Subtle blur
  26367. */
  26368. Low = 0,
  26369. /**
  26370. * Medium blur
  26371. */
  26372. Medium = 1,
  26373. /**
  26374. * Large blur
  26375. */
  26376. High = 2,
  26377. }
  26378. /**
  26379. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  26380. */
  26381. class DepthOfFieldEffect extends PostProcessRenderEffect {
  26382. private _circleOfConfusion;
  26383. /**
  26384. * Internal, blurs from high to low
  26385. */
  26386. private _depthOfFieldBlurY;
  26387. private _dofMerge;
  26388. /**
  26389. * Internal post processes in depth of field effect
  26390. */
  26391. /**
  26392. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  26393. */
  26394. focalLength: number;
  26395. /**
  26396. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  26397. */
  26398. fStop: number;
  26399. /**
  26400. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  26401. */
  26402. focusDistance: number;
  26403. /**
  26404. * 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.
  26405. */
  26406. lensSize: number;
  26407. /**
  26408. * Creates a new instance DepthOfFieldEffect
  26409. * @param scene The scene the effect belongs to.
  26410. * @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.
  26411. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  26412. * @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)
  26413. */
  26414. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  26415. /**
  26416. * 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.
  26417. */
  26418. depthTexture: RenderTargetTexture;
  26419. /**
  26420. * Disposes each of the internal effects for a given camera.
  26421. * @param camera The camera to dispose the effect on.
  26422. */
  26423. disposeEffects(camera: Camera): void;
  26424. /**
  26425. * Internal
  26426. */
  26427. /**
  26428. * Internal
  26429. * @returns if all the contained post processes are ready.
  26430. */
  26431. }
  26432. }
  26433. declare module BABYLON {
  26434. /**
  26435. * Options to be set when merging outputs from the default pipeline.
  26436. */
  26437. class DepthOfFieldMergePostProcessOptions {
  26438. /**
  26439. * The original image to merge on top of
  26440. */
  26441. originalFromInput: PostProcess;
  26442. /**
  26443. * Parameters to perform the merge of the depth of field effect
  26444. */
  26445. depthOfField?: {
  26446. circleOfConfusion: PostProcess;
  26447. blurSteps: Array<PostProcess>;
  26448. };
  26449. /**
  26450. * Parameters to perform the merge of bloom effect
  26451. */
  26452. bloom?: {
  26453. blurred: PostProcess;
  26454. weight: number;
  26455. };
  26456. }
  26457. /**
  26458. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  26459. */
  26460. class DepthOfFieldMergePostProcess extends PostProcess {
  26461. private blurSteps;
  26462. /**
  26463. * Creates a new instance of DepthOfFieldMergePostProcess
  26464. * @param name The name of the effect.
  26465. * @param originalFromInput Post process which's input will be used for the merge.
  26466. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  26467. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  26468. * @param options The required width/height ratio to downsize to before computing the render pass.
  26469. * @param camera The camera to apply the render pass to.
  26470. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  26471. * @param engine The engine which the post process will be applied. (default: current engine)
  26472. * @param reusable If the post process can be reused on the same frame. (default: false)
  26473. * @param textureType Type of textures used when performing the post process. (default: 0)
  26474. * @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)
  26475. */
  26476. 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);
  26477. /**
  26478. * Updates the effect with the current post process compile time values and recompiles the shader.
  26479. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  26480. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  26481. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  26482. * @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
  26483. * @param onCompiled Called when the shader has been compiled.
  26484. * @param onError Called if there is an error when compiling a shader.
  26485. */
  26486. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  26487. }
  26488. }
  26489. declare module BABYLON {
  26490. class DisplayPassPostProcess extends PostProcess {
  26491. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  26492. }
  26493. }
  26494. declare module BABYLON {
  26495. /**
  26496. * 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.
  26497. */
  26498. class ExtractHighlightsPostProcess extends PostProcess {
  26499. /**
  26500. * The luminance threshold, pixels below this value will be set to black.
  26501. */
  26502. threshold: number;
  26503. /**
  26504. * Internal
  26505. */
  26506. /**
  26507. * Post process which has the input texture to be used when performing highlight extraction
  26508. */
  26509. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  26510. }
  26511. }
  26512. declare module BABYLON {
  26513. class FilterPostProcess extends PostProcess {
  26514. kernelMatrix: Matrix;
  26515. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  26516. }
  26517. }
  26518. declare module BABYLON {
  26519. class FxaaPostProcess extends PostProcess {
  26520. texelWidth: number;
  26521. texelHeight: number;
  26522. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  26523. private _getDefines();
  26524. }
  26525. }
  26526. declare module BABYLON {
  26527. /**
  26528. * The GrainPostProcess adds noise to the image at mid luminance levels
  26529. */
  26530. class GrainPostProcess extends PostProcess {
  26531. /**
  26532. * The intensity of the grain added (default: 30)
  26533. */
  26534. intensity: number;
  26535. /**
  26536. * If the grain should be randomized on every frame
  26537. */
  26538. animated: boolean;
  26539. /**
  26540. * Creates a new instance of @see GrainPostProcess
  26541. * @param name The name of the effect.
  26542. * @param options The required width/height ratio to downsize to before computing the render pass.
  26543. * @param camera The camera to apply the render pass to.
  26544. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  26545. * @param engine The engine which the post process will be applied. (default: current engine)
  26546. * @param reusable If the post process can be reused on the same frame. (default: false)
  26547. * @param textureType Type of textures used when performing the post process. (default: 0)
  26548. * @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)
  26549. */
  26550. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  26551. }
  26552. }
  26553. declare module BABYLON {
  26554. class HighlightsPostProcess extends PostProcess {
  26555. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  26556. }
  26557. }
  26558. declare module BABYLON {
  26559. class ImageProcessingPostProcess extends PostProcess {
  26560. /**
  26561. * Default configuration related to image processing available in the PBR Material.
  26562. */
  26563. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  26564. /**
  26565. * Gets the image processing configuration used either in this material.
  26566. */
  26567. /**
  26568. * Sets the Default image processing configuration used either in the this material.
  26569. *
  26570. * If sets to null, the scene one is in use.
  26571. */
  26572. imageProcessingConfiguration: ImageProcessingConfiguration;
  26573. /**
  26574. * Keep track of the image processing observer to allow dispose and replace.
  26575. */
  26576. private _imageProcessingObserver;
  26577. /**
  26578. * Attaches a new image processing configuration to the PBR Material.
  26579. * @param configuration
  26580. */
  26581. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  26582. /**
  26583. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  26584. */
  26585. /**
  26586. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  26587. */
  26588. colorCurves: Nullable<ColorCurves>;
  26589. /**
  26590. * Gets wether the color curves effect is enabled.
  26591. */
  26592. /**
  26593. * Sets wether the color curves effect is enabled.
  26594. */
  26595. colorCurvesEnabled: boolean;
  26596. /**
  26597. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  26598. */
  26599. /**
  26600. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  26601. */
  26602. colorGradingTexture: Nullable<BaseTexture>;
  26603. /**
  26604. * Gets wether the color grading effect is enabled.
  26605. */
  26606. /**
  26607. * Gets wether the color grading effect is enabled.
  26608. */
  26609. colorGradingEnabled: boolean;
  26610. /**
  26611. * Gets exposure used in the effect.
  26612. */
  26613. /**
  26614. * Sets exposure used in the effect.
  26615. */
  26616. exposure: number;
  26617. /**
  26618. * Gets wether tonemapping is enabled or not.
  26619. */
  26620. /**
  26621. * Sets wether tonemapping is enabled or not
  26622. */
  26623. toneMappingEnabled: boolean;
  26624. /**
  26625. * Gets contrast used in the effect.
  26626. */
  26627. /**
  26628. * Sets contrast used in the effect.
  26629. */
  26630. contrast: number;
  26631. /**
  26632. * Gets Vignette stretch size.
  26633. */
  26634. /**
  26635. * Sets Vignette stretch size.
  26636. */
  26637. vignetteStretch: number;
  26638. /**
  26639. * Gets Vignette centre X Offset.
  26640. */
  26641. /**
  26642. * Sets Vignette centre X Offset.
  26643. */
  26644. vignetteCentreX: number;
  26645. /**
  26646. * Gets Vignette centre Y Offset.
  26647. */
  26648. /**
  26649. * Sets Vignette centre Y Offset.
  26650. */
  26651. vignetteCentreY: number;
  26652. /**
  26653. * Gets Vignette weight or intensity of the vignette effect.
  26654. */
  26655. /**
  26656. * Sets Vignette weight or intensity of the vignette effect.
  26657. */
  26658. vignetteWeight: number;
  26659. /**
  26660. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  26661. * if vignetteEnabled is set to true.
  26662. */
  26663. /**
  26664. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  26665. * if vignetteEnabled is set to true.
  26666. */
  26667. vignetteColor: Color4;
  26668. /**
  26669. * Gets Camera field of view used by the Vignette effect.
  26670. */
  26671. /**
  26672. * Sets Camera field of view used by the Vignette effect.
  26673. */
  26674. vignetteCameraFov: number;
  26675. /**
  26676. * Gets the vignette blend mode allowing different kind of effect.
  26677. */
  26678. /**
  26679. * Sets the vignette blend mode allowing different kind of effect.
  26680. */
  26681. vignetteBlendMode: number;
  26682. /**
  26683. * Gets wether the vignette effect is enabled.
  26684. */
  26685. /**
  26686. * Sets wether the vignette effect is enabled.
  26687. */
  26688. vignetteEnabled: boolean;
  26689. private _fromLinearSpace;
  26690. /**
  26691. * Gets wether the input of the processing is in Gamma or Linear Space.
  26692. */
  26693. /**
  26694. * Sets wether the input of the processing is in Gamma or Linear Space.
  26695. */
  26696. fromLinearSpace: boolean;
  26697. /**
  26698. * Defines cache preventing GC.
  26699. */
  26700. private _defines;
  26701. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  26702. getClassName(): string;
  26703. protected _updateParameters(): void;
  26704. dispose(camera?: Camera): void;
  26705. }
  26706. }
  26707. declare module BABYLON {
  26708. class PassPostProcess extends PostProcess {
  26709. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  26710. }
  26711. }
  26712. declare module BABYLON {
  26713. type PostProcessOptions = {
  26714. width: number;
  26715. height: number;
  26716. };
  26717. /**
  26718. * PostProcess can be used to apply a shader to a texture after it has been rendered
  26719. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  26720. */
  26721. class PostProcess {
  26722. /** Name of the PostProcess. */ name: string;
  26723. /**
  26724. * Width of the texture to apply the post process on
  26725. */
  26726. width: number;
  26727. /**
  26728. * Height of the texture to apply the post process on
  26729. */
  26730. height: number;
  26731. /**
  26732. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  26733. */
  26734. /**
  26735. * Sampling mode used by the shader
  26736. * See https://doc.babylonjs.com/classes/3.1/texture
  26737. */
  26738. renderTargetSamplingMode: number;
  26739. /**
  26740. * Clear color to use when screen clearing
  26741. */
  26742. clearColor: Color4;
  26743. /**
  26744. * If the buffer needs to be cleared before applying the post process. (default: true)
  26745. * Should be set to false if shader will overwrite all previous pixels.
  26746. */
  26747. autoClear: boolean;
  26748. /**
  26749. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  26750. */
  26751. alphaMode: number;
  26752. /**
  26753. * Sets the setAlphaBlendConstants of the babylon engine
  26754. */
  26755. alphaConstants: Color4;
  26756. /**
  26757. * Animations to be used for the post processing
  26758. */
  26759. animations: Animation[];
  26760. /**
  26761. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  26762. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  26763. */
  26764. enablePixelPerfectMode: boolean;
  26765. /**
  26766. * Force the postprocess to be applied without taking in account viewport
  26767. */
  26768. forceFullscreenViewport: boolean;
  26769. /**
  26770. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  26771. *
  26772. * | Value | Type | Description |
  26773. * | ----- | ----------------------------------- | ----------- |
  26774. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  26775. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  26776. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  26777. *
  26778. */
  26779. scaleMode: number;
  26780. /**
  26781. * Force textures to be a power of two (default: false)
  26782. */
  26783. alwaysForcePOT: boolean;
  26784. /**
  26785. * Number of sample textures (default: 1)
  26786. */
  26787. samples: number;
  26788. /**
  26789. * Modify the scale of the post process to be the same as the viewport (default: false)
  26790. */
  26791. adaptScaleToCurrentViewport: boolean;
  26792. private _camera;
  26793. private _scene;
  26794. private _engine;
  26795. private _options;
  26796. private _reusable;
  26797. private _textureType;
  26798. /**
  26799. * Smart array of input and output textures for the post process.
  26800. */
  26801. /**
  26802. * The index in _textures that corresponds to the output texture.
  26803. */
  26804. private _effect;
  26805. private _samplers;
  26806. private _fragmentUrl;
  26807. private _vertexUrl;
  26808. private _parameters;
  26809. private _scaleRatio;
  26810. protected _indexParameters: any;
  26811. private _shareOutputWithPostProcess;
  26812. private _texelSize;
  26813. private _forcedOutputTexture;
  26814. /**
  26815. * An event triggered when the postprocess is activated.
  26816. */
  26817. onActivateObservable: Observable<Camera>;
  26818. private _onActivateObserver;
  26819. /**
  26820. * A function that is added to the onActivateObservable
  26821. */
  26822. onActivate: Nullable<(camera: Camera) => void>;
  26823. /**
  26824. * An event triggered when the postprocess changes its size.
  26825. */
  26826. onSizeChangedObservable: Observable<PostProcess>;
  26827. private _onSizeChangedObserver;
  26828. /**
  26829. * A function that is added to the onSizeChangedObservable
  26830. */
  26831. onSizeChanged: (postProcess: PostProcess) => void;
  26832. /**
  26833. * An event triggered when the postprocess applies its effect.
  26834. */
  26835. onApplyObservable: Observable<Effect>;
  26836. private _onApplyObserver;
  26837. /**
  26838. * A function that is added to the onApplyObservable
  26839. */
  26840. onApply: (effect: Effect) => void;
  26841. /**
  26842. * An event triggered before rendering the postprocess
  26843. */
  26844. onBeforeRenderObservable: Observable<Effect>;
  26845. private _onBeforeRenderObserver;
  26846. /**
  26847. * A function that is added to the onBeforeRenderObservable
  26848. */
  26849. onBeforeRender: (effect: Effect) => void;
  26850. /**
  26851. * An event triggered after rendering the postprocess
  26852. */
  26853. onAfterRenderObservable: Observable<Effect>;
  26854. private _onAfterRenderObserver;
  26855. /**
  26856. * A function that is added to the onAfterRenderObservable
  26857. */
  26858. onAfterRender: (efect: Effect) => void;
  26859. /**
  26860. * 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
  26861. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  26862. */
  26863. inputTexture: InternalTexture;
  26864. /**
  26865. * Gets the camera which post process is applied to.
  26866. * @returns The camera the post process is applied to.
  26867. */
  26868. getCamera(): Camera;
  26869. /**
  26870. * Gets the texel size of the postprocess.
  26871. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  26872. */
  26873. readonly texelSize: Vector2;
  26874. /**
  26875. * Creates a new instance PostProcess
  26876. * @param name The name of the PostProcess.
  26877. * @param fragmentUrl The url of the fragment shader to be used.
  26878. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  26879. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  26880. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  26881. * @param camera The camera to apply the render pass to.
  26882. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  26883. * @param engine The engine which the post process will be applied. (default: current engine)
  26884. * @param reusable If the post process can be reused on the same frame. (default: false)
  26885. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  26886. * @param textureType Type of textures used when performing the post process. (default: 0)
  26887. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  26888. * @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
  26889. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  26890. */
  26891. constructor(/** Name of the PostProcess. */ 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);
  26892. /**
  26893. * Gets the engine which this post process belongs to.
  26894. * @returns The engine the post process was enabled with.
  26895. */
  26896. getEngine(): Engine;
  26897. /**
  26898. * The effect that is created when initializing the post process.
  26899. * @returns The created effect corrisponding the the postprocess.
  26900. */
  26901. getEffect(): Effect;
  26902. /**
  26903. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  26904. * @param postProcess The post process to share the output with.
  26905. * @returns This post process.
  26906. */
  26907. shareOutputWith(postProcess: PostProcess): PostProcess;
  26908. /**
  26909. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  26910. * This should be called if the post process that shares output with this post process is disabled/disposed.
  26911. */
  26912. useOwnOutput(): void;
  26913. /**
  26914. * Updates the effect with the current post process compile time values and recompiles the shader.
  26915. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  26916. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  26917. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  26918. * @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
  26919. * @param onCompiled Called when the shader has been compiled.
  26920. * @param onError Called if there is an error when compiling a shader.
  26921. */
  26922. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  26923. /**
  26924. * The post process is reusable if it can be used multiple times within one frame.
  26925. * @returns If the post process is reusable
  26926. */
  26927. isReusable(): boolean;
  26928. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  26929. markTextureDirty(): void;
  26930. /**
  26931. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  26932. * 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.
  26933. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  26934. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  26935. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  26936. * @returns The target texture that was bound to be written to.
  26937. */
  26938. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  26939. /**
  26940. * If the post process is supported.
  26941. */
  26942. readonly isSupported: boolean;
  26943. /**
  26944. * The aspect ratio of the output texture.
  26945. */
  26946. readonly aspectRatio: number;
  26947. /**
  26948. * Get a value indicating if the post-process is ready to be used
  26949. * @returns true if the post-process is ready (shader is compiled)
  26950. */
  26951. isReady(): boolean;
  26952. /**
  26953. * Binds all textures and uniforms to the shader, this will be run on every pass.
  26954. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  26955. */
  26956. apply(): Nullable<Effect>;
  26957. private _disposeTextures();
  26958. /**
  26959. * Disposes the post process.
  26960. * @param camera The camera to dispose the post process on.
  26961. */
  26962. dispose(camera?: Camera): void;
  26963. }
  26964. }
  26965. declare module BABYLON {
  26966. /**
  26967. * PostProcessManager is used to manage one or more post processes or post process pipelines
  26968. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  26969. */
  26970. class PostProcessManager {
  26971. private _scene;
  26972. private _indexBuffer;
  26973. private _vertexBuffers;
  26974. /**
  26975. * Creates a new instance PostProcess
  26976. * @param scene The scene that the post process is associated with.
  26977. */
  26978. constructor(scene: Scene);
  26979. private _prepareBuffers();
  26980. private _buildIndexBuffer();
  26981. /**
  26982. * Rebuilds the vertex buffers of the manager.
  26983. */
  26984. /**
  26985. * Prepares a frame to be run through a post process.
  26986. * @param sourceTexture The input texture to the post procesess. (default: null)
  26987. * @param postProcesses An array of post processes to be run. (default: null)
  26988. * @returns True if the post processes were able to be run.
  26989. */
  26990. /**
  26991. * Manually render a set of post processes to a texture.
  26992. * @param postProcesses An array of post processes to be run.
  26993. * @param targetTexture The target texture to render to.
  26994. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  26995. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  26996. * @param lodLevel defines which lod of the texture to render to
  26997. */
  26998. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  26999. /**
  27000. * Finalize the result of the output of the postprocesses.
  27001. * @param doNotPresent If true the result will not be displayed to the screen.
  27002. * @param targetTexture The target texture to render to.
  27003. * @param faceIndex The index of the face to bind the target texture to.
  27004. * @param postProcesses The array of post processes to render.
  27005. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  27006. */
  27007. /**
  27008. * Disposes of the post process manager.
  27009. */
  27010. dispose(): void;
  27011. }
  27012. }
  27013. declare module BABYLON {
  27014. class RefractionPostProcess extends PostProcess {
  27015. color: Color3;
  27016. depth: number;
  27017. colorLevel: number;
  27018. private _refTexture;
  27019. private _ownRefractionTexture;
  27020. /**
  27021. * Gets or sets the refraction texture
  27022. * Please note that you are responsible for disposing the texture if you set it manually
  27023. */
  27024. refractionTexture: Texture;
  27025. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  27026. dispose(camera: Camera): void;
  27027. }
  27028. }
  27029. declare module BABYLON {
  27030. /**
  27031. * The SharpenPostProcess applies a sharpen kernel to every pixel
  27032. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  27033. */
  27034. class SharpenPostProcess extends PostProcess {
  27035. /**
  27036. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  27037. */
  27038. colorAmount: number;
  27039. /**
  27040. * How much sharpness should be applied (default: 0.3)
  27041. */
  27042. edgeAmount: number;
  27043. /**
  27044. * Creates a new instance ConvolutionPostProcess
  27045. * @param name The name of the effect.
  27046. * @param options The required width/height ratio to downsize to before computing the render pass.
  27047. * @param camera The camera to apply the render pass to.
  27048. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  27049. * @param engine The engine which the post process will be applied. (default: current engine)
  27050. * @param reusable If the post process can be reused on the same frame. (default: false)
  27051. * @param textureType Type of textures used when performing the post process. (default: 0)
  27052. * @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)
  27053. */
  27054. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  27055. }
  27056. }
  27057. declare module BABYLON {
  27058. class StereoscopicInterlacePostProcess extends PostProcess {
  27059. private _stepSize;
  27060. private _passedProcess;
  27061. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  27062. }
  27063. }
  27064. declare module BABYLON {
  27065. /** Defines operator used for tonemapping */
  27066. enum TonemappingOperator {
  27067. /** Hable */
  27068. Hable = 0,
  27069. /** Reinhard */
  27070. Reinhard = 1,
  27071. /** HejiDawson */
  27072. HejiDawson = 2,
  27073. /** Photographic */
  27074. Photographic = 3,
  27075. }
  27076. /**
  27077. * Defines a post process to apply tone mapping
  27078. */
  27079. class TonemapPostProcess extends PostProcess {
  27080. private _operator;
  27081. /** Defines the required exposure adjustement */
  27082. exposureAdjustment: number;
  27083. /**
  27084. * Creates a new TonemapPostProcess
  27085. * @param name defines the name of the postprocess
  27086. * @param _operator defines the operator to use
  27087. * @param exposureAdjustment defines the required exposure adjustement
  27088. * @param camera defines the camera to use (can be null)
  27089. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  27090. * @param engine defines the hosting engine (can be ignore if camera is set)
  27091. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  27092. */
  27093. constructor(name: string, _operator: TonemappingOperator,
  27094. /** Defines the required exposure adjustement */
  27095. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  27096. }
  27097. }
  27098. declare module BABYLON {
  27099. class VolumetricLightScatteringPostProcess extends PostProcess {
  27100. private _volumetricLightScatteringPass;
  27101. private _volumetricLightScatteringRTT;
  27102. private _viewPort;
  27103. private _screenCoordinates;
  27104. private _cachedDefines;
  27105. /**
  27106. * If not undefined, the mesh position is computed from the attached node position
  27107. */
  27108. attachedNode: {
  27109. position: Vector3;
  27110. };
  27111. /**
  27112. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  27113. */
  27114. customMeshPosition: Vector3;
  27115. /**
  27116. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  27117. */
  27118. useCustomMeshPosition: boolean;
  27119. /**
  27120. * If the post-process should inverse the light scattering direction
  27121. */
  27122. invert: boolean;
  27123. /**
  27124. * The internal mesh used by the post-process
  27125. */
  27126. mesh: Mesh;
  27127. useDiffuseColor: boolean;
  27128. /**
  27129. * Array containing the excluded meshes not rendered in the internal pass
  27130. */
  27131. excludedMeshes: AbstractMesh[];
  27132. /**
  27133. * Controls the overall intensity of the post-process
  27134. */
  27135. exposure: number;
  27136. /**
  27137. * Dissipates each sample's contribution in range [0, 1]
  27138. */
  27139. decay: number;
  27140. /**
  27141. * Controls the overall intensity of each sample
  27142. */
  27143. weight: number;
  27144. /**
  27145. * Controls the density of each sample
  27146. */
  27147. density: number;
  27148. /**
  27149. * @constructor
  27150. * @param {string} name - The post-process name
  27151. * @param {any} ratio - The size of the post-process and/or internal pass (0.5 means that your postprocess will have a width = canvas.width 0.5 and a height = canvas.height 0.5)
  27152. * @param {BABYLON.Camera} camera - The camera that the post-process will be attached to
  27153. * @param {BABYLON.Mesh} mesh - The mesh used to create the light scattering
  27154. * @param {number} samples - The post-process quality, default 100
  27155. * @param {number} samplingMode - The post-process filtering mode
  27156. * @param {BABYLON.Engine} engine - The babylon engine
  27157. * @param {boolean} reusable - If the post-process is reusable
  27158. * @param {BABYLON.Scene} scene - The constructor needs a scene reference to initialize internal components. If "camera" is null (RenderPipelineà, "scene" must be provided
  27159. */
  27160. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  27161. getClassName(): string;
  27162. private _isReady(subMesh, useInstances);
  27163. /**
  27164. * Sets the new light position for light scattering effect
  27165. * @param {BABYLON.Vector3} The new custom light position
  27166. */
  27167. setCustomMeshPosition(position: Vector3): void;
  27168. /**
  27169. * Returns the light position for light scattering effect
  27170. * @return {BABYLON.Vector3} The custom light position
  27171. */
  27172. getCustomMeshPosition(): Vector3;
  27173. /**
  27174. * Disposes the internal assets and detaches the post-process from the camera
  27175. */
  27176. dispose(camera: Camera): void;
  27177. /**
  27178. * Returns the render target texture used by the post-process
  27179. * @return {BABYLON.RenderTargetTexture} The render target texture used by the post-process
  27180. */
  27181. getPass(): RenderTargetTexture;
  27182. private _meshExcluded(mesh);
  27183. private _createPass(scene, ratio);
  27184. private _updateMeshScreenCoordinates(scene);
  27185. /**
  27186. * Creates a default mesh for the Volumeric Light Scattering post-process
  27187. * @param {string} The mesh name
  27188. * @param {BABYLON.Scene} The scene where to create the mesh
  27189. * @return {BABYLON.Mesh} the default mesh
  27190. */
  27191. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  27192. }
  27193. }
  27194. declare module BABYLON {
  27195. class VRDistortionCorrectionPostProcess extends PostProcess {
  27196. private _isRightEye;
  27197. private _distortionFactors;
  27198. private _postProcessScaleFactor;
  27199. private _lensCenterOffset;
  27200. private _scaleIn;
  27201. private _scaleFactor;
  27202. private _lensCenter;
  27203. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  27204. }
  27205. }
  27206. declare module BABYLON {
  27207. /**
  27208. * Class used to evalaute queries containing `and` and `or` operators
  27209. */
  27210. class AndOrNotEvaluator {
  27211. /**
  27212. * Evaluate a query
  27213. * @param query defines the query to evaluate
  27214. * @param evaluateCallback defines the callback used to filter result
  27215. * @returns true if the query matches
  27216. */
  27217. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  27218. private static _HandleParenthesisContent(parenthesisContent, evaluateCallback);
  27219. private static _SimplifyNegation(booleanString);
  27220. }
  27221. }
  27222. declare module BABYLON {
  27223. /**
  27224. * Defines the list of states available for a task inside a {BABYLON.AssetsManager}
  27225. */
  27226. enum AssetTaskState {
  27227. /**
  27228. * Initialization
  27229. */
  27230. INIT = 0,
  27231. /**
  27232. * Running
  27233. */
  27234. RUNNING = 1,
  27235. /**
  27236. * Done
  27237. */
  27238. DONE = 2,
  27239. /**
  27240. * Error
  27241. */
  27242. ERROR = 3,
  27243. }
  27244. /**
  27245. * Define an abstract asset task used with a {BABYLON.AssetsManager} class to load assets into a scene
  27246. */
  27247. abstract class AbstractAssetTask {
  27248. /**
  27249. * Task name
  27250. */ name: string;
  27251. /**
  27252. * Callback called when the task is successful
  27253. */
  27254. onSuccess: (task: any) => void;
  27255. /**
  27256. * Callback called when the task is not successful
  27257. */
  27258. onError: (task: any, message?: string, exception?: any) => void;
  27259. /**
  27260. * Creates a new {BABYLON.AssetsManager}
  27261. * @param name defines the name of the task
  27262. */
  27263. constructor(
  27264. /**
  27265. * Task name
  27266. */ name: string);
  27267. private _isCompleted;
  27268. private _taskState;
  27269. private _errorObject;
  27270. /**
  27271. * Get if the task is completed
  27272. */
  27273. readonly isCompleted: boolean;
  27274. /**
  27275. * Gets the current state of the task
  27276. */
  27277. readonly taskState: AssetTaskState;
  27278. /**
  27279. * Gets the current error object (if task is in error)
  27280. */
  27281. readonly errorObject: {
  27282. message?: string;
  27283. exception?: any;
  27284. };
  27285. /**
  27286. * Internal only
  27287. * @hidden
  27288. */
  27289. /**
  27290. * Execute the current task
  27291. * @param scene defines the scene where you want your assets to be loaded
  27292. * @param onSuccess is a callback called when the task is successfully executed
  27293. * @param onError is a callback called if an error occurs
  27294. */
  27295. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  27296. /**
  27297. * Execute the current task
  27298. * @param scene defines the scene where you want your assets to be loaded
  27299. * @param onSuccess is a callback called when the task is successfully executed
  27300. * @param onError is a callback called if an error occurs
  27301. */
  27302. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  27303. /**
  27304. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  27305. * This can be used with failed tasks that have the reason for failure fixed.
  27306. */
  27307. reset(): void;
  27308. private onErrorCallback(onError, message?, exception?);
  27309. private onDoneCallback(onSuccess, onError);
  27310. }
  27311. /**
  27312. * Define the interface used by progress events raised during assets loading
  27313. */
  27314. interface IAssetsProgressEvent {
  27315. /**
  27316. * Defines the number of remaining tasks to process
  27317. */
  27318. remainingCount: number;
  27319. /**
  27320. * Defines the total number of tasks
  27321. */
  27322. totalCount: number;
  27323. /**
  27324. * Defines the task that was just processed
  27325. */
  27326. task: AbstractAssetTask;
  27327. }
  27328. /**
  27329. * Class used to share progress information about assets loading
  27330. */
  27331. class AssetsProgressEvent implements IAssetsProgressEvent {
  27332. /**
  27333. * Defines the number of remaining tasks to process
  27334. */
  27335. remainingCount: number;
  27336. /**
  27337. * Defines the total number of tasks
  27338. */
  27339. totalCount: number;
  27340. /**
  27341. * Defines the task that was just processed
  27342. */
  27343. task: AbstractAssetTask;
  27344. /**
  27345. * Creates a {BABYLON.AssetsProgressEvent}
  27346. * @param remainingCount defines the number of remaining tasks to process
  27347. * @param totalCount defines the total number of tasks
  27348. * @param task defines the task that was just processed
  27349. */
  27350. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  27351. }
  27352. /**
  27353. * Define a task used by {BABYLON.AssetsManager} to load meshes
  27354. */
  27355. class MeshAssetTask extends AbstractAssetTask {
  27356. /**
  27357. * Defines the name of the task
  27358. */
  27359. name: string;
  27360. /**
  27361. * Defines the list of mesh's names you want to load
  27362. */
  27363. meshesNames: any;
  27364. /**
  27365. * Defines the root url to use as a base to load your meshes and associated resources
  27366. */
  27367. rootUrl: string;
  27368. /**
  27369. * Defines the filename of the scene to load from
  27370. */
  27371. sceneFilename: string;
  27372. /**
  27373. * Gets the list of loaded meshes
  27374. */
  27375. loadedMeshes: Array<AbstractMesh>;
  27376. /**
  27377. * Gets the list of loaded particle systems
  27378. */
  27379. loadedParticleSystems: Array<ParticleSystem>;
  27380. /**
  27381. * Gets the list of loaded skeletons
  27382. */
  27383. loadedSkeletons: Array<Skeleton>;
  27384. /**
  27385. * Callback called when the task is successful
  27386. */
  27387. onSuccess: (task: MeshAssetTask) => void;
  27388. /**
  27389. * Callback called when the task is successful
  27390. */
  27391. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  27392. /**
  27393. * Creates a new {BABYLON.MeshAssetTask}
  27394. * @param name defines the name of the task
  27395. * @param meshesNames defines the list of mesh's names you want to load
  27396. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  27397. * @param sceneFilename defines the filename of the scene to load from
  27398. */
  27399. constructor(
  27400. /**
  27401. * Defines the name of the task
  27402. */
  27403. name: string,
  27404. /**
  27405. * Defines the list of mesh's names you want to load
  27406. */
  27407. meshesNames: any,
  27408. /**
  27409. * Defines the root url to use as a base to load your meshes and associated resources
  27410. */
  27411. rootUrl: string,
  27412. /**
  27413. * Defines the filename of the scene to load from
  27414. */
  27415. sceneFilename: string);
  27416. /**
  27417. * Execute the current task
  27418. * @param scene defines the scene where you want your assets to be loaded
  27419. * @param onSuccess is a callback called when the task is successfully executed
  27420. * @param onError is a callback called if an error occurs
  27421. */
  27422. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  27423. }
  27424. /**
  27425. * Define a task used by {BABYLON.AssetsManager} to load text content
  27426. */
  27427. class TextFileAssetTask extends AbstractAssetTask {
  27428. /**
  27429. * Defines the name of the task
  27430. */
  27431. name: string;
  27432. /**
  27433. * Defines the location of the file to load
  27434. */
  27435. url: string;
  27436. /**
  27437. * Gets the loaded text string
  27438. */
  27439. text: string;
  27440. /**
  27441. * Callback called when the task is successful
  27442. */
  27443. onSuccess: (task: TextFileAssetTask) => void;
  27444. /**
  27445. * Callback called when the task is successful
  27446. */
  27447. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  27448. /**
  27449. * Creates a new TextFileAssetTask object
  27450. * @param name defines the name of the task
  27451. * @param url defines the location of the file to load
  27452. */
  27453. constructor(
  27454. /**
  27455. * Defines the name of the task
  27456. */
  27457. name: string,
  27458. /**
  27459. * Defines the location of the file to load
  27460. */
  27461. url: string);
  27462. /**
  27463. * Execute the current task
  27464. * @param scene defines the scene where you want your assets to be loaded
  27465. * @param onSuccess is a callback called when the task is successfully executed
  27466. * @param onError is a callback called if an error occurs
  27467. */
  27468. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  27469. }
  27470. /**
  27471. * Define a task used by {BABYLON.AssetsManager} to load binary data
  27472. */
  27473. class BinaryFileAssetTask extends AbstractAssetTask {
  27474. /**
  27475. * Defines the name of the task
  27476. */
  27477. name: string;
  27478. /**
  27479. * Defines the location of the file to load
  27480. */
  27481. url: string;
  27482. /**
  27483. * Gets the lodaded data (as an array buffer)
  27484. */
  27485. data: ArrayBuffer;
  27486. /**
  27487. * Callback called when the task is successful
  27488. */
  27489. onSuccess: (task: BinaryFileAssetTask) => void;
  27490. /**
  27491. * Callback called when the task is successful
  27492. */
  27493. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  27494. /**
  27495. * Creates a new BinaryFileAssetTask object
  27496. * @param name defines the name of the new task
  27497. * @param url defines the location of the file to load
  27498. */
  27499. constructor(
  27500. /**
  27501. * Defines the name of the task
  27502. */
  27503. name: string,
  27504. /**
  27505. * Defines the location of the file to load
  27506. */
  27507. url: string);
  27508. /**
  27509. * Execute the current task
  27510. * @param scene defines the scene where you want your assets to be loaded
  27511. * @param onSuccess is a callback called when the task is successfully executed
  27512. * @param onError is a callback called if an error occurs
  27513. */
  27514. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  27515. }
  27516. /**
  27517. * Define a task used by {BABYLON.AssetsManager} to load images
  27518. */
  27519. class ImageAssetTask extends AbstractAssetTask {
  27520. /**
  27521. * Defines the name of the task
  27522. */
  27523. name: string;
  27524. /**
  27525. * Defines the location of the image to load
  27526. */
  27527. url: string;
  27528. /**
  27529. * Gets the loaded images
  27530. */
  27531. image: HTMLImageElement;
  27532. /**
  27533. * Callback called when the task is successful
  27534. */
  27535. onSuccess: (task: ImageAssetTask) => void;
  27536. /**
  27537. * Callback called when the task is successful
  27538. */
  27539. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  27540. /**
  27541. * Creates a new ImageAssetTask
  27542. * @param name defines the name of the task
  27543. * @param url defines the location of the image to load
  27544. */
  27545. constructor(
  27546. /**
  27547. * Defines the name of the task
  27548. */
  27549. name: string,
  27550. /**
  27551. * Defines the location of the image to load
  27552. */
  27553. url: string);
  27554. /**
  27555. * Execute the current task
  27556. * @param scene defines the scene where you want your assets to be loaded
  27557. * @param onSuccess is a callback called when the task is successfully executed
  27558. * @param onError is a callback called if an error occurs
  27559. */
  27560. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  27561. }
  27562. /**
  27563. * Defines the interface used by texture loading tasks
  27564. */
  27565. interface ITextureAssetTask<TEX extends BaseTexture> {
  27566. /**
  27567. * Gets the loaded texture
  27568. */
  27569. texture: TEX;
  27570. }
  27571. /**
  27572. * Define a task used by {BABYLON.AssetsManager} to load 2D textures
  27573. */
  27574. class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  27575. /**
  27576. * Defines the name of the task
  27577. */
  27578. name: string;
  27579. /**
  27580. * Defines the location of the file to load
  27581. */
  27582. url: string;
  27583. /**
  27584. * Defines if mipmap should not be generated (default is false)
  27585. */
  27586. noMipmap: boolean | undefined;
  27587. /**
  27588. * Defines if texture must be inverted on Y axis (default is false)
  27589. */
  27590. invertY: boolean | undefined;
  27591. /**
  27592. * Defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  27593. */
  27594. samplingMode: number;
  27595. /**
  27596. * Gets the loaded texture
  27597. */
  27598. texture: Texture;
  27599. /**
  27600. * Callback called when the task is successful
  27601. */
  27602. onSuccess: (task: TextureAssetTask) => void;
  27603. /**
  27604. * Callback called when the task is successful
  27605. */
  27606. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  27607. /**
  27608. * Creates a new TextureAssetTask object
  27609. * @param name defines the name of the task
  27610. * @param url defines the location of the file to load
  27611. * @param noMipmap defines if mipmap should not be generated (default is false)
  27612. * @param invertY defines if texture must be inverted on Y axis (default is false)
  27613. * @param samplingMode defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  27614. */
  27615. constructor(
  27616. /**
  27617. * Defines the name of the task
  27618. */
  27619. name: string,
  27620. /**
  27621. * Defines the location of the file to load
  27622. */
  27623. url: string,
  27624. /**
  27625. * Defines if mipmap should not be generated (default is false)
  27626. */
  27627. noMipmap?: boolean | undefined,
  27628. /**
  27629. * Defines if texture must be inverted on Y axis (default is false)
  27630. */
  27631. invertY?: boolean | undefined,
  27632. /**
  27633. * Defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  27634. */
  27635. samplingMode?: number);
  27636. /**
  27637. * Execute the current task
  27638. * @param scene defines the scene where you want your assets to be loaded
  27639. * @param onSuccess is a callback called when the task is successfully executed
  27640. * @param onError is a callback called if an error occurs
  27641. */
  27642. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  27643. }
  27644. /**
  27645. * Define a task used by {BABYLON.AssetsManager} to load cube textures
  27646. */
  27647. class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  27648. /**
  27649. * Defines the name of the task
  27650. */
  27651. name: string;
  27652. /**
  27653. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  27654. */
  27655. url: string;
  27656. /**
  27657. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  27658. */
  27659. extensions: string[] | undefined;
  27660. /**
  27661. * Defines if mipmaps should not be generated (default is false)
  27662. */
  27663. noMipmap: boolean | undefined;
  27664. /**
  27665. * Defines the explicit list of files (undefined by default)
  27666. */
  27667. files: string[] | undefined;
  27668. /**
  27669. * Gets the loaded texture
  27670. */
  27671. texture: CubeTexture;
  27672. /**
  27673. * Callback called when the task is successful
  27674. */
  27675. onSuccess: (task: CubeTextureAssetTask) => void;
  27676. /**
  27677. * Callback called when the task is successful
  27678. */
  27679. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  27680. /**
  27681. * Creates a new CubeTextureAssetTask
  27682. * @param name defines the name of the task
  27683. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  27684. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  27685. * @param noMipmap defines if mipmaps should not be generated (default is false)
  27686. * @param files defines the explicit list of files (undefined by default)
  27687. */
  27688. constructor(
  27689. /**
  27690. * Defines the name of the task
  27691. */
  27692. name: string,
  27693. /**
  27694. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  27695. */
  27696. url: string,
  27697. /**
  27698. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  27699. */
  27700. extensions?: string[] | undefined,
  27701. /**
  27702. * Defines if mipmaps should not be generated (default is false)
  27703. */
  27704. noMipmap?: boolean | undefined,
  27705. /**
  27706. * Defines the explicit list of files (undefined by default)
  27707. */
  27708. files?: string[] | undefined);
  27709. /**
  27710. * Execute the current task
  27711. * @param scene defines the scene where you want your assets to be loaded
  27712. * @param onSuccess is a callback called when the task is successfully executed
  27713. * @param onError is a callback called if an error occurs
  27714. */
  27715. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  27716. }
  27717. /**
  27718. * Define a task used by {BABYLON.AssetsManager} to load HDR cube textures
  27719. */
  27720. class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  27721. /**
  27722. * Defines the name of the task
  27723. */
  27724. name: string;
  27725. /**
  27726. * Defines the location of the file to load
  27727. */
  27728. url: string;
  27729. /**
  27730. * Defines the desired size (the more it increases the longer the generation will be)
  27731. */
  27732. size: number;
  27733. /**
  27734. * Defines if mipmaps should not be generated (default is false)
  27735. */
  27736. noMipmap: boolean;
  27737. /**
  27738. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  27739. */
  27740. generateHarmonics: boolean;
  27741. /**
  27742. * 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)
  27743. */
  27744. gammaSpace: boolean;
  27745. /**
  27746. * Internal Use Only
  27747. */
  27748. reserved: boolean;
  27749. /**
  27750. * Gets the loaded texture
  27751. */
  27752. texture: HDRCubeTexture;
  27753. /**
  27754. * Callback called when the task is successful
  27755. */
  27756. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  27757. /**
  27758. * Callback called when the task is successful
  27759. */
  27760. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  27761. /**
  27762. * Creates a new HDRCubeTextureAssetTask object
  27763. * @param name defines the name of the task
  27764. * @param url defines the location of the file to load
  27765. * @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.
  27766. * @param noMipmap defines if mipmaps should not be generated (default is false)
  27767. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  27768. * @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)
  27769. * @param reserved Internal use only
  27770. */
  27771. constructor(
  27772. /**
  27773. * Defines the name of the task
  27774. */
  27775. name: string,
  27776. /**
  27777. * Defines the location of the file to load
  27778. */
  27779. url: string,
  27780. /**
  27781. * Defines the desired size (the more it increases the longer the generation will be)
  27782. */
  27783. size: number,
  27784. /**
  27785. * Defines if mipmaps should not be generated (default is false)
  27786. */
  27787. noMipmap?: boolean,
  27788. /**
  27789. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  27790. */
  27791. generateHarmonics?: boolean,
  27792. /**
  27793. * 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)
  27794. */
  27795. gammaSpace?: boolean,
  27796. /**
  27797. * Internal Use Only
  27798. */
  27799. reserved?: boolean);
  27800. /**
  27801. * Execute the current task
  27802. * @param scene defines the scene where you want your assets to be loaded
  27803. * @param onSuccess is a callback called when the task is successfully executed
  27804. * @param onError is a callback called if an error occurs
  27805. */
  27806. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  27807. }
  27808. /**
  27809. * This class can be used to easily import assets into a scene
  27810. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  27811. */
  27812. class AssetsManager {
  27813. private _scene;
  27814. private _isLoading;
  27815. protected _tasks: AbstractAssetTask[];
  27816. protected _waitingTasksCount: number;
  27817. protected _totalTasksCount: number;
  27818. /**
  27819. * Callback called when all tasks are processed
  27820. */
  27821. onFinish: (tasks: AbstractAssetTask[]) => void;
  27822. /**
  27823. * Callback called when a task is successful
  27824. */
  27825. onTaskSuccess: (task: AbstractAssetTask) => void;
  27826. /**
  27827. * Callback called when a task had an error
  27828. */
  27829. onTaskError: (task: AbstractAssetTask) => void;
  27830. /**
  27831. * Callback called when a task is done (whatever the result is)
  27832. */
  27833. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  27834. /**
  27835. * Observable called when all tasks are processed
  27836. */
  27837. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  27838. /**
  27839. * Observable called when a task had an error
  27840. */
  27841. onTaskErrorObservable: Observable<AbstractAssetTask>;
  27842. /**
  27843. * Observable called when a task is successful
  27844. */
  27845. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  27846. /**
  27847. * Observable called when a task is done (whatever the result is)
  27848. */
  27849. onProgressObservable: Observable<IAssetsProgressEvent>;
  27850. /**
  27851. * Gets or sets a boolean defining if the {BABYLON.AssetsManager} should use the default loading screen
  27852. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  27853. */
  27854. useDefaultLoadingScreen: boolean;
  27855. /**
  27856. * Creates a new AssetsManager
  27857. * @param scene defines the scene to work on
  27858. */
  27859. constructor(scene: Scene);
  27860. /**
  27861. * Add a {BABYLON.MeshAssetTask} to the list of active tasks
  27862. * @param taskName defines the name of the new task
  27863. * @param meshesNames defines the name of meshes to load
  27864. * @param rootUrl defines the root url to use to locate files
  27865. * @param sceneFilename defines the filename of the scene file
  27866. * @returns a new {BABYLON.MeshAssetTask} object
  27867. */
  27868. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  27869. /**
  27870. * Add a {BABYLON.TextFileAssetTask} to the list of active tasks
  27871. * @param taskName defines the name of the new task
  27872. * @param url defines the url of the file to load
  27873. * @returns a new {BABYLON.TextFileAssetTask} object
  27874. */
  27875. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  27876. /**
  27877. * Add a {BABYLON.BinaryFileAssetTask} to the list of active tasks
  27878. * @param taskName defines the name of the new task
  27879. * @param url defines the url of the file to load
  27880. * @returns a new {BABYLON.BinaryFileAssetTask} object
  27881. */
  27882. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  27883. /**
  27884. * Add a {BABYLON.ImageAssetTask} to the list of active tasks
  27885. * @param taskName defines the name of the new task
  27886. * @param url defines the url of the file to load
  27887. * @returns a new {BABYLON.ImageAssetTask} object
  27888. */
  27889. addImageTask(taskName: string, url: string): ImageAssetTask;
  27890. /**
  27891. * Add a {BABYLON.TextureAssetTask} to the list of active tasks
  27892. * @param taskName defines the name of the new task
  27893. * @param url defines the url of the file to load
  27894. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  27895. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  27896. * @param samplingMode defines the sampling mode to use (BABYLON.Texture.TRILINEAR_SAMPLINGMODE by default)
  27897. * @returns a new {BABYLON.TextureAssetTask} object
  27898. */
  27899. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  27900. /**
  27901. * Add a {BABYLON.CubeTextureAssetTask} to the list of active tasks
  27902. * @param taskName defines the name of the new task
  27903. * @param url defines the url of the file to load
  27904. * @param extensions defines the extension to use to load the cube map (can be null)
  27905. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  27906. * @param files defines the list of files to load (can be null)
  27907. * @returns a new {BABYLON.CubeTextureAssetTask} object
  27908. */
  27909. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  27910. /**
  27911. *
  27912. * Add a {BABYLON.HDRCubeTextureAssetTask} to the list of active tasks
  27913. * @param taskName defines the name of the new task
  27914. * @param url defines the url of the file to load
  27915. * @param size defines the size you want for the cubemap (can be null)
  27916. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  27917. * @param generateHarmonics defines if you want to automatically generate (true by default)
  27918. * @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)
  27919. * @param reserved Internal use only
  27920. * @returns a new {BABYLON.HDRCubeTextureAssetTask} object
  27921. */
  27922. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  27923. /**
  27924. * Remove a task from the assets manager.
  27925. * @param task the task to remove
  27926. */
  27927. removeTask(task: AbstractAssetTask): void;
  27928. private _decreaseWaitingTasksCount(task);
  27929. private _runTask(task);
  27930. /**
  27931. * Reset the {BABYLON.AssetsManager} and remove all tasks
  27932. * @return the current instance of the {BABYLON.AssetsManager}
  27933. */
  27934. reset(): AssetsManager;
  27935. /**
  27936. * Start the loading process
  27937. * @return the current instance of the {BABYLON.AssetsManager}
  27938. */
  27939. load(): AssetsManager;
  27940. }
  27941. }
  27942. declare module BABYLON {
  27943. /**
  27944. * Class used to enable access to IndexedDB
  27945. * @see @https://developer.mozilla.org/en-US/docs/Web/API/IndexedDB_API
  27946. */
  27947. class Database {
  27948. private callbackManifestChecked;
  27949. private currentSceneUrl;
  27950. private db;
  27951. private _enableSceneOffline;
  27952. private _enableTexturesOffline;
  27953. private manifestVersionFound;
  27954. private mustUpdateRessources;
  27955. private hasReachedQuota;
  27956. private isSupported;
  27957. private idbFactory;
  27958. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  27959. static IsUASupportingBlobStorage: boolean;
  27960. /** Gets a boolean indicating if Database storate is enabled */
  27961. static IDBStorageEnabled: boolean;
  27962. /**
  27963. * Gets a boolean indicating if scene must be saved in the database
  27964. */
  27965. readonly enableSceneOffline: boolean;
  27966. /**
  27967. * Gets a boolean indicating if textures must be saved in the database
  27968. */
  27969. readonly enableTexturesOffline: boolean;
  27970. /**
  27971. * Creates a new Database
  27972. * @param urlToScene defines the url to load the scene
  27973. * @param callbackManifestChecked defines the callback to use when manifest is checked
  27974. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  27975. */
  27976. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  27977. private static _ParseURL;
  27978. private static _ReturnFullUrlLocation;
  27979. private _checkManifestFile();
  27980. /**
  27981. * Open the database and make it available
  27982. * @param successCallback defines the callback to call on success
  27983. * @param errorCallback defines the callback to call on error
  27984. */
  27985. openAsync(successCallback: () => void, errorCallback: () => void): void;
  27986. /**
  27987. * Loads an image from the database
  27988. * @param url defines the url to load from
  27989. * @param image defines the target DOM image
  27990. */
  27991. loadImageFromDB(url: string, image: HTMLImageElement): void;
  27992. private _loadImageFromDBAsync(url, image, notInDBCallback);
  27993. private _saveImageIntoDBAsync(url, image);
  27994. private _checkVersionFromDB(url, versionLoaded);
  27995. private _loadVersionFromDBAsync(url, callback, updateInDBCallback);
  27996. private _saveVersionIntoDBAsync(url, callback);
  27997. /**
  27998. * Loads a file from database
  27999. * @param url defines the URL to load from
  28000. * @param sceneLoaded defines a callback to call on success
  28001. * @param progressCallBack defines a callback to call when progress changed
  28002. * @param errorCallback defines a callback to call on error
  28003. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  28004. */
  28005. loadFileFromDB(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  28006. private _loadFileFromDBAsync(url, callback, notInDBCallback, useArrayBuffer?);
  28007. private _saveFileIntoDBAsync(url, callback, progressCallback?, useArrayBuffer?);
  28008. }
  28009. }
  28010. declare module BABYLON {
  28011. interface DDSInfo {
  28012. width: number;
  28013. height: number;
  28014. mipmapCount: number;
  28015. isFourCC: boolean;
  28016. isRGB: boolean;
  28017. isLuminance: boolean;
  28018. isCube: boolean;
  28019. isCompressed: boolean;
  28020. dxgiFormat: number;
  28021. textureType: number;
  28022. /** Sphericle polynomial created for the dds texture */
  28023. sphericalPolynomial?: SphericalPolynomial;
  28024. }
  28025. class DDSTools {
  28026. static StoreLODInAlphaChannel: boolean;
  28027. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  28028. private static _FloatView;
  28029. private static _Int32View;
  28030. private static _ToHalfFloat(value);
  28031. private static _FromHalfFloat(value);
  28032. private static _GetHalfFloatAsFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod);
  28033. private static _GetHalfFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod);
  28034. private static _GetFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod);
  28035. private static _GetFloatAsUIntRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod);
  28036. private static _GetHalfFloatAsUIntRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod);
  28037. private static _GetRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, rOffset, gOffset, bOffset, aOffset);
  28038. private static _ExtractLongWordOrder(value);
  28039. private static _GetRGBArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, rOffset, gOffset, bOffset);
  28040. private static _GetLuminanceArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer);
  28041. static UploadDDSLevels(engine: Engine, gl: WebGLRenderingContext, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  28042. }
  28043. }
  28044. declare module BABYLON {
  28045. function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  28046. function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28047. function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28048. function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28049. function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28050. function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28051. function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28052. function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28053. function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28054. function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28055. function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28056. function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28057. /**
  28058. * Decorator used to define property that can be serialized as reference to a camera
  28059. * @param sourceName defines the name of the property to decorate
  28060. */
  28061. function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28062. class SerializationHelper {
  28063. static Serialize<T>(entity: T, serializationObject?: any): any;
  28064. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  28065. static Clone<T>(creationFunction: () => T, source: T): T;
  28066. static Instanciate<T>(creationFunction: () => T, source: T): T;
  28067. }
  28068. }
  28069. declare module BABYLON {
  28070. /**
  28071. * Wrapper class for promise with external resolve and reject.
  28072. */
  28073. class Deferred<T> {
  28074. /**
  28075. * The promise associated with this deferred object.
  28076. */
  28077. readonly promise: Promise<T>;
  28078. private _resolve;
  28079. private _reject;
  28080. /**
  28081. * The resolve method of the promise associated with this deferred object.
  28082. */
  28083. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  28084. /**
  28085. * The reject method of the promise associated with this deferred object.
  28086. */
  28087. readonly reject: (reason?: any) => void;
  28088. /**
  28089. * Constructor for this deferred object.
  28090. */
  28091. constructor();
  28092. }
  28093. }
  28094. declare module BABYLON {
  28095. /**
  28096. * Raw texture data and descriptor sufficient for WebGL texture upload
  28097. */
  28098. interface EnvironmentTextureInfo {
  28099. /**
  28100. * Version of the environment map
  28101. */
  28102. version: number;
  28103. /**
  28104. * Width of image
  28105. */
  28106. width: number;
  28107. /**
  28108. * Irradiance information stored in the file.
  28109. */
  28110. irradiance: any;
  28111. /**
  28112. * Specular information stored in the file.
  28113. */
  28114. specular: any;
  28115. }
  28116. /**
  28117. * Sets of helpers addressing the serialization and deserialization of environment texture
  28118. * stored in a BabylonJS env file.
  28119. * Those files are usually stored as .env files.
  28120. */
  28121. class EnvironmentTextureTools {
  28122. /**
  28123. * Magic number identifying the env file.
  28124. */
  28125. private static _MagicBytes;
  28126. /**
  28127. * Gets the environment info from an env file.
  28128. * @param data The array buffer containing the .env bytes.
  28129. * @returns the environment file info (the json header) if successfully parsed.
  28130. */
  28131. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  28132. /**
  28133. * Creates an environment texture from a loaded cube texture.
  28134. * @param texture defines the cube texture to convert in env file
  28135. * @return a promise containing the environment data if succesfull.
  28136. */
  28137. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  28138. /**
  28139. * Creates a JSON representation of the spherical data.
  28140. * @param texture defines the texture containing the polynomials
  28141. * @return the JSON representation of the spherical info
  28142. */
  28143. private static _CreateEnvTextureIrradiance(texture);
  28144. /**
  28145. * Uploads the texture info contained in the env file to te GPU.
  28146. * @param texture defines the internal texture to upload to
  28147. * @param arrayBuffer defines the buffer cotaining the data to load
  28148. * @param info defines the texture info retrieved through the GetEnvInfo method
  28149. * @returns a promise
  28150. */
  28151. static UploadLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  28152. /**
  28153. * Uploads spherical polynomials information to the texture.
  28154. * @param texture defines the texture we are trying to upload the information to
  28155. * @param arrayBuffer defines the array buffer holding the data
  28156. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  28157. */
  28158. static UploadPolynomials(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): void;
  28159. /**
  28160. * Upload spherical polynomial coefficients to the texture
  28161. * @param polynmials Spherical polynmial coefficients (9)
  28162. * @param outPolynomialCoefficents Polynomial coefficients (9) object to store result
  28163. */
  28164. private static _UploadSP(polynmials, outPolynomialCoefficents);
  28165. /**
  28166. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  28167. * L = (1/pi) * E * rho
  28168. *
  28169. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  28170. * @param harmonics Spherical harmonic coefficients (9)
  28171. */
  28172. private static _ConvertSHIrradianceToLambertianRadiance(harmonics);
  28173. /**
  28174. * Convert spherical harmonics to spherical polynomial coefficients
  28175. * @param harmonics Spherical harmonic coefficients (9)
  28176. * @param outPolynomialCoefficents Polynomial coefficients (9) object to store result
  28177. */
  28178. private static _ConvertSHToSP(harmonics, outPolynomialCoefficents);
  28179. }
  28180. }
  28181. declare module BABYLON {
  28182. class FilesInput {
  28183. static FilesToLoad: {
  28184. [key: string]: File;
  28185. };
  28186. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  28187. private _engine;
  28188. private _currentScene;
  28189. private _sceneLoadedCallback;
  28190. private _progressCallback;
  28191. private _additionalRenderLoopLogicCallback;
  28192. private _textureLoadingCallback;
  28193. private _startingProcessingFilesCallback;
  28194. private _onReloadCallback;
  28195. private _errorCallback;
  28196. private _elementToMonitor;
  28197. private _sceneFileToLoad;
  28198. private _filesToLoad;
  28199. constructor(engine: Engine, scene: Scene, sceneLoadedCallback: (sceneFile: File, scene: Scene) => void, progressCallback: (progress: SceneLoaderProgressEvent) => void, additionalRenderLoopLogicCallback: () => void, textureLoadingCallback: (remaining: number) => void, startingProcessingFilesCallback: () => void, onReloadCallback: (sceneFile: File) => void, errorCallback: (sceneFile: File, scene: Scene, message: string) => void);
  28200. private _dragEnterHandler;
  28201. private _dragOverHandler;
  28202. private _dropHandler;
  28203. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  28204. dispose(): void;
  28205. private renderFunction();
  28206. private drag(e);
  28207. private drop(eventDrop);
  28208. private _traverseFolder(folder, files, remaining, callback);
  28209. private _processFiles(files);
  28210. loadFiles(event: any): void;
  28211. private _processReload();
  28212. reload(): void;
  28213. }
  28214. }
  28215. declare module BABYLON {
  28216. /**
  28217. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  28218. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  28219. */
  28220. class KhronosTextureContainer {
  28221. arrayBuffer: any;
  28222. static HEADER_LEN: number;
  28223. static COMPRESSED_2D: number;
  28224. static COMPRESSED_3D: number;
  28225. static TEX_2D: number;
  28226. static TEX_3D: number;
  28227. glType: number;
  28228. glTypeSize: number;
  28229. glFormat: number;
  28230. glInternalFormat: number;
  28231. glBaseInternalFormat: number;
  28232. pixelWidth: number;
  28233. pixelHeight: number;
  28234. pixelDepth: number;
  28235. numberOfArrayElements: number;
  28236. numberOfFaces: number;
  28237. numberOfMipmapLevels: number;
  28238. bytesOfKeyValueData: number;
  28239. loadType: number;
  28240. /**
  28241. * @param {ArrayBuffer} arrayBuffer- contents of the KTX container file
  28242. * @param {number} facesExpected- should be either 1 or 6, based whether a cube texture or or
  28243. * @param {boolean} threeDExpected- provision for indicating that data should be a 3D texture, not implemented
  28244. * @param {boolean} textureArrayExpected- provision for indicating that data should be a texture array, not implemented
  28245. */
  28246. constructor(arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  28247. switchEndainness(val: number): number;
  28248. /**
  28249. * It is assumed that the texture has already been created & is currently bound
  28250. */
  28251. uploadLevels(gl: WebGLRenderingContext, loadMipmaps: boolean): void;
  28252. private _upload2DCompressedLevels(gl, loadMipmaps);
  28253. }
  28254. }
  28255. declare module BABYLON {
  28256. /**
  28257. * A class serves as a medium between the observable and its observers
  28258. */
  28259. class EventState {
  28260. /**
  28261. * Create a new EventState
  28262. * @param mask defines the mask associated with this state
  28263. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  28264. * @param target defines the original target of the state
  28265. * @param currentTarget defines the current target of the state
  28266. */
  28267. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  28268. /**
  28269. * Initialize the current event state
  28270. * @param mask defines the mask associated with this state
  28271. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  28272. * @param target defines the original target of the state
  28273. * @param currentTarget defines the current target of the state
  28274. * @returns the current event state
  28275. */
  28276. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  28277. /**
  28278. * An Observer can set this property to true to prevent subsequent observers of being notified
  28279. */
  28280. skipNextObservers: boolean;
  28281. /**
  28282. * Get the mask value that were used to trigger the event corresponding to this EventState object
  28283. */
  28284. mask: number;
  28285. /**
  28286. * The object that originally notified the event
  28287. */
  28288. target?: any;
  28289. /**
  28290. * The current object in the bubbling phase
  28291. */
  28292. currentTarget?: any;
  28293. /**
  28294. * This will be populated with the return value of the last function that was executed.
  28295. * If it is the first function in the callback chain it will be the event data.
  28296. */
  28297. lastReturnValue?: any;
  28298. }
  28299. /**
  28300. * Represent an Observer registered to a given Observable object.
  28301. */
  28302. class Observer<T> {
  28303. /**
  28304. * Defines the callback to call when the observer is notified
  28305. */
  28306. callback: (eventData: T, eventState: EventState) => void;
  28307. /**
  28308. * Defines the mask of the observer (used to filter notifications)
  28309. */
  28310. mask: number;
  28311. /**
  28312. * Defines the current scope used to restore the JS context
  28313. */
  28314. scope: any;
  28315. /** @hidden */
  28316. /**
  28317. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  28318. */
  28319. unregisterOnNextCall: boolean;
  28320. /**
  28321. * Creates a new observer
  28322. * @param callback defines the callback to call when the observer is notified
  28323. * @param mask defines the mask of the observer (used to filter notifications)
  28324. * @param scope defines the current scope used to restore the JS context
  28325. */
  28326. constructor(
  28327. /**
  28328. * Defines the callback to call when the observer is notified
  28329. */
  28330. callback: (eventData: T, eventState: EventState) => void,
  28331. /**
  28332. * Defines the mask of the observer (used to filter notifications)
  28333. */
  28334. mask: number,
  28335. /**
  28336. * Defines the current scope used to restore the JS context
  28337. */
  28338. scope?: any);
  28339. }
  28340. /**
  28341. * Represent a list of observers registered to multiple Observables object.
  28342. */
  28343. class MultiObserver<T> {
  28344. private _observers;
  28345. private _observables;
  28346. /**
  28347. * Release associated resources
  28348. */
  28349. dispose(): void;
  28350. /**
  28351. * Raise a callback when one of the observable will notify
  28352. * @param observables defines a list of observables to watch
  28353. * @param callback defines the callback to call on notification
  28354. * @param mask defines the mask used to filter notifications
  28355. * @param scope defines the current scope used to restore the JS context
  28356. * @returns the new MultiObserver
  28357. */
  28358. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  28359. }
  28360. /**
  28361. * The Observable class is a simple implementation of the Observable pattern.
  28362. *
  28363. * 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.
  28364. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  28365. * 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).
  28366. * 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.
  28367. */
  28368. class Observable<T> {
  28369. private _observers;
  28370. private _eventState;
  28371. private _onObserverAdded;
  28372. /**
  28373. * Creates a new observable
  28374. * @param onObserverAdded defines a callback to call when a new observer is added
  28375. */
  28376. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  28377. /**
  28378. * Create a new Observer with the specified callback
  28379. * @param callback the callback that will be executed for that Observer
  28380. * @param mask the mask used to filter observers
  28381. * @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.
  28382. * @param scope optional scope for the callback to be called from
  28383. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  28384. * @returns the new observer created for the callback
  28385. */
  28386. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  28387. /**
  28388. * Create a new Observer with the specified callback and unregisters after the next notification
  28389. * @param callback the callback that will be executed for that Observer
  28390. * @returns the new observer created for the callback
  28391. */
  28392. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  28393. /**
  28394. * Remove an Observer from the Observable object
  28395. * @param observer the instance of the Observer to remove
  28396. * @returns false if it doesn't belong to this Observable
  28397. */
  28398. remove(observer: Nullable<Observer<T>>): boolean;
  28399. /**
  28400. * Remove a callback from the Observable object
  28401. * @param callback the callback to remove
  28402. * @param scope optional scope. If used only the callbacks with this scope will be removed
  28403. * @returns false if it doesn't belong to this Observable
  28404. */
  28405. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  28406. private _deferUnregister(observer);
  28407. /**
  28408. * Notify all Observers by calling their respective callback with the given data
  28409. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  28410. * @param eventData defines the data to send to all observers
  28411. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  28412. * @param target defines the original target of the state
  28413. * @param currentTarget defines the current target of the state
  28414. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  28415. */
  28416. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  28417. /**
  28418. * Calling this will execute each callback, expecting it to be a promise or return a value.
  28419. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  28420. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  28421. * and it is crucial that all callbacks will be executed.
  28422. * The order of the callbacks is kept, callbacks are not executed parallel.
  28423. *
  28424. * @param eventData The data to be sent to each callback
  28425. * @param mask is used to filter observers defaults to -1
  28426. * @param target defines the callback target (see EventState)
  28427. * @param currentTarget defines he current object in the bubbling phase
  28428. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  28429. */
  28430. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  28431. /**
  28432. * Notify a specific observer
  28433. * @param observer defines the observer to notify
  28434. * @param eventData defines the data to be sent to each callback
  28435. * @param mask is used to filter observers defaults to -1
  28436. */
  28437. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  28438. /**
  28439. * Gets a boolean indicating if the observable has at least one observer
  28440. * @returns true is the Observable has at least one Observer registered
  28441. */
  28442. hasObservers(): boolean;
  28443. /**
  28444. * Clear the list of observers
  28445. */
  28446. clear(): void;
  28447. /**
  28448. * Clone the current observable
  28449. * @returns a new observable
  28450. */
  28451. clone(): Observable<T>;
  28452. /**
  28453. * Does this observable handles observer registered with a given mask
  28454. * @param mask defines the mask to be tested
  28455. * @return whether or not one observer registered with the given mask is handeled
  28456. **/
  28457. hasSpecificMask(mask?: number): boolean;
  28458. }
  28459. }
  28460. declare module BABYLON {
  28461. /**
  28462. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  28463. */
  28464. class PerformanceMonitor {
  28465. private _enabled;
  28466. private _rollingFrameTime;
  28467. private _lastFrameTimeMs;
  28468. /**
  28469. * constructor
  28470. * @param frameSampleSize The number of samples required to saturate the sliding window
  28471. */
  28472. constructor(frameSampleSize?: number);
  28473. /**
  28474. * Samples current frame
  28475. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  28476. */
  28477. sampleFrame(timeMs?: number): void;
  28478. /**
  28479. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  28480. * @return Average frame time in milliseconds
  28481. */
  28482. readonly averageFrameTime: number;
  28483. /**
  28484. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  28485. * @return Frame time variance in milliseconds squared
  28486. */
  28487. readonly averageFrameTimeVariance: number;
  28488. /**
  28489. * Returns the frame time of the most recent frame
  28490. * @return Frame time in milliseconds
  28491. */
  28492. readonly instantaneousFrameTime: number;
  28493. /**
  28494. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  28495. * @return Framerate in frames per second
  28496. */
  28497. readonly averageFPS: number;
  28498. /**
  28499. * Returns the average framerate in frames per second using the most recent frame time
  28500. * @return Framerate in frames per second
  28501. */
  28502. readonly instantaneousFPS: number;
  28503. /**
  28504. * Returns true if enough samples have been taken to completely fill the sliding window
  28505. * @return true if saturated
  28506. */
  28507. readonly isSaturated: boolean;
  28508. /**
  28509. * Enables contributions to the sliding window sample set
  28510. */
  28511. enable(): void;
  28512. /**
  28513. * Disables contributions to the sliding window sample set
  28514. * Samples will not be interpolated over the disabled period
  28515. */
  28516. disable(): void;
  28517. /**
  28518. * Returns true if sampling is enabled
  28519. * @return true if enabled
  28520. */
  28521. readonly isEnabled: boolean;
  28522. /**
  28523. * Resets performance monitor
  28524. */
  28525. reset(): void;
  28526. }
  28527. /**
  28528. * RollingAverage
  28529. *
  28530. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  28531. */
  28532. class RollingAverage {
  28533. /**
  28534. * Current average
  28535. */
  28536. average: number;
  28537. /**
  28538. * Current variance
  28539. */
  28540. variance: number;
  28541. protected _samples: Array<number>;
  28542. protected _sampleCount: number;
  28543. protected _pos: number;
  28544. protected _m2: number;
  28545. /**
  28546. * constructor
  28547. * @param length The number of samples required to saturate the sliding window
  28548. */
  28549. constructor(length: number);
  28550. /**
  28551. * Adds a sample to the sample set
  28552. * @param v The sample value
  28553. */
  28554. add(v: number): void;
  28555. /**
  28556. * Returns previously added values or null if outside of history or outside the sliding window domain
  28557. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  28558. * @return Value previously recorded with add() or null if outside of range
  28559. */
  28560. history(i: number): number;
  28561. /**
  28562. * Returns true if enough samples have been taken to completely fill the sliding window
  28563. * @return true if sample-set saturated
  28564. */
  28565. isSaturated(): boolean;
  28566. /**
  28567. * Resets the rolling average (equivalent to 0 samples taken so far)
  28568. */
  28569. reset(): void;
  28570. /**
  28571. * Wraps a value around the sample range boundaries
  28572. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  28573. * @return Wrapped position in sample range
  28574. */
  28575. protected _wrapPosition(i: number): number;
  28576. }
  28577. }
  28578. declare module BABYLON {
  28579. /**
  28580. * Helper class that provides a small promise polyfill
  28581. */
  28582. class PromisePolyfill {
  28583. /**
  28584. * Static function used to check if the polyfill is required
  28585. * If this is the case then the function will inject the polyfill to window.Promise
  28586. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  28587. */
  28588. static Apply(force?: boolean): void;
  28589. }
  28590. }
  28591. declare module BABYLON {
  28592. /**
  28593. * Defines the root class used to create scene optimization to use with SceneOptimizer
  28594. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  28595. */
  28596. class SceneOptimization {
  28597. /**
  28598. * Defines the priority of this optimization (0 by default which means first in the list)
  28599. */
  28600. priority: number;
  28601. /**
  28602. * Gets a string describing the action executed by the current optimization
  28603. * @returns description string
  28604. */
  28605. getDescription(): string;
  28606. /**
  28607. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  28608. * @param scene defines the current scene where to apply this optimization
  28609. * @param optimizer defines the current optimizer
  28610. * @returns true if everything that can be done was applied
  28611. */
  28612. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  28613. /**
  28614. * Creates the SceneOptimization object
  28615. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  28616. * @param desc defines the description associated with the optimization
  28617. */
  28618. constructor(
  28619. /**
  28620. * Defines the priority of this optimization (0 by default which means first in the list)
  28621. */
  28622. priority?: number);
  28623. }
  28624. /**
  28625. * Defines an optimization used to reduce the size of render target textures
  28626. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  28627. */
  28628. class TextureOptimization extends SceneOptimization {
  28629. /**
  28630. * Defines the priority of this optimization (0 by default which means first in the list)
  28631. */
  28632. priority: number;
  28633. /**
  28634. * 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
  28635. */
  28636. maximumSize: number;
  28637. /**
  28638. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  28639. */
  28640. step: number;
  28641. /**
  28642. * Gets a string describing the action executed by the current optimization
  28643. * @returns description string
  28644. */
  28645. getDescription(): string;
  28646. /**
  28647. * Creates the TextureOptimization object
  28648. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  28649. * @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
  28650. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  28651. */
  28652. constructor(
  28653. /**
  28654. * Defines the priority of this optimization (0 by default which means first in the list)
  28655. */
  28656. priority?: number,
  28657. /**
  28658. * 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
  28659. */
  28660. maximumSize?: number,
  28661. /**
  28662. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  28663. */
  28664. step?: number);
  28665. /**
  28666. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  28667. * @param scene defines the current scene where to apply this optimization
  28668. * @param optimizer defines the current optimizer
  28669. * @returns true if everything that can be done was applied
  28670. */
  28671. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  28672. }
  28673. /**
  28674. * Defines an optimization used to increase or decrease the rendering resolution
  28675. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  28676. */
  28677. class HardwareScalingOptimization extends SceneOptimization {
  28678. /**
  28679. * Defines the priority of this optimization (0 by default which means first in the list)
  28680. */
  28681. priority: number;
  28682. /**
  28683. * Defines the maximum scale to use (2 by default)
  28684. */
  28685. maximumScale: number;
  28686. /**
  28687. * Defines the step to use between two passes (0.5 by default)
  28688. */
  28689. step: number;
  28690. private _currentScale;
  28691. private _directionOffset;
  28692. /**
  28693. * Gets a string describing the action executed by the current optimization
  28694. * @return description string
  28695. */
  28696. getDescription(): string;
  28697. /**
  28698. * Creates the HardwareScalingOptimization object
  28699. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  28700. * @param maximumScale defines the maximum scale to use (2 by default)
  28701. * @param step defines the step to use between two passes (0.5 by default)
  28702. */
  28703. constructor(
  28704. /**
  28705. * Defines the priority of this optimization (0 by default which means first in the list)
  28706. */
  28707. priority?: number,
  28708. /**
  28709. * Defines the maximum scale to use (2 by default)
  28710. */
  28711. maximumScale?: number,
  28712. /**
  28713. * Defines the step to use between two passes (0.5 by default)
  28714. */
  28715. step?: number);
  28716. /**
  28717. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  28718. * @param scene defines the current scene where to apply this optimization
  28719. * @param optimizer defines the current optimizer
  28720. * @returns true if everything that can be done was applied
  28721. */
  28722. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  28723. }
  28724. /**
  28725. * Defines an optimization used to remove shadows
  28726. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  28727. */
  28728. class ShadowsOptimization extends SceneOptimization {
  28729. /**
  28730. * Gets a string describing the action executed by the current optimization
  28731. * @return description string
  28732. */
  28733. getDescription(): string;
  28734. /**
  28735. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  28736. * @param scene defines the current scene where to apply this optimization
  28737. * @param optimizer defines the current optimizer
  28738. * @returns true if everything that can be done was applied
  28739. */
  28740. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  28741. }
  28742. /**
  28743. * Defines an optimization used to turn post-processes off
  28744. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  28745. */
  28746. class PostProcessesOptimization extends SceneOptimization {
  28747. /**
  28748. * Gets a string describing the action executed by the current optimization
  28749. * @return description string
  28750. */
  28751. getDescription(): string;
  28752. /**
  28753. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  28754. * @param scene defines the current scene where to apply this optimization
  28755. * @param optimizer defines the current optimizer
  28756. * @returns true if everything that can be done was applied
  28757. */
  28758. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  28759. }
  28760. /**
  28761. * Defines an optimization used to turn lens flares off
  28762. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  28763. */
  28764. class LensFlaresOptimization extends SceneOptimization {
  28765. /**
  28766. * Gets a string describing the action executed by the current optimization
  28767. * @return description string
  28768. */
  28769. getDescription(): string;
  28770. /**
  28771. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  28772. * @param scene defines the current scene where to apply this optimization
  28773. * @param optimizer defines the current optimizer
  28774. * @returns true if everything that can be done was applied
  28775. */
  28776. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  28777. }
  28778. /**
  28779. * Defines an optimization based on user defined callback.
  28780. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  28781. */
  28782. class CustomOptimization extends SceneOptimization {
  28783. /**
  28784. * Callback called to apply the custom optimization.
  28785. */
  28786. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  28787. /**
  28788. * Callback called to get custom description
  28789. */
  28790. onGetDescription: () => string;
  28791. /**
  28792. * Gets a string describing the action executed by the current optimization
  28793. * @returns description string
  28794. */
  28795. getDescription(): string;
  28796. /**
  28797. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  28798. * @param scene defines the current scene where to apply this optimization
  28799. * @param optimizer defines the current optimizer
  28800. * @returns true if everything that can be done was applied
  28801. */
  28802. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  28803. }
  28804. /**
  28805. * Defines an optimization used to turn particles off
  28806. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  28807. */
  28808. class ParticlesOptimization extends SceneOptimization {
  28809. /**
  28810. * Gets a string describing the action executed by the current optimization
  28811. * @return description string
  28812. */
  28813. getDescription(): string;
  28814. /**
  28815. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  28816. * @param scene defines the current scene where to apply this optimization
  28817. * @param optimizer defines the current optimizer
  28818. * @returns true if everything that can be done was applied
  28819. */
  28820. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  28821. }
  28822. /**
  28823. * Defines an optimization used to turn render targets off
  28824. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  28825. */
  28826. class RenderTargetsOptimization extends SceneOptimization {
  28827. /**
  28828. * Gets a string describing the action executed by the current optimization
  28829. * @return description string
  28830. */
  28831. getDescription(): string;
  28832. /**
  28833. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  28834. * @param scene defines the current scene where to apply this optimization
  28835. * @param optimizer defines the current optimizer
  28836. * @returns true if everything that can be done was applied
  28837. */
  28838. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  28839. }
  28840. /**
  28841. * Defines an optimization used to merge meshes with compatible materials
  28842. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  28843. */
  28844. class MergeMeshesOptimization extends SceneOptimization {
  28845. private static _UpdateSelectionTree;
  28846. /**
  28847. * Gets or sets a boolean which defines if optimization octree has to be updated
  28848. */
  28849. /**
  28850. * Gets or sets a boolean which defines if optimization octree has to be updated
  28851. */
  28852. static UpdateSelectionTree: boolean;
  28853. /**
  28854. * Gets a string describing the action executed by the current optimization
  28855. * @return description string
  28856. */
  28857. getDescription(): string;
  28858. private _canBeMerged;
  28859. /**
  28860. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  28861. * @param scene defines the current scene where to apply this optimization
  28862. * @param optimizer defines the current optimizer
  28863. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  28864. * @returns true if everything that can be done was applied
  28865. */
  28866. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  28867. }
  28868. /**
  28869. * Defines a list of options used by SceneOptimizer
  28870. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  28871. */
  28872. class SceneOptimizerOptions {
  28873. /**
  28874. * Defines the target frame rate to reach (60 by default)
  28875. */
  28876. targetFrameRate: number;
  28877. /**
  28878. * Defines the interval between two checkes (2000ms by default)
  28879. */
  28880. trackerDuration: number;
  28881. /**
  28882. * Gets the list of optimizations to apply
  28883. */
  28884. optimizations: SceneOptimization[];
  28885. /**
  28886. * Creates a new list of options used by SceneOptimizer
  28887. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  28888. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  28889. */
  28890. constructor(
  28891. /**
  28892. * Defines the target frame rate to reach (60 by default)
  28893. */
  28894. targetFrameRate?: number,
  28895. /**
  28896. * Defines the interval between two checkes (2000ms by default)
  28897. */
  28898. trackerDuration?: number);
  28899. /**
  28900. * Add a new optimization
  28901. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  28902. * @returns the current SceneOptimizerOptions
  28903. */
  28904. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  28905. /**
  28906. * Add a new custom optimization
  28907. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  28908. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  28909. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  28910. * @returns the current SceneOptimizerOptions
  28911. */
  28912. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  28913. /**
  28914. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  28915. * @param targetFrameRate defines the target frame rate (60 by default)
  28916. * @returns a SceneOptimizerOptions object
  28917. */
  28918. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  28919. /**
  28920. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  28921. * @param targetFrameRate defines the target frame rate (60 by default)
  28922. * @returns a SceneOptimizerOptions object
  28923. */
  28924. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  28925. /**
  28926. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  28927. * @param targetFrameRate defines the target frame rate (60 by default)
  28928. * @returns a SceneOptimizerOptions object
  28929. */
  28930. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  28931. }
  28932. /**
  28933. * Class used to run optimizations in order to reach a target frame rate
  28934. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  28935. */
  28936. class SceneOptimizer implements IDisposable {
  28937. private _isRunning;
  28938. private _options;
  28939. private _scene;
  28940. private _currentPriorityLevel;
  28941. private _targetFrameRate;
  28942. private _trackerDuration;
  28943. private _currentFrameRate;
  28944. private _sceneDisposeObserver;
  28945. private _improvementMode;
  28946. /**
  28947. * Defines an observable called when the optimizer reaches the target frame rate
  28948. */
  28949. onSuccessObservable: Observable<SceneOptimizer>;
  28950. /**
  28951. * Defines an observable called when the optimizer enables an optimization
  28952. */
  28953. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  28954. /**
  28955. * Defines an observable called when the optimizer is not able to reach the target frame rate
  28956. */
  28957. onFailureObservable: Observable<SceneOptimizer>;
  28958. /**
  28959. * Gets a boolean indicating if the optimizer is in improvement mode
  28960. */
  28961. readonly isInImprovementMode: boolean;
  28962. /**
  28963. * Gets the current priority level (0 at start)
  28964. */
  28965. readonly currentPriorityLevel: number;
  28966. /**
  28967. * Gets the current frame rate checked by the SceneOptimizer
  28968. */
  28969. readonly currentFrameRate: number;
  28970. /**
  28971. * Gets or sets the current target frame rate (60 by default)
  28972. */
  28973. /**
  28974. * Gets or sets the current target frame rate (60 by default)
  28975. */
  28976. targetFrameRate: number;
  28977. /**
  28978. * Gets or sets the current interval between two checks (every 2000ms by default)
  28979. */
  28980. /**
  28981. * Gets or sets the current interval between two checks (every 2000ms by default)
  28982. */
  28983. trackerDuration: number;
  28984. /**
  28985. * Gets the list of active optimizations
  28986. */
  28987. readonly optimizations: SceneOptimization[];
  28988. /**
  28989. * Creates a new SceneOptimizer
  28990. * @param scene defines the scene to work on
  28991. * @param options defines the options to use with the SceneOptimizer
  28992. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  28993. * @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)
  28994. */
  28995. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  28996. /**
  28997. * Stops the current optimizer
  28998. */
  28999. stop(): void;
  29000. /**
  29001. * Reset the optimizer to initial step (current priority level = 0)
  29002. */
  29003. reset(): void;
  29004. /**
  29005. * Start the optimizer. By default it will try to reach a specific framerate
  29006. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  29007. */
  29008. start(): void;
  29009. private _checkCurrentState();
  29010. /**
  29011. * Release all resources
  29012. */
  29013. dispose(): void;
  29014. /**
  29015. * Helper function to create a SceneOptimizer with one single line of code
  29016. * @param scene defines the scene to work on
  29017. * @param options defines the options to use with the SceneOptimizer
  29018. * @param onSuccess defines a callback to call on success
  29019. * @param onFailure defines a callback to call on failure
  29020. * @returns the new SceneOptimizer object
  29021. */
  29022. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  29023. }
  29024. }
  29025. declare module BABYLON {
  29026. class SceneSerializer {
  29027. static ClearCache(): void;
  29028. static Serialize(scene: Scene): any;
  29029. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  29030. }
  29031. }
  29032. declare module BABYLON {
  29033. class SmartArray<T> {
  29034. data: Array<T>;
  29035. length: number;
  29036. protected _id: number;
  29037. [index: number]: T;
  29038. constructor(capacity: number);
  29039. push(value: T): void;
  29040. forEach(func: (content: T) => void): void;
  29041. sort(compareFn: (a: T, b: T) => number): void;
  29042. reset(): void;
  29043. dispose(): void;
  29044. concat(array: any): void;
  29045. indexOf(value: T): number;
  29046. contains(value: T): boolean;
  29047. private static _GlobalId;
  29048. }
  29049. class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  29050. private _duplicateId;
  29051. [index: number]: T;
  29052. push(value: T): void;
  29053. pushNoDuplicate(value: T): boolean;
  29054. reset(): void;
  29055. concatWithNoDuplicate(array: any): void;
  29056. }
  29057. }
  29058. declare module BABYLON {
  29059. /**
  29060. * This class implement a typical dictionary using a string as key and the generic type T as value.
  29061. * The underlying implementation relies on an associative array to ensure the best performances.
  29062. * The value can be anything including 'null' but except 'undefined'
  29063. */
  29064. class StringDictionary<T> {
  29065. /**
  29066. * This will clear this dictionary and copy the content from the 'source' one.
  29067. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  29068. * @param source the dictionary to take the content from and copy to this dictionary
  29069. */
  29070. copyFrom(source: StringDictionary<T>): void;
  29071. /**
  29072. * Get a value based from its key
  29073. * @param key the given key to get the matching value from
  29074. * @return the value if found, otherwise undefined is returned
  29075. */
  29076. get(key: string): T | undefined;
  29077. /**
  29078. * Get a value from its key or add it if it doesn't exist.
  29079. * This method will ensure you that a given key/data will be present in the dictionary.
  29080. * @param key the given key to get the matching value from
  29081. * @param factory the factory that will create the value if the key is not present in the dictionary.
  29082. * The factory will only be invoked if there's no data for the given key.
  29083. * @return the value corresponding to the key.
  29084. */
  29085. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  29086. /**
  29087. * Get a value from its key if present in the dictionary otherwise add it
  29088. * @param key the key to get the value from
  29089. * @param val if there's no such key/value pair in the dictionary add it with this value
  29090. * @return the value corresponding to the key
  29091. */
  29092. getOrAdd(key: string, val: T): T;
  29093. /**
  29094. * Check if there's a given key in the dictionary
  29095. * @param key the key to check for
  29096. * @return true if the key is present, false otherwise
  29097. */
  29098. contains(key: string): boolean;
  29099. /**
  29100. * Add a new key and its corresponding value
  29101. * @param key the key to add
  29102. * @param value the value corresponding to the key
  29103. * @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
  29104. */
  29105. add(key: string, value: T): boolean;
  29106. set(key: string, value: T): boolean;
  29107. /**
  29108. * Get the element of the given key and remove it from the dictionary
  29109. * @param key
  29110. */
  29111. getAndRemove(key: string): Nullable<T>;
  29112. /**
  29113. * Remove a key/value from the dictionary.
  29114. * @param key the key to remove
  29115. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  29116. */
  29117. remove(key: string): boolean;
  29118. /**
  29119. * Clear the whole content of the dictionary
  29120. */
  29121. clear(): void;
  29122. readonly count: number;
  29123. /**
  29124. * Execute a callback on each key/val of the dictionary.
  29125. * Note that you can remove any element in this dictionary in the callback implementation
  29126. * @param callback the callback to execute on a given key/value pair
  29127. */
  29128. forEach(callback: (key: string, val: T) => void): void;
  29129. /**
  29130. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  29131. * If the callback returns null or undefined the method will iterate to the next key/value pair
  29132. * Note that you can remove any element in this dictionary in the callback implementation
  29133. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  29134. */
  29135. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  29136. private _count;
  29137. private _data;
  29138. }
  29139. }
  29140. declare module BABYLON {
  29141. class Tags {
  29142. static EnableFor(obj: any): void;
  29143. static DisableFor(obj: any): void;
  29144. static HasTags(obj: any): boolean;
  29145. static GetTags(obj: any, asString?: boolean): any;
  29146. static AddTagsTo(obj: any, tagsString: string): void;
  29147. private static _AddTagTo(obj: any, tag: string): void;
  29148. static RemoveTagsFrom(obj: any, tagsString: string): void;
  29149. private static _RemoveTagFrom(obj: any, tag: string): void;
  29150. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  29151. }
  29152. }
  29153. declare module BABYLON {
  29154. class TextureTools {
  29155. /**
  29156. * Uses the GPU to create a copy texture rescaled at a given size
  29157. * @param texture Texture to copy from
  29158. * @param width Desired width
  29159. * @param height Desired height
  29160. * @return Generated texture
  29161. */
  29162. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  29163. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  29164. private static _environmentBRDFBase64Texture;
  29165. }
  29166. }
  29167. declare module BABYLON {
  29168. class TGATools {
  29169. private static _TYPE_INDEXED;
  29170. private static _TYPE_RGB;
  29171. private static _TYPE_GREY;
  29172. private static _TYPE_RLE_INDEXED;
  29173. private static _TYPE_RLE_RGB;
  29174. private static _TYPE_RLE_GREY;
  29175. private static _ORIGIN_MASK;
  29176. private static _ORIGIN_SHIFT;
  29177. private static _ORIGIN_BL;
  29178. private static _ORIGIN_BR;
  29179. private static _ORIGIN_UL;
  29180. private static _ORIGIN_UR;
  29181. static GetTGAHeader(data: Uint8Array): any;
  29182. static UploadContent(gl: WebGLRenderingContext, data: Uint8Array): void;
  29183. 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;
  29184. 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;
  29185. 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;
  29186. 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;
  29187. 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;
  29188. 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;
  29189. }
  29190. }
  29191. declare module BABYLON {
  29192. interface IAnimatable {
  29193. animations: Array<Animation>;
  29194. }
  29195. /** Interface used by value gradients (color, factor, ...) */
  29196. interface IValueGradient {
  29197. /**
  29198. * Gets or sets the gradient value (between 0 and 1)
  29199. */
  29200. gradient: number;
  29201. }
  29202. /** Class used to store color gradient */
  29203. class ColorGradient implements IValueGradient {
  29204. /**
  29205. * Gets or sets the gradient value (between 0 and 1)
  29206. */
  29207. gradient: number;
  29208. /**
  29209. * Gets or sets associated color
  29210. */
  29211. color: Color4;
  29212. }
  29213. /** Class used to store factor gradient */
  29214. class FactorGradient implements IValueGradient {
  29215. /**
  29216. * Gets or sets the gradient value (between 0 and 1)
  29217. */
  29218. gradient: number;
  29219. /**
  29220. * Gets or sets associated factor
  29221. */
  29222. factor: number;
  29223. }
  29224. class LoadFileError extends Error {
  29225. request: XMLHttpRequest | undefined;
  29226. private static _setPrototypeOf;
  29227. constructor(message: string, request?: XMLHttpRequest | undefined);
  29228. }
  29229. class RetryStrategy {
  29230. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  29231. }
  29232. interface IFileRequest {
  29233. /**
  29234. * Raised when the request is complete (success or error).
  29235. */
  29236. onCompleteObservable: Observable<IFileRequest>;
  29237. /**
  29238. * Aborts the request for a file.
  29239. */
  29240. abort: () => void;
  29241. }
  29242. class Tools {
  29243. static BaseUrl: string;
  29244. static DefaultRetryStrategy: (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  29245. /**
  29246. * Default behaviour for cors in the application.
  29247. * It can be a string if the expected behavior is identical in the entire app.
  29248. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  29249. */
  29250. static CorsBehavior: string | ((url: string | string[]) => string);
  29251. static UseFallbackTexture: boolean;
  29252. /**
  29253. * Use this object to register external classes like custom textures or material
  29254. * to allow the laoders to instantiate them
  29255. */
  29256. static RegisteredExternalClasses: {
  29257. [key: string]: Object;
  29258. };
  29259. static fallbackTexture: string;
  29260. /**
  29261. * Interpolates between a and b via alpha
  29262. * @param a The lower value (returned when alpha = 0)
  29263. * @param b The upper value (returned when alpha = 1)
  29264. * @param alpha The interpolation-factor
  29265. * @return The mixed value
  29266. */
  29267. static Mix(a: number, b: number, alpha: number): number;
  29268. static Instantiate(className: string): any;
  29269. /**
  29270. * Provides a slice function that will work even on IE
  29271. * @param data defines the array to slice
  29272. * @param start defines the start of the data (optional)
  29273. * @param end defines the end of the data (optional)
  29274. * @returns the new sliced array
  29275. */
  29276. static Slice<T>(data: T, start?: number, end?: number): T;
  29277. static SetImmediate(action: () => void): void;
  29278. static IsExponentOfTwo(value: number): boolean;
  29279. private static _tmpFloatArray;
  29280. /**
  29281. * Returns the nearest 32-bit single precision float representation of a Number
  29282. * @param value A Number. If the parameter is of a different type, it will get converted
  29283. * to a number or to NaN if it cannot be converted
  29284. * @returns number
  29285. */
  29286. static FloatRound(value: number): number;
  29287. /**
  29288. * Find the next highest power of two.
  29289. * @param x Number to start search from.
  29290. * @return Next highest power of two.
  29291. */
  29292. static CeilingPOT(x: number): number;
  29293. /**
  29294. * Find the next lowest power of two.
  29295. * @param x Number to start search from.
  29296. * @return Next lowest power of two.
  29297. */
  29298. static FloorPOT(x: number): number;
  29299. /**
  29300. * Find the nearest power of two.
  29301. * @param x Number to start search from.
  29302. * @return Next nearest power of two.
  29303. */
  29304. static NearestPOT(x: number): number;
  29305. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  29306. static GetFilename(path: string): string;
  29307. /**
  29308. * Extracts the "folder" part of a path (everything before the filename).
  29309. * @param uri The URI to extract the info from
  29310. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  29311. * @returns The "folder" part of the path
  29312. */
  29313. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  29314. static GetDOMTextContent(element: HTMLElement): string;
  29315. static ToDegrees(angle: number): number;
  29316. static ToRadians(angle: number): number;
  29317. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  29318. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  29319. minimum: Vector3;
  29320. maximum: Vector3;
  29321. };
  29322. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  29323. minimum: Vector3;
  29324. maximum: Vector3;
  29325. };
  29326. static Vector2ArrayFeeder(array: Array<Vector2> | Float32Array): (i: number) => Nullable<Vector2>;
  29327. static ExtractMinAndMaxVector2(feeder: (index: number) => Vector2, bias?: Nullable<Vector2>): {
  29328. minimum: Vector2;
  29329. maximum: Vector2;
  29330. };
  29331. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  29332. static GetPointerPrefix(): string;
  29333. /**
  29334. * @param func - the function to be called
  29335. * @param requester - the object that will request the next frame. Falls back to window.
  29336. */
  29337. static QueueNewFrame(func: () => void, requester?: any): number;
  29338. static RequestFullscreen(element: HTMLElement): void;
  29339. static ExitFullscreen(): void;
  29340. static SetCorsBehavior(url: string | string[], element: {
  29341. crossOrigin: string | null;
  29342. }): void;
  29343. static CleanUrl(url: string): string;
  29344. static PreprocessUrl: (url: string) => string;
  29345. /**
  29346. * Loads an image as an HTMLImageElement.
  29347. * @param input url string, ArrayBuffer, or Blob to load
  29348. * @param onLoad callback called when the image successfully loads
  29349. * @param onError callback called when the image fails to load
  29350. * @param database database for caching
  29351. * @returns the HTMLImageElement of the loaded image
  29352. */
  29353. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, database: Nullable<Database>): HTMLImageElement;
  29354. 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;
  29355. /**
  29356. * Load a script (identified by an url). When the url returns, the
  29357. * content of this file is added into a new script element, attached to the DOM (body element)
  29358. */
  29359. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void): void;
  29360. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  29361. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  29362. static FileAsURL(content: string): string;
  29363. static Format(value: number, decimals?: number): string;
  29364. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  29365. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  29366. static IsEmpty(obj: any): boolean;
  29367. static RegisterTopRootEvents(events: {
  29368. name: string;
  29369. handler: Nullable<(e: FocusEvent) => any>;
  29370. }[]): void;
  29371. static UnregisterTopRootEvents(events: {
  29372. name: string;
  29373. handler: Nullable<(e: FocusEvent) => any>;
  29374. }[]): void;
  29375. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  29376. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  29377. /**
  29378. * Downloads a blob in the browser
  29379. * @param blob defines the blob to download
  29380. * @param fileName defines the name of the downloaded file
  29381. */
  29382. static Download(blob: Blob, fileName: string): void;
  29383. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  29384. /**
  29385. * Generates an image screenshot from the specified camera.
  29386. *
  29387. * @param engine The engine to use for rendering
  29388. * @param camera The camera to use for rendering
  29389. * @param size This parameter can be set to a single number or to an object with the
  29390. * following (optional) properties: precision, width, height. If a single number is passed,
  29391. * it will be used for both width and height. If an object is passed, the screenshot size
  29392. * will be derived from the parameters. The precision property is a multiplier allowing
  29393. * rendering at a higher or lower resolution.
  29394. * @param successCallback The callback receives a single parameter which contains the
  29395. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  29396. * src parameter of an <img> to display it.
  29397. * @param mimeType The MIME type of the screenshot image (default: image/png).
  29398. * Check your browser for supported MIME types.
  29399. * @param samples Texture samples (default: 1)
  29400. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  29401. * @param fileName A name for for the downloaded file.
  29402. * @constructor
  29403. */
  29404. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  29405. static ValidateXHRData(xhr: XMLHttpRequest, dataType?: number): boolean;
  29406. /**
  29407. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  29408. * Be aware Math.random() could cause collisions, but:
  29409. * "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"
  29410. */
  29411. static RandomId(): string;
  29412. /**
  29413. * Test if the given uri is a base64 string.
  29414. * @param uri The uri to test
  29415. * @return True if the uri is a base64 string or false otherwise.
  29416. */
  29417. static IsBase64(uri: string): boolean;
  29418. /**
  29419. * Decode the given base64 uri.
  29420. * @param uri The uri to decode
  29421. * @return The decoded base64 data.
  29422. */
  29423. static DecodeBase64(uri: string): ArrayBuffer;
  29424. private static _NoneLogLevel;
  29425. private static _MessageLogLevel;
  29426. private static _WarningLogLevel;
  29427. private static _ErrorLogLevel;
  29428. private static _LogCache;
  29429. static errorsCount: number;
  29430. static OnNewCacheEntry: (entry: string) => void;
  29431. static readonly NoneLogLevel: number;
  29432. static readonly MessageLogLevel: number;
  29433. static readonly WarningLogLevel: number;
  29434. static readonly ErrorLogLevel: number;
  29435. static readonly AllLogLevel: number;
  29436. private static _AddLogEntry(entry);
  29437. private static _FormatMessage(message);
  29438. private static _LogDisabled(message);
  29439. private static _LogEnabled(message);
  29440. private static _WarnDisabled(message);
  29441. private static _WarnEnabled(message);
  29442. private static _ErrorDisabled(message);
  29443. private static _ErrorEnabled(message);
  29444. static Log: (message: string) => void;
  29445. static Warn: (message: string) => void;
  29446. static Error: (message: string) => void;
  29447. static readonly LogCache: string;
  29448. static ClearLogCache(): void;
  29449. static LogLevels: number;
  29450. static IsWindowObjectExist(): boolean;
  29451. private static _PerformanceNoneLogLevel;
  29452. private static _PerformanceUserMarkLogLevel;
  29453. private static _PerformanceConsoleLogLevel;
  29454. private static _performance;
  29455. static readonly PerformanceNoneLogLevel: number;
  29456. static readonly PerformanceUserMarkLogLevel: number;
  29457. static readonly PerformanceConsoleLogLevel: number;
  29458. static PerformanceLogLevel: number;
  29459. private static _StartPerformanceCounterDisabled(counterName: string, condition?: boolean): void;
  29460. private static _EndPerformanceCounterDisabled(counterName: string, condition?: boolean): void;
  29461. private static _StartUserMark(counterName: string, condition?: boolean): void;
  29462. private static _EndUserMark(counterName: string, condition?: boolean): void;
  29463. private static _StartPerformanceConsole(counterName: string, condition?: boolean): void;
  29464. private static _EndPerformanceConsole(counterName: string, condition?: boolean): void;
  29465. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  29466. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  29467. static readonly Now: number;
  29468. /**
  29469. * This method will return the name of the class used to create the instance of the given object.
  29470. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  29471. * @param object the object to get the class name from
  29472. * @return the name of the class, will be "object" for a custom data type not using the @className decorator
  29473. */
  29474. static GetClassName(object: any, isType?: boolean): string;
  29475. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  29476. /**
  29477. * This method will return the name of the full name of the class, including its owning module (if any).
  29478. * 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).
  29479. * @param object the object to get the class name from
  29480. * @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.
  29481. */
  29482. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  29483. /**
  29484. * This method can be used with hashCodeFromStream when your input is an array of values that are either: number, string, boolean or custom type implementing the getHashCode():number method.
  29485. * @param array
  29486. */
  29487. static arrayOrStringFeeder(array: any): (i: number) => number;
  29488. /**
  29489. * Compute the hashCode of a stream of number
  29490. * To compute the HashCode on a string or an Array of data types implementing the getHashCode() method, use the arrayOrStringFeeder method.
  29491. * @param feeder a callback that will be called until it returns null, each valid returned values will be used to compute the hash code.
  29492. * @return the hash code computed
  29493. */
  29494. static hashCodeFromStream(feeder: (index: number) => number): number;
  29495. /**
  29496. * Returns a promise that resolves after the given amount of time.
  29497. * @param delay Number of milliseconds to delay
  29498. * @returns Promise that resolves after the given amount of time
  29499. */
  29500. static DelayAsync(delay: number): Promise<void>;
  29501. /**
  29502. * Gets the current gradient from an array of IValueGradient
  29503. * @param ratio defines the current ratio to get
  29504. * @param gradients defines the array of IValueGradient
  29505. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  29506. */
  29507. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  29508. }
  29509. /**
  29510. * This class is used to track a performance counter which is number based.
  29511. * The user has access to many properties which give statistics of different nature
  29512. *
  29513. * The implementer can track two kinds of Performance Counter: time and count
  29514. * 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.
  29515. * 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.
  29516. */
  29517. class PerfCounter {
  29518. static Enabled: boolean;
  29519. /**
  29520. * Returns the smallest value ever
  29521. */
  29522. readonly min: number;
  29523. /**
  29524. * Returns the biggest value ever
  29525. */
  29526. readonly max: number;
  29527. /**
  29528. * Returns the average value since the performance counter is running
  29529. */
  29530. readonly average: number;
  29531. /**
  29532. * Returns the average value of the last second the counter was monitored
  29533. */
  29534. readonly lastSecAverage: number;
  29535. /**
  29536. * Returns the current value
  29537. */
  29538. readonly current: number;
  29539. readonly total: number;
  29540. readonly count: number;
  29541. constructor();
  29542. /**
  29543. * Call this method to start monitoring a new frame.
  29544. * 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.
  29545. */
  29546. fetchNewFrame(): void;
  29547. /**
  29548. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  29549. * @param newCount the count value to add to the monitored count
  29550. * @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.
  29551. */
  29552. addCount(newCount: number, fetchResult: boolean): void;
  29553. /**
  29554. * Start monitoring this performance counter
  29555. */
  29556. beginMonitoring(): void;
  29557. /**
  29558. * Compute the time lapsed since the previous beginMonitoring() call.
  29559. * @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
  29560. */
  29561. endMonitoring(newFrame?: boolean): void;
  29562. private _fetchResult();
  29563. private _startMonitoringTime;
  29564. private _min;
  29565. private _max;
  29566. private _average;
  29567. private _current;
  29568. private _totalValueCount;
  29569. private _totalAccumulated;
  29570. private _lastSecAverage;
  29571. private _lastSecAccumulated;
  29572. private _lastSecTime;
  29573. private _lastSecValueCount;
  29574. }
  29575. /**
  29576. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  29577. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  29578. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  29579. * @param name The name of the class, case should be preserved
  29580. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  29581. */
  29582. function className(name: string, module?: string): (target: Object) => void;
  29583. /**
  29584. * An implementation of a loop for asynchronous functions.
  29585. */
  29586. class AsyncLoop {
  29587. iterations: number;
  29588. private _fn;
  29589. private _successCallback;
  29590. index: number;
  29591. private _done;
  29592. /**
  29593. * Constroctor.
  29594. * @param iterations the number of iterations.
  29595. * @param _fn the function to run each iteration
  29596. * @param _successCallback the callback that will be called upon succesful execution
  29597. * @param offset starting offset.
  29598. */
  29599. constructor(iterations: number, _fn: (asyncLoop: AsyncLoop) => void, _successCallback: () => void, offset?: number);
  29600. /**
  29601. * Execute the next iteration. Must be called after the last iteration was finished.
  29602. */
  29603. executeNext(): void;
  29604. /**
  29605. * Break the loop and run the success callback.
  29606. */
  29607. breakLoop(): void;
  29608. /**
  29609. * Helper function
  29610. */
  29611. static Run(iterations: number, _fn: (asyncLoop: AsyncLoop) => void, _successCallback: () => void, offset?: number): AsyncLoop;
  29612. /**
  29613. * A for-loop that will run a given number of iterations synchronous and the rest async.
  29614. * @param iterations total number of iterations
  29615. * @param syncedIterations number of synchronous iterations in each async iteration.
  29616. * @param fn the function to call each iteration.
  29617. * @param callback a success call back that will be called when iterating stops.
  29618. * @param breakFunction a break condition (optional)
  29619. * @param timeout timeout settings for the setTimeout function. default - 0.
  29620. * @constructor
  29621. */
  29622. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): void;
  29623. }
  29624. }
  29625. declare module BABYLON {
  29626. /**
  29627. * Defines the potential axis of a Joystick
  29628. */
  29629. enum JoystickAxis {
  29630. /** X axis */
  29631. X = 0,
  29632. /** Y axis */
  29633. Y = 1,
  29634. /** Z axis */
  29635. Z = 2,
  29636. }
  29637. /**
  29638. * Class used to define virtual joystick (used in touch mode)
  29639. */
  29640. class VirtualJoystick {
  29641. /**
  29642. * Gets or sets a boolean indicating that left and right values must be inverted
  29643. */
  29644. reverseLeftRight: boolean;
  29645. /**
  29646. * Gets or sets a boolean indicating that up and down values must be inverted
  29647. */
  29648. reverseUpDown: boolean;
  29649. /**
  29650. * Gets the offset value for the position (ie. the change of the position value)
  29651. */
  29652. deltaPosition: Vector3;
  29653. /**
  29654. * Gets a boolean indicating if the virtual joystick was pressed
  29655. */
  29656. pressed: boolean;
  29657. private static _globalJoystickIndex;
  29658. private static vjCanvas;
  29659. private static vjCanvasContext;
  29660. private static vjCanvasWidth;
  29661. private static vjCanvasHeight;
  29662. private static halfWidth;
  29663. private _action;
  29664. private _axisTargetedByLeftAndRight;
  29665. private _axisTargetedByUpAndDown;
  29666. private _joystickSensibility;
  29667. private _inversedSensibility;
  29668. private _joystickPointerID;
  29669. private _joystickColor;
  29670. private _joystickPointerPos;
  29671. private _joystickPreviousPointerPos;
  29672. private _joystickPointerStartPos;
  29673. private _deltaJoystickVector;
  29674. private _leftJoystick;
  29675. private _touches;
  29676. private _onPointerDownHandlerRef;
  29677. private _onPointerMoveHandlerRef;
  29678. private _onPointerUpHandlerRef;
  29679. private _onResize;
  29680. /**
  29681. * Creates a new virtual joystick
  29682. * @param leftJoystick defines that the joystick is for left hand (false by default)
  29683. */
  29684. constructor(leftJoystick?: boolean);
  29685. /**
  29686. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  29687. * @param newJoystickSensibility defines the new sensibility
  29688. */
  29689. setJoystickSensibility(newJoystickSensibility: number): void;
  29690. private _onPointerDown(e);
  29691. private _onPointerMove(e);
  29692. private _onPointerUp(e);
  29693. /**
  29694. * Change the color of the virtual joystick
  29695. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  29696. */
  29697. setJoystickColor(newColor: string): void;
  29698. /**
  29699. * Defines a callback to call when the joystick is touched
  29700. * @param action defines the callback
  29701. */
  29702. setActionOnTouch(action: () => any): void;
  29703. /**
  29704. * Defines which axis you'd like to control for left & right
  29705. * @param axis defines the axis to use
  29706. */
  29707. setAxisForLeftRight(axis: JoystickAxis): void;
  29708. /**
  29709. * Defines which axis you'd like to control for up & down
  29710. * @param axis defines the axis to use
  29711. */
  29712. setAxisForUpDown(axis: JoystickAxis): void;
  29713. private _drawVirtualJoystick();
  29714. /**
  29715. * Release internal HTML canvas
  29716. */
  29717. releaseCanvas(): void;
  29718. }
  29719. }
  29720. declare module BABYLON {
  29721. /**
  29722. * Helper class to push actions to a pool of workers.
  29723. */
  29724. class WorkerPool implements IDisposable {
  29725. private _workerInfos;
  29726. private _pendingActions;
  29727. /**
  29728. * Constructor
  29729. * @param workers Array of workers to use for actions
  29730. */
  29731. constructor(workers: Array<Worker>);
  29732. /**
  29733. * Terminates all workers and clears any pending actions.
  29734. */
  29735. dispose(): void;
  29736. /**
  29737. * Pushes an action to the worker pool. If all the workers are active, the action will be
  29738. * pended until a worker has completed its action.
  29739. * @param action The action to perform. Call onComplete when the action is complete.
  29740. */
  29741. push(action: (worker: Worker, onComplete: () => void) => void): void;
  29742. private _execute(workerInfo, action);
  29743. }
  29744. }
  29745. declare module BABYLON {
  29746. class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  29747. readonly name: string;
  29748. private _zoomStopsAnimation;
  29749. private _idleRotationSpeed;
  29750. private _idleRotationWaitTime;
  29751. private _idleRotationSpinupTime;
  29752. /**
  29753. * Gets the flag that indicates if user zooming should stop animation.
  29754. */
  29755. /**
  29756. * Sets the flag that indicates if user zooming should stop animation.
  29757. */
  29758. zoomStopsAnimation: boolean;
  29759. /**
  29760. * Gets the default speed at which the camera rotates around the model.
  29761. */
  29762. /**
  29763. * Sets the default speed at which the camera rotates around the model.
  29764. */
  29765. idleRotationSpeed: number;
  29766. /**
  29767. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  29768. */
  29769. /**
  29770. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  29771. */
  29772. idleRotationWaitTime: number;
  29773. /**
  29774. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  29775. */
  29776. /**
  29777. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  29778. */
  29779. idleRotationSpinupTime: number;
  29780. /**
  29781. * Gets a value indicating if the camera is currently rotating because of this behavior
  29782. */
  29783. readonly rotationInProgress: boolean;
  29784. private _onPrePointerObservableObserver;
  29785. private _onAfterCheckInputsObserver;
  29786. private _attachedCamera;
  29787. private _isPointerDown;
  29788. private _lastFrameTime;
  29789. private _lastInteractionTime;
  29790. private _cameraRotationSpeed;
  29791. init(): void;
  29792. attach(camera: ArcRotateCamera): void;
  29793. detach(): void;
  29794. /**
  29795. * Returns true if user is scrolling.
  29796. * @return true if user is scrolling.
  29797. */
  29798. private _userIsZooming();
  29799. private _lastFrameRadius;
  29800. private _shouldAnimationStopForInteraction();
  29801. /**
  29802. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  29803. */
  29804. private _applyUserInteraction();
  29805. private _userIsMoving();
  29806. }
  29807. }
  29808. declare module BABYLON {
  29809. /**
  29810. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  29811. */
  29812. class BouncingBehavior implements Behavior<ArcRotateCamera> {
  29813. readonly name: string;
  29814. /**
  29815. * The easing function used by animations
  29816. */
  29817. static EasingFunction: BackEase;
  29818. /**
  29819. * The easing mode used by animations
  29820. */
  29821. static EasingMode: number;
  29822. /**
  29823. * The duration of the animation, in milliseconds
  29824. */
  29825. transitionDuration: number;
  29826. /**
  29827. * Length of the distance animated by the transition when lower radius is reached
  29828. */
  29829. lowerRadiusTransitionRange: number;
  29830. /**
  29831. * Length of the distance animated by the transition when upper radius is reached
  29832. */
  29833. upperRadiusTransitionRange: number;
  29834. private _autoTransitionRange;
  29835. /**
  29836. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  29837. */
  29838. /**
  29839. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  29840. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  29841. */
  29842. autoTransitionRange: boolean;
  29843. private _attachedCamera;
  29844. private _onAfterCheckInputsObserver;
  29845. private _onMeshTargetChangedObserver;
  29846. init(): void;
  29847. attach(camera: ArcRotateCamera): void;
  29848. detach(): void;
  29849. private _radiusIsAnimating;
  29850. private _radiusBounceTransition;
  29851. private _animatables;
  29852. private _cachedWheelPrecision;
  29853. /**
  29854. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  29855. * @param radiusLimit The limit to check against.
  29856. * @return Bool to indicate if at limit.
  29857. */
  29858. private _isRadiusAtLimit(radiusLimit);
  29859. /**
  29860. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  29861. * @param radiusDelta The delta by which to animate to. Can be negative.
  29862. */
  29863. private _applyBoundRadiusAnimation(radiusDelta);
  29864. /**
  29865. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  29866. */
  29867. protected _clearAnimationLocks(): void;
  29868. /**
  29869. * Stops and removes all animations that have been applied to the camera
  29870. */
  29871. stopAllAnimations(): void;
  29872. }
  29873. }
  29874. declare module BABYLON {
  29875. class FramingBehavior implements Behavior<ArcRotateCamera> {
  29876. readonly name: string;
  29877. private _mode;
  29878. private _radiusScale;
  29879. private _positionScale;
  29880. private _defaultElevation;
  29881. private _elevationReturnTime;
  29882. private _elevationReturnWaitTime;
  29883. private _zoomStopsAnimation;
  29884. private _framingTime;
  29885. /**
  29886. * The easing function used by animations
  29887. */
  29888. static EasingFunction: ExponentialEase;
  29889. /**
  29890. * The easing mode used by animations
  29891. */
  29892. static EasingMode: number;
  29893. /**
  29894. * Gets current mode used by the behavior.
  29895. */
  29896. /**
  29897. * Sets the current mode used by the behavior
  29898. */
  29899. mode: number;
  29900. /**
  29901. * Gets the scale applied to the radius
  29902. */
  29903. /**
  29904. * Sets the scale applied to the radius (1 by default)
  29905. */
  29906. radiusScale: number;
  29907. /**
  29908. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  29909. */
  29910. /**
  29911. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  29912. */
  29913. positionScale: number;
  29914. /**
  29915. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  29916. * behaviour is triggered, in radians.
  29917. */
  29918. /**
  29919. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  29920. * behaviour is triggered, in radians.
  29921. */
  29922. defaultElevation: number;
  29923. /**
  29924. * Gets the time (in milliseconds) taken to return to the default beta position.
  29925. * Negative value indicates camera should not return to default.
  29926. */
  29927. /**
  29928. * Sets the time (in milliseconds) taken to return to the default beta position.
  29929. * Negative value indicates camera should not return to default.
  29930. */
  29931. elevationReturnTime: number;
  29932. /**
  29933. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  29934. */
  29935. /**
  29936. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  29937. */
  29938. elevationReturnWaitTime: number;
  29939. /**
  29940. * Gets the flag that indicates if user zooming should stop animation.
  29941. */
  29942. /**
  29943. * Sets the flag that indicates if user zooming should stop animation.
  29944. */
  29945. zoomStopsAnimation: boolean;
  29946. /**
  29947. * Gets the transition time when framing the mesh, in milliseconds
  29948. */
  29949. /**
  29950. * Sets the transition time when framing the mesh, in milliseconds
  29951. */
  29952. framingTime: number;
  29953. private _onPrePointerObservableObserver;
  29954. private _onAfterCheckInputsObserver;
  29955. private _onMeshTargetChangedObserver;
  29956. private _attachedCamera;
  29957. private _isPointerDown;
  29958. private _lastInteractionTime;
  29959. init(): void;
  29960. attach(camera: ArcRotateCamera): void;
  29961. detach(): void;
  29962. private _animatables;
  29963. private _betaIsAnimating;
  29964. private _betaTransition;
  29965. private _radiusTransition;
  29966. private _vectorTransition;
  29967. /**
  29968. * Targets the given mesh and updates zoom level accordingly.
  29969. * @param mesh The mesh to target.
  29970. * @param radius Optional. If a cached radius position already exists, overrides default.
  29971. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  29972. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  29973. * @param onAnimationEnd Callback triggered at the end of the framing animation
  29974. */
  29975. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  29976. /**
  29977. * Targets the given mesh with its children and updates zoom level accordingly.
  29978. * @param mesh The mesh to target.
  29979. * @param radius Optional. If a cached radius position already exists, overrides default.
  29980. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  29981. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  29982. * @param onAnimationEnd Callback triggered at the end of the framing animation
  29983. */
  29984. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  29985. /**
  29986. * Targets the given meshes with their children and updates zoom level accordingly.
  29987. * @param meshes The mesh to target.
  29988. * @param radius Optional. If a cached radius position already exists, overrides default.
  29989. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  29990. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  29991. * @param onAnimationEnd Callback triggered at the end of the framing animation
  29992. */
  29993. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  29994. /**
  29995. * Targets the given mesh and updates zoom level accordingly.
  29996. * @param mesh The mesh to target.
  29997. * @param radius Optional. If a cached radius position already exists, overrides default.
  29998. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  29999. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  30000. * @param onAnimationEnd Callback triggered at the end of the framing animation
  30001. */
  30002. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  30003. /**
  30004. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  30005. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  30006. * frustum width.
  30007. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  30008. * to fully enclose the mesh in the viewing frustum.
  30009. */
  30010. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  30011. /**
  30012. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  30013. * is automatically returned to its default position (expected to be above ground plane).
  30014. */
  30015. private _maintainCameraAboveGround();
  30016. /**
  30017. * Returns the frustum slope based on the canvas ratio and camera FOV
  30018. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  30019. */
  30020. private _getFrustumSlope();
  30021. /**
  30022. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  30023. */
  30024. private _clearAnimationLocks();
  30025. /**
  30026. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  30027. */
  30028. private _applyUserInteraction();
  30029. /**
  30030. * Stops and removes all animations that have been applied to the camera
  30031. */
  30032. stopAllAnimations(): void;
  30033. /**
  30034. * Gets a value indicating if the user is moving the camera
  30035. */
  30036. readonly isUserIsMoving: boolean;
  30037. /**
  30038. * The camera can move all the way towards the mesh.
  30039. */
  30040. static IgnoreBoundsSizeMode: number;
  30041. /**
  30042. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  30043. */
  30044. static FitFrustumSidesMode: number;
  30045. }
  30046. }
  30047. declare module BABYLON {
  30048. /**
  30049. * A behavior that when attached to a mesh will allow the mesh to be scaled
  30050. */
  30051. class MultiPointerScaleBehavior implements Behavior<Mesh> {
  30052. private _dragBehaviorA;
  30053. private _dragBehaviorB;
  30054. private _startDistance;
  30055. private _initialScale;
  30056. private _targetScale;
  30057. private _ownerNode;
  30058. private _sceneRenderObserver;
  30059. constructor();
  30060. /**
  30061. * The name of the behavior
  30062. */
  30063. readonly name: string;
  30064. /**
  30065. * Initializes the behavior
  30066. */
  30067. init(): void;
  30068. private _getCurrentDistance();
  30069. /**
  30070. * Attaches the scale behavior the passed in mesh
  30071. * @param ownerNode The mesh that will be scaled around once attached
  30072. */
  30073. attach(ownerNode: Mesh): void;
  30074. /**
  30075. * Detaches the behavior from the mesh
  30076. */
  30077. detach(): void;
  30078. }
  30079. }
  30080. declare module BABYLON {
  30081. /**
  30082. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  30083. */
  30084. class PointerDragBehavior implements Behavior<Mesh> {
  30085. private options;
  30086. private _attachedNode;
  30087. private _dragPlane;
  30088. private _scene;
  30089. private _pointerObserver;
  30090. private static _planeScene;
  30091. /**
  30092. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  30093. */
  30094. currentDraggingPointerID: number;
  30095. /**
  30096. * The last position where the pointer hit the drag plane in world space
  30097. */
  30098. lastDragPosition: Vector3;
  30099. /**
  30100. * If the behavior is currently in a dragging state
  30101. */
  30102. dragging: boolean;
  30103. /**
  30104. * 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)
  30105. */
  30106. dragDeltaRatio: number;
  30107. /**
  30108. * If the drag plane orientation should be updated during the dragging (Default: true)
  30109. */
  30110. updateDragPlane: boolean;
  30111. private _debugMode;
  30112. private _moving;
  30113. /**
  30114. * Fires each time the attached mesh is dragged with the pointer
  30115. * * delta between last drag position and current drag position in world space
  30116. * * dragDistance along the drag axis
  30117. * * dragPlaneNormal normal of the current drag plane used during the drag
  30118. * * dragPlanePoint in world space where the drag intersects the drag plane
  30119. */
  30120. onDragObservable: Observable<{
  30121. delta: Vector3;
  30122. dragPlanePoint: Vector3;
  30123. dragPlaneNormal: Vector3;
  30124. dragDistance: number;
  30125. pointerId: number;
  30126. }>;
  30127. /**
  30128. * Fires each time a drag begins (eg. mouse down on mesh)
  30129. */
  30130. onDragStartObservable: Observable<{
  30131. dragPlanePoint: Vector3;
  30132. pointerId: number;
  30133. }>;
  30134. /**
  30135. * Fires each time a drag ends (eg. mouse release after drag)
  30136. */
  30137. onDragEndObservable: Observable<{
  30138. dragPlanePoint: Vector3;
  30139. pointerId: number;
  30140. }>;
  30141. /**
  30142. * If the attached mesh should be moved when dragged
  30143. */
  30144. moveAttached: boolean;
  30145. /**
  30146. * If the drag behavior will react to drag events (Default: true)
  30147. */
  30148. enabled: boolean;
  30149. /**
  30150. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  30151. */
  30152. useObjectOrienationForDragging: boolean;
  30153. /**
  30154. * Creates a pointer drag behavior that can be attached to a mesh
  30155. * @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)
  30156. */
  30157. constructor(options: {
  30158. dragAxis?: Vector3;
  30159. dragPlaneNormal?: Vector3;
  30160. });
  30161. /**
  30162. * The name of the behavior
  30163. */
  30164. readonly name: string;
  30165. /**
  30166. * Initializes the behavior
  30167. */
  30168. init(): void;
  30169. private _tmpVector;
  30170. private _worldDragAxis;
  30171. /**
  30172. * Attaches the drag behavior the passed in mesh
  30173. * @param ownerNode The mesh that will be dragged around once attached
  30174. */
  30175. attach(ownerNode: Mesh): void;
  30176. releaseDrag(): void;
  30177. private _pickWithRayOnDragPlane(ray);
  30178. private _pointA;
  30179. private _pointB;
  30180. private _pointC;
  30181. private _lineA;
  30182. private _lineB;
  30183. private _localAxis;
  30184. private _lookAt;
  30185. private _updateDragPlanePosition(ray, dragPlanePosition);
  30186. /**
  30187. * Detaches the behavior from the mesh
  30188. */
  30189. detach(): void;
  30190. }
  30191. }
  30192. declare module BABYLON {
  30193. /**
  30194. * 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
  30195. */
  30196. class SixDofDragBehavior implements Behavior<Mesh> {
  30197. private static _virtualScene;
  30198. private _ownerNode;
  30199. private _sceneRenderObserver;
  30200. private _scene;
  30201. private _targetPosition;
  30202. private _virtualOriginMesh;
  30203. private _virtualDragMesh;
  30204. private _pointerObserver;
  30205. private _moving;
  30206. private _startingOrientation;
  30207. /**
  30208. * 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: 5)
  30209. */
  30210. private zDragFactor;
  30211. /**
  30212. * If the behavior is currently in a dragging state
  30213. */
  30214. dragging: boolean;
  30215. /**
  30216. * 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)
  30217. */
  30218. dragDeltaRatio: number;
  30219. /**
  30220. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  30221. */
  30222. currentDraggingPointerID: number;
  30223. constructor();
  30224. /**
  30225. * The name of the behavior
  30226. */
  30227. readonly name: string;
  30228. /**
  30229. * Initializes the behavior
  30230. */
  30231. init(): void;
  30232. /**
  30233. * Attaches the scale behavior the passed in mesh
  30234. * @param ownerNode The mesh that will be scaled around once attached
  30235. */
  30236. attach(ownerNode: Mesh): void;
  30237. /**
  30238. * Detaches the behavior from the mesh
  30239. */
  30240. detach(): void;
  30241. }
  30242. }
  30243. declare module BABYLON {
  30244. class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  30245. camera: ArcRotateCamera;
  30246. gamepad: Nullable<Gamepad>;
  30247. private _onGamepadConnectedObserver;
  30248. private _onGamepadDisconnectedObserver;
  30249. gamepadRotationSensibility: number;
  30250. gamepadMoveSensibility: number;
  30251. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  30252. detachControl(element: Nullable<HTMLElement>): void;
  30253. checkInputs(): void;
  30254. getClassName(): string;
  30255. getSimpleName(): string;
  30256. }
  30257. }
  30258. declare module BABYLON {
  30259. class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  30260. camera: ArcRotateCamera;
  30261. private _keys;
  30262. keysUp: number[];
  30263. keysDown: number[];
  30264. keysLeft: number[];
  30265. keysRight: number[];
  30266. keysReset: number[];
  30267. panningSensibility: number;
  30268. zoomingSensibility: number;
  30269. useAltToZoom: boolean;
  30270. private _ctrlPressed;
  30271. private _altPressed;
  30272. private _onCanvasBlurObserver;
  30273. private _onKeyboardObserver;
  30274. private _engine;
  30275. private _scene;
  30276. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  30277. detachControl(element: Nullable<HTMLElement>): void;
  30278. checkInputs(): void;
  30279. getClassName(): string;
  30280. getSimpleName(): string;
  30281. }
  30282. }
  30283. declare module BABYLON {
  30284. class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  30285. camera: ArcRotateCamera;
  30286. private _wheel;
  30287. private _observer;
  30288. wheelPrecision: number;
  30289. /**
  30290. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  30291. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  30292. */
  30293. wheelDeltaPercentage: number;
  30294. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  30295. detachControl(element: Nullable<HTMLElement>): void;
  30296. getClassName(): string;
  30297. getSimpleName(): string;
  30298. }
  30299. }
  30300. declare module BABYLON {
  30301. class ArcRotateCameraPointersInput implements ICameraInput<ArcRotateCamera> {
  30302. camera: ArcRotateCamera;
  30303. buttons: number[];
  30304. angularSensibilityX: number;
  30305. angularSensibilityY: number;
  30306. pinchPrecision: number;
  30307. /**
  30308. * pinchDeltaPercentage will be used instead of pinchPrecision if different from 0.
  30309. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  30310. */
  30311. pinchDeltaPercentage: number;
  30312. panningSensibility: number;
  30313. multiTouchPanning: boolean;
  30314. multiTouchPanAndZoom: boolean;
  30315. private _isPanClick;
  30316. pinchInwards: boolean;
  30317. private _pointerInput;
  30318. private _observer;
  30319. private _onMouseMove;
  30320. private _onGestureStart;
  30321. private _onGesture;
  30322. private _MSGestureHandler;
  30323. private _onLostFocus;
  30324. private _onContextMenu;
  30325. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  30326. detachControl(element: Nullable<HTMLElement>): void;
  30327. getClassName(): string;
  30328. getSimpleName(): string;
  30329. }
  30330. }
  30331. declare module BABYLON {
  30332. class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  30333. camera: ArcRotateCamera;
  30334. alphaCorrection: number;
  30335. betaCorrection: number;
  30336. gammaCorrection: number;
  30337. private _alpha;
  30338. private _gamma;
  30339. private _dirty;
  30340. private _deviceOrientationHandler;
  30341. constructor();
  30342. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  30343. checkInputs(): void;
  30344. detachControl(element: Nullable<HTMLElement>): void;
  30345. getClassName(): string;
  30346. getSimpleName(): string;
  30347. }
  30348. }
  30349. declare module BABYLON {
  30350. /**
  30351. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  30352. * Screen rotation is taken into account.
  30353. */
  30354. class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  30355. private _camera;
  30356. private _screenOrientationAngle;
  30357. private _constantTranform;
  30358. private _screenQuaternion;
  30359. private _alpha;
  30360. private _beta;
  30361. private _gamma;
  30362. constructor();
  30363. camera: FreeCamera;
  30364. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  30365. private _orientationChanged;
  30366. private _deviceOrientation;
  30367. detachControl(element: Nullable<HTMLElement>): void;
  30368. checkInputs(): void;
  30369. getClassName(): string;
  30370. getSimpleName(): string;
  30371. }
  30372. }
  30373. declare module BABYLON {
  30374. class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  30375. camera: FreeCamera;
  30376. gamepad: Nullable<Gamepad>;
  30377. private _onGamepadConnectedObserver;
  30378. private _onGamepadDisconnectedObserver;
  30379. gamepadAngularSensibility: number;
  30380. gamepadMoveSensibility: number;
  30381. private _cameraTransform;
  30382. private _deltaTransform;
  30383. private _vector3;
  30384. private _vector2;
  30385. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  30386. detachControl(element: Nullable<HTMLElement>): void;
  30387. checkInputs(): void;
  30388. getClassName(): string;
  30389. getSimpleName(): string;
  30390. }
  30391. }
  30392. declare module BABYLON {
  30393. class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  30394. camera: FreeCamera;
  30395. private _keys;
  30396. private _onCanvasBlurObserver;
  30397. private _onKeyboardObserver;
  30398. private _engine;
  30399. private _scene;
  30400. keysUp: number[];
  30401. keysDown: number[];
  30402. keysLeft: number[];
  30403. keysRight: number[];
  30404. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  30405. detachControl(element: Nullable<HTMLElement>): void;
  30406. checkInputs(): void;
  30407. getClassName(): string;
  30408. getSimpleName(): string;
  30409. }
  30410. }
  30411. declare module BABYLON {
  30412. class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  30413. touchEnabled: boolean;
  30414. camera: FreeCamera;
  30415. buttons: number[];
  30416. angularSensibility: number;
  30417. private _pointerInput;
  30418. private _onMouseMove;
  30419. private _observer;
  30420. private previousPosition;
  30421. constructor(touchEnabled?: boolean);
  30422. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  30423. detachControl(element: Nullable<HTMLElement>): void;
  30424. getClassName(): string;
  30425. getSimpleName(): string;
  30426. }
  30427. }
  30428. declare module BABYLON {
  30429. class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  30430. camera: FreeCamera;
  30431. private _offsetX;
  30432. private _offsetY;
  30433. private _pointerPressed;
  30434. private _pointerInput;
  30435. private _observer;
  30436. private _onLostFocus;
  30437. touchAngularSensibility: number;
  30438. touchMoveSensibility: number;
  30439. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  30440. detachControl(element: Nullable<HTMLElement>): void;
  30441. checkInputs(): void;
  30442. getClassName(): string;
  30443. getSimpleName(): string;
  30444. }
  30445. }
  30446. declare module BABYLON {
  30447. class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  30448. camera: FreeCamera;
  30449. private _leftjoystick;
  30450. private _rightjoystick;
  30451. getLeftJoystick(): VirtualJoystick;
  30452. getRightJoystick(): VirtualJoystick;
  30453. checkInputs(): void;
  30454. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  30455. detachControl(element: Nullable<HTMLElement>): void;
  30456. getClassName(): string;
  30457. getSimpleName(): string;
  30458. }
  30459. }
  30460. declare module BABYLON {
  30461. class VRCameraMetrics {
  30462. hResolution: number;
  30463. vResolution: number;
  30464. hScreenSize: number;
  30465. vScreenSize: number;
  30466. vScreenCenter: number;
  30467. eyeToScreenDistance: number;
  30468. lensSeparationDistance: number;
  30469. interpupillaryDistance: number;
  30470. distortionK: number[];
  30471. chromaAbCorrection: number[];
  30472. postProcessScaleFactor: number;
  30473. lensCenterOffset: number;
  30474. compensateDistortion: boolean;
  30475. readonly aspectRatio: number;
  30476. readonly aspectRatioFov: number;
  30477. readonly leftHMatrix: Matrix;
  30478. readonly rightHMatrix: Matrix;
  30479. readonly leftPreViewMatrix: Matrix;
  30480. readonly rightPreViewMatrix: Matrix;
  30481. static GetDefault(): VRCameraMetrics;
  30482. }
  30483. }
  30484. declare module BABYLON {
  30485. class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  30486. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  30487. getClassName(): string;
  30488. }
  30489. class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  30490. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  30491. getClassName(): string;
  30492. }
  30493. class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  30494. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  30495. getClassName(): string;
  30496. }
  30497. }
  30498. declare module BABYLON {
  30499. /**
  30500. * Options to modify the vr teleportation behavior.
  30501. */
  30502. interface VRTeleportationOptions {
  30503. /**
  30504. * The name of the mesh which should be used as the teleportation floor. (default: null)
  30505. */
  30506. floorMeshName?: string;
  30507. /**
  30508. * A list of meshes to be used as the teleportation floor. (default: empty)
  30509. */
  30510. floorMeshes?: Mesh[];
  30511. }
  30512. /**
  30513. * Options to modify the vr experience helper's behavior.
  30514. */
  30515. interface VRExperienceHelperOptions extends WebVROptions {
  30516. /**
  30517. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  30518. */
  30519. createDeviceOrientationCamera?: boolean;
  30520. /**
  30521. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  30522. */
  30523. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  30524. /**
  30525. * Uses the main button on the controller to toggle the laser casted. (default: true)
  30526. */
  30527. laserToggle?: boolean;
  30528. /**
  30529. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  30530. */
  30531. floorMeshes?: Mesh[];
  30532. }
  30533. /**
  30534. * Helps to quickly add VR support to an existing scene.
  30535. * See http://doc.babylonjs.com/how_to/webvr_helper
  30536. */
  30537. class VRExperienceHelper {
  30538. /** Options to modify the vr experience helper's behavior. */ webVROptions: VRExperienceHelperOptions;
  30539. private _scene;
  30540. private _position;
  30541. private _btnVR;
  30542. private _btnVRDisplayed;
  30543. private _webVRsupported;
  30544. private _webVRready;
  30545. private _webVRrequesting;
  30546. private _webVRpresenting;
  30547. private _fullscreenVRpresenting;
  30548. private _canvas;
  30549. private _webVRCamera;
  30550. private _vrDeviceOrientationCamera;
  30551. private _deviceOrientationCamera;
  30552. private _existingCamera;
  30553. private _onKeyDown;
  30554. private _onVrDisplayPresentChange;
  30555. private _onVRDisplayChanged;
  30556. private _onVRRequestPresentStart;
  30557. private _onVRRequestPresentComplete;
  30558. /**
  30559. * Observable raised when entering VR.
  30560. */
  30561. onEnteringVRObservable: Observable<VRExperienceHelper>;
  30562. /**
  30563. * Observable raised when exiting VR.
  30564. */
  30565. onExitingVRObservable: Observable<VRExperienceHelper>;
  30566. /**
  30567. * Observable raised when controller mesh is loaded.
  30568. */
  30569. onControllerMeshLoadedObservable: Observable<WebVRController>;
  30570. /** Return this.onEnteringVRObservable
  30571. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  30572. */
  30573. readonly onEnteringVR: Observable<VRExperienceHelper>;
  30574. /** Return this.onExitingVRObservable
  30575. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  30576. */
  30577. readonly onExitingVR: Observable<VRExperienceHelper>;
  30578. /** Return this.onControllerMeshLoadedObservable
  30579. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  30580. */
  30581. readonly onControllerMeshLoaded: Observable<WebVRController>;
  30582. private _rayLength;
  30583. private _useCustomVRButton;
  30584. private _teleportationRequested;
  30585. private _teleportActive;
  30586. private _floorMeshName;
  30587. private _floorMeshesCollection;
  30588. private _rotationAllowed;
  30589. private _teleportBackwardsVector;
  30590. private _teleportationTarget;
  30591. private _isDefaultTeleportationTarget;
  30592. private _postProcessMove;
  30593. private _teleportationFillColor;
  30594. private _teleportationBorderColor;
  30595. private _rotationAngle;
  30596. private _haloCenter;
  30597. private _cameraGazer;
  30598. private _padSensibilityUp;
  30599. private _padSensibilityDown;
  30600. private leftController;
  30601. private rightController;
  30602. /**
  30603. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  30604. */
  30605. onNewMeshSelected: Observable<AbstractMesh>;
  30606. /**
  30607. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  30608. */
  30609. onNewMeshPicked: Observable<PickingInfo>;
  30610. private _circleEase;
  30611. /**
  30612. * Observable raised before camera teleportation
  30613. */
  30614. onBeforeCameraTeleport: Observable<Vector3>;
  30615. /**
  30616. * Observable raised after camera teleportation
  30617. */
  30618. onAfterCameraTeleport: Observable<Vector3>;
  30619. /**
  30620. * Observable raised when current selected mesh gets unselected
  30621. */
  30622. onSelectedMeshUnselected: Observable<AbstractMesh>;
  30623. private _raySelectionPredicate;
  30624. /**
  30625. * To be optionaly changed by user to define custom ray selection
  30626. */
  30627. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  30628. /**
  30629. * To be optionaly changed by user to define custom selection logic (after ray selection)
  30630. */
  30631. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  30632. /**
  30633. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  30634. */
  30635. teleportationEnabled: boolean;
  30636. private _defaultHeight;
  30637. private _teleportationInitialized;
  30638. private _interactionsEnabled;
  30639. private _interactionsRequested;
  30640. private _displayGaze;
  30641. private _displayLaserPointer;
  30642. /**
  30643. * The mesh used to display where the user is going to teleport.
  30644. */
  30645. /**
  30646. * Sets the mesh to be used to display where the user is going to teleport.
  30647. */
  30648. teleportationTarget: Mesh;
  30649. /**
  30650. * The mesh used to display where the user is selecting,
  30651. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  30652. * See http://doc.babylonjs.com/resources/baking_transformations
  30653. */
  30654. gazeTrackerMesh: Mesh;
  30655. /**
  30656. * If the ray of the gaze should be displayed.
  30657. */
  30658. /**
  30659. * Sets if the ray of the gaze should be displayed.
  30660. */
  30661. displayGaze: boolean;
  30662. /**
  30663. * If the ray of the LaserPointer should be displayed.
  30664. */
  30665. /**
  30666. * Sets if the ray of the LaserPointer should be displayed.
  30667. */
  30668. displayLaserPointer: boolean;
  30669. /**
  30670. * The deviceOrientationCamera used as the camera when not in VR.
  30671. */
  30672. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  30673. /**
  30674. * Based on the current WebVR support, returns the current VR camera used.
  30675. */
  30676. readonly currentVRCamera: Nullable<Camera>;
  30677. /**
  30678. * The webVRCamera which is used when in VR.
  30679. */
  30680. readonly webVRCamera: WebVRFreeCamera;
  30681. /**
  30682. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  30683. */
  30684. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  30685. private readonly _teleportationRequestInitiated;
  30686. /**
  30687. * Instantiates a VRExperienceHelper.
  30688. * Helps to quickly add VR support to an existing scene.
  30689. * @param scene The scene the VRExperienceHelper belongs to.
  30690. * @param webVROptions Options to modify the vr experience helper's behavior.
  30691. */
  30692. constructor(scene: Scene, /** Options to modify the vr experience helper's behavior. */ webVROptions?: VRExperienceHelperOptions);
  30693. private _onDefaultMeshLoaded(webVRController);
  30694. private _onResize;
  30695. private _onFullscreenChange;
  30696. /**
  30697. * Gets a value indicating if we are currently in VR mode.
  30698. */
  30699. readonly isInVRMode: boolean;
  30700. private onVrDisplayPresentChange();
  30701. private onVRDisplayChanged(eventArgs);
  30702. private moveButtonToBottomRight();
  30703. private displayVRButton();
  30704. private updateButtonVisibility();
  30705. /**
  30706. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  30707. * Otherwise, will use the fullscreen API.
  30708. */
  30709. enterVR(): void;
  30710. /**
  30711. * Attempt to exit VR, or fullscreen.
  30712. */
  30713. exitVR(): void;
  30714. /**
  30715. * The position of the vr experience helper.
  30716. */
  30717. /**
  30718. * Sets the position of the vr experience helper.
  30719. */
  30720. position: Vector3;
  30721. /**
  30722. * Enables controllers and user interactions suck as selecting and object or clicking on an object.
  30723. */
  30724. enableInteractions(): void;
  30725. private readonly _noControllerIsActive;
  30726. private beforeRender;
  30727. private _isTeleportationFloor(mesh);
  30728. /**
  30729. * Adds a floor mesh to be used for teleportation.
  30730. * @param floorMesh the mesh to be used for teleportation.
  30731. */
  30732. addFloorMesh(floorMesh: Mesh): void;
  30733. /**
  30734. * Removes a floor mesh from being used for teleportation.
  30735. * @param floorMesh the mesh to be removed.
  30736. */
  30737. removeFloorMesh(floorMesh: Mesh): void;
  30738. /**
  30739. * Enables interactions and teleportation using the VR controllers and gaze.
  30740. * @param vrTeleportationOptions options to modify teleportation behavior.
  30741. */
  30742. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  30743. private _onNewGamepadConnected;
  30744. private _tryEnableInteractionOnController;
  30745. private _onNewGamepadDisconnected;
  30746. private _enableInteractionOnController(controller);
  30747. private _checkTeleportWithRay(stateObject, gazer);
  30748. private _checkRotate(stateObject, gazer);
  30749. private _checkTeleportBackwards(stateObject, gazer);
  30750. private _enableTeleportationOnController(controller);
  30751. private _createTeleportationCircles();
  30752. private _displayTeleportationTarget();
  30753. private _hideTeleportationTarget();
  30754. private _rotateCamera(right);
  30755. private _moveTeleportationSelectorTo(hit, gazer, ray);
  30756. private _workingVector;
  30757. private _workingQuaternion;
  30758. private _workingMatrix;
  30759. private _teleportCamera(location);
  30760. private _convertNormalToDirectionOfRay(normal, ray);
  30761. private _castRayAndSelectObject(gazer);
  30762. private _notifySelectedMeshUnselected(mesh);
  30763. /**
  30764. * Sets the color of the laser ray from the vr controllers.
  30765. * @param color new color for the ray.
  30766. */
  30767. changeLaserColor(color: Color3): void;
  30768. /**
  30769. * Sets the color of the ray from the vr headsets gaze.
  30770. * @param color new color for the ray.
  30771. */
  30772. changeGazeColor(color: Color3): void;
  30773. /**
  30774. * Exits VR and disposes of the vr experience helper
  30775. */
  30776. dispose(): void;
  30777. /**
  30778. * Gets the name of the VRExperienceHelper class
  30779. * @returns "VRExperienceHelper"
  30780. */
  30781. getClassName(): string;
  30782. }
  30783. }
  30784. declare module BABYLON {
  30785. /**
  30786. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  30787. * IMPORTANT!! The data is right-hand data.
  30788. * @export
  30789. * @interface DevicePose
  30790. */
  30791. interface DevicePose {
  30792. /**
  30793. * The position of the device, values in array are [x,y,z].
  30794. */
  30795. readonly position: Nullable<Float32Array>;
  30796. /**
  30797. * The linearVelocity of the device, values in array are [x,y,z].
  30798. */
  30799. readonly linearVelocity: Nullable<Float32Array>;
  30800. /**
  30801. * The linearAcceleration of the device, values in array are [x,y,z].
  30802. */
  30803. readonly linearAcceleration: Nullable<Float32Array>;
  30804. /**
  30805. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  30806. */
  30807. readonly orientation: Nullable<Float32Array>;
  30808. /**
  30809. * The angularVelocity of the device, values in array are [x,y,z].
  30810. */
  30811. readonly angularVelocity: Nullable<Float32Array>;
  30812. /**
  30813. * The angularAcceleration of the device, values in array are [x,y,z].
  30814. */
  30815. readonly angularAcceleration: Nullable<Float32Array>;
  30816. }
  30817. /**
  30818. * Interface representing a pose controlled object in Babylon.
  30819. * A pose controlled object has both regular pose values as well as pose values
  30820. * from an external device such as a VR head mounted display
  30821. */
  30822. interface PoseControlled {
  30823. /**
  30824. * The position of the object in babylon space.
  30825. */
  30826. position: Vector3;
  30827. /**
  30828. * The rotation quaternion of the object in babylon space.
  30829. */
  30830. rotationQuaternion: Quaternion;
  30831. /**
  30832. * The position of the device in babylon space.
  30833. */
  30834. devicePosition?: Vector3;
  30835. /**
  30836. * The rotation quaternion of the device in babylon space.
  30837. */
  30838. deviceRotationQuaternion: Quaternion;
  30839. /**
  30840. * The raw pose coming from the device.
  30841. */
  30842. rawPose: Nullable<DevicePose>;
  30843. /**
  30844. * The scale of the device to be used when translating from device space to babylon space.
  30845. */
  30846. deviceScaleFactor: number;
  30847. /**
  30848. * Updates the poseControlled values based on the input device pose.
  30849. * @param poseData the pose data to update the object with
  30850. */
  30851. updateFromDevice(poseData: DevicePose): void;
  30852. }
  30853. /**
  30854. * Set of options to customize the webVRCamera
  30855. */
  30856. interface WebVROptions {
  30857. /**
  30858. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  30859. */
  30860. trackPosition?: boolean;
  30861. /**
  30862. * Sets the scale of the vrDevice in babylon space. (default: 1)
  30863. */
  30864. positionScale?: number;
  30865. /**
  30866. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  30867. */
  30868. displayName?: string;
  30869. /**
  30870. * Should the native controller meshes be initialized. (default: true)
  30871. */
  30872. controllerMeshes?: boolean;
  30873. /**
  30874. * Creating a default HemiLight only on controllers. (default: true)
  30875. */
  30876. defaultLightingOnControllers?: boolean;
  30877. /**
  30878. * If you don't want to use the default VR button of the helper. (default: false)
  30879. */
  30880. useCustomVRButton?: boolean;
  30881. /**
  30882. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  30883. */
  30884. customVRButton?: HTMLButtonElement;
  30885. /**
  30886. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  30887. */
  30888. rayLength?: number;
  30889. /**
  30890. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  30891. */
  30892. defaultHeight?: number;
  30893. }
  30894. /**
  30895. * This represents a WebVR camera.
  30896. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  30897. * @example http://doc.babylonjs.com/how_to/webvr_camera
  30898. */
  30899. class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  30900. private webVROptions;
  30901. /**
  30902. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  30903. */
  30904. /**
  30905. * The rawPose of the vrDevice.
  30906. */
  30907. rawPose: Nullable<DevicePose>;
  30908. private _onVREnabled;
  30909. private _specsVersion;
  30910. private _attached;
  30911. private _frameData;
  30912. protected _descendants: Array<Node>;
  30913. private _deviceRoomPosition;
  30914. private _deviceRoomRotationQuaternion;
  30915. private _standingMatrix;
  30916. /**
  30917. * Represents device position in babylon space.
  30918. */
  30919. devicePosition: Vector3;
  30920. /**
  30921. * Represents device rotation in babylon space.
  30922. */
  30923. deviceRotationQuaternion: Quaternion;
  30924. /**
  30925. * The scale of the device to be used when translating from device space to babylon space.
  30926. */
  30927. deviceScaleFactor: number;
  30928. private _deviceToWorld;
  30929. private _worldToDevice;
  30930. /**
  30931. * References to the webVR controllers for the vrDevice.
  30932. */
  30933. controllers: Array<WebVRController>;
  30934. /**
  30935. * Emits an event when a controller is attached.
  30936. */
  30937. onControllersAttachedObservable: Observable<WebVRController[]>;
  30938. /**
  30939. * Emits an event when a controller's mesh has been loaded;
  30940. */
  30941. onControllerMeshLoadedObservable: Observable<WebVRController>;
  30942. /**
  30943. * If the rig cameras be used as parent instead of this camera.
  30944. */
  30945. rigParenting: boolean;
  30946. private _lightOnControllers;
  30947. private _defaultHeight?;
  30948. /**
  30949. * Instantiates a WebVRFreeCamera.
  30950. * @param name The name of the WebVRFreeCamera
  30951. * @param position The starting anchor position for the camera
  30952. * @param scene The scene the camera belongs to
  30953. * @param webVROptions a set of customizable options for the webVRCamera
  30954. */
  30955. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  30956. /**
  30957. * Gets the device distance from the ground in meters.
  30958. * @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.
  30959. */
  30960. deviceDistanceToRoomGround(): number;
  30961. /**
  30962. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  30963. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  30964. */
  30965. useStandingMatrix(callback?: (bool: boolean) => void): void;
  30966. /**
  30967. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  30968. * @returns A promise with a boolean set to if the standing matrix is supported.
  30969. */
  30970. useStandingMatrixAsync(): Promise<boolean>;
  30971. /**
  30972. * Disposes the camera
  30973. */
  30974. dispose(): void;
  30975. /**
  30976. * Gets a vrController by name.
  30977. * @param name The name of the controller to retreive
  30978. * @returns the controller matching the name specified or null if not found
  30979. */
  30980. getControllerByName(name: string): Nullable<WebVRController>;
  30981. private _leftController;
  30982. /**
  30983. * The controller corrisponding to the users left hand.
  30984. */
  30985. readonly leftController: Nullable<WebVRController>;
  30986. private _rightController;
  30987. /**
  30988. * The controller corrisponding to the users right hand.
  30989. */
  30990. readonly rightController: Nullable<WebVRController>;
  30991. /**
  30992. * Casts a ray forward from the vrCamera's gaze.
  30993. * @param length Length of the ray (default: 100)
  30994. * @returns the ray corrisponding to the gaze
  30995. */
  30996. getForwardRay(length?: number): Ray;
  30997. /**
  30998. * Updates the camera based on device's frame data
  30999. */
  31000. /**
  31001. * Updates the poseControlled values based on the input device pose.
  31002. * @param poseData Pose coming from the device
  31003. */
  31004. updateFromDevice(poseData: DevicePose): void;
  31005. /**
  31006. * WebVR's attach control will start broadcasting frames to the device.
  31007. * Note that in certain browsers (chrome for example) this function must be called
  31008. * within a user-interaction callback. Example:
  31009. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  31010. *
  31011. * @param element html element to attach the vrDevice to
  31012. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  31013. */
  31014. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  31015. /**
  31016. * Detaches the camera from the html element and disables VR
  31017. *
  31018. * @param element html element to detach from
  31019. */
  31020. detachControl(element: HTMLElement): void;
  31021. /**
  31022. * @returns the name of this class
  31023. */
  31024. getClassName(): string;
  31025. /**
  31026. * Calls resetPose on the vrDisplay
  31027. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  31028. */
  31029. resetToCurrentRotation(): void;
  31030. /**
  31031. * Updates the rig cameras (left and right eye)
  31032. */
  31033. private _workingVector;
  31034. private _oneVector;
  31035. private _workingMatrix;
  31036. private updateCacheCalled;
  31037. /**
  31038. * Updates the cached values of the camera
  31039. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  31040. */
  31041. /**
  31042. * Updates the current device position and rotation in the babylon world
  31043. */
  31044. update(): void;
  31045. /**
  31046. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  31047. * @returns an identity matrix
  31048. */
  31049. /**
  31050. * This function is called by the two RIG cameras.
  31051. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  31052. */
  31053. protected _getWebVRViewMatrix(): Matrix;
  31054. protected _getWebVRProjectionMatrix(): Matrix;
  31055. private _onGamepadConnectedObserver;
  31056. private _onGamepadDisconnectedObserver;
  31057. /**
  31058. * Initializes the controllers and their meshes
  31059. */
  31060. initControllers(): void;
  31061. }
  31062. }
  31063. declare module BABYLON {
  31064. interface IOctreeContainer<T> {
  31065. blocks: Array<OctreeBlock<T>>;
  31066. }
  31067. class Octree<T> {
  31068. maxDepth: number;
  31069. blocks: Array<OctreeBlock<T>>;
  31070. dynamicContent: T[];
  31071. private _maxBlockCapacity;
  31072. private _selectionContent;
  31073. private _creationFunc;
  31074. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number, maxDepth?: number);
  31075. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  31076. addMesh(entry: T): void;
  31077. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  31078. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  31079. intersectsRay(ray: Ray): SmartArray<T>;
  31080. 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;
  31081. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  31082. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  31083. }
  31084. }
  31085. declare module BABYLON {
  31086. class OctreeBlock<T> {
  31087. entries: T[];
  31088. blocks: Array<OctreeBlock<T>>;
  31089. private _depth;
  31090. private _maxDepth;
  31091. private _capacity;
  31092. private _minPoint;
  31093. private _maxPoint;
  31094. private _boundingVectors;
  31095. private _creationFunc;
  31096. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  31097. readonly capacity: number;
  31098. readonly minPoint: Vector3;
  31099. readonly maxPoint: Vector3;
  31100. addEntry(entry: T): void;
  31101. addEntries(entries: T[]): void;
  31102. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  31103. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  31104. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  31105. createInnerBlocks(): void;
  31106. }
  31107. }
  31108. declare module BABYLON {
  31109. /**
  31110. * Google Daydream controller
  31111. */
  31112. class DaydreamController extends WebVRController {
  31113. /**
  31114. * Base Url for the controller model.
  31115. */
  31116. static MODEL_BASE_URL: string;
  31117. /**
  31118. * File name for the controller model.
  31119. */
  31120. static MODEL_FILENAME: string;
  31121. /**
  31122. * Gamepad Id prefix used to identify Daydream Controller.
  31123. */
  31124. static readonly GAMEPAD_ID_PREFIX: string;
  31125. /**
  31126. * Creates a new DaydreamController from a gamepad
  31127. * @param vrGamepad the gamepad that the controller should be created from
  31128. */
  31129. constructor(vrGamepad: any);
  31130. /**
  31131. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  31132. * @param scene scene in which to add meshes
  31133. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  31134. */
  31135. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  31136. /**
  31137. * Called once for each button that changed state since the last frame
  31138. * @param buttonIdx Which button index changed
  31139. * @param state New state of the button
  31140. * @param changes Which properties on the state changed since last frame
  31141. */
  31142. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  31143. }
  31144. }
  31145. declare module BABYLON {
  31146. /**
  31147. * Gear VR Controller
  31148. */
  31149. class GearVRController extends WebVRController {
  31150. /**
  31151. * Base Url for the controller model.
  31152. */
  31153. static MODEL_BASE_URL: string;
  31154. /**
  31155. * File name for the controller model.
  31156. */
  31157. static MODEL_FILENAME: string;
  31158. /**
  31159. * Gamepad Id prefix used to identify this controller.
  31160. */
  31161. static readonly GAMEPAD_ID_PREFIX: string;
  31162. private readonly _buttonIndexToObservableNameMap;
  31163. /**
  31164. * Creates a new GearVRController from a gamepad
  31165. * @param vrGamepad the gamepad that the controller should be created from
  31166. */
  31167. constructor(vrGamepad: any);
  31168. /**
  31169. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  31170. * @param scene scene in which to add meshes
  31171. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  31172. */
  31173. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  31174. /**
  31175. * Called once for each button that changed state since the last frame
  31176. * @param buttonIdx Which button index changed
  31177. * @param state New state of the button
  31178. * @param changes Which properties on the state changed since last frame
  31179. */
  31180. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  31181. }
  31182. }
  31183. declare module BABYLON {
  31184. /**
  31185. * Generic Controller
  31186. */
  31187. class GenericController extends WebVRController {
  31188. /**
  31189. * Base Url for the controller model.
  31190. */
  31191. static readonly MODEL_BASE_URL: string;
  31192. /**
  31193. * File name for the controller model.
  31194. */
  31195. static readonly MODEL_FILENAME: string;
  31196. /**
  31197. * Creates a new GenericController from a gamepad
  31198. * @param vrGamepad the gamepad that the controller should be created from
  31199. */
  31200. constructor(vrGamepad: any);
  31201. /**
  31202. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  31203. * @param scene scene in which to add meshes
  31204. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  31205. */
  31206. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  31207. /**
  31208. * Called once for each button that changed state since the last frame
  31209. * @param buttonIdx Which button index changed
  31210. * @param state New state of the button
  31211. * @param changes Which properties on the state changed since last frame
  31212. */
  31213. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  31214. }
  31215. }
  31216. declare module BABYLON {
  31217. /**
  31218. * Oculus Touch Controller
  31219. */
  31220. class OculusTouchController extends WebVRController {
  31221. /**
  31222. * Base Url for the controller model.
  31223. */
  31224. static MODEL_BASE_URL: string;
  31225. /**
  31226. * File name for the left controller model.
  31227. */
  31228. static MODEL_LEFT_FILENAME: string;
  31229. /**
  31230. * File name for the right controller model.
  31231. */
  31232. static MODEL_RIGHT_FILENAME: string;
  31233. /**
  31234. * Fired when the secondary trigger on this controller is modified
  31235. */
  31236. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  31237. /**
  31238. * Fired when the thumb rest on this controller is modified
  31239. */
  31240. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  31241. /**
  31242. * Creates a new OculusTouchController from a gamepad
  31243. * @param vrGamepad the gamepad that the controller should be created from
  31244. */
  31245. constructor(vrGamepad: any);
  31246. /**
  31247. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  31248. * @param scene scene in which to add meshes
  31249. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  31250. */
  31251. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  31252. /**
  31253. * Fired when the A button on this controller is modified
  31254. */
  31255. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  31256. /**
  31257. * Fired when the B button on this controller is modified
  31258. */
  31259. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  31260. /**
  31261. * Fired when the X button on this controller is modified
  31262. */
  31263. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  31264. /**
  31265. * Fired when the Y button on this controller is modified
  31266. */
  31267. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  31268. /**
  31269. * Called once for each button that changed state since the last frame
  31270. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  31271. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  31272. * 2) secondary trigger (same)
  31273. * 3) A (right) X (left), touch, pressed = value
  31274. * 4) B / Y
  31275. * 5) thumb rest
  31276. * @param buttonIdx Which button index changed
  31277. * @param state New state of the button
  31278. * @param changes Which properties on the state changed since last frame
  31279. */
  31280. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  31281. }
  31282. }
  31283. declare module BABYLON {
  31284. /**
  31285. * Defines the types of pose enabled controllers that are supported
  31286. */
  31287. enum PoseEnabledControllerType {
  31288. /**
  31289. * HTC Vive
  31290. */
  31291. VIVE = 0,
  31292. /**
  31293. * Oculus Rift
  31294. */
  31295. OCULUS = 1,
  31296. /**
  31297. * Windows mixed reality
  31298. */
  31299. WINDOWS = 2,
  31300. /**
  31301. * Samsung gear VR
  31302. */
  31303. GEAR_VR = 3,
  31304. /**
  31305. * Google Daydream
  31306. */
  31307. DAYDREAM = 4,
  31308. /**
  31309. * Generic
  31310. */
  31311. GENERIC = 5,
  31312. }
  31313. /**
  31314. * Defines the MutableGamepadButton interface for the state of a gamepad button
  31315. */
  31316. interface MutableGamepadButton {
  31317. /**
  31318. * Value of the button/trigger
  31319. */
  31320. value: number;
  31321. /**
  31322. * If the button/trigger is currently touched
  31323. */
  31324. touched: boolean;
  31325. /**
  31326. * If the button/trigger is currently pressed
  31327. */
  31328. pressed: boolean;
  31329. }
  31330. /**
  31331. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  31332. * @hidden
  31333. */
  31334. interface ExtendedGamepadButton extends GamepadButton {
  31335. /**
  31336. * If the button/trigger is currently pressed
  31337. */
  31338. readonly pressed: boolean;
  31339. /**
  31340. * If the button/trigger is currently touched
  31341. */
  31342. readonly touched: boolean;
  31343. /**
  31344. * Value of the button/trigger
  31345. */
  31346. readonly value: number;
  31347. }
  31348. /**
  31349. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  31350. */
  31351. class PoseEnabledControllerHelper {
  31352. /**
  31353. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  31354. * @param vrGamepad the gamepad to initialized
  31355. * @returns a vr controller of the type the gamepad identified as
  31356. */
  31357. static InitiateController(vrGamepad: any): OculusTouchController | WindowsMotionController | ViveController | GearVRController | DaydreamController | GenericController;
  31358. }
  31359. /**
  31360. * Defines the PoseEnabledController object that contains state of a vr capable controller
  31361. */
  31362. class PoseEnabledController extends Gamepad implements PoseControlled {
  31363. private _deviceRoomPosition;
  31364. private _deviceRoomRotationQuaternion;
  31365. /**
  31366. * The device position in babylon space
  31367. */
  31368. devicePosition: Vector3;
  31369. /**
  31370. * The device rotation in babylon space
  31371. */
  31372. deviceRotationQuaternion: Quaternion;
  31373. /**
  31374. * The scale factor of the device in babylon space
  31375. */
  31376. deviceScaleFactor: number;
  31377. /**
  31378. * (Likely devicePosition should be used instead) The device position in its room space
  31379. */
  31380. position: Vector3;
  31381. /**
  31382. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  31383. */
  31384. rotationQuaternion: Quaternion;
  31385. /**
  31386. * The type of controller (Eg. Windows mixed reality)
  31387. */
  31388. controllerType: PoseEnabledControllerType;
  31389. protected _calculatedPosition: Vector3;
  31390. private _calculatedRotation;
  31391. /**
  31392. * The raw pose from the device
  31393. */
  31394. rawPose: DevicePose;
  31395. /**
  31396. * Internal, the mesh attached to the controller
  31397. */
  31398. private _poseControlledCamera;
  31399. private _leftHandSystemQuaternion;
  31400. /**
  31401. * Internal, matrix used to convert room space to babylon space
  31402. */
  31403. /**
  31404. * Node to be used when casting a ray from the controller
  31405. */
  31406. /**
  31407. * Name of the child mesh that can be used to cast a ray from the controller
  31408. */
  31409. static readonly POINTING_POSE: string;
  31410. /**
  31411. * Creates a new PoseEnabledController from a gamepad
  31412. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  31413. */
  31414. constructor(browserGamepad: any);
  31415. private _workingMatrix;
  31416. /**
  31417. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  31418. */
  31419. update(): void;
  31420. /**
  31421. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  31422. * @param poseData raw pose fromthe device
  31423. */
  31424. updateFromDevice(poseData: DevicePose): void;
  31425. /**
  31426. * @hidden
  31427. */
  31428. /**
  31429. * Attaches a mesh to the controller
  31430. * @param mesh the mesh to be attached
  31431. */
  31432. attachToMesh(mesh: AbstractMesh): void;
  31433. /**
  31434. * Attaches the controllers mesh to a camera
  31435. * @param camera the camera the mesh should be attached to
  31436. */
  31437. attachToPoseControlledCamera(camera: TargetCamera): void;
  31438. /**
  31439. * Disposes of the controller
  31440. */
  31441. dispose(): void;
  31442. /**
  31443. * The mesh that is attached to the controller
  31444. */
  31445. readonly mesh: Nullable<AbstractMesh>;
  31446. /**
  31447. * Gets the ray of the controller in the direction the controller is pointing
  31448. * @param length the length the resulting ray should be
  31449. * @returns a ray in the direction the controller is pointing
  31450. */
  31451. getForwardRay(length?: number): Ray;
  31452. }
  31453. }
  31454. declare module BABYLON {
  31455. /**
  31456. * Vive Controller
  31457. */
  31458. class ViveController extends WebVRController {
  31459. /**
  31460. * Base Url for the controller model.
  31461. */
  31462. static MODEL_BASE_URL: string;
  31463. /**
  31464. * File name for the controller model.
  31465. */
  31466. static MODEL_FILENAME: string;
  31467. /**
  31468. * Creates a new ViveController from a gamepad
  31469. * @param vrGamepad the gamepad that the controller should be created from
  31470. */
  31471. constructor(vrGamepad: any);
  31472. /**
  31473. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  31474. * @param scene scene in which to add meshes
  31475. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  31476. */
  31477. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  31478. /**
  31479. * Fired when the left button on this controller is modified
  31480. */
  31481. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  31482. /**
  31483. * Fired when the right button on this controller is modified
  31484. */
  31485. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  31486. /**
  31487. * Fired when the menu button on this controller is modified
  31488. */
  31489. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  31490. /**
  31491. * Called once for each button that changed state since the last frame
  31492. * Vive mapping:
  31493. * 0: touchpad
  31494. * 1: trigger
  31495. * 2: left AND right buttons
  31496. * 3: menu button
  31497. * @param buttonIdx Which button index changed
  31498. * @param state New state of the button
  31499. * @param changes Which properties on the state changed since last frame
  31500. */
  31501. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  31502. }
  31503. }
  31504. declare module BABYLON {
  31505. /**
  31506. * Defines the WebVRController object that represents controllers tracked in 3D space
  31507. */
  31508. abstract class WebVRController extends PoseEnabledController {
  31509. /**
  31510. * Internal, the default controller model for the controller
  31511. */
  31512. protected _defaultModel: AbstractMesh;
  31513. /**
  31514. * Fired when the trigger state has changed
  31515. */
  31516. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  31517. /**
  31518. * Fired when the main button state has changed
  31519. */
  31520. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  31521. /**
  31522. * Fired when the secondary button state has changed
  31523. */
  31524. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  31525. /**
  31526. * Fired when the pad state has changed
  31527. */
  31528. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  31529. /**
  31530. * Fired when controllers stick values have changed
  31531. */
  31532. onPadValuesChangedObservable: Observable<StickValues>;
  31533. /**
  31534. * Array of button availible on the controller
  31535. */
  31536. protected _buttons: Array<MutableGamepadButton>;
  31537. private _onButtonStateChange;
  31538. /**
  31539. * Fired when a controller button's state has changed
  31540. * @param callback the callback containing the button that was modified
  31541. */
  31542. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  31543. /**
  31544. * X and Y axis corrisponding to the controllers joystick
  31545. */
  31546. pad: StickValues;
  31547. /**
  31548. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  31549. */
  31550. hand: string;
  31551. /**
  31552. * The default controller model for the controller
  31553. */
  31554. readonly defaultModel: AbstractMesh;
  31555. /**
  31556. * Creates a new WebVRController from a gamepad
  31557. * @param vrGamepad the gamepad that the WebVRController should be created from
  31558. */
  31559. constructor(vrGamepad: any);
  31560. /**
  31561. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  31562. */
  31563. update(): void;
  31564. /**
  31565. * Function to be called when a button is modified
  31566. */
  31567. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  31568. /**
  31569. * Loads a mesh and attaches it to the controller
  31570. * @param scene the scene the mesh should be added to
  31571. * @param meshLoaded callback for when the mesh has been loaded
  31572. */
  31573. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  31574. private _setButtonValue(newState, currentState, buttonIndex);
  31575. private _changes;
  31576. private _checkChanges(newState, currentState);
  31577. /**
  31578. * Disposes of th webVRCOntroller
  31579. */
  31580. dispose(): void;
  31581. }
  31582. }
  31583. declare module BABYLON {
  31584. /**
  31585. * Defines the WindowsMotionController object that the state of the windows motion controller
  31586. */
  31587. class WindowsMotionController extends WebVRController {
  31588. /**
  31589. * The base url used to load the left and right controller models
  31590. */
  31591. static MODEL_BASE_URL: string;
  31592. /**
  31593. * The name of the left controller model file
  31594. */
  31595. static MODEL_LEFT_FILENAME: string;
  31596. /**
  31597. * The name of the right controller model file
  31598. */
  31599. static MODEL_RIGHT_FILENAME: string;
  31600. /**
  31601. * The controller name prefix for this controller type
  31602. */
  31603. static readonly GAMEPAD_ID_PREFIX: string;
  31604. /**
  31605. * The controller id pattern for this controller type
  31606. */
  31607. private static readonly GAMEPAD_ID_PATTERN;
  31608. private _loadedMeshInfo;
  31609. private readonly _mapping;
  31610. /**
  31611. * Fired when the trackpad on this controller is clicked
  31612. */
  31613. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  31614. /**
  31615. * Fired when the trackpad on this controller is modified
  31616. */
  31617. onTrackpadValuesChangedObservable: Observable<StickValues>;
  31618. /**
  31619. * The current x and y values of this controller's trackpad
  31620. */
  31621. trackpad: StickValues;
  31622. /**
  31623. * Creates a new WindowsMotionController from a gamepad
  31624. * @param vrGamepad the gamepad that the controller should be created from
  31625. */
  31626. constructor(vrGamepad: any);
  31627. /**
  31628. * Fired when the trigger on this controller is modified
  31629. */
  31630. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  31631. /**
  31632. * Fired when the menu button on this controller is modified
  31633. */
  31634. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  31635. /**
  31636. * Fired when the grip button on this controller is modified
  31637. */
  31638. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  31639. /**
  31640. * Fired when the thumbstick button on this controller is modified
  31641. */
  31642. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  31643. /**
  31644. * Fired when the touchpad button on this controller is modified
  31645. */
  31646. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  31647. /**
  31648. * Fired when the touchpad values on this controller are modified
  31649. */
  31650. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  31651. private _updateTrackpad();
  31652. /**
  31653. * Called once per frame by the engine.
  31654. */
  31655. update(): void;
  31656. /**
  31657. * Called once for each button that changed state since the last frame
  31658. * @param buttonIdx Which button index changed
  31659. * @param state New state of the button
  31660. * @param changes Which properties on the state changed since last frame
  31661. */
  31662. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  31663. /**
  31664. * Moves the buttons on the controller mesh based on their current state
  31665. * @param buttonName the name of the button to move
  31666. * @param buttonValue the value of the button which determines the buttons new position
  31667. */
  31668. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  31669. /**
  31670. * Moves the axis on the controller mesh based on its current state
  31671. * @param axis the index of the axis
  31672. * @param axisValue the value of the axis which determines the meshes new position
  31673. * @hidden
  31674. */
  31675. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  31676. /**
  31677. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  31678. * @param scene scene in which to add meshes
  31679. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  31680. */
  31681. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  31682. /**
  31683. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  31684. * can be transformed by button presses and axes values, based on this._mapping.
  31685. *
  31686. * @param scene scene in which the meshes exist
  31687. * @param meshes list of meshes that make up the controller model to process
  31688. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  31689. */
  31690. private processModel(scene, meshes);
  31691. private createMeshInfo(rootNode);
  31692. /**
  31693. * Gets the ray of the controller in the direction the controller is pointing
  31694. * @param length the length the resulting ray should be
  31695. * @returns a ray in the direction the controller is pointing
  31696. */
  31697. getForwardRay(length?: number): Ray;
  31698. /**
  31699. * Disposes of the controller
  31700. */
  31701. dispose(): void;
  31702. }
  31703. }
  31704. declare module BABYLON {
  31705. /**
  31706. * Interface to implement to create a shadow generator compatible with BJS.
  31707. */
  31708. interface IShadowGenerator {
  31709. /**
  31710. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  31711. * @returns The render target texture if present otherwise, null
  31712. */
  31713. getShadowMap(): Nullable<RenderTargetTexture>;
  31714. /**
  31715. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  31716. * @returns The render target texture if the shadow map is present otherwise, null
  31717. */
  31718. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  31719. /**
  31720. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  31721. * @param subMesh The submesh we want to render in the shadow map
  31722. * @param useInstances Defines wether will draw in the map using instances
  31723. * @returns true if ready otherwise, false
  31724. */
  31725. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  31726. /**
  31727. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  31728. * @param defines Defines of the material we want to update
  31729. * @param lightIndex Index of the light in the enabled light list of the material
  31730. */
  31731. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  31732. /**
  31733. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  31734. * defined in the generator but impacting the effect).
  31735. * It implies the unifroms available on the materials are the standard BJS ones.
  31736. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  31737. * @param effect The effect we are binfing the information for
  31738. */
  31739. bindShadowLight(lightIndex: string, effect: Effect): void;
  31740. /**
  31741. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  31742. * (eq to shadow prjection matrix * light transform matrix)
  31743. * @returns The transform matrix used to create the shadow map
  31744. */
  31745. getTransformMatrix(): Matrix;
  31746. /**
  31747. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  31748. * Cube and 2D textures for instance.
  31749. */
  31750. recreateShadowMap(): void;
  31751. /**
  31752. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  31753. * @param onCompiled Callback triggered at the and of the effects compilation
  31754. * @param options Sets of optional options forcing the compilation with different modes
  31755. */
  31756. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  31757. useInstances: boolean;
  31758. }>): void;
  31759. /**
  31760. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  31761. * @param options Sets of optional options forcing the compilation with different modes
  31762. * @returns A promise that resolves when the compilation completes
  31763. */
  31764. forceCompilationAsync(options?: Partial<{
  31765. useInstances: boolean;
  31766. }>): Promise<void>;
  31767. /**
  31768. * Serializes the shadow generator setup to a json object.
  31769. * @returns The serialized JSON object
  31770. */
  31771. serialize(): any;
  31772. /**
  31773. * Disposes the Shadow map and related Textures and effects.
  31774. */
  31775. dispose(): void;
  31776. }
  31777. /**
  31778. * Default implementation IShadowGenerator.
  31779. * This is the main object responsible of generating shadows in the framework.
  31780. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  31781. */
  31782. class ShadowGenerator implements IShadowGenerator {
  31783. /**
  31784. * Shadow generator mode None: no filtering applied.
  31785. */
  31786. static readonly FILTER_NONE: number;
  31787. /**
  31788. * Shadow generator mode ESM: Exponential Shadow Mapping.
  31789. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  31790. */
  31791. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  31792. /**
  31793. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  31794. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  31795. */
  31796. static readonly FILTER_POISSONSAMPLING: number;
  31797. /**
  31798. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  31799. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  31800. */
  31801. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  31802. /**
  31803. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  31804. * edge artifacts on steep falloff.
  31805. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  31806. */
  31807. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  31808. /**
  31809. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  31810. * edge artifacts on steep falloff.
  31811. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  31812. */
  31813. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  31814. /**
  31815. * Shadow generator mode PCF: Percentage Closer Filtering
  31816. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  31817. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  31818. */
  31819. static readonly FILTER_PCF: number;
  31820. /**
  31821. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  31822. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  31823. * Contact Hardening
  31824. */
  31825. static readonly FILTER_PCSS: number;
  31826. /**
  31827. * Reserved for PCF and PCSS
  31828. * Highest Quality.
  31829. *
  31830. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  31831. *
  31832. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  31833. */
  31834. static readonly QUALITY_HIGH: number;
  31835. /**
  31836. * Reserved for PCF and PCSS
  31837. * Good tradeoff for quality/perf cross devices
  31838. *
  31839. * Execute PCF on a 3*3 kernel.
  31840. *
  31841. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  31842. */
  31843. static readonly QUALITY_MEDIUM: number;
  31844. /**
  31845. * Reserved for PCF and PCSS
  31846. * The lowest quality but the fastest.
  31847. *
  31848. * Execute PCF on a 1*1 kernel.
  31849. *
  31850. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  31851. */
  31852. static readonly QUALITY_LOW: number;
  31853. private _bias;
  31854. /**
  31855. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  31856. */
  31857. /**
  31858. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  31859. */
  31860. bias: number;
  31861. private _normalBias;
  31862. /**
  31863. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  31864. */
  31865. /**
  31866. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  31867. */
  31868. normalBias: number;
  31869. private _blurBoxOffset;
  31870. /**
  31871. * Gets the blur box offset: offset applied during the blur pass.
  31872. * Only usefull if useKernelBlur = false
  31873. */
  31874. /**
  31875. * Sets the blur box offset: offset applied during the blur pass.
  31876. * Only usefull if useKernelBlur = false
  31877. */
  31878. blurBoxOffset: number;
  31879. private _blurScale;
  31880. /**
  31881. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  31882. * 2 means half of the size.
  31883. */
  31884. /**
  31885. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  31886. * 2 means half of the size.
  31887. */
  31888. blurScale: number;
  31889. private _blurKernel;
  31890. /**
  31891. * Gets the blur kernel: kernel size of the blur pass.
  31892. * Only usefull if useKernelBlur = true
  31893. */
  31894. /**
  31895. * Sets the blur kernel: kernel size of the blur pass.
  31896. * Only usefull if useKernelBlur = true
  31897. */
  31898. blurKernel: number;
  31899. private _useKernelBlur;
  31900. /**
  31901. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  31902. * Only usefull in filtered mode (useBlurExponentialShadowMap...)
  31903. */
  31904. /**
  31905. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  31906. * Only usefull in filtered mode (useBlurExponentialShadowMap...)
  31907. */
  31908. useKernelBlur: boolean;
  31909. private _depthScale;
  31910. /**
  31911. * Gets the depth scale used in ESM mode.
  31912. */
  31913. /**
  31914. * Sets the depth scale used in ESM mode.
  31915. * This can override the scale stored on the light.
  31916. */
  31917. depthScale: number;
  31918. private _filter;
  31919. /**
  31920. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  31921. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  31922. */
  31923. /**
  31924. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  31925. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  31926. */
  31927. filter: number;
  31928. /**
  31929. * Gets if the current filter is set to Poisson Sampling.
  31930. */
  31931. /**
  31932. * Sets the current filter to Poisson Sampling.
  31933. */
  31934. usePoissonSampling: boolean;
  31935. /**
  31936. * Gets if the current filter is set to VSM.
  31937. * DEPRECATED. Should use useExponentialShadowMap instead.
  31938. */
  31939. /**
  31940. * Sets the current filter is to VSM.
  31941. * DEPRECATED. Should use useExponentialShadowMap instead.
  31942. */
  31943. useVarianceShadowMap: boolean;
  31944. /**
  31945. * Gets if the current filter is set to blurred VSM.
  31946. * DEPRECATED. Should use useBlurExponentialShadowMap instead.
  31947. */
  31948. /**
  31949. * Sets the current filter is to blurred VSM.
  31950. * DEPRECATED. Should use useBlurExponentialShadowMap instead.
  31951. */
  31952. useBlurVarianceShadowMap: boolean;
  31953. /**
  31954. * Gets if the current filter is set to ESM.
  31955. */
  31956. /**
  31957. * Sets the current filter is to ESM.
  31958. */
  31959. useExponentialShadowMap: boolean;
  31960. /**
  31961. * Gets if the current filter is set to filtered ESM.
  31962. */
  31963. /**
  31964. * Gets if the current filter is set to filtered ESM.
  31965. */
  31966. useBlurExponentialShadowMap: boolean;
  31967. /**
  31968. * Gets if the current filter is set to "close ESM" (using the inverse of the
  31969. * exponential to prevent steep falloff artifacts).
  31970. */
  31971. /**
  31972. * Sets the current filter to "close ESM" (using the inverse of the
  31973. * exponential to prevent steep falloff artifacts).
  31974. */
  31975. useCloseExponentialShadowMap: boolean;
  31976. /**
  31977. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  31978. * exponential to prevent steep falloff artifacts).
  31979. */
  31980. /**
  31981. * Sets the current filter to filtered "close ESM" (using the inverse of the
  31982. * exponential to prevent steep falloff artifacts).
  31983. */
  31984. useBlurCloseExponentialShadowMap: boolean;
  31985. /**
  31986. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  31987. */
  31988. /**
  31989. * Sets the current filter to "PCF" (percentage closer filtering).
  31990. */
  31991. usePercentageCloserFiltering: boolean;
  31992. private _filteringQuality;
  31993. /**
  31994. * Gets the PCF or PCSS Quality.
  31995. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  31996. */
  31997. /**
  31998. * Sets the PCF or PCSS Quality.
  31999. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  32000. */
  32001. filteringQuality: number;
  32002. /**
  32003. * Gets if the current filter is set to "PCSS" (contact hardening).
  32004. */
  32005. /**
  32006. * Sets the current filter to "PCSS" (contact hardening).
  32007. */
  32008. useContactHardeningShadow: boolean;
  32009. private _contactHardeningLightSizeUVRatio;
  32010. /**
  32011. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  32012. * Using a ratio helps keeping shape stability independently of the map size.
  32013. *
  32014. * It does not account for the light projection as it was having too much
  32015. * instability during the light setup or during light position changes.
  32016. *
  32017. * Only valid if useContactHardeningShadow is true.
  32018. */
  32019. /**
  32020. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  32021. * Using a ratio helps keeping shape stability independently of the map size.
  32022. *
  32023. * It does not account for the light projection as it was having too much
  32024. * instability during the light setup or during light position changes.
  32025. *
  32026. * Only valid if useContactHardeningShadow is true.
  32027. */
  32028. contactHardeningLightSizeUVRatio: number;
  32029. private _darkness;
  32030. /**
  32031. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  32032. * 0 means strongest and 1 would means no shadow.
  32033. * @returns the darkness.
  32034. */
  32035. getDarkness(): number;
  32036. /**
  32037. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  32038. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  32039. * @returns the shadow generator allowing fluent coding.
  32040. */
  32041. setDarkness(darkness: number): ShadowGenerator;
  32042. private _transparencyShadow;
  32043. /**
  32044. * Sets the ability to have transparent shadow (boolean).
  32045. * @param transparent True if transparent else False
  32046. * @returns the shadow generator allowing fluent coding
  32047. */
  32048. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  32049. private _shadowMap;
  32050. private _shadowMap2;
  32051. /**
  32052. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  32053. * @returns The render target texture if present otherwise, null
  32054. */
  32055. getShadowMap(): Nullable<RenderTargetTexture>;
  32056. /**
  32057. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  32058. * @returns The render target texture if the shadow map is present otherwise, null
  32059. */
  32060. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  32061. /**
  32062. * Helper function to add a mesh and its descendants to the list of shadow casters.
  32063. * @param mesh Mesh to add
  32064. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  32065. * @returns the Shadow Generator itself
  32066. */
  32067. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  32068. /**
  32069. * Helper function to remove a mesh and its descendants from the list of shadow casters
  32070. * @param mesh Mesh to remove
  32071. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  32072. * @returns the Shadow Generator itself
  32073. */
  32074. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  32075. /**
  32076. * Controls the extent to which the shadows fade out at the edge of the frustum
  32077. * Used only by directionals and spots
  32078. */
  32079. frustumEdgeFalloff: number;
  32080. private _light;
  32081. /**
  32082. * Returns the associated light object.
  32083. * @returns the light generating the shadow
  32084. */
  32085. getLight(): IShadowLight;
  32086. /**
  32087. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  32088. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  32089. * It might on the other hand introduce peter panning.
  32090. */
  32091. forceBackFacesOnly: boolean;
  32092. private _scene;
  32093. private _lightDirection;
  32094. private _effect;
  32095. private _viewMatrix;
  32096. private _projectionMatrix;
  32097. private _transformMatrix;
  32098. private _cachedPosition;
  32099. private _cachedDirection;
  32100. private _cachedDefines;
  32101. private _currentRenderID;
  32102. private _boxBlurPostprocess;
  32103. private _kernelBlurXPostprocess;
  32104. private _kernelBlurYPostprocess;
  32105. private _blurPostProcesses;
  32106. private _mapSize;
  32107. private _currentFaceIndex;
  32108. private _currentFaceIndexCache;
  32109. private _textureType;
  32110. private _defaultTextureMatrix;
  32111. /**
  32112. * Creates a ShadowGenerator object.
  32113. * A ShadowGenerator is the required tool to use the shadows.
  32114. * Each light casting shadows needs to use its own ShadowGenerator.
  32115. * Documentation : http://doc.babylonjs.com/tutorials/shadows
  32116. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  32117. * @param light The light object generating the shadows.
  32118. * @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.
  32119. */
  32120. constructor(mapSize: number, light: IShadowLight, useFullFloatFirst?: boolean);
  32121. private _initializeGenerator();
  32122. private _initializeShadowMap();
  32123. private _initializeBlurRTTAndPostProcesses();
  32124. private _renderForShadowMap(opaqueSubMeshes, alphaTestSubMeshes, transparentSubMeshes, depthOnlySubMeshes);
  32125. private _renderSubMeshForShadowMap(subMesh);
  32126. private _applyFilterValues();
  32127. /**
  32128. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  32129. * @param onCompiled Callback triggered at the and of the effects compilation
  32130. * @param options Sets of optional options forcing the compilation with different modes
  32131. */
  32132. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  32133. useInstances: boolean;
  32134. }>): void;
  32135. /**
  32136. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  32137. * @param options Sets of optional options forcing the compilation with different modes
  32138. * @returns A promise that resolves when the compilation completes
  32139. */
  32140. forceCompilationAsync(options?: Partial<{
  32141. useInstances: boolean;
  32142. }>): Promise<void>;
  32143. /**
  32144. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  32145. * @param subMesh The submesh we want to render in the shadow map
  32146. * @param useInstances Defines wether will draw in the map using instances
  32147. * @returns true if ready otherwise, false
  32148. */
  32149. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  32150. /**
  32151. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  32152. * @param defines Defines of the material we want to update
  32153. * @param lightIndex Index of the light in the enabled light list of the material
  32154. */
  32155. prepareDefines(defines: any, lightIndex: number): void;
  32156. /**
  32157. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  32158. * defined in the generator but impacting the effect).
  32159. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  32160. * @param effect The effect we are binfing the information for
  32161. */
  32162. bindShadowLight(lightIndex: string, effect: Effect): void;
  32163. /**
  32164. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  32165. * (eq to shadow prjection matrix * light transform matrix)
  32166. * @returns The transform matrix used to create the shadow map
  32167. */
  32168. getTransformMatrix(): Matrix;
  32169. /**
  32170. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  32171. * Cube and 2D textures for instance.
  32172. */
  32173. recreateShadowMap(): void;
  32174. private _disposeBlurPostProcesses();
  32175. private _disposeRTTandPostProcesses();
  32176. /**
  32177. * Disposes the ShadowGenerator.
  32178. * Returns nothing.
  32179. */
  32180. dispose(): void;
  32181. /**
  32182. * Serializes the shadow generator setup to a json object.
  32183. * @returns The serialized JSON object
  32184. */
  32185. serialize(): any;
  32186. /**
  32187. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  32188. * @param parsedShadowGenerator The JSON object to parse
  32189. * @param scene The scene to create the shadow map for
  32190. * @returns The parsed shadow generator
  32191. */
  32192. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  32193. }
  32194. }
  32195. declare module BABYLON {
  32196. }
  32197. declare module BABYLON {
  32198. /**
  32199. * Background material used to create an efficient environement around your scene.
  32200. */
  32201. class BackgroundMaterial extends PushMaterial {
  32202. /**
  32203. * Standard reflectance value at parallel view angle.
  32204. */
  32205. static StandardReflectance0: number;
  32206. /**
  32207. * Standard reflectance value at grazing angle.
  32208. */
  32209. static StandardReflectance90: number;
  32210. protected _primaryColor: Color3;
  32211. /**
  32212. * Key light Color (multiply against the environement texture)
  32213. */
  32214. primaryColor: Color3;
  32215. protected __perceptualColor: Nullable<Color3>;
  32216. /**
  32217. * Experimental Internal Use Only.
  32218. *
  32219. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  32220. * This acts as a helper to set the primary color to a more "human friendly" value.
  32221. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  32222. * output color as close as possible from the chosen value.
  32223. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  32224. * part of lighting setup.)
  32225. */
  32226. protected _primaryColorShadowLevel: float;
  32227. /**
  32228. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  32229. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  32230. */
  32231. primaryColorShadowLevel: float;
  32232. protected _primaryColorHighlightLevel: float;
  32233. /**
  32234. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  32235. * The primary color is used at the level chosen to define what the white area would look.
  32236. */
  32237. primaryColorHighlightLevel: float;
  32238. protected _reflectionTexture: Nullable<BaseTexture>;
  32239. /**
  32240. * Reflection Texture used in the material.
  32241. * Should be author in a specific way for the best result (refer to the documentation).
  32242. */
  32243. reflectionTexture: Nullable<BaseTexture>;
  32244. protected _reflectionBlur: float;
  32245. /**
  32246. * Reflection Texture level of blur.
  32247. *
  32248. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  32249. * texture twice.
  32250. */
  32251. reflectionBlur: float;
  32252. protected _diffuseTexture: Nullable<BaseTexture>;
  32253. /**
  32254. * Diffuse Texture used in the material.
  32255. * Should be author in a specific way for the best result (refer to the documentation).
  32256. */
  32257. diffuseTexture: Nullable<BaseTexture>;
  32258. protected _shadowLights: Nullable<IShadowLight[]>;
  32259. /**
  32260. * Specify the list of lights casting shadow on the material.
  32261. * All scene shadow lights will be included if null.
  32262. */
  32263. shadowLights: Nullable<IShadowLight[]>;
  32264. protected _shadowLevel: float;
  32265. /**
  32266. * Helps adjusting the shadow to a softer level if required.
  32267. * 0 means black shadows and 1 means no shadows.
  32268. */
  32269. shadowLevel: float;
  32270. protected _sceneCenter: Vector3;
  32271. /**
  32272. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  32273. * It is usually zero but might be interesting to modify according to your setup.
  32274. */
  32275. sceneCenter: Vector3;
  32276. protected _opacityFresnel: boolean;
  32277. /**
  32278. * This helps specifying that the material is falling off to the sky box at grazing angle.
  32279. * This helps ensuring a nice transition when the camera goes under the ground.
  32280. */
  32281. opacityFresnel: boolean;
  32282. protected _reflectionFresnel: boolean;
  32283. /**
  32284. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  32285. * This helps adding a mirror texture on the ground.
  32286. */
  32287. reflectionFresnel: boolean;
  32288. protected _reflectionFalloffDistance: number;
  32289. /**
  32290. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  32291. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  32292. */
  32293. reflectionFalloffDistance: number;
  32294. protected _reflectionAmount: number;
  32295. /**
  32296. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  32297. */
  32298. reflectionAmount: number;
  32299. protected _reflectionReflectance0: number;
  32300. /**
  32301. * This specifies the weight of the reflection at grazing angle.
  32302. */
  32303. reflectionReflectance0: number;
  32304. protected _reflectionReflectance90: number;
  32305. /**
  32306. * This specifies the weight of the reflection at a perpendicular point of view.
  32307. */
  32308. reflectionReflectance90: number;
  32309. /**
  32310. * Sets the reflection reflectance fresnel values according to the default standard
  32311. * empirically know to work well :-)
  32312. */
  32313. reflectionStandardFresnelWeight: number;
  32314. protected _useRGBColor: boolean;
  32315. /**
  32316. * Helps to directly use the maps channels instead of their level.
  32317. */
  32318. useRGBColor: boolean;
  32319. protected _enableNoise: boolean;
  32320. /**
  32321. * This helps reducing the banding effect that could occur on the background.
  32322. */
  32323. enableNoise: boolean;
  32324. /**
  32325. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  32326. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  32327. * Recommended to be keep at 1.0 except for special cases.
  32328. */
  32329. fovMultiplier: number;
  32330. private _fovMultiplier;
  32331. /**
  32332. * Enable the FOV adjustment feature controlled by fovMultiplier.
  32333. */
  32334. useEquirectangularFOV: boolean;
  32335. private _maxSimultaneousLights;
  32336. /**
  32337. * Number of Simultaneous lights allowed on the material.
  32338. */
  32339. maxSimultaneousLights: int;
  32340. /**
  32341. * Default configuration related to image processing available in the Background Material.
  32342. */
  32343. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  32344. /**
  32345. * Keep track of the image processing observer to allow dispose and replace.
  32346. */
  32347. private _imageProcessingObserver;
  32348. /**
  32349. * Attaches a new image processing configuration to the PBR Material.
  32350. * @param configuration (if null the scene configuration will be use)
  32351. */
  32352. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  32353. /**
  32354. * Gets the image processing configuration used either in this material.
  32355. */
  32356. /**
  32357. * Sets the Default image processing configuration used either in the this material.
  32358. *
  32359. * If sets to null, the scene one is in use.
  32360. */
  32361. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  32362. /**
  32363. * Gets wether the color curves effect is enabled.
  32364. */
  32365. /**
  32366. * Sets wether the color curves effect is enabled.
  32367. */
  32368. cameraColorCurvesEnabled: boolean;
  32369. /**
  32370. * Gets wether the color grading effect is enabled.
  32371. */
  32372. /**
  32373. * Gets wether the color grading effect is enabled.
  32374. */
  32375. cameraColorGradingEnabled: boolean;
  32376. /**
  32377. * Gets wether tonemapping is enabled or not.
  32378. */
  32379. /**
  32380. * Sets wether tonemapping is enabled or not
  32381. */
  32382. cameraToneMappingEnabled: boolean;
  32383. /**
  32384. * The camera exposure used on this material.
  32385. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  32386. * This corresponds to a photographic exposure.
  32387. */
  32388. /**
  32389. * The camera exposure used on this material.
  32390. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  32391. * This corresponds to a photographic exposure.
  32392. */
  32393. cameraExposure: float;
  32394. /**
  32395. * Gets The camera contrast used on this material.
  32396. */
  32397. /**
  32398. * Sets The camera contrast used on this material.
  32399. */
  32400. cameraContrast: float;
  32401. /**
  32402. * Gets the Color Grading 2D Lookup Texture.
  32403. */
  32404. /**
  32405. * Sets the Color Grading 2D Lookup Texture.
  32406. */
  32407. cameraColorGradingTexture: Nullable<BaseTexture>;
  32408. /**
  32409. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  32410. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  32411. * 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;
  32412. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  32413. */
  32414. /**
  32415. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  32416. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  32417. * 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;
  32418. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  32419. */
  32420. cameraColorCurves: Nullable<ColorCurves>;
  32421. /**
  32422. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  32423. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  32424. */
  32425. switchToBGR: boolean;
  32426. private _renderTargets;
  32427. private _reflectionControls;
  32428. private _white;
  32429. private _primaryShadowColor;
  32430. private _primaryHighlightColor;
  32431. /**
  32432. * Instantiates a Background Material in the given scene
  32433. * @param name The friendly name of the material
  32434. * @param scene The scene to add the material to
  32435. */
  32436. constructor(name: string, scene: Scene);
  32437. /**
  32438. * The entire material has been created in order to prevent overdraw.
  32439. * @returns false
  32440. */
  32441. needAlphaTesting(): boolean;
  32442. /**
  32443. * The entire material has been created in order to prevent overdraw.
  32444. * @returns true if blending is enable
  32445. */
  32446. needAlphaBlending(): boolean;
  32447. /**
  32448. * Checks wether the material is ready to be rendered for a given mesh.
  32449. * @param mesh The mesh to render
  32450. * @param subMesh The submesh to check against
  32451. * @param useInstances Specify wether or not the material is used with instances
  32452. * @returns true if all the dependencies are ready (Textures, Effects...)
  32453. */
  32454. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  32455. /**
  32456. * Compute the primary color according to the chosen perceptual color.
  32457. */
  32458. private _computePrimaryColorFromPerceptualColor();
  32459. /**
  32460. * Compute the highlights and shadow colors according to their chosen levels.
  32461. */
  32462. private _computePrimaryColors();
  32463. /**
  32464. * Build the uniform buffer used in the material.
  32465. */
  32466. buildUniformLayout(): void;
  32467. /**
  32468. * Unbind the material.
  32469. */
  32470. unbind(): void;
  32471. /**
  32472. * Bind only the world matrix to the material.
  32473. * @param world The world matrix to bind.
  32474. */
  32475. bindOnlyWorldMatrix(world: Matrix): void;
  32476. /**
  32477. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  32478. * @param world The world matrix to bind.
  32479. * @param subMesh The submesh to bind for.
  32480. */
  32481. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  32482. /**
  32483. * Dispose the material.
  32484. * @param forceDisposeEffect Force disposal of the associated effect.
  32485. * @param forceDisposeTextures Force disposal of the associated textures.
  32486. */
  32487. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  32488. /**
  32489. * Clones the material.
  32490. * @param name The cloned name.
  32491. * @returns The cloned material.
  32492. */
  32493. clone(name: string): BackgroundMaterial;
  32494. /**
  32495. * Serializes the current material to its JSON representation.
  32496. * @returns The JSON representation.
  32497. */
  32498. serialize(): any;
  32499. /**
  32500. * Gets the class name of the material
  32501. * @returns "BackgroundMaterial"
  32502. */
  32503. getClassName(): string;
  32504. /**
  32505. * Parse a JSON input to create back a background material.
  32506. * @param source The JSON data to parse
  32507. * @param scene The scene to create the parsed material in
  32508. * @param rootUrl The root url of the assets the material depends upon
  32509. * @returns the instantiated BackgroundMaterial.
  32510. */
  32511. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  32512. }
  32513. }
  32514. declare module BABYLON {
  32515. /**
  32516. * The Physically based material base class of BJS.
  32517. *
  32518. * This offers the main features of a standard PBR material.
  32519. * For more information, please refer to the documentation :
  32520. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  32521. */
  32522. abstract class PBRBaseMaterial extends PushMaterial {
  32523. /**
  32524. * Intensity of the direct lights e.g. the four lights available in your scene.
  32525. * This impacts both the direct diffuse and specular highlights.
  32526. */
  32527. protected _directIntensity: number;
  32528. /**
  32529. * Intensity of the emissive part of the material.
  32530. * This helps controlling the emissive effect without modifying the emissive color.
  32531. */
  32532. protected _emissiveIntensity: number;
  32533. /**
  32534. * Intensity of the environment e.g. how much the environment will light the object
  32535. * either through harmonics for rough material or through the refelction for shiny ones.
  32536. */
  32537. protected _environmentIntensity: number;
  32538. /**
  32539. * This is a special control allowing the reduction of the specular highlights coming from the
  32540. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  32541. */
  32542. protected _specularIntensity: number;
  32543. /**
  32544. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  32545. */
  32546. private _lightingInfos;
  32547. /**
  32548. * Debug Control allowing disabling the bump map on this material.
  32549. */
  32550. protected _disableBumpMap: boolean;
  32551. /**
  32552. * AKA Diffuse Texture in standard nomenclature.
  32553. */
  32554. protected _albedoTexture: BaseTexture;
  32555. /**
  32556. * AKA Occlusion Texture in other nomenclature.
  32557. */
  32558. protected _ambientTexture: BaseTexture;
  32559. /**
  32560. * AKA Occlusion Texture Intensity in other nomenclature.
  32561. */
  32562. protected _ambientTextureStrength: number;
  32563. /**
  32564. * Stores the alpha values in a texture.
  32565. */
  32566. protected _opacityTexture: BaseTexture;
  32567. /**
  32568. * Stores the reflection values in a texture.
  32569. */
  32570. protected _reflectionTexture: BaseTexture;
  32571. /**
  32572. * Stores the refraction values in a texture.
  32573. */
  32574. protected _refractionTexture: BaseTexture;
  32575. /**
  32576. * Stores the emissive values in a texture.
  32577. */
  32578. protected _emissiveTexture: BaseTexture;
  32579. /**
  32580. * AKA Specular texture in other nomenclature.
  32581. */
  32582. protected _reflectivityTexture: BaseTexture;
  32583. /**
  32584. * Used to switch from specular/glossiness to metallic/roughness workflow.
  32585. */
  32586. protected _metallicTexture: BaseTexture;
  32587. /**
  32588. * Specifies the metallic scalar of the metallic/roughness workflow.
  32589. * Can also be used to scale the metalness values of the metallic texture.
  32590. */
  32591. protected _metallic: number;
  32592. /**
  32593. * Specifies the roughness scalar of the metallic/roughness workflow.
  32594. * Can also be used to scale the roughness values of the metallic texture.
  32595. */
  32596. protected _roughness: number;
  32597. /**
  32598. * Used to enable roughness/glossiness fetch from a separate chanel depending on the current mode.
  32599. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  32600. */
  32601. protected _microSurfaceTexture: BaseTexture;
  32602. /**
  32603. * Stores surface normal data used to displace a mesh in a texture.
  32604. */
  32605. protected _bumpTexture: BaseTexture;
  32606. /**
  32607. * Stores the pre-calculated light information of a mesh in a texture.
  32608. */
  32609. protected _lightmapTexture: BaseTexture;
  32610. /**
  32611. * The color of a material in ambient lighting.
  32612. */
  32613. protected _ambientColor: Color3;
  32614. /**
  32615. * AKA Diffuse Color in other nomenclature.
  32616. */
  32617. protected _albedoColor: Color3;
  32618. /**
  32619. * AKA Specular Color in other nomenclature.
  32620. */
  32621. protected _reflectivityColor: Color3;
  32622. /**
  32623. * The color applied when light is reflected from a material.
  32624. */
  32625. protected _reflectionColor: Color3;
  32626. /**
  32627. * The color applied when light is emitted from a material.
  32628. */
  32629. protected _emissiveColor: Color3;
  32630. /**
  32631. * AKA Glossiness in other nomenclature.
  32632. */
  32633. protected _microSurface: number;
  32634. /**
  32635. * source material index of refraction (IOR)' / 'destination material IOR.
  32636. */
  32637. protected _indexOfRefraction: number;
  32638. /**
  32639. * Controls if refraction needs to be inverted on Y. This could be usefull for procedural texture.
  32640. */
  32641. protected _invertRefractionY: boolean;
  32642. /**
  32643. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  32644. * Materials half opaque for instance using refraction could benefit from this control.
  32645. */
  32646. protected _linkRefractionWithTransparency: boolean;
  32647. /**
  32648. * Specifies that the material will use the light map as a show map.
  32649. */
  32650. protected _useLightmapAsShadowmap: boolean;
  32651. /**
  32652. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  32653. * makes the reflect vector face the model (under horizon).
  32654. */
  32655. protected _useHorizonOcclusion: boolean;
  32656. /**
  32657. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  32658. * too much the area relying on ambient texture to define their ambient occlusion.
  32659. */
  32660. protected _useRadianceOcclusion: boolean;
  32661. /**
  32662. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  32663. */
  32664. protected _useAlphaFromAlbedoTexture: boolean;
  32665. /**
  32666. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  32667. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  32668. */
  32669. protected _useSpecularOverAlpha: boolean;
  32670. /**
  32671. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  32672. */
  32673. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  32674. /**
  32675. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  32676. */
  32677. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  32678. /**
  32679. * Specifies if the metallic texture contains the roughness information in its green channel.
  32680. */
  32681. protected _useRoughnessFromMetallicTextureGreen: boolean;
  32682. /**
  32683. * Specifies if the metallic texture contains the metallness information in its blue channel.
  32684. */
  32685. protected _useMetallnessFromMetallicTextureBlue: boolean;
  32686. /**
  32687. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  32688. */
  32689. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  32690. /**
  32691. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  32692. */
  32693. protected _useAmbientInGrayScale: boolean;
  32694. /**
  32695. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  32696. * The material will try to infer what glossiness each pixel should be.
  32697. */
  32698. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  32699. /**
  32700. * BJS is using an harcoded light falloff based on a manually sets up range.
  32701. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  32702. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  32703. */
  32704. protected _usePhysicalLightFalloff: boolean;
  32705. /**
  32706. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  32707. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  32708. */
  32709. protected _useRadianceOverAlpha: boolean;
  32710. /**
  32711. * Allows using an object space normal map (instead of tangent space).
  32712. */
  32713. protected _useObjectSpaceNormalMap: boolean;
  32714. /**
  32715. * Allows using the bump map in parallax mode.
  32716. */
  32717. protected _useParallax: boolean;
  32718. /**
  32719. * Allows using the bump map in parallax occlusion mode.
  32720. */
  32721. protected _useParallaxOcclusion: boolean;
  32722. /**
  32723. * Controls the scale bias of the parallax mode.
  32724. */
  32725. protected _parallaxScaleBias: number;
  32726. /**
  32727. * If sets to true, disables all the lights affecting the material.
  32728. */
  32729. protected _disableLighting: boolean;
  32730. /**
  32731. * Number of Simultaneous lights allowed on the material.
  32732. */
  32733. protected _maxSimultaneousLights: number;
  32734. /**
  32735. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  32736. */
  32737. protected _invertNormalMapX: boolean;
  32738. /**
  32739. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  32740. */
  32741. protected _invertNormalMapY: boolean;
  32742. /**
  32743. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  32744. */
  32745. protected _twoSidedLighting: boolean;
  32746. /**
  32747. * Defines the alpha limits in alpha test mode.
  32748. */
  32749. protected _alphaCutOff: number;
  32750. /**
  32751. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  32752. */
  32753. protected _forceAlphaTest: boolean;
  32754. /**
  32755. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  32756. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  32757. */
  32758. protected _useAlphaFresnel: boolean;
  32759. /**
  32760. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  32761. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  32762. */
  32763. protected _useLinearAlphaFresnel: boolean;
  32764. /**
  32765. * The transparency mode of the material.
  32766. */
  32767. protected _transparencyMode: Nullable<number>;
  32768. /**
  32769. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  32770. * from cos thetav and roughness:
  32771. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  32772. */
  32773. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  32774. /**
  32775. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  32776. */
  32777. protected _forceIrradianceInFragment: boolean;
  32778. /**
  32779. * Force normal to face away from face.
  32780. */
  32781. protected _forceNormalForward: boolean;
  32782. /**
  32783. * Enables specular anti aliasing in the PBR shader.
  32784. * It will both interacts on the Geometry for analytical and IBL lighting.
  32785. * It also prefilter the roughness map based on the bump values.
  32786. */
  32787. protected _enableSpecularAntiAliasing: boolean;
  32788. /**
  32789. * Default configuration related to image processing available in the PBR Material.
  32790. */
  32791. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  32792. /**
  32793. * Keep track of the image processing observer to allow dispose and replace.
  32794. */
  32795. private _imageProcessingObserver;
  32796. /**
  32797. * Attaches a new image processing configuration to the PBR Material.
  32798. * @param configuration
  32799. */
  32800. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  32801. /**
  32802. * Stores the available render targets.
  32803. */
  32804. private _renderTargets;
  32805. /**
  32806. * Sets the global ambient color for the material used in lighting calculations.
  32807. */
  32808. private _globalAmbientColor;
  32809. /**
  32810. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  32811. */
  32812. private _useLogarithmicDepth;
  32813. /**
  32814. * If set to true, no lighting calculations will be applied.
  32815. */
  32816. private _unlit;
  32817. /**
  32818. * Instantiates a new PBRMaterial instance.
  32819. *
  32820. * @param name The material name
  32821. * @param scene The scene the material will be use in.
  32822. */
  32823. constructor(name: string, scene: Scene);
  32824. /**
  32825. * Gets the name of the material class.
  32826. */
  32827. getClassName(): string;
  32828. /**
  32829. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  32830. */
  32831. /**
  32832. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  32833. */
  32834. useLogarithmicDepth: boolean;
  32835. /**
  32836. * Gets the current transparency mode.
  32837. */
  32838. /**
  32839. * Sets the transparency mode of the material.
  32840. *
  32841. * | Value | Type | Description |
  32842. * | ----- | ----------------------------------- | ----------- |
  32843. * | 0 | OPAQUE | |
  32844. * | 1 | ALPHATEST | |
  32845. * | 2 | ALPHABLEND | |
  32846. * | 3 | ALPHATESTANDBLEND | |
  32847. *
  32848. */
  32849. transparencyMode: Nullable<number>;
  32850. /**
  32851. * Returns true if alpha blending should be disabled.
  32852. */
  32853. private readonly _disableAlphaBlending;
  32854. /**
  32855. * Specifies whether or not this material should be rendered in alpha blend mode.
  32856. */
  32857. needAlphaBlending(): boolean;
  32858. /**
  32859. * Specifies if the mesh will require alpha blending.
  32860. * @param mesh - BJS mesh.
  32861. */
  32862. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  32863. /**
  32864. * Specifies whether or not this material should be rendered in alpha test mode.
  32865. */
  32866. needAlphaTesting(): boolean;
  32867. /**
  32868. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  32869. */
  32870. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  32871. /**
  32872. * Gets the texture used for the alpha test.
  32873. */
  32874. getAlphaTestTexture(): BaseTexture;
  32875. /**
  32876. * Stores the reflectivity values based on metallic roughness workflow.
  32877. */
  32878. private static _scaledReflectivity;
  32879. /**
  32880. * Specifies that the submesh is ready to be used.
  32881. * @param mesh - BJS mesh.
  32882. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  32883. * @param useInstances - Specifies that instances should be used.
  32884. * @returns - boolean indicating that the submesh is ready or not.
  32885. */
  32886. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  32887. /**
  32888. * Specifies if the material uses metallic roughness workflow.
  32889. * @returns boolean specifiying if the material uses metallic roughness workflow.
  32890. */
  32891. isMetallicWorkflow(): boolean;
  32892. private _prepareEffect(mesh, defines, onCompiled?, onError?, useInstances?, useClipPlane?);
  32893. private _prepareDefines(mesh, defines, useInstances?, useClipPlane?);
  32894. /**
  32895. * Force shader compilation
  32896. */
  32897. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  32898. clipPlane: boolean;
  32899. }>): void;
  32900. /**
  32901. * Initializes the uniform buffer layout for the shader.
  32902. */
  32903. buildUniformLayout(): void;
  32904. /**
  32905. * Unbinds the textures.
  32906. */
  32907. unbind(): void;
  32908. /**
  32909. * Binds the submesh data.
  32910. * @param world - The world matrix.
  32911. * @param mesh - The BJS mesh.
  32912. * @param subMesh - A submesh of the BJS mesh.
  32913. */
  32914. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  32915. /**
  32916. * Returns the animatable textures.
  32917. * @returns - Array of animatable textures.
  32918. */
  32919. getAnimatables(): IAnimatable[];
  32920. /**
  32921. * Returns the texture used for reflections.
  32922. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  32923. */
  32924. private _getReflectionTexture();
  32925. /**
  32926. * Returns the texture used for refraction or null if none is used.
  32927. * @returns - Refection texture if present. If no refraction texture and refraction
  32928. * is linked with transparency, returns environment texture. Otherwise, returns null.
  32929. */
  32930. private _getRefractionTexture();
  32931. /**
  32932. * Disposes the resources of the material.
  32933. * @param forceDisposeEffect - Forces the disposal of effects.
  32934. * @param forceDisposeTextures - Forces the disposal of all textures.
  32935. */
  32936. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  32937. }
  32938. }
  32939. declare module BABYLON {
  32940. /**
  32941. * The Physically based simple base material of BJS.
  32942. *
  32943. * This enables better naming and convention enforcements on top of the pbrMaterial.
  32944. * It is used as the base class for both the specGloss and metalRough conventions.
  32945. */
  32946. abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  32947. /**
  32948. * Number of Simultaneous lights allowed on the material.
  32949. */
  32950. maxSimultaneousLights: number;
  32951. /**
  32952. * If sets to true, disables all the lights affecting the material.
  32953. */
  32954. disableLighting: boolean;
  32955. /**
  32956. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  32957. */
  32958. environmentTexture: BaseTexture;
  32959. /**
  32960. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  32961. */
  32962. invertNormalMapX: boolean;
  32963. /**
  32964. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  32965. */
  32966. invertNormalMapY: boolean;
  32967. /**
  32968. * Normal map used in the model.
  32969. */
  32970. normalTexture: BaseTexture;
  32971. /**
  32972. * Emissivie color used to self-illuminate the model.
  32973. */
  32974. emissiveColor: Color3;
  32975. /**
  32976. * Emissivie texture used to self-illuminate the model.
  32977. */
  32978. emissiveTexture: BaseTexture;
  32979. /**
  32980. * Occlusion Channel Strenght.
  32981. */
  32982. occlusionStrength: number;
  32983. /**
  32984. * Occlusion Texture of the material (adding extra occlusion effects).
  32985. */
  32986. occlusionTexture: BaseTexture;
  32987. /**
  32988. * Defines the alpha limits in alpha test mode.
  32989. */
  32990. alphaCutOff: number;
  32991. /**
  32992. * Gets the current double sided mode.
  32993. */
  32994. /**
  32995. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  32996. */
  32997. doubleSided: boolean;
  32998. lightmapTexture: BaseTexture;
  32999. useLightmapAsShadowmap: boolean;
  33000. /**
  33001. * Return the active textures of the material.
  33002. */
  33003. getActiveTextures(): BaseTexture[];
  33004. hasTexture(texture: BaseTexture): boolean;
  33005. /**
  33006. * Instantiates a new PBRMaterial instance.
  33007. *
  33008. * @param name The material name
  33009. * @param scene The scene the material will be use in.
  33010. */
  33011. constructor(name: string, scene: Scene);
  33012. getClassName(): string;
  33013. }
  33014. }
  33015. declare module BABYLON {
  33016. /**
  33017. * The Physically based material of BJS.
  33018. *
  33019. * This offers the main features of a standard PBR material.
  33020. * For more information, please refer to the documentation :
  33021. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  33022. */
  33023. class PBRMaterial extends PBRBaseMaterial {
  33024. private static _PBRMATERIAL_OPAQUE;
  33025. /**
  33026. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  33027. */
  33028. static readonly PBRMATERIAL_OPAQUE: number;
  33029. /**
  33030. * Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  33031. */
  33032. private static _PBRMATERIAL_ALPHATEST;
  33033. /**
  33034. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  33035. */
  33036. static readonly PBRMATERIAL_ALPHATEST: number;
  33037. /**
  33038. * Represents the value for Alpha Blend. Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  33039. */
  33040. private static _PBRMATERIAL_ALPHABLEND;
  33041. /**
  33042. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  33043. */
  33044. static readonly PBRMATERIAL_ALPHABLEND: number;
  33045. /**
  33046. * Represents the value for Alpha Test and Blend. Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  33047. * They are also discarded below the alpha cutoff threshold to improve performances.
  33048. */
  33049. private static _PBRMATERIAL_ALPHATESTANDBLEND;
  33050. /**
  33051. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  33052. * They are also discarded below the alpha cutoff threshold to improve performances.
  33053. */
  33054. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  33055. /**
  33056. * Intensity of the direct lights e.g. the four lights available in your scene.
  33057. * This impacts both the direct diffuse and specular highlights.
  33058. */
  33059. directIntensity: number;
  33060. /**
  33061. * Intensity of the emissive part of the material.
  33062. * This helps controlling the emissive effect without modifying the emissive color.
  33063. */
  33064. emissiveIntensity: number;
  33065. /**
  33066. * Intensity of the environment e.g. how much the environment will light the object
  33067. * either through harmonics for rough material or through the refelction for shiny ones.
  33068. */
  33069. environmentIntensity: number;
  33070. /**
  33071. * This is a special control allowing the reduction of the specular highlights coming from the
  33072. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  33073. */
  33074. specularIntensity: number;
  33075. /**
  33076. * Debug Control allowing disabling the bump map on this material.
  33077. */
  33078. disableBumpMap: boolean;
  33079. /**
  33080. * AKA Diffuse Texture in standard nomenclature.
  33081. */
  33082. albedoTexture: BaseTexture;
  33083. /**
  33084. * AKA Occlusion Texture in other nomenclature.
  33085. */
  33086. ambientTexture: BaseTexture;
  33087. /**
  33088. * AKA Occlusion Texture Intensity in other nomenclature.
  33089. */
  33090. ambientTextureStrength: number;
  33091. /**
  33092. * Stores the alpha values in a texture.
  33093. */
  33094. opacityTexture: BaseTexture;
  33095. /**
  33096. * Stores the reflection values in a texture.
  33097. */
  33098. reflectionTexture: Nullable<BaseTexture>;
  33099. /**
  33100. * Stores the emissive values in a texture.
  33101. */
  33102. emissiveTexture: BaseTexture;
  33103. /**
  33104. * AKA Specular texture in other nomenclature.
  33105. */
  33106. reflectivityTexture: BaseTexture;
  33107. /**
  33108. * Used to switch from specular/glossiness to metallic/roughness workflow.
  33109. */
  33110. metallicTexture: BaseTexture;
  33111. /**
  33112. * Specifies the metallic scalar of the metallic/roughness workflow.
  33113. * Can also be used to scale the metalness values of the metallic texture.
  33114. */
  33115. metallic: number;
  33116. /**
  33117. * Specifies the roughness scalar of the metallic/roughness workflow.
  33118. * Can also be used to scale the roughness values of the metallic texture.
  33119. */
  33120. roughness: number;
  33121. /**
  33122. * Used to enable roughness/glossiness fetch from a separate chanel depending on the current mode.
  33123. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  33124. */
  33125. microSurfaceTexture: BaseTexture;
  33126. /**
  33127. * Stores surface normal data used to displace a mesh in a texture.
  33128. */
  33129. bumpTexture: BaseTexture;
  33130. /**
  33131. * Stores the pre-calculated light information of a mesh in a texture.
  33132. */
  33133. lightmapTexture: BaseTexture;
  33134. /**
  33135. * Stores the refracted light information in a texture.
  33136. */
  33137. refractionTexture: BaseTexture;
  33138. /**
  33139. * The color of a material in ambient lighting.
  33140. */
  33141. ambientColor: Color3;
  33142. /**
  33143. * AKA Diffuse Color in other nomenclature.
  33144. */
  33145. albedoColor: Color3;
  33146. /**
  33147. * AKA Specular Color in other nomenclature.
  33148. */
  33149. reflectivityColor: Color3;
  33150. /**
  33151. * The color reflected from the material.
  33152. */
  33153. reflectionColor: Color3;
  33154. /**
  33155. * The color emitted from the material.
  33156. */
  33157. emissiveColor: Color3;
  33158. /**
  33159. * AKA Glossiness in other nomenclature.
  33160. */
  33161. microSurface: number;
  33162. /**
  33163. * source material index of refraction (IOR)' / 'destination material IOR.
  33164. */
  33165. indexOfRefraction: number;
  33166. /**
  33167. * Controls if refraction needs to be inverted on Y. This could be usefull for procedural texture.
  33168. */
  33169. invertRefractionY: boolean;
  33170. /**
  33171. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  33172. * Materials half opaque for instance using refraction could benefit from this control.
  33173. */
  33174. linkRefractionWithTransparency: boolean;
  33175. useLightmapAsShadowmap: boolean;
  33176. /**
  33177. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  33178. */
  33179. useAlphaFromAlbedoTexture: boolean;
  33180. /**
  33181. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  33182. */
  33183. forceAlphaTest: boolean;
  33184. /**
  33185. * Defines the alpha limits in alpha test mode.
  33186. */
  33187. alphaCutOff: number;
  33188. /**
  33189. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  33190. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  33191. */
  33192. useSpecularOverAlpha: boolean;
  33193. /**
  33194. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  33195. */
  33196. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  33197. /**
  33198. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  33199. */
  33200. useRoughnessFromMetallicTextureAlpha: boolean;
  33201. /**
  33202. * Specifies if the metallic texture contains the roughness information in its green channel.
  33203. */
  33204. useRoughnessFromMetallicTextureGreen: boolean;
  33205. /**
  33206. * Specifies if the metallic texture contains the metallness information in its blue channel.
  33207. */
  33208. useMetallnessFromMetallicTextureBlue: boolean;
  33209. /**
  33210. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  33211. */
  33212. useAmbientOcclusionFromMetallicTextureRed: boolean;
  33213. /**
  33214. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  33215. */
  33216. useAmbientInGrayScale: boolean;
  33217. /**
  33218. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  33219. * The material will try to infer what glossiness each pixel should be.
  33220. */
  33221. useAutoMicroSurfaceFromReflectivityMap: boolean;
  33222. /**
  33223. * BJS is using an harcoded light falloff based on a manually sets up range.
  33224. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  33225. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  33226. */
  33227. usePhysicalLightFalloff: boolean;
  33228. /**
  33229. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  33230. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  33231. */
  33232. useRadianceOverAlpha: boolean;
  33233. /**
  33234. * Allows using an object space normal map (instead of tangent space).
  33235. */
  33236. useObjectSpaceNormalMap: boolean;
  33237. /**
  33238. * Allows using the bump map in parallax mode.
  33239. */
  33240. useParallax: boolean;
  33241. /**
  33242. * Allows using the bump map in parallax occlusion mode.
  33243. */
  33244. useParallaxOcclusion: boolean;
  33245. /**
  33246. * Controls the scale bias of the parallax mode.
  33247. */
  33248. parallaxScaleBias: number;
  33249. /**
  33250. * If sets to true, disables all the lights affecting the material.
  33251. */
  33252. disableLighting: boolean;
  33253. /**
  33254. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  33255. */
  33256. forceIrradianceInFragment: boolean;
  33257. /**
  33258. * Number of Simultaneous lights allowed on the material.
  33259. */
  33260. maxSimultaneousLights: number;
  33261. /**
  33262. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  33263. */
  33264. invertNormalMapX: boolean;
  33265. /**
  33266. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  33267. */
  33268. invertNormalMapY: boolean;
  33269. /**
  33270. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  33271. */
  33272. twoSidedLighting: boolean;
  33273. /**
  33274. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  33275. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  33276. */
  33277. useAlphaFresnel: boolean;
  33278. /**
  33279. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  33280. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  33281. */
  33282. useLinearAlphaFresnel: boolean;
  33283. /**
  33284. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  33285. * And/Or occlude the blended part.
  33286. */
  33287. environmentBRDFTexture: Nullable<BaseTexture>;
  33288. /**
  33289. * Force normal to face away from face.
  33290. */
  33291. forceNormalForward: boolean;
  33292. /**
  33293. * Enables specular anti aliasing in the PBR shader.
  33294. * It will both interacts on the Geometry for analytical and IBL lighting.
  33295. * It also prefilter the roughness map based on the bump values.
  33296. */
  33297. enableSpecularAntiAliasing: boolean;
  33298. /**
  33299. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  33300. * makes the reflect vector face the model (under horizon).
  33301. */
  33302. useHorizonOcclusion: boolean;
  33303. /**
  33304. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  33305. * too much the area relying on ambient texture to define their ambient occlusion.
  33306. */
  33307. useRadianceOcclusion: boolean;
  33308. /**
  33309. * If set to true, no lighting calculations will be applied.
  33310. */
  33311. unlit: boolean;
  33312. /**
  33313. * Gets the image processing configuration used either in this material.
  33314. */
  33315. /**
  33316. * Sets the Default image processing configuration used either in the this material.
  33317. *
  33318. * If sets to null, the scene one is in use.
  33319. */
  33320. imageProcessingConfiguration: ImageProcessingConfiguration;
  33321. /**
  33322. * Gets wether the color curves effect is enabled.
  33323. */
  33324. /**
  33325. * Sets wether the color curves effect is enabled.
  33326. */
  33327. cameraColorCurvesEnabled: boolean;
  33328. /**
  33329. * Gets wether the color grading effect is enabled.
  33330. */
  33331. /**
  33332. * Gets wether the color grading effect is enabled.
  33333. */
  33334. cameraColorGradingEnabled: boolean;
  33335. /**
  33336. * Gets wether tonemapping is enabled or not.
  33337. */
  33338. /**
  33339. * Sets wether tonemapping is enabled or not
  33340. */
  33341. cameraToneMappingEnabled: boolean;
  33342. /**
  33343. * The camera exposure used on this material.
  33344. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  33345. * This corresponds to a photographic exposure.
  33346. */
  33347. /**
  33348. * The camera exposure used on this material.
  33349. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  33350. * This corresponds to a photographic exposure.
  33351. */
  33352. cameraExposure: number;
  33353. /**
  33354. * Gets The camera contrast used on this material.
  33355. */
  33356. /**
  33357. * Sets The camera contrast used on this material.
  33358. */
  33359. cameraContrast: number;
  33360. /**
  33361. * Gets the Color Grading 2D Lookup Texture.
  33362. */
  33363. /**
  33364. * Sets the Color Grading 2D Lookup Texture.
  33365. */
  33366. cameraColorGradingTexture: Nullable<BaseTexture>;
  33367. /**
  33368. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  33369. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  33370. * 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;
  33371. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  33372. */
  33373. /**
  33374. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  33375. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  33376. * 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;
  33377. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  33378. */
  33379. cameraColorCurves: Nullable<ColorCurves>;
  33380. /**
  33381. * Instantiates a new PBRMaterial instance.
  33382. *
  33383. * @param name The material name
  33384. * @param scene The scene the material will be use in.
  33385. */
  33386. constructor(name: string, scene: Scene);
  33387. /**
  33388. * Returns the name of this material class.
  33389. */
  33390. getClassName(): string;
  33391. /**
  33392. * Returns an array of the actively used textures.
  33393. * @returns - Array of BaseTextures
  33394. */
  33395. getActiveTextures(): BaseTexture[];
  33396. /**
  33397. * Checks to see if a texture is used in the material.
  33398. * @param texture - Base texture to use.
  33399. * @returns - Boolean specifying if a texture is used in the material.
  33400. */
  33401. hasTexture(texture: BaseTexture): boolean;
  33402. /**
  33403. * Makes a duplicate of the current material.
  33404. * @param name - name to use for the new material.
  33405. */
  33406. clone(name: string): PBRMaterial;
  33407. /**
  33408. * Serializes this PBR Material.
  33409. * @returns - An object with the serialized material.
  33410. */
  33411. serialize(): any;
  33412. /**
  33413. * Parses a PBR Material from a serialized object.
  33414. * @param source - Serialized object.
  33415. * @param scene - BJS scene instance.
  33416. * @param rootUrl - url for the scene object
  33417. * @returns - PBRMaterial
  33418. */
  33419. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  33420. }
  33421. }
  33422. declare module BABYLON {
  33423. /**
  33424. * The PBR material of BJS following the metal roughness convention.
  33425. *
  33426. * This fits to the PBR convention in the GLTF definition:
  33427. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  33428. */
  33429. class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  33430. /**
  33431. * The base color has two different interpretations depending on the value of metalness.
  33432. * When the material is a metal, the base color is the specific measured reflectance value
  33433. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  33434. * of the material.
  33435. */
  33436. baseColor: Color3;
  33437. /**
  33438. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  33439. * well as opacity information in the alpha channel.
  33440. */
  33441. baseTexture: BaseTexture;
  33442. /**
  33443. * Specifies the metallic scalar value of the material.
  33444. * Can also be used to scale the metalness values of the metallic texture.
  33445. */
  33446. metallic: number;
  33447. /**
  33448. * Specifies the roughness scalar value of the material.
  33449. * Can also be used to scale the roughness values of the metallic texture.
  33450. */
  33451. roughness: number;
  33452. /**
  33453. * Texture containing both the metallic value in the B channel and the
  33454. * roughness value in the G channel to keep better precision.
  33455. */
  33456. metallicRoughnessTexture: BaseTexture;
  33457. /**
  33458. * Instantiates a new PBRMetalRoughnessMaterial instance.
  33459. *
  33460. * @param name The material name
  33461. * @param scene The scene the material will be use in.
  33462. */
  33463. constructor(name: string, scene: Scene);
  33464. /**
  33465. * Return the currrent class name of the material.
  33466. */
  33467. getClassName(): string;
  33468. /**
  33469. * Return the active textures of the material.
  33470. */
  33471. getActiveTextures(): BaseTexture[];
  33472. /**
  33473. * Checks to see if a texture is used in the material.
  33474. * @param texture - Base texture to use.
  33475. * @returns - Boolean specifying if a texture is used in the material.
  33476. */
  33477. hasTexture(texture: BaseTexture): boolean;
  33478. /**
  33479. * Makes a duplicate of the current material.
  33480. * @param name - name to use for the new material.
  33481. */
  33482. clone(name: string): PBRMetallicRoughnessMaterial;
  33483. /**
  33484. * Serialize the material to a parsable JSON object.
  33485. */
  33486. serialize(): any;
  33487. /**
  33488. * Parses a JSON object correponding to the serialize function.
  33489. */
  33490. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  33491. }
  33492. }
  33493. declare module BABYLON {
  33494. /**
  33495. * The PBR material of BJS following the specular glossiness convention.
  33496. *
  33497. * This fits to the PBR convention in the GLTF definition:
  33498. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  33499. */
  33500. class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  33501. /**
  33502. * Specifies the diffuse color of the material.
  33503. */
  33504. diffuseColor: Color3;
  33505. /**
  33506. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  33507. * channel.
  33508. */
  33509. diffuseTexture: BaseTexture;
  33510. /**
  33511. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  33512. */
  33513. specularColor: Color3;
  33514. /**
  33515. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  33516. */
  33517. glossiness: number;
  33518. /**
  33519. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  33520. */
  33521. specularGlossinessTexture: BaseTexture;
  33522. /**
  33523. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  33524. *
  33525. * @param name The material name
  33526. * @param scene The scene the material will be use in.
  33527. */
  33528. constructor(name: string, scene: Scene);
  33529. /**
  33530. * Return the currrent class name of the material.
  33531. */
  33532. getClassName(): string;
  33533. /**
  33534. * Return the active textures of the material.
  33535. */
  33536. getActiveTextures(): BaseTexture[];
  33537. /**
  33538. * Checks to see if a texture is used in the material.
  33539. * @param texture - Base texture to use.
  33540. * @returns - Boolean specifying if a texture is used in the material.
  33541. */
  33542. hasTexture(texture: BaseTexture): boolean;
  33543. /**
  33544. * Makes a duplicate of the current material.
  33545. * @param name - name to use for the new material.
  33546. */
  33547. clone(name: string): PBRSpecularGlossinessMaterial;
  33548. /**
  33549. * Serialize the material to a parsable JSON object.
  33550. */
  33551. serialize(): any;
  33552. /**
  33553. * Parses a JSON object correponding to the serialize function.
  33554. */
  33555. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  33556. }
  33557. }
  33558. declare module BABYLON {
  33559. class BaseTexture {
  33560. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  33561. name: string;
  33562. private _hasAlpha;
  33563. hasAlpha: boolean;
  33564. getAlphaFromRGB: boolean;
  33565. level: number;
  33566. coordinatesIndex: number;
  33567. private _coordinatesMode;
  33568. /**
  33569. * How a texture is mapped.
  33570. *
  33571. * | Value | Type | Description |
  33572. * | ----- | ----------------------------------- | ----------- |
  33573. * | 0 | EXPLICIT_MODE | |
  33574. * | 1 | SPHERICAL_MODE | |
  33575. * | 2 | PLANAR_MODE | |
  33576. * | 3 | CUBIC_MODE | |
  33577. * | 4 | PROJECTION_MODE | |
  33578. * | 5 | SKYBOX_MODE | |
  33579. * | 6 | INVCUBIC_MODE | |
  33580. * | 7 | EQUIRECTANGULAR_MODE | |
  33581. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  33582. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  33583. */
  33584. coordinatesMode: number;
  33585. /**
  33586. * | Value | Type | Description |
  33587. * | ----- | ------------------ | ----------- |
  33588. * | 0 | CLAMP_ADDRESSMODE | |
  33589. * | 1 | WRAP_ADDRESSMODE | |
  33590. * | 2 | MIRROR_ADDRESSMODE | |
  33591. */
  33592. wrapU: number;
  33593. /**
  33594. * | Value | Type | Description |
  33595. * | ----- | ------------------ | ----------- |
  33596. * | 0 | CLAMP_ADDRESSMODE | |
  33597. * | 1 | WRAP_ADDRESSMODE | |
  33598. * | 2 | MIRROR_ADDRESSMODE | |
  33599. */
  33600. wrapV: number;
  33601. /**
  33602. * | Value | Type | Description |
  33603. * | ----- | ------------------ | ----------- |
  33604. * | 0 | CLAMP_ADDRESSMODE | |
  33605. * | 1 | WRAP_ADDRESSMODE | |
  33606. * | 2 | MIRROR_ADDRESSMODE | |
  33607. */
  33608. wrapR: number;
  33609. anisotropicFilteringLevel: number;
  33610. isCube: boolean;
  33611. is3D: boolean;
  33612. gammaSpace: boolean;
  33613. /**
  33614. * Gets whether or not the texture contains RGBD data.
  33615. */
  33616. readonly isRGBD: boolean;
  33617. invertZ: boolean;
  33618. lodLevelInAlpha: boolean;
  33619. lodGenerationOffset: number;
  33620. lodGenerationScale: number;
  33621. isRenderTarget: boolean;
  33622. readonly uid: string;
  33623. toString(): string;
  33624. getClassName(): string;
  33625. animations: Animation[];
  33626. /**
  33627. * An event triggered when the texture is disposed.
  33628. */
  33629. onDisposeObservable: Observable<BaseTexture>;
  33630. private _onDisposeObserver;
  33631. onDispose: () => void;
  33632. delayLoadState: number;
  33633. private _scene;
  33634. private _uid;
  33635. readonly isBlocking: boolean;
  33636. constructor(scene: Nullable<Scene>);
  33637. getScene(): Nullable<Scene>;
  33638. getTextureMatrix(): Matrix;
  33639. getReflectionTextureMatrix(): Matrix;
  33640. getInternalTexture(): Nullable<InternalTexture>;
  33641. isReadyOrNotBlocking(): boolean;
  33642. isReady(): boolean;
  33643. private _cachedSize;
  33644. getSize(): ISize;
  33645. getBaseSize(): ISize;
  33646. scale(ratio: number): void;
  33647. readonly canRescale: boolean;
  33648. delayLoad(): void;
  33649. clone(): Nullable<BaseTexture>;
  33650. readonly textureType: number;
  33651. readonly textureFormat: number;
  33652. /**
  33653. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  33654. * This will returns an RGBA array buffer containing either in values (0-255) or
  33655. * float values (0-1) depending of the underlying buffer type.
  33656. * @param faceIndex The face of the texture to read (in case of cube texture)
  33657. * @param level The LOD level of the texture to read (in case of Mip Maps)
  33658. * @returns The Array buffer containing the pixels data.
  33659. */
  33660. readPixels(faceIndex?: number, level?: number): Nullable<ArrayBufferView>;
  33661. releaseInternalTexture(): void;
  33662. sphericalPolynomial: Nullable<SphericalPolynomial>;
  33663. protected readonly _lodTextureHigh: Nullable<BaseTexture>;
  33664. protected readonly _lodTextureMid: Nullable<BaseTexture>;
  33665. protected readonly _lodTextureLow: Nullable<BaseTexture>;
  33666. dispose(): void;
  33667. serialize(): any;
  33668. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  33669. }
  33670. }
  33671. declare module BABYLON {
  33672. /**
  33673. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  33674. * It can help converting any input color in a desired output one. This can then be used to create effects
  33675. * from sepia, black and white to sixties or futuristic rendering...
  33676. *
  33677. * The only supported format is currently 3dl.
  33678. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table/
  33679. */
  33680. class ColorGradingTexture extends BaseTexture {
  33681. /**
  33682. * The current texture matrix. (will always be identity in color grading texture)
  33683. */
  33684. private _textureMatrix;
  33685. /**
  33686. * The texture URL.
  33687. */
  33688. url: string;
  33689. /**
  33690. * Empty line regex stored for GC.
  33691. */
  33692. private static _noneEmptyLineRegex;
  33693. private _engine;
  33694. /**
  33695. * Instantiates a ColorGradingTexture from the following parameters.
  33696. *
  33697. * @param url The location of the color gradind data (currently only supporting 3dl)
  33698. * @param scene The scene the texture will be used in
  33699. */
  33700. constructor(url: string, scene: Scene);
  33701. /**
  33702. * Returns the texture matrix used in most of the material.
  33703. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  33704. */
  33705. getTextureMatrix(): Matrix;
  33706. /**
  33707. * Occurs when the file being loaded is a .3dl LUT file.
  33708. */
  33709. private load3dlTexture();
  33710. /**
  33711. * Starts the loading process of the texture.
  33712. */
  33713. private loadTexture();
  33714. /**
  33715. * Clones the color gradind texture.
  33716. */
  33717. clone(): ColorGradingTexture;
  33718. /**
  33719. * Called during delayed load for textures.
  33720. */
  33721. delayLoad(): void;
  33722. /**
  33723. * Parses a color grading texture serialized by Babylon.
  33724. * @param parsedTexture The texture information being parsedTexture
  33725. * @param scene The scene to load the texture in
  33726. * @param rootUrl The root url of the data assets to load
  33727. * @return A color gradind texture
  33728. */
  33729. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<ColorGradingTexture>;
  33730. /**
  33731. * Serializes the LUT texture to json format.
  33732. */
  33733. serialize(): any;
  33734. }
  33735. }
  33736. declare module BABYLON {
  33737. class CubeTexture extends BaseTexture {
  33738. url: string;
  33739. coordinatesMode: number;
  33740. /**
  33741. * Gets or sets the center of the bounding box associated with the cube texture
  33742. * It must define where the camera used to render the texture was set
  33743. */
  33744. boundingBoxPosition: Vector3;
  33745. private _boundingBoxSize;
  33746. /**
  33747. * Gets or sets the size of the bounding box associated with the cube texture
  33748. * When defined, the cubemap will switch to local mode
  33749. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  33750. * @example https://www.babylonjs-playground.com/#RNASML
  33751. */
  33752. boundingBoxSize: Vector3;
  33753. protected _rotationY: number;
  33754. /**
  33755. * Gets texture matrix rotation angle around Y axis radians.
  33756. */
  33757. /**
  33758. * Sets texture matrix rotation angle around Y axis in radians.
  33759. */
  33760. rotationY: number;
  33761. private _noMipmap;
  33762. private _files;
  33763. private _extensions;
  33764. private _textureMatrix;
  33765. private _format;
  33766. private _createPolynomials;
  33767. /** @hidden */
  33768. protected readonly _prefiltered: boolean;
  33769. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  33770. /**
  33771. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  33772. * @param url defines the url of the prefiltered texture
  33773. * @param scene defines the scene the texture is attached to
  33774. * @param forcedExtension defines the extension of the file if different from the url
  33775. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  33776. * @return the prefiltered texture
  33777. */
  33778. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  33779. /**
  33780. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  33781. * as prefiltered data.
  33782. * @param rootUrl defines the url of the texture or the root name of the six images
  33783. * @param scene defines the scene the texture is attached to
  33784. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  33785. * @param noMipmap defines if mipmaps should be created or not
  33786. * @param files defines the six files to load for the different faces
  33787. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  33788. * @param onError defines a callback triggered in case of error during load
  33789. * @param format defines the internal format to use for the texture once loaded
  33790. * @param prefiltered defines whether or not the texture is created from prefiltered data
  33791. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  33792. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  33793. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  33794. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  33795. * @return the cube texture
  33796. */
  33797. 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);
  33798. delayLoad(): void;
  33799. getReflectionTextureMatrix(): Matrix;
  33800. setReflectionTextureMatrix(value: Matrix): void;
  33801. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  33802. clone(): CubeTexture;
  33803. }
  33804. }
  33805. declare module BABYLON {
  33806. /**
  33807. * A class extending {BABYLON.Texture} allowing drawing on a texture
  33808. * @see http://doc.babylonjs.com/how_to/dynamictexture
  33809. */
  33810. class DynamicTexture extends Texture {
  33811. private _generateMipMaps;
  33812. private _canvas;
  33813. private _context;
  33814. private _engine;
  33815. /**
  33816. * Creates a {BABYLON.DynamicTexture}
  33817. * @param name defines the name of the texture
  33818. * @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
  33819. * @param scene defines the scene where you want the texture
  33820. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  33821. * @param samplingMode defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  33822. * @param format defines the texture format to use (default is BABYLON.Engine.TEXTUREFORMAT_RGBA)
  33823. */
  33824. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  33825. /**
  33826. * Gets the current state of canRescale
  33827. */
  33828. readonly canRescale: boolean;
  33829. private _recreate(textureSize);
  33830. /**
  33831. * Scales the texture
  33832. * @param ratio the scale factor to apply to both width and height
  33833. */
  33834. scale(ratio: number): void;
  33835. /**
  33836. * Resizes the texture
  33837. * @param width the new width
  33838. * @param height the new height
  33839. */
  33840. scaleTo(width: number, height: number): void;
  33841. /**
  33842. * Gets the context of the canvas used by the texture
  33843. * @returns the canvas context of the dynamic texture
  33844. */
  33845. getContext(): CanvasRenderingContext2D;
  33846. /**
  33847. * Clears the texture
  33848. */
  33849. clear(): void;
  33850. /**
  33851. * Updates the texture
  33852. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  33853. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  33854. */
  33855. update(invertY?: boolean, premulAlpha?: boolean): void;
  33856. /**
  33857. * Draws text onto the texture
  33858. * @param text defines the text to be drawn
  33859. * @param x defines the placement of the text from the left
  33860. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  33861. * @param font defines the font to be used with font-style, font-size, font-name
  33862. * @param color defines the color used for the text
  33863. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  33864. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  33865. * @param update defines whether texture is immediately update (default is true)
  33866. */
  33867. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  33868. /**
  33869. * Clones the texture
  33870. * @returns the clone of the texture.
  33871. */
  33872. clone(): DynamicTexture;
  33873. /** @hidden */
  33874. }
  33875. }
  33876. declare module BABYLON {
  33877. /**
  33878. * This represents a texture coming from an HDR input.
  33879. *
  33880. * The only supported format is currently panorama picture stored in RGBE format.
  33881. * Example of such files can be found on HDRLib: http://hdrlib.com/
  33882. */
  33883. class HDRCubeTexture extends BaseTexture {
  33884. private static _facesMapping;
  33885. private _generateHarmonics;
  33886. private _noMipmap;
  33887. private _textureMatrix;
  33888. private _size;
  33889. private _onLoad;
  33890. private _onError;
  33891. /**
  33892. * The texture URL.
  33893. */
  33894. url: string;
  33895. /**
  33896. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  33897. */
  33898. coordinatesMode: number;
  33899. protected _isBlocking: boolean;
  33900. /**
  33901. * Gets wether or not the texture is blocking during loading.
  33902. */
  33903. /**
  33904. * Sets wether or not the texture is blocking during loading.
  33905. */
  33906. isBlocking: boolean;
  33907. protected _rotationY: number;
  33908. /**
  33909. * Gets texture matrix rotation angle around Y axis radians.
  33910. */
  33911. /**
  33912. * Sets texture matrix rotation angle around Y axis in radians.
  33913. */
  33914. rotationY: number;
  33915. /**
  33916. * Gets or sets the center of the bounding box associated with the cube texture
  33917. * It must define where the camera used to render the texture was set
  33918. */
  33919. boundingBoxPosition: Vector3;
  33920. private _boundingBoxSize;
  33921. /**
  33922. * Gets or sets the size of the bounding box associated with the cube texture
  33923. * When defined, the cubemap will switch to local mode
  33924. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  33925. * @example https://www.babylonjs-playground.com/#RNASML
  33926. */
  33927. boundingBoxSize: Vector3;
  33928. /**
  33929. * Instantiates an HDRTexture from the following parameters.
  33930. *
  33931. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  33932. * @param scene The scene the texture will be used in
  33933. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  33934. * @param noMipmap Forces to not generate the mipmap if true
  33935. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  33936. * @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)
  33937. * @param reserved Reserved flag for internal use.
  33938. */
  33939. 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>);
  33940. /**
  33941. * Occurs when the file is raw .hdr file.
  33942. */
  33943. private loadTexture();
  33944. clone(): HDRCubeTexture;
  33945. delayLoad(): void;
  33946. getReflectionTextureMatrix(): Matrix;
  33947. setReflectionTextureMatrix(value: Matrix): void;
  33948. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  33949. serialize(): any;
  33950. }
  33951. }
  33952. declare module BABYLON {
  33953. /**
  33954. * Class used to store data associated with WebGL texture data for the engine
  33955. * This class should not be used directly
  33956. */
  33957. class InternalTexture implements IInternalTextureTracker {
  33958. /**
  33959. * The source of the texture data is unknown
  33960. */
  33961. static DATASOURCE_UNKNOWN: number;
  33962. /**
  33963. * Texture data comes from an URL
  33964. */
  33965. static DATASOURCE_URL: number;
  33966. /**
  33967. * Texture data is only used for temporary storage
  33968. */
  33969. static DATASOURCE_TEMP: number;
  33970. /**
  33971. * Texture data comes from raw data (ArrayBuffer)
  33972. */
  33973. static DATASOURCE_RAW: number;
  33974. /**
  33975. * Texture content is dynamic (video or dynamic texture)
  33976. */
  33977. static DATASOURCE_DYNAMIC: number;
  33978. /**
  33979. * Texture content is generated by rendering to it
  33980. */
  33981. static DATASOURCE_RENDERTARGET: number;
  33982. /**
  33983. * Texture content is part of a multi render target process
  33984. */
  33985. static DATASOURCE_MULTIRENDERTARGET: number;
  33986. /**
  33987. * Texture data comes from a cube data file
  33988. */
  33989. static DATASOURCE_CUBE: number;
  33990. /**
  33991. * Texture data comes from a raw cube data
  33992. */
  33993. static DATASOURCE_CUBERAW: number;
  33994. /**
  33995. * Texture data come from a prefiltered cube data file
  33996. */
  33997. static DATASOURCE_CUBEPREFILTERED: number;
  33998. /**
  33999. * Texture content is raw 3D data
  34000. */
  34001. static DATASOURCE_RAW3D: number;
  34002. /**
  34003. * Texture content is a depth texture
  34004. */
  34005. static DATASOURCE_DEPTHTEXTURE: number;
  34006. /**
  34007. * Defines if the texture is ready
  34008. */
  34009. isReady: boolean;
  34010. /**
  34011. * Defines if the texture is a cube texture
  34012. */
  34013. isCube: boolean;
  34014. /**
  34015. * Defines if the texture contains 3D data
  34016. */
  34017. is3D: boolean;
  34018. /**
  34019. * Gets the URL used to load this texture
  34020. */
  34021. url: string;
  34022. /**
  34023. * Gets the sampling mode of the texture
  34024. */
  34025. samplingMode: number;
  34026. /**
  34027. * Gets a boolean indicating if the texture needs mipmaps generation
  34028. */
  34029. generateMipMaps: boolean;
  34030. /**
  34031. * Gets the number of samples used by the texture (WebGL2+ only)
  34032. */
  34033. samples: number;
  34034. /**
  34035. * Gets the type of the texture
  34036. */
  34037. type: number;
  34038. /**
  34039. * Gets the format of the texture
  34040. */
  34041. format: number;
  34042. /**
  34043. * Observable called when the texture is loaded
  34044. */
  34045. onLoadedObservable: Observable<InternalTexture>;
  34046. /**
  34047. * Gets the width of the texture
  34048. */
  34049. width: number;
  34050. /**
  34051. * Gets the height of the texture
  34052. */
  34053. height: number;
  34054. /**
  34055. * Gets the depth of the texture
  34056. */
  34057. depth: number;
  34058. /**
  34059. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  34060. */
  34061. baseWidth: number;
  34062. /**
  34063. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  34064. */
  34065. baseHeight: number;
  34066. /**
  34067. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  34068. */
  34069. baseDepth: number;
  34070. /**
  34071. * Gets a boolean indicating if the texture is inverted on Y axis
  34072. */
  34073. invertY: boolean;
  34074. /**
  34075. * Gets or set the previous tracker in the list
  34076. */
  34077. previous: Nullable<IInternalTextureTracker>;
  34078. /**
  34079. * Gets or set the next tracker in the list
  34080. */
  34081. next: Nullable<IInternalTextureTracker>;
  34082. /** @hidden */
  34083. /** @hidden */
  34084. /** @hidden */
  34085. /** @hidden */
  34086. /** @hidden */
  34087. /** @hidden */
  34088. /** @hidden */
  34089. /** @hidden */
  34090. /** @hidden */
  34091. /** @hidden */
  34092. /** @hidden */
  34093. /** @hidden */
  34094. /** @hidden */
  34095. /** @hidden */
  34096. /** @hidden */
  34097. /** @hidden */
  34098. /** @hidden */
  34099. /** @hidden */
  34100. /** @hidden */
  34101. /** @hidden */
  34102. /** @hidden */
  34103. /** @hidden */
  34104. /** @hidden */
  34105. /** @hidden */
  34106. /** @hidden */
  34107. /** @hidden */
  34108. /** @hidden */
  34109. /** @hidden */
  34110. /** @hidden */
  34111. /** @hidden */
  34112. /** @hidden */
  34113. /** @hidden */
  34114. /** @hidden */
  34115. /** @hidden */
  34116. /** @hidden */
  34117. private _engine;
  34118. /**
  34119. * Gets the Engine the texture belongs to.
  34120. * @returns The babylon engine
  34121. */
  34122. getEngine(): Engine;
  34123. /**
  34124. * Gets the data source type of the texture (can be one of the BABYLON.InternalTexture.DATASOURCE_XXXX)
  34125. */
  34126. readonly dataSource: number;
  34127. /**
  34128. * Creates a new InternalTexture
  34129. * @param engine defines the engine to use
  34130. * @param dataSource defines the type of data that will be used
  34131. */
  34132. constructor(engine: Engine, dataSource: number);
  34133. /**
  34134. * Increments the number of references (ie. the number of {BABYLON.Texture} that point to it)
  34135. */
  34136. incrementReferences(): void;
  34137. /**
  34138. * Change the size of the texture (not the size of the content)
  34139. * @param width defines the new width
  34140. * @param height defines the new height
  34141. * @param depth defines the new depth (1 by default)
  34142. */
  34143. updateSize(width: int, height: int, depth?: int): void;
  34144. /** @hidden */
  34145. /**
  34146. * Dispose the current allocated resources
  34147. */
  34148. dispose(): void;
  34149. }
  34150. }
  34151. declare module BABYLON {
  34152. /**
  34153. * Internal interface used to track {BABYLON.InternalTexture} already bound to the GL context
  34154. */
  34155. interface IInternalTextureTracker {
  34156. /**
  34157. * Gets or set the previous tracker in the list
  34158. */
  34159. previous: Nullable<IInternalTextureTracker>;
  34160. /**
  34161. * Gets or set the next tracker in the list
  34162. */
  34163. next: Nullable<IInternalTextureTracker>;
  34164. }
  34165. /**
  34166. * Internal class used by the engine to get list of {BABYLON.InternalTexture} already bound to the GL context
  34167. */
  34168. class DummyInternalTextureTracker {
  34169. /**
  34170. * Gets or set the previous tracker in the list
  34171. */
  34172. previous: Nullable<IInternalTextureTracker>;
  34173. /**
  34174. * Gets or set the next tracker in the list
  34175. */
  34176. next: Nullable<IInternalTextureTracker>;
  34177. }
  34178. }
  34179. declare module BABYLON {
  34180. class MirrorTexture extends RenderTargetTexture {
  34181. private scene;
  34182. mirrorPlane: Plane;
  34183. private _transformMatrix;
  34184. private _mirrorMatrix;
  34185. private _savedViewMatrix;
  34186. private _blurX;
  34187. private _blurY;
  34188. private _adaptiveBlurKernel;
  34189. private _blurKernelX;
  34190. private _blurKernelY;
  34191. private _blurRatio;
  34192. blurRatio: number;
  34193. adaptiveBlurKernel: number;
  34194. blurKernel: number;
  34195. blurKernelX: number;
  34196. blurKernelY: number;
  34197. private _autoComputeBlurKernel();
  34198. protected _onRatioRescale(): void;
  34199. private _updateGammaSpace();
  34200. private _imageProcessingConfigChangeObserver;
  34201. constructor(name: string, size: number | {
  34202. width: number;
  34203. height: number;
  34204. } | {
  34205. ratio: number;
  34206. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  34207. private _preparePostProcesses();
  34208. clone(): MirrorTexture;
  34209. serialize(): any;
  34210. dispose(): void;
  34211. }
  34212. }
  34213. declare module BABYLON {
  34214. interface IMultiRenderTargetOptions {
  34215. generateMipMaps?: boolean;
  34216. types?: number[];
  34217. samplingModes?: number[];
  34218. generateDepthBuffer?: boolean;
  34219. generateStencilBuffer?: boolean;
  34220. generateDepthTexture?: boolean;
  34221. textureCount?: number;
  34222. doNotChangeAspectRatio?: boolean;
  34223. defaultType?: number;
  34224. }
  34225. class MultiRenderTarget extends RenderTargetTexture {
  34226. private _internalTextures;
  34227. private _textures;
  34228. readonly isSupported: boolean;
  34229. private _multiRenderTargetOptions;
  34230. readonly textures: Texture[];
  34231. readonly depthTexture: Texture;
  34232. wrapU: number;
  34233. wrapV: number;
  34234. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  34235. private _createInternalTextures();
  34236. private _createTextures();
  34237. samples: number;
  34238. resize(size: any): void;
  34239. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  34240. dispose(): void;
  34241. releaseInternalTextures(): void;
  34242. }
  34243. }
  34244. declare module BABYLON {
  34245. class RawTexture extends Texture {
  34246. format: number;
  34247. private _engine;
  34248. constructor(data: ArrayBufferView, width: number, height: number, format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  34249. update(data: ArrayBufferView): void;
  34250. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  34251. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  34252. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  34253. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  34254. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  34255. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  34256. }
  34257. }
  34258. declare module BABYLON {
  34259. /**
  34260. * Class used to store 3D textures containing user data
  34261. */
  34262. class RawTexture3D extends Texture {
  34263. /** Gets or sets the texture format to use */
  34264. format: number;
  34265. private _engine;
  34266. /**
  34267. * Create a new RawTexture3D
  34268. * @param data defines the data of the texture
  34269. * @param width defines the width of the texture
  34270. * @param height defines the height of the texture
  34271. * @param depth defines the depth of the texture
  34272. * @param format defines the texture format to use
  34273. * @param scene defines the hosting scene
  34274. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  34275. * @param invertY defines if texture must be stored with Y axis inverted
  34276. * @param samplingMode defines the sampling mode to use (BABYLON.Texture.TRILINEAR_SAMPLINGMODE by default)
  34277. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  34278. */
  34279. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  34280. /** Gets or sets the texture format to use */
  34281. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  34282. /**
  34283. * Update the texture with new data
  34284. * @param data defines the data to store in the texture
  34285. */
  34286. update(data: ArrayBufferView): void;
  34287. }
  34288. }
  34289. declare module BABYLON {
  34290. /**
  34291. * Creates a refraction texture used by refraction channel of the standard material.
  34292. * @param name the texture name
  34293. * @param size size of the underlying texture
  34294. * @param scene root scene
  34295. */
  34296. class RefractionTexture extends RenderTargetTexture {
  34297. refractionPlane: Plane;
  34298. depth: number;
  34299. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  34300. clone(): RefractionTexture;
  34301. serialize(): any;
  34302. }
  34303. }
  34304. declare module BABYLON {
  34305. class RenderTargetTexture extends Texture {
  34306. isCube: boolean;
  34307. private static _REFRESHRATE_RENDER_ONCE: number;
  34308. private static _REFRESHRATE_RENDER_ONEVERYFRAME: number;
  34309. private static _REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  34310. static readonly REFRESHRATE_RENDER_ONCE: number;
  34311. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  34312. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  34313. /**
  34314. * Use this predicate to dynamically define the list of mesh you want to render.
  34315. * If set, the renderList property will be overwritten.
  34316. */
  34317. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  34318. /**
  34319. * Use this list to define the list of mesh you want to render.
  34320. */
  34321. renderList: Nullable<Array<AbstractMesh>>;
  34322. renderParticles: boolean;
  34323. renderSprites: boolean;
  34324. coordinatesMode: number;
  34325. activeCamera: Nullable<Camera>;
  34326. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  34327. useCameraPostProcesses: boolean;
  34328. ignoreCameraViewport: boolean;
  34329. private _postProcessManager;
  34330. private _postProcesses;
  34331. private _resizeObserver;
  34332. /**
  34333. * An event triggered when the texture is unbind.
  34334. */
  34335. onBeforeBindObservable: Observable<RenderTargetTexture>;
  34336. /**
  34337. * An event triggered when the texture is unbind.
  34338. */
  34339. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  34340. private _onAfterUnbindObserver;
  34341. onAfterUnbind: () => void;
  34342. /**
  34343. * An event triggered before rendering the texture
  34344. */
  34345. onBeforeRenderObservable: Observable<number>;
  34346. private _onBeforeRenderObserver;
  34347. onBeforeRender: (faceIndex: number) => void;
  34348. /**
  34349. * An event triggered after rendering the texture
  34350. */
  34351. onAfterRenderObservable: Observable<number>;
  34352. private _onAfterRenderObserver;
  34353. onAfterRender: (faceIndex: number) => void;
  34354. /**
  34355. * An event triggered after the texture clear
  34356. */
  34357. onClearObservable: Observable<Engine>;
  34358. private _onClearObserver;
  34359. onClear: (Engine: Engine) => void;
  34360. clearColor: Color4;
  34361. protected _size: number | {
  34362. width: number;
  34363. height: number;
  34364. };
  34365. protected _initialSizeParameter: number | {
  34366. width: number;
  34367. height: number;
  34368. } | {
  34369. ratio: number;
  34370. };
  34371. protected _sizeRatio: Nullable<number>;
  34372. protected _renderingManager: RenderingManager;
  34373. protected _doNotChangeAspectRatio: boolean;
  34374. protected _currentRefreshId: number;
  34375. protected _refreshRate: number;
  34376. protected _textureMatrix: Matrix;
  34377. protected _samples: number;
  34378. protected _renderTargetOptions: RenderTargetCreationOptions;
  34379. readonly renderTargetOptions: RenderTargetCreationOptions;
  34380. protected _engine: Engine;
  34381. protected _onRatioRescale(): void;
  34382. /**
  34383. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  34384. * It must define where the camera used to render the texture is set
  34385. */
  34386. boundingBoxPosition: Vector3;
  34387. private _boundingBoxSize;
  34388. /**
  34389. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  34390. * When defined, the cubemap will switch to local mode
  34391. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  34392. * @example https://www.babylonjs-playground.com/#RNASML
  34393. */
  34394. boundingBoxSize: Vector3;
  34395. /**
  34396. * In case the RTT has been created with a depth texture, get the associated
  34397. * depth texture.
  34398. * Otherwise, return null.
  34399. */
  34400. depthStencilTexture: Nullable<InternalTexture>;
  34401. /**
  34402. * Instantiate a render target texture. This is mainly to render of screen the scene to for instance apply post processse
  34403. * or used a shadow, depth texture...
  34404. * @param name The friendly name of the texture
  34405. * @param size The size of the RTT (number if square, or {with: number, height:number} or {ratio:} to define a ratio from the main scene)
  34406. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  34407. * @param generateMipMaps True if mip maps need to be generated after render.
  34408. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  34409. * @param type The type of the buffer in the RTT (int, half float, float...)
  34410. * @param isCube True if a cube texture needs to be created
  34411. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  34412. * @param generateDepthBuffer True to generate a depth buffer
  34413. * @param generateStencilBuffer True to generate a stencil buffer
  34414. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  34415. */
  34416. constructor(name: string, size: number | {
  34417. width: number;
  34418. height: number;
  34419. } | {
  34420. ratio: number;
  34421. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean);
  34422. /**
  34423. * Creates a depth stencil texture.
  34424. * This is only available in WebGL 2 or with the depth texture extension available.
  34425. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  34426. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  34427. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  34428. */
  34429. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  34430. private _processSizeParameter(size);
  34431. samples: number;
  34432. resetRefreshCounter(): void;
  34433. refreshRate: number;
  34434. addPostProcess(postProcess: PostProcess): void;
  34435. clearPostProcesses(dispose?: boolean): void;
  34436. removePostProcess(postProcess: PostProcess): void;
  34437. getRenderSize(): number;
  34438. getRenderWidth(): number;
  34439. getRenderHeight(): number;
  34440. readonly canRescale: boolean;
  34441. scale(ratio: number): void;
  34442. getReflectionTextureMatrix(): Matrix;
  34443. resize(size: number | {
  34444. width: number;
  34445. height: number;
  34446. } | {
  34447. ratio: number;
  34448. }): void;
  34449. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  34450. private _bestReflectionRenderTargetDimension(renderDimension, scale);
  34451. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  34452. private renderToTarget(faceIndex, currentRenderList, currentRenderListLength, useCameraPostProcess, dumpForDebug);
  34453. /**
  34454. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  34455. * This allowed control for front to back rendering or reversly depending of the special needs.
  34456. *
  34457. * @param renderingGroupId The rendering group id corresponding to its index
  34458. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  34459. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  34460. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  34461. */
  34462. 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;
  34463. /**
  34464. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  34465. *
  34466. * @param renderingGroupId The rendering group id corresponding to its index
  34467. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  34468. */
  34469. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  34470. clone(): RenderTargetTexture;
  34471. serialize(): any;
  34472. disposeFramebufferObjects(): void;
  34473. dispose(): void;
  34474. /**
  34475. * Clear the info related to rendering groups preventing retention point in material dispose.
  34476. */
  34477. freeRenderingGroups(): void;
  34478. }
  34479. }
  34480. declare module BABYLON {
  34481. class Texture extends BaseTexture {
  34482. static NEAREST_SAMPLINGMODE: number;
  34483. static NEAREST_NEAREST_MIPLINEAR: number;
  34484. static BILINEAR_SAMPLINGMODE: number;
  34485. static LINEAR_LINEAR_MIPNEAREST: number;
  34486. static TRILINEAR_SAMPLINGMODE: number;
  34487. static LINEAR_LINEAR_MIPLINEAR: number;
  34488. static NEAREST_NEAREST_MIPNEAREST: number;
  34489. static NEAREST_LINEAR_MIPNEAREST: number;
  34490. static NEAREST_LINEAR_MIPLINEAR: number;
  34491. static NEAREST_LINEAR: number;
  34492. static NEAREST_NEAREST: number;
  34493. static LINEAR_NEAREST_MIPNEAREST: number;
  34494. static LINEAR_NEAREST_MIPLINEAR: number;
  34495. static LINEAR_LINEAR: number;
  34496. static LINEAR_NEAREST: number;
  34497. static EXPLICIT_MODE: number;
  34498. static SPHERICAL_MODE: number;
  34499. static PLANAR_MODE: number;
  34500. static CUBIC_MODE: number;
  34501. static PROJECTION_MODE: number;
  34502. static SKYBOX_MODE: number;
  34503. static INVCUBIC_MODE: number;
  34504. static EQUIRECTANGULAR_MODE: number;
  34505. static FIXED_EQUIRECTANGULAR_MODE: number;
  34506. static FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  34507. static CLAMP_ADDRESSMODE: number;
  34508. static WRAP_ADDRESSMODE: number;
  34509. static MIRROR_ADDRESSMODE: number;
  34510. /**
  34511. * 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
  34512. */
  34513. static UseSerializedUrlIfAny: boolean;
  34514. url: Nullable<string>;
  34515. uOffset: number;
  34516. vOffset: number;
  34517. uScale: number;
  34518. vScale: number;
  34519. uAng: number;
  34520. vAng: number;
  34521. wAng: number;
  34522. /**
  34523. * Defines the center of rotation (U)
  34524. */
  34525. uRotationCenter: number;
  34526. /**
  34527. * Defines the center of rotation (V)
  34528. */
  34529. vRotationCenter: number;
  34530. /**
  34531. * Defines the center of rotation (W)
  34532. */
  34533. wRotationCenter: number;
  34534. readonly noMipmap: boolean;
  34535. private _noMipmap;
  34536. private _rowGenerationMatrix;
  34537. private _cachedTextureMatrix;
  34538. private _projectionModeMatrix;
  34539. private _t0;
  34540. private _t1;
  34541. private _t2;
  34542. private _cachedUOffset;
  34543. private _cachedVOffset;
  34544. private _cachedUScale;
  34545. private _cachedVScale;
  34546. private _cachedUAng;
  34547. private _cachedVAng;
  34548. private _cachedWAng;
  34549. private _cachedProjectionMatrixId;
  34550. private _cachedCoordinatesMode;
  34551. /** @hidden */
  34552. private _deleteBuffer;
  34553. protected _format: Nullable<number>;
  34554. private _delayedOnLoad;
  34555. private _delayedOnError;
  34556. protected _onLoadObservable: Nullable<Observable<Texture>>;
  34557. protected _isBlocking: boolean;
  34558. isBlocking: boolean;
  34559. readonly samplingMode: number;
  34560. 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);
  34561. /**
  34562. * Update the url (and optional buffer) of this texture if url was null during construction.
  34563. * @param url the url of the texture
  34564. * @param buffer the buffer of the texture (defaults to null)
  34565. */
  34566. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>): void;
  34567. delayLoad(): void;
  34568. updateSamplingMode(samplingMode: number): void;
  34569. private _prepareRowForTextureGeneration(x, y, z, t);
  34570. getTextureMatrix(): Matrix;
  34571. getReflectionTextureMatrix(): Matrix;
  34572. clone(): Texture;
  34573. readonly onLoadObservable: Observable<Texture>;
  34574. serialize(): any;
  34575. getClassName(): string;
  34576. dispose(): void;
  34577. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  34578. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  34579. 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;
  34580. }
  34581. }
  34582. declare module BABYLON {
  34583. /**
  34584. * Settings for finer control over video usage
  34585. */
  34586. interface VideoTextureSettings {
  34587. /**
  34588. * Applies `autoplay` to video, if specified
  34589. */
  34590. autoPlay?: boolean;
  34591. /**
  34592. * Applies `loop` to video, if specified
  34593. */
  34594. loop?: boolean;
  34595. /**
  34596. * Automatically updates internal texture from video at every frame in the render loop
  34597. */
  34598. autoUpdateTexture: boolean;
  34599. /**
  34600. * Image src displayed during the video loading or until the user interacts with the video.
  34601. */
  34602. poster?: string;
  34603. }
  34604. class VideoTexture extends Texture {
  34605. /**
  34606. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  34607. */
  34608. readonly autoUpdateTexture: boolean;
  34609. /**
  34610. * The video instance used by the texture internally
  34611. */
  34612. readonly video: HTMLVideoElement;
  34613. private _onUserActionRequestedObservable;
  34614. readonly onUserActionRequestedObservable: Observable<Texture>;
  34615. private _generateMipMaps;
  34616. private _engine;
  34617. private _stillImageCaptured;
  34618. /**
  34619. * Creates a video texture.
  34620. * Sample : https://doc.babylonjs.com/how_to/video_texture
  34621. * @param {string | null} name optional name, will detect from video source, if not defined
  34622. * @param {(string | string[] | HTMLVideoElement)} src can be used to provide an url, array of urls or an already setup HTML video element.
  34623. * @param {BABYLON.Scene} scene is obviously the current scene.
  34624. * @param {boolean} generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  34625. * @param {boolean} invertY is false by default but can be used to invert video on Y axis
  34626. * @param {number} samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  34627. * @param {VideoTextureSettings} [settings] allows finer control over video usage
  34628. */
  34629. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  34630. private _getName(src);
  34631. private _getVideo(src);
  34632. private _createInternalTexture;
  34633. private reset;
  34634. /**
  34635. * Internal method to initiate `update`.
  34636. */
  34637. /**
  34638. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  34639. */
  34640. update(): void;
  34641. /**
  34642. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  34643. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  34644. */
  34645. updateTexture(isVisible: boolean): void;
  34646. protected _updateInternalTexture: (e?: Event | undefined) => void;
  34647. /**
  34648. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  34649. * @param url New url.
  34650. */
  34651. updateURL(url: string): void;
  34652. dispose(): void;
  34653. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  34654. minWidth: number;
  34655. maxWidth: number;
  34656. minHeight: number;
  34657. maxHeight: number;
  34658. deviceId: string;
  34659. }): void;
  34660. }
  34661. }
  34662. declare module BABYLON {
  34663. /**
  34664. * Particle emitter emitting particles from the inside of a box.
  34665. * It emits the particles randomly between 2 given directions.
  34666. */
  34667. class BoxParticleEmitter implements IParticleEmitterType {
  34668. /**
  34669. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  34670. */
  34671. direction1: Vector3;
  34672. /**
  34673. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  34674. */
  34675. direction2: Vector3;
  34676. /**
  34677. * 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.
  34678. */
  34679. minEmitBox: Vector3;
  34680. /**
  34681. * 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.
  34682. */
  34683. maxEmitBox: Vector3;
  34684. /**
  34685. * Creates a new instance BoxParticleEmitter
  34686. */
  34687. constructor();
  34688. /**
  34689. * Called by the particle System when the direction is computed for the created particle.
  34690. * @param worldMatrix is the world matrix of the particle system
  34691. * @param directionToUpdate is the direction vector to update with the result
  34692. * @param particle is the particle we are computed the direction for
  34693. */
  34694. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  34695. /**
  34696. * Called by the particle System when the position is computed for the created particle.
  34697. * @param worldMatrix is the world matrix of the particle system
  34698. * @param positionToUpdate is the position vector to update with the result
  34699. * @param particle is the particle we are computed the position for
  34700. */
  34701. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  34702. /**
  34703. * Clones the current emitter and returns a copy of it
  34704. * @returns the new emitter
  34705. */
  34706. clone(): BoxParticleEmitter;
  34707. /**
  34708. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  34709. * @param effect defines the update shader
  34710. */
  34711. applyToShader(effect: Effect): void;
  34712. /**
  34713. * Returns a string to use to update the GPU particles update shader
  34714. * @returns a string containng the defines string
  34715. */
  34716. getEffectDefines(): string;
  34717. /**
  34718. * Returns the string "BoxEmitter"
  34719. * @returns a string containing the class name
  34720. */
  34721. getClassName(): string;
  34722. /**
  34723. * Serializes the particle system to a JSON object.
  34724. * @returns the JSON object
  34725. */
  34726. serialize(): any;
  34727. /**
  34728. * Parse properties from a JSON object
  34729. * @param serializationObject defines the JSON object
  34730. */
  34731. parse(serializationObject: any): void;
  34732. }
  34733. }
  34734. declare module BABYLON {
  34735. /**
  34736. * Particle emitter emitting particles from the inside of a cone.
  34737. * It emits the particles alongside the cone volume from the base to the particle.
  34738. * The emission direction might be randomized.
  34739. */
  34740. class ConeParticleEmitter implements IParticleEmitterType {
  34741. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  34742. directionRandomizer: number;
  34743. private _radius;
  34744. private _angle;
  34745. private _height;
  34746. /**
  34747. * Gets or sets the radius of the emission cone
  34748. */
  34749. radius: number;
  34750. /**
  34751. * Gets or sets the angle of the emission cone
  34752. */
  34753. angle: number;
  34754. private _buildHeight();
  34755. /**
  34756. * Creates a new instance ConeParticleEmitter
  34757. * @param radius the radius of the emission cone (1 by default)
  34758. * @param angles the cone base angle (PI by default)
  34759. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  34760. */
  34761. constructor(radius?: number, angle?: number,
  34762. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  34763. directionRandomizer?: number);
  34764. /**
  34765. * Called by the particle System when the direction is computed for the created particle.
  34766. * @param worldMatrix is the world matrix of the particle system
  34767. * @param directionToUpdate is the direction vector to update with the result
  34768. * @param particle is the particle we are computed the direction for
  34769. */
  34770. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  34771. /**
  34772. * Called by the particle System when the position is computed for the created particle.
  34773. * @param worldMatrix is the world matrix of the particle system
  34774. * @param positionToUpdate is the position vector to update with the result
  34775. * @param particle is the particle we are computed the position for
  34776. */
  34777. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  34778. /**
  34779. * Clones the current emitter and returns a copy of it
  34780. * @returns the new emitter
  34781. */
  34782. clone(): ConeParticleEmitter;
  34783. /**
  34784. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  34785. * @param effect defines the update shader
  34786. */
  34787. applyToShader(effect: Effect): void;
  34788. /**
  34789. * Returns a string to use to update the GPU particles update shader
  34790. * @returns a string containng the defines string
  34791. */
  34792. getEffectDefines(): string;
  34793. /**
  34794. * Returns the string "BoxEmitter"
  34795. * @returns a string containing the class name
  34796. */
  34797. getClassName(): string;
  34798. /**
  34799. * Serializes the particle system to a JSON object.
  34800. * @returns the JSON object
  34801. */
  34802. serialize(): any;
  34803. /**
  34804. * Parse properties from a JSON object
  34805. * @param serializationObject defines the JSON object
  34806. */
  34807. parse(serializationObject: any): void;
  34808. }
  34809. }
  34810. declare module BABYLON {
  34811. /**
  34812. * Particle emitter represents a volume emitting particles.
  34813. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  34814. */
  34815. interface IParticleEmitterType {
  34816. /**
  34817. * Called by the particle System when the direction is computed for the created particle.
  34818. * @param worldMatrix is the world matrix of the particle system
  34819. * @param directionToUpdate is the direction vector to update with the result
  34820. * @param particle is the particle we are computed the direction for
  34821. */
  34822. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  34823. /**
  34824. * Called by the particle System when the position is computed for the created particle.
  34825. * @param worldMatrix is the world matrix of the particle system
  34826. * @param positionToUpdate is the position vector to update with the result
  34827. * @param particle is the particle we are computed the position for
  34828. */
  34829. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  34830. /**
  34831. * Clones the current emitter and returns a copy of it
  34832. * @returns the new emitter
  34833. */
  34834. clone(): IParticleEmitterType;
  34835. /**
  34836. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  34837. * @param effect defines the update shader
  34838. */
  34839. applyToShader(effect: Effect): void;
  34840. /**
  34841. * Returns a string to use to update the GPU particles update shader
  34842. * @returns the effect defines string
  34843. */
  34844. getEffectDefines(): string;
  34845. /**
  34846. * Returns a string representing the class name
  34847. * @returns a string containing the class name
  34848. */
  34849. getClassName(): string;
  34850. /**
  34851. * Serializes the particle system to a JSON object.
  34852. * @returns the JSON object
  34853. */
  34854. serialize(): any;
  34855. /**
  34856. * Parse properties from a JSON object
  34857. * @param serializationObject defines the JSON object
  34858. */
  34859. parse(serializationObject: any): void;
  34860. }
  34861. }
  34862. declare module BABYLON {
  34863. /**
  34864. * Particle emitter emitting particles from the inside of a sphere.
  34865. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  34866. */
  34867. class SphereParticleEmitter implements IParticleEmitterType {
  34868. /**
  34869. * The radius of the emission sphere.
  34870. */
  34871. radius: number;
  34872. /**
  34873. * How much to randomize the particle direction [0-1].
  34874. */
  34875. directionRandomizer: number;
  34876. /**
  34877. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  34878. */
  34879. radiusRange: number;
  34880. /**
  34881. * Creates a new instance SphereParticleEmitter
  34882. * @param radius the radius of the emission sphere (1 by default)
  34883. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  34884. */
  34885. constructor(
  34886. /**
  34887. * The radius of the emission sphere.
  34888. */
  34889. radius?: number,
  34890. /**
  34891. * How much to randomize the particle direction [0-1].
  34892. */
  34893. directionRandomizer?: number);
  34894. /**
  34895. * Called by the particle System when the direction is computed for the created particle.
  34896. * @param worldMatrix is the world matrix of the particle system
  34897. * @param directionToUpdate is the direction vector to update with the result
  34898. * @param particle is the particle we are computed the direction for
  34899. */
  34900. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  34901. /**
  34902. * Called by the particle System when the position is computed for the created particle.
  34903. * @param worldMatrix is the world matrix of the particle system
  34904. * @param positionToUpdate is the position vector to update with the result
  34905. * @param particle is the particle we are computed the position for
  34906. */
  34907. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  34908. /**
  34909. * Clones the current emitter and returns a copy of it
  34910. * @returns the new emitter
  34911. */
  34912. clone(): SphereParticleEmitter;
  34913. /**
  34914. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  34915. * @param effect defines the update shader
  34916. */
  34917. applyToShader(effect: Effect): void;
  34918. /**
  34919. * Returns a string to use to update the GPU particles update shader
  34920. * @returns a string containng the defines string
  34921. */
  34922. getEffectDefines(): string;
  34923. /**
  34924. * Returns the string "SphereParticleEmitter"
  34925. * @returns a string containing the class name
  34926. */
  34927. getClassName(): string;
  34928. /**
  34929. * Serializes the particle system to a JSON object.
  34930. * @returns the JSON object
  34931. */
  34932. serialize(): any;
  34933. /**
  34934. * Parse properties from a JSON object
  34935. * @param serializationObject defines the JSON object
  34936. */
  34937. parse(serializationObject: any): void;
  34938. }
  34939. /**
  34940. * Particle emitter emitting particles from the inside of a sphere.
  34941. * It emits the particles randomly between two vectors.
  34942. */
  34943. class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  34944. /**
  34945. * The min limit of the emission direction.
  34946. */
  34947. direction1: Vector3;
  34948. /**
  34949. * The max limit of the emission direction.
  34950. */
  34951. direction2: Vector3;
  34952. /**
  34953. * Creates a new instance SphereDirectedParticleEmitter
  34954. * @param radius the radius of the emission sphere (1 by default)
  34955. * @param direction1 the min limit of the emission direction (up vector by default)
  34956. * @param direction2 the max limit of the emission direction (up vector by default)
  34957. */
  34958. constructor(radius?: number,
  34959. /**
  34960. * The min limit of the emission direction.
  34961. */
  34962. direction1?: Vector3,
  34963. /**
  34964. * The max limit of the emission direction.
  34965. */
  34966. direction2?: Vector3);
  34967. /**
  34968. * Called by the particle System when the direction is computed for the created particle.
  34969. * @param worldMatrix is the world matrix of the particle system
  34970. * @param directionToUpdate is the direction vector to update with the result
  34971. * @param particle is the particle we are computed the direction for
  34972. */
  34973. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  34974. /**
  34975. * Clones the current emitter and returns a copy of it
  34976. * @returns the new emitter
  34977. */
  34978. clone(): SphereDirectedParticleEmitter;
  34979. /**
  34980. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  34981. * @param effect defines the update shader
  34982. */
  34983. applyToShader(effect: Effect): void;
  34984. /**
  34985. * Returns a string to use to update the GPU particles update shader
  34986. * @returns a string containng the defines string
  34987. */
  34988. getEffectDefines(): string;
  34989. /**
  34990. * Returns the string "SphereDirectedParticleEmitter"
  34991. * @returns a string containing the class name
  34992. */
  34993. getClassName(): string;
  34994. /**
  34995. * Serializes the particle system to a JSON object.
  34996. * @returns the JSON object
  34997. */
  34998. serialize(): any;
  34999. /**
  35000. * Parse properties from a JSON object
  35001. * @param serializationObject defines the JSON object
  35002. */
  35003. parse(serializationObject: any): void;
  35004. }
  35005. }
  35006. declare var DracoDecoderModule: any;
  35007. declare var WebAssembly: any;
  35008. declare module BABYLON {
  35009. /**
  35010. * Configuration for Draco compression
  35011. */
  35012. interface IDracoCompressionConfiguration {
  35013. /**
  35014. * Configuration for the decoder.
  35015. */
  35016. decoder?: {
  35017. /**
  35018. * The url to the WebAssembly module.
  35019. */
  35020. wasmUrl?: string;
  35021. /**
  35022. * The url to the WebAssembly binary.
  35023. */
  35024. wasmBinaryUrl?: string;
  35025. /**
  35026. * The url to the fallback JavaScript module.
  35027. */
  35028. fallbackUrl?: string;
  35029. };
  35030. }
  35031. /**
  35032. * Draco compression (https://google.github.io/draco/)
  35033. *
  35034. * This class wraps the Draco module.
  35035. *
  35036. * **Encoder**
  35037. *
  35038. * The encoder is not currently implemented.
  35039. *
  35040. * **Decoder**
  35041. *
  35042. * By default, the configuration points to a copy of the Draco decoder files for glTF from https://preview.babylonjs.com.
  35043. *
  35044. * To update the configuration, use the following code:
  35045. * ```javascript
  35046. * BABYLON.DracoCompression.Configuration = {
  35047. * decoder: {
  35048. * wasmUrl: "<url to the WebAssembly library>",
  35049. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  35050. * fallbackUrl: "<url to the fallback JavaScript library>",
  35051. * }
  35052. * };
  35053. * ```
  35054. *
  35055. * 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.
  35056. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  35057. * Use `BABYLON.DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  35058. *
  35059. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  35060. * ```javascript
  35061. * var dracoCompression = new BABYLON.DracoCompression();
  35062. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  35063. * [BABYLON.VertexBuffer.PositionKind]: 0
  35064. * });
  35065. * ```
  35066. *
  35067. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  35068. */
  35069. class DracoCompression implements IDisposable {
  35070. private static _DecoderModulePromise;
  35071. /**
  35072. * The configuration. Defaults to the following urls:
  35073. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  35074. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  35075. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  35076. */
  35077. static Configuration: IDracoCompressionConfiguration;
  35078. /**
  35079. * Returns true if the decoder is available.
  35080. */
  35081. static readonly DecoderAvailable: boolean;
  35082. /**
  35083. * Constructor
  35084. */
  35085. constructor();
  35086. /**
  35087. * Stop all async operations and release resources.
  35088. */
  35089. dispose(): void;
  35090. /**
  35091. * Decode Draco compressed mesh data to vertex data.
  35092. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  35093. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  35094. * @returns A promise that resolves with the decoded vertex data
  35095. */
  35096. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes: {
  35097. [kind: string]: number;
  35098. }): Promise<VertexData>;
  35099. private static _GetDecoderModule();
  35100. private static _LoadScriptAsync(url);
  35101. private static _LoadFileAsync(url);
  35102. }
  35103. }
  35104. declare module BABYLON {
  35105. class CannonJSPlugin implements IPhysicsEnginePlugin {
  35106. private _useDeltaForWorldStep;
  35107. world: any;
  35108. name: string;
  35109. private _physicsMaterials;
  35110. private _fixedTimeStep;
  35111. BJSCANNON: any;
  35112. constructor(_useDeltaForWorldStep?: boolean, iterations?: number);
  35113. setGravity(gravity: Vector3): void;
  35114. setTimeStep(timeStep: number): void;
  35115. getTimeStep(): number;
  35116. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  35117. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  35118. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  35119. generatePhysicsBody(impostor: PhysicsImpostor): void;
  35120. private _processChildMeshes(mainImpostor);
  35121. removePhysicsBody(impostor: PhysicsImpostor): void;
  35122. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  35123. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  35124. private _addMaterial(name, friction, restitution);
  35125. private _checkWithEpsilon(value);
  35126. private _createShape(impostor);
  35127. private _createHeightmap(object, pointDepth?);
  35128. private _minus90X;
  35129. private _plus90X;
  35130. private _tmpPosition;
  35131. private _tmpDeltaPosition;
  35132. private _tmpUnityRotation;
  35133. private _updatePhysicsBodyTransformation(impostor);
  35134. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  35135. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  35136. isSupported(): boolean;
  35137. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  35138. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  35139. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  35140. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  35141. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  35142. getBodyMass(impostor: PhysicsImpostor): number;
  35143. getBodyFriction(impostor: PhysicsImpostor): number;
  35144. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  35145. getBodyRestitution(impostor: PhysicsImpostor): number;
  35146. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  35147. sleepBody(impostor: PhysicsImpostor): void;
  35148. wakeUpBody(impostor: PhysicsImpostor): void;
  35149. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  35150. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  35151. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  35152. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  35153. getRadius(impostor: PhysicsImpostor): number;
  35154. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  35155. dispose(): void;
  35156. private _extendNamespace();
  35157. }
  35158. }
  35159. declare module BABYLON {
  35160. class OimoJSPlugin implements IPhysicsEnginePlugin {
  35161. world: any;
  35162. name: string;
  35163. BJSOIMO: any;
  35164. constructor(iterations?: number);
  35165. setGravity(gravity: Vector3): void;
  35166. setTimeStep(timeStep: number): void;
  35167. getTimeStep(): number;
  35168. private _tmpImpostorsArray;
  35169. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  35170. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  35171. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  35172. generatePhysicsBody(impostor: PhysicsImpostor): void;
  35173. private _tmpPositionVector;
  35174. removePhysicsBody(impostor: PhysicsImpostor): void;
  35175. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  35176. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  35177. isSupported(): boolean;
  35178. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  35179. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  35180. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  35181. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  35182. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  35183. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  35184. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  35185. getBodyMass(impostor: PhysicsImpostor): number;
  35186. getBodyFriction(impostor: PhysicsImpostor): number;
  35187. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  35188. getBodyRestitution(impostor: PhysicsImpostor): number;
  35189. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  35190. sleepBody(impostor: PhysicsImpostor): void;
  35191. wakeUpBody(impostor: PhysicsImpostor): void;
  35192. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  35193. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  35194. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  35195. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  35196. getRadius(impostor: PhysicsImpostor): number;
  35197. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  35198. dispose(): void;
  35199. }
  35200. }
  35201. declare module BABYLON {
  35202. /**
  35203. * This represents a set of one or more post processes in Babylon.
  35204. * A post process can be used to apply a shader to a texture after it is rendered.
  35205. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  35206. */
  35207. class PostProcessRenderEffect {
  35208. private _postProcesses;
  35209. private _getPostProcesses;
  35210. private _singleInstance;
  35211. private _cameras;
  35212. private _indicesForCamera;
  35213. /**
  35214. * Name of the effect
  35215. */
  35216. /**
  35217. * Instantiates a post process render effect.
  35218. * A post process can be used to apply a shader to a texture after it is rendered.
  35219. * @param engine The engine the effect is tied to
  35220. * @param name The name of the effect
  35221. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  35222. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  35223. */
  35224. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  35225. /**
  35226. * Checks if all the post processes in the effect are supported.
  35227. */
  35228. readonly isSupported: boolean;
  35229. /**
  35230. * Updates the current state of the effect
  35231. */
  35232. /**
  35233. * Attaches the effect on cameras
  35234. * @param cameras The camera to attach to.
  35235. */
  35236. /**
  35237. * Attaches the effect on cameras
  35238. * @param cameras The camera to attach to.
  35239. */
  35240. /**
  35241. * Detatches the effect on cameras
  35242. * @param cameras The camera to detatch from.
  35243. */
  35244. /**
  35245. * Detatches the effect on cameras
  35246. * @param cameras The camera to detatch from.
  35247. */
  35248. /**
  35249. * Enables the effect on given cameras
  35250. * @param cameras The camera to enable.
  35251. */
  35252. /**
  35253. * Enables the effect on given cameras
  35254. * @param cameras The camera to enable.
  35255. */
  35256. /**
  35257. * Disables the effect on the given cameras
  35258. * @param cameras The camera to disable.
  35259. */
  35260. /**
  35261. * Disables the effect on the given cameras
  35262. * @param cameras The camera to disable.
  35263. */
  35264. /**
  35265. * Gets a list of the post processes contained in the effect.
  35266. * @param camera The camera to get the post processes on.
  35267. * @returns The list of the post processes in the effect.
  35268. */
  35269. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  35270. }
  35271. }
  35272. declare module BABYLON {
  35273. class PostProcessRenderPipeline {
  35274. private engine;
  35275. private _renderEffects;
  35276. private _renderEffectsForIsolatedPass;
  35277. protected _cameras: Camera[];
  35278. constructor(engine: Engine, name: string);
  35279. getClassName(): string;
  35280. readonly isSupported: boolean;
  35281. addEffect(renderEffect: PostProcessRenderEffect): void;
  35282. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  35283. dispose(): void;
  35284. }
  35285. }
  35286. declare module BABYLON {
  35287. class PostProcessRenderPipelineManager {
  35288. private _renderPipelines;
  35289. constructor();
  35290. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  35291. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: Camera, unique?: boolean): void;
  35292. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: Camera[], unique?: boolean): void;
  35293. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: Camera): void;
  35294. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: Camera[]): void;
  35295. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera): void;
  35296. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera[]): void;
  35297. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera): void;
  35298. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera[]): void;
  35299. update(): void;
  35300. dispose(): void;
  35301. }
  35302. }
  35303. declare module BABYLON {
  35304. /**
  35305. * Helper class dealing with the extraction of spherical polynomial dataArray
  35306. * from a cube map.
  35307. */
  35308. class CubeMapToSphericalPolynomialTools {
  35309. private static FileFaces;
  35310. /**
  35311. * Converts a texture to the according Spherical Polynomial data.
  35312. * This extracts the first 3 orders only as they are the only one used in the lighting.
  35313. *
  35314. * @param texture The texture to extract the information from.
  35315. * @return The Spherical Polynomial data.
  35316. */
  35317. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  35318. /**
  35319. * Converts a cubemap to the according Spherical Polynomial data.
  35320. * This extracts the first 3 orders only as they are the only one used in the lighting.
  35321. *
  35322. * @param cubeInfo The Cube map to extract the information from.
  35323. * @return The Spherical Polynomial data.
  35324. */
  35325. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  35326. }
  35327. }
  35328. declare module BABYLON {
  35329. /**
  35330. * Header information of HDR texture files.
  35331. */
  35332. interface HDRInfo {
  35333. /**
  35334. * The height of the texture in pixels.
  35335. */
  35336. height: number;
  35337. /**
  35338. * The width of the texture in pixels.
  35339. */
  35340. width: number;
  35341. /**
  35342. * The index of the beginning of the data in the binary file.
  35343. */
  35344. dataPosition: number;
  35345. }
  35346. /**
  35347. * This groups tools to convert HDR texture to native colors array.
  35348. */
  35349. class HDRTools {
  35350. private static Ldexp(mantissa, exponent);
  35351. private static Rgbe2float(float32array, red, green, blue, exponent, index);
  35352. private static readStringLine(uint8array, startIndex);
  35353. /**
  35354. * Reads header information from an RGBE texture stored in a native array.
  35355. * More information on this format are available here:
  35356. * https://en.wikipedia.org/wiki/RGBE_image_format
  35357. *
  35358. * @param uint8array The binary file stored in native array.
  35359. * @return The header information.
  35360. */
  35361. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  35362. /**
  35363. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  35364. * This RGBE texture needs to store the information as a panorama.
  35365. *
  35366. * More information on this format are available here:
  35367. * https://en.wikipedia.org/wiki/RGBE_image_format
  35368. *
  35369. * @param buffer The binary file stored in an array buffer.
  35370. * @param size The expected size of the extracted cubemap.
  35371. * @return The Cube Map information.
  35372. */
  35373. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  35374. /**
  35375. * Returns the pixels data extracted from an RGBE texture.
  35376. * This pixels will be stored left to right up to down in the R G B order in one array.
  35377. *
  35378. * More information on this format are available here:
  35379. * https://en.wikipedia.org/wiki/RGBE_image_format
  35380. *
  35381. * @param uint8array The binary file stored in an array buffer.
  35382. * @param hdrInfo The header information of the file.
  35383. * @return The pixels data in RGB right to left up to down order.
  35384. */
  35385. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  35386. private static RGBE_ReadPixels_RLE(uint8array, hdrInfo);
  35387. }
  35388. }
  35389. declare module BABYLON {
  35390. /**
  35391. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  35392. */
  35393. interface CubeMapInfo {
  35394. /**
  35395. * The pixel array for the front face.
  35396. * This is stored in format, left to right, up to down format.
  35397. */
  35398. front: Nullable<ArrayBufferView>;
  35399. /**
  35400. * The pixel array for the back face.
  35401. * This is stored in format, left to right, up to down format.
  35402. */
  35403. back: Nullable<ArrayBufferView>;
  35404. /**
  35405. * The pixel array for the left face.
  35406. * This is stored in format, left to right, up to down format.
  35407. */
  35408. left: Nullable<ArrayBufferView>;
  35409. /**
  35410. * The pixel array for the right face.
  35411. * This is stored in format, left to right, up to down format.
  35412. */
  35413. right: Nullable<ArrayBufferView>;
  35414. /**
  35415. * The pixel array for the up face.
  35416. * This is stored in format, left to right, up to down format.
  35417. */
  35418. up: Nullable<ArrayBufferView>;
  35419. /**
  35420. * The pixel array for the down face.
  35421. * This is stored in format, left to right, up to down format.
  35422. */
  35423. down: Nullable<ArrayBufferView>;
  35424. /**
  35425. * The size of the cubemap stored.
  35426. *
  35427. * Each faces will be size * size pixels.
  35428. */
  35429. size: number;
  35430. /**
  35431. * The format of the texture.
  35432. *
  35433. * RGBA, RGB.
  35434. */
  35435. format: number;
  35436. /**
  35437. * The type of the texture data.
  35438. *
  35439. * UNSIGNED_INT, FLOAT.
  35440. */
  35441. type: number;
  35442. /**
  35443. * Specifies whether the texture is in gamma space.
  35444. */
  35445. gammaSpace: boolean;
  35446. }
  35447. /**
  35448. * Helper class usefull to convert panorama picture to their cubemap representation in 6 faces.
  35449. */
  35450. class PanoramaToCubeMapTools {
  35451. private static FACE_FRONT;
  35452. private static FACE_BACK;
  35453. private static FACE_RIGHT;
  35454. private static FACE_LEFT;
  35455. private static FACE_DOWN;
  35456. private static FACE_UP;
  35457. /**
  35458. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  35459. *
  35460. * @param float32Array The source data.
  35461. * @param inputWidth The width of the input panorama.
  35462. * @param inputhHeight The height of the input panorama.
  35463. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  35464. * @return The cubemap data
  35465. */
  35466. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  35467. private static CreateCubemapTexture(texSize, faceData, float32Array, inputWidth, inputHeight);
  35468. private static CalcProjectionSpherical(vDir, float32Array, inputWidth, inputHeight);
  35469. }
  35470. }
  35471. declare module BABYLON {
  35472. class CustomProceduralTexture extends ProceduralTexture {
  35473. private _animate;
  35474. private _time;
  35475. private _config;
  35476. private _texturePath;
  35477. constructor(name: string, texturePath: any, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  35478. private loadJson(jsonUrl);
  35479. isReady(): boolean;
  35480. render(useCameraPostProcess?: boolean): void;
  35481. updateTextures(): void;
  35482. updateShaderUniforms(): void;
  35483. animate: boolean;
  35484. }
  35485. }
  35486. declare module BABYLON {
  35487. class ProceduralTexture extends Texture {
  35488. isCube: boolean;
  35489. private _size;
  35490. isEnabled: boolean;
  35491. private _currentRefreshId;
  35492. private _refreshRate;
  35493. onGenerated: () => void;
  35494. private _vertexBuffers;
  35495. private _indexBuffer;
  35496. private _effect;
  35497. private _uniforms;
  35498. private _samplers;
  35499. private _fragment;
  35500. ;
  35501. private _floats;
  35502. private _floatsArrays;
  35503. private _colors3;
  35504. private _colors4;
  35505. private _vectors2;
  35506. private _vectors3;
  35507. private _matrices;
  35508. private _fallbackTexture;
  35509. private _fallbackTextureUsed;
  35510. private _engine;
  35511. constructor(name: string, size: any, fragment: any, scene: Scene, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  35512. private _createIndexBuffer();
  35513. reset(): void;
  35514. isReady(): boolean;
  35515. resetRefreshCounter(): void;
  35516. setFragment(fragment: any): void;
  35517. refreshRate: number;
  35518. getRenderSize(): number;
  35519. resize(size: number, generateMipMaps: boolean): void;
  35520. private _checkUniform(uniformName);
  35521. setTexture(name: string, texture: Texture): ProceduralTexture;
  35522. setFloat(name: string, value: number): ProceduralTexture;
  35523. setFloats(name: string, value: number[]): ProceduralTexture;
  35524. setColor3(name: string, value: Color3): ProceduralTexture;
  35525. setColor4(name: string, value: Color4): ProceduralTexture;
  35526. setVector2(name: string, value: Vector2): ProceduralTexture;
  35527. setVector3(name: string, value: Vector3): ProceduralTexture;
  35528. setMatrix(name: string, value: Matrix): ProceduralTexture;
  35529. render(useCameraPostProcess?: boolean): void;
  35530. clone(): ProceduralTexture;
  35531. dispose(): void;
  35532. }
  35533. }
  35534. declare module BABYLON {
  35535. /**
  35536. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  35537. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  35538. */
  35539. class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  35540. private _scene;
  35541. private _originalCameras;
  35542. /**
  35543. * ID of the sharpen post process,
  35544. */
  35545. private readonly SharpenPostProcessId;
  35546. /**
  35547. * ID of the image processing post process;
  35548. */
  35549. readonly ImageProcessingPostProcessId: string;
  35550. /**
  35551. * ID of the Fast Approximate Anti-Aliasing post process;
  35552. */
  35553. readonly FxaaPostProcessId: string;
  35554. /**
  35555. * ID of the chromatic aberration post process,
  35556. */
  35557. private readonly ChromaticAberrationPostProcessId;
  35558. /**
  35559. * ID of the grain post process
  35560. */
  35561. private readonly GrainPostProcessId;
  35562. /**
  35563. * Sharpen post process which will apply a sharpen convolution to enhance edges
  35564. */
  35565. sharpen: SharpenPostProcess;
  35566. private _sharpenEffect;
  35567. private bloom;
  35568. /**
  35569. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  35570. */
  35571. depthOfField: DepthOfFieldEffect;
  35572. /**
  35573. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  35574. */
  35575. fxaa: FxaaPostProcess;
  35576. /**
  35577. * Image post processing pass used to perform operations such as tone mapping or color grading.
  35578. */
  35579. imageProcessing: ImageProcessingPostProcess;
  35580. /**
  35581. * Chromatic aberration post process which will shift rgb colors in the image
  35582. */
  35583. chromaticAberration: ChromaticAberrationPostProcess;
  35584. private _chromaticAberrationEffect;
  35585. /**
  35586. * Grain post process which add noise to the image
  35587. */
  35588. grain: GrainPostProcess;
  35589. private _grainEffect;
  35590. /**
  35591. * Glow post process which adds a glow to emmisive areas of the image
  35592. */
  35593. private _glowLayer;
  35594. /**
  35595. * Animations which can be used to tweak settings over a period of time
  35596. */
  35597. animations: Animation[];
  35598. private _imageProcessingConfigurationObserver;
  35599. private _sharpenEnabled;
  35600. private _bloomEnabled;
  35601. private _depthOfFieldEnabled;
  35602. private _depthOfFieldBlurLevel;
  35603. private _fxaaEnabled;
  35604. private _imageProcessingEnabled;
  35605. private _defaultPipelineTextureType;
  35606. private _bloomScale;
  35607. private _chromaticAberrationEnabled;
  35608. private _grainEnabled;
  35609. private _buildAllowed;
  35610. /**
  35611. * Enable or disable the sharpen process from the pipeline
  35612. */
  35613. sharpenEnabled: boolean;
  35614. private _resizeObserver;
  35615. private _hardwareScaleLevel;
  35616. private _bloomKernel;
  35617. /**
  35618. * Specifies the size of the bloom blur kernel, relative to the final output size
  35619. */
  35620. bloomKernel: number;
  35621. /**
  35622. * Specifies the weight of the bloom in the final rendering
  35623. */
  35624. private _bloomWeight;
  35625. /**
  35626. * Specifies the luma threshold for the area that will be blurred by the bloom
  35627. */
  35628. private _bloomThreshold;
  35629. private _hdr;
  35630. /**
  35631. * The strength of the bloom.
  35632. */
  35633. bloomWeight: number;
  35634. /**
  35635. * The strength of the bloom.
  35636. */
  35637. bloomThreshold: number;
  35638. /**
  35639. * The scale of the bloom, lower value will provide better performance.
  35640. */
  35641. bloomScale: number;
  35642. /**
  35643. * Enable or disable the bloom from the pipeline
  35644. */
  35645. bloomEnabled: boolean;
  35646. private _rebuildBloom();
  35647. /**
  35648. * If the depth of field is enabled.
  35649. */
  35650. depthOfFieldEnabled: boolean;
  35651. /**
  35652. * Blur level of the depth of field effect. (Higher blur will effect performance)
  35653. */
  35654. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  35655. /**
  35656. * If the anti aliasing is enabled.
  35657. */
  35658. fxaaEnabled: boolean;
  35659. private _samples;
  35660. /**
  35661. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  35662. */
  35663. samples: number;
  35664. /**
  35665. * If image processing is enabled.
  35666. */
  35667. imageProcessingEnabled: boolean;
  35668. /**
  35669. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  35670. */
  35671. glowLayerEnabled: boolean;
  35672. /**
  35673. * Enable or disable the chromaticAberration process from the pipeline
  35674. */
  35675. chromaticAberrationEnabled: boolean;
  35676. /**
  35677. * Enable or disable the grain process from the pipeline
  35678. */
  35679. grainEnabled: boolean;
  35680. /**
  35681. * @constructor
  35682. * @param {string} name - The rendering pipeline name (default: "")
  35683. * @param {boolean} hdr - If high dynamic range textures should be used (default: true)
  35684. * @param {BABYLON.Scene} scene - The scene linked to this pipeline (default: the last created scene)
  35685. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  35686. * @param {boolean} automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  35687. */
  35688. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  35689. /**
  35690. * Force the compilation of the entire pipeline.
  35691. */
  35692. prepare(): void;
  35693. private _hasCleared;
  35694. private _prevPostProcess;
  35695. private _prevPrevPostProcess;
  35696. private _setAutoClearAndTextureSharing(postProcess, skipTextureSharing?);
  35697. private _buildPipeline();
  35698. private _disposePostProcesses(disposeNonRecreated?);
  35699. /**
  35700. * Dispose of the pipeline and stop all post processes
  35701. */
  35702. dispose(): void;
  35703. /**
  35704. * Serialize the rendering pipeline (Used when exporting)
  35705. * @returns the serialized object
  35706. */
  35707. serialize(): any;
  35708. /**
  35709. * Parse the serialized pipeline
  35710. * @param source Source pipeline.
  35711. * @param scene The scene to load the pipeline to.
  35712. * @param rootUrl The URL of the serialized pipeline.
  35713. * @returns An instantiated pipeline from the serialized object.
  35714. */
  35715. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  35716. }
  35717. }
  35718. declare module BABYLON {
  35719. class LensRenderingPipeline extends PostProcessRenderPipeline {
  35720. /**
  35721. * The chromatic aberration PostProcess id in the pipeline
  35722. */
  35723. LensChromaticAberrationEffect: string;
  35724. /**
  35725. * The highlights enhancing PostProcess id in the pipeline
  35726. */
  35727. HighlightsEnhancingEffect: string;
  35728. /**
  35729. * The depth-of-field PostProcess id in the pipeline
  35730. */
  35731. LensDepthOfFieldEffect: string;
  35732. private _scene;
  35733. private _depthTexture;
  35734. private _grainTexture;
  35735. private _chromaticAberrationPostProcess;
  35736. private _highlightsPostProcess;
  35737. private _depthOfFieldPostProcess;
  35738. private _edgeBlur;
  35739. private _grainAmount;
  35740. private _chromaticAberration;
  35741. private _distortion;
  35742. private _highlightsGain;
  35743. private _highlightsThreshold;
  35744. private _dofDistance;
  35745. private _dofAperture;
  35746. private _dofDarken;
  35747. private _dofPentagon;
  35748. private _blurNoise;
  35749. /**
  35750. * @constructor
  35751. *
  35752. * Effect parameters are as follow:
  35753. * {
  35754. * chromatic_aberration: number; // from 0 to x (1 for realism)
  35755. * edge_blur: number; // from 0 to x (1 for realism)
  35756. * distortion: number; // from 0 to x (1 for realism)
  35757. * grain_amount: number; // from 0 to 1
  35758. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  35759. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  35760. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  35761. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  35762. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  35763. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  35764. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  35765. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  35766. * }
  35767. * Note: if an effect parameter is unset, effect is disabled
  35768. *
  35769. * @param {string} name - The rendering pipeline name
  35770. * @param {object} parameters - An object containing all parameters (see above)
  35771. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  35772. * @param {number} ratio - The size of the postprocesses (0.5 means that your postprocess will have a width = canvas.width 0.5 and a height = canvas.height 0.5)
  35773. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  35774. */
  35775. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  35776. setEdgeBlur(amount: number): void;
  35777. disableEdgeBlur(): void;
  35778. setGrainAmount(amount: number): void;
  35779. disableGrain(): void;
  35780. setChromaticAberration(amount: number): void;
  35781. disableChromaticAberration(): void;
  35782. setEdgeDistortion(amount: number): void;
  35783. disableEdgeDistortion(): void;
  35784. setFocusDistance(amount: number): void;
  35785. disableDepthOfField(): void;
  35786. setAperture(amount: number): void;
  35787. setDarkenOutOfFocus(amount: number): void;
  35788. enablePentagonBokeh(): void;
  35789. disablePentagonBokeh(): void;
  35790. enableNoiseBlur(): void;
  35791. disableNoiseBlur(): void;
  35792. setHighlightsGain(amount: number): void;
  35793. setHighlightsThreshold(amount: number): void;
  35794. disableHighlights(): void;
  35795. /**
  35796. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  35797. */
  35798. dispose(disableDepthRender?: boolean): void;
  35799. private _createChromaticAberrationPostProcess(ratio);
  35800. private _createHighlightsPostProcess(ratio);
  35801. private _createDepthOfFieldPostProcess(ratio);
  35802. private _createGrainTexture();
  35803. }
  35804. }
  35805. declare module BABYLON {
  35806. class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  35807. /**
  35808. * The PassPostProcess id in the pipeline that contains the original scene color
  35809. */
  35810. SSAOOriginalSceneColorEffect: string;
  35811. /**
  35812. * The SSAO PostProcess id in the pipeline
  35813. */
  35814. SSAORenderEffect: string;
  35815. /**
  35816. * The horizontal blur PostProcess id in the pipeline
  35817. */
  35818. SSAOBlurHRenderEffect: string;
  35819. /**
  35820. * The vertical blur PostProcess id in the pipeline
  35821. */
  35822. SSAOBlurVRenderEffect: string;
  35823. /**
  35824. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  35825. */
  35826. SSAOCombineRenderEffect: string;
  35827. /**
  35828. * The output strength of the SSAO post-process. Default value is 1.0.
  35829. */
  35830. totalStrength: number;
  35831. /**
  35832. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  35833. */
  35834. maxZ: number;
  35835. /**
  35836. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  35837. */
  35838. minZAspect: number;
  35839. /**
  35840. * Number of samples used for the SSAO calculations. Default value is 8
  35841. */
  35842. private _samples;
  35843. /**
  35844. * Ratio object used for SSAO ratio and blur ratio
  35845. */
  35846. private _ratio;
  35847. /**
  35848. * Dynamically generated sphere sampler.
  35849. */
  35850. private _sampleSphere;
  35851. /**
  35852. * Blur filter offsets
  35853. */
  35854. private _samplerOffsets;
  35855. samples: number;
  35856. /**
  35857. * Are we using bilateral blur ?
  35858. */
  35859. private _expensiveBlur;
  35860. expensiveBlur: boolean;
  35861. /**
  35862. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  35863. */
  35864. radius: number;
  35865. /**
  35866. * The base color of the SSAO post-process
  35867. * The final result is "base + ssao" between [0, 1]
  35868. */
  35869. base: number;
  35870. /**
  35871. * Support test.
  35872. */
  35873. static readonly IsSupported: boolean;
  35874. private _scene;
  35875. private _depthTexture;
  35876. private _normalTexture;
  35877. private _randomTexture;
  35878. private _originalColorPostProcess;
  35879. private _ssaoPostProcess;
  35880. private _blurHPostProcess;
  35881. private _blurVPostProcess;
  35882. private _ssaoCombinePostProcess;
  35883. private _firstUpdate;
  35884. /**
  35885. * @constructor
  35886. * @param {string} name - The rendering pipeline name
  35887. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  35888. * @param {any} ratio - The size of the postprocesses. Can be a number shared between passes or an object for more precision: { ssaoRatio: 0.5, blurRatio: 1.0 }
  35889. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  35890. */
  35891. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  35892. /**
  35893. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  35894. */
  35895. dispose(disableGeometryBufferRenderer?: boolean): void;
  35896. private _createBlurPostProcess(ssaoRatio, blurRatio);
  35897. private _generateHemisphere();
  35898. private _createSSAOPostProcess(ratio);
  35899. private _createSSAOCombinePostProcess(ratio);
  35900. private _createRandomTexture();
  35901. /**
  35902. * Serialize the rendering pipeline (Used when exporting)
  35903. * @returns the serialized object
  35904. */
  35905. serialize(): any;
  35906. /**
  35907. * Parse the serialized pipeline
  35908. * @param source Source pipeline.
  35909. * @param scene The scene to load the pipeline to.
  35910. * @param rootUrl The URL of the serialized pipeline.
  35911. * @returns An instantiated pipeline from the serialized object.
  35912. */
  35913. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  35914. }
  35915. }
  35916. declare module BABYLON {
  35917. class SSAORenderingPipeline extends PostProcessRenderPipeline {
  35918. /**
  35919. * The PassPostProcess id in the pipeline that contains the original scene color
  35920. */
  35921. SSAOOriginalSceneColorEffect: string;
  35922. /**
  35923. * The SSAO PostProcess id in the pipeline
  35924. */
  35925. SSAORenderEffect: string;
  35926. /**
  35927. * The horizontal blur PostProcess id in the pipeline
  35928. */
  35929. SSAOBlurHRenderEffect: string;
  35930. /**
  35931. * The vertical blur PostProcess id in the pipeline
  35932. */
  35933. SSAOBlurVRenderEffect: string;
  35934. /**
  35935. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  35936. */
  35937. SSAOCombineRenderEffect: string;
  35938. /**
  35939. * The output strength of the SSAO post-process. Default value is 1.0.
  35940. */
  35941. totalStrength: number;
  35942. /**
  35943. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  35944. */
  35945. radius: number;
  35946. /**
  35947. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  35948. * Must not be equal to fallOff and superior to fallOff.
  35949. * Default value is 0.975
  35950. */
  35951. area: number;
  35952. /**
  35953. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  35954. * Must not be equal to area and inferior to area.
  35955. * Default value is 0.0
  35956. */
  35957. fallOff: number;
  35958. /**
  35959. * The base color of the SSAO post-process
  35960. * The final result is "base + ssao" between [0, 1]
  35961. */
  35962. base: number;
  35963. private _scene;
  35964. private _depthTexture;
  35965. private _randomTexture;
  35966. private _originalColorPostProcess;
  35967. private _ssaoPostProcess;
  35968. private _blurHPostProcess;
  35969. private _blurVPostProcess;
  35970. private _ssaoCombinePostProcess;
  35971. private _firstUpdate;
  35972. /**
  35973. * @constructor
  35974. * @param {string} name - The rendering pipeline name
  35975. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  35976. * @param {any} ratio - The size of the postprocesses. Can be a number shared between passes or an object for more precision: { ssaoRatio: 0.5, combineRatio: 1.0 }
  35977. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  35978. */
  35979. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  35980. /**
  35981. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  35982. */
  35983. dispose(disableDepthRender?: boolean): void;
  35984. private _createBlurPostProcess(ratio);
  35985. private _createSSAOPostProcess(ratio);
  35986. private _createSSAOCombinePostProcess(ratio);
  35987. private _createRandomTexture();
  35988. }
  35989. }
  35990. declare module BABYLON {
  35991. class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  35992. /**
  35993. * Public members
  35994. */
  35995. originalPostProcess: Nullable<PostProcess>;
  35996. downSampleX4PostProcess: Nullable<PostProcess>;
  35997. brightPassPostProcess: Nullable<PostProcess>;
  35998. blurHPostProcesses: PostProcess[];
  35999. blurVPostProcesses: PostProcess[];
  36000. textureAdderPostProcess: Nullable<PostProcess>;
  36001. volumetricLightPostProcess: Nullable<PostProcess>;
  36002. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  36003. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  36004. volumetricLightMergePostProces: Nullable<PostProcess>;
  36005. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  36006. luminancePostProcess: Nullable<PostProcess>;
  36007. luminanceDownSamplePostProcesses: PostProcess[];
  36008. hdrPostProcess: Nullable<PostProcess>;
  36009. textureAdderFinalPostProcess: Nullable<PostProcess>;
  36010. lensFlareFinalPostProcess: Nullable<PostProcess>;
  36011. hdrFinalPostProcess: Nullable<PostProcess>;
  36012. lensFlarePostProcess: Nullable<PostProcess>;
  36013. lensFlareComposePostProcess: Nullable<PostProcess>;
  36014. motionBlurPostProcess: Nullable<PostProcess>;
  36015. depthOfFieldPostProcess: Nullable<PostProcess>;
  36016. brightThreshold: number;
  36017. blurWidth: number;
  36018. horizontalBlur: boolean;
  36019. exposure: number;
  36020. lensTexture: Nullable<Texture>;
  36021. volumetricLightCoefficient: number;
  36022. volumetricLightPower: number;
  36023. volumetricLightBlurScale: number;
  36024. sourceLight: Nullable<SpotLight | DirectionalLight>;
  36025. hdrMinimumLuminance: number;
  36026. hdrDecreaseRate: number;
  36027. hdrIncreaseRate: number;
  36028. lensColorTexture: Nullable<Texture>;
  36029. lensFlareStrength: number;
  36030. lensFlareGhostDispersal: number;
  36031. lensFlareHaloWidth: number;
  36032. lensFlareDistortionStrength: number;
  36033. lensStarTexture: Nullable<Texture>;
  36034. lensFlareDirtTexture: Nullable<Texture>;
  36035. depthOfFieldDistance: number;
  36036. depthOfFieldBlurWidth: number;
  36037. motionStrength: number;
  36038. animations: Animation[];
  36039. /**
  36040. * Private members
  36041. */
  36042. private _scene;
  36043. private _currentDepthOfFieldSource;
  36044. private _basePostProcess;
  36045. private _hdrCurrentLuminance;
  36046. private _floatTextureType;
  36047. private _ratio;
  36048. private _bloomEnabled;
  36049. private _depthOfFieldEnabled;
  36050. private _vlsEnabled;
  36051. private _lensFlareEnabled;
  36052. private _hdrEnabled;
  36053. private _motionBlurEnabled;
  36054. private _motionBlurSamples;
  36055. private _volumetricLightStepsCount;
  36056. BloomEnabled: boolean;
  36057. DepthOfFieldEnabled: boolean;
  36058. LensFlareEnabled: boolean;
  36059. HDREnabled: boolean;
  36060. VLSEnabled: boolean;
  36061. MotionBlurEnabled: boolean;
  36062. volumetricLightStepsCount: number;
  36063. motionBlurSamples: number;
  36064. /**
  36065. * @constructor
  36066. * @param {string} name - The rendering pipeline name
  36067. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  36068. * @param {any} ratio - The size of the postprocesses (0.5 means that your postprocess will have a width = canvas.width 0.5 and a height = canvas.height 0.5)
  36069. * @param {BABYLON.PostProcess} originalPostProcess - the custom original color post-process. Must be "reusable". Can be null.
  36070. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  36071. */
  36072. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  36073. private _buildPipeline();
  36074. private _createDownSampleX4PostProcess(scene, ratio);
  36075. private _createBrightPassPostProcess(scene, ratio);
  36076. private _createBlurPostProcesses(scene, ratio, indice, blurWidthKey?);
  36077. private _createTextureAdderPostProcess(scene, ratio);
  36078. private _createVolumetricLightPostProcess(scene, ratio);
  36079. private _createLuminancePostProcesses(scene, textureType);
  36080. private _createHdrPostProcess(scene, ratio);
  36081. private _createLensFlarePostProcess(scene, ratio);
  36082. private _createDepthOfFieldPostProcess(scene, ratio);
  36083. private _createMotionBlurPostProcess(scene, ratio);
  36084. private _getDepthTexture();
  36085. private _disposePostProcesses();
  36086. /**
  36087. * Dispose of the pipeline and stop all post processes
  36088. */
  36089. dispose(): void;
  36090. /**
  36091. * Serialize the rendering pipeline (Used when exporting)
  36092. * @returns the serialized object
  36093. */
  36094. serialize(): any;
  36095. /**
  36096. * Parse the serialized pipeline
  36097. * @param source Source pipeline.
  36098. * @param scene The scene to load the pipeline to.
  36099. * @param rootUrl The URL of the serialized pipeline.
  36100. * @returns An instantiated pipeline from the serialized object.
  36101. */
  36102. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  36103. static LuminanceSteps: number;
  36104. }
  36105. }
  36106. declare module BABYLON.GUI {
  36107. /**
  36108. * Define a style used by control to automatically setup properties based on a template.
  36109. * Only support font related properties so far
  36110. */
  36111. class Style implements BABYLON.IDisposable {
  36112. private _fontFamily;
  36113. private _fontStyle;
  36114. private _fontWeight;
  36115. /** @hidden */
  36116. /** @hidden */
  36117. /**
  36118. * Observable raised when the style values are changed
  36119. */
  36120. onChangedObservable: Observable<Style>;
  36121. /**
  36122. * Creates a new style object
  36123. * @param host defines the AdvancedDynamicTexture which hosts this style
  36124. */
  36125. constructor(host: AdvancedDynamicTexture);
  36126. /**
  36127. * Gets or sets the font size
  36128. */
  36129. fontSize: string | number;
  36130. /**
  36131. * Gets or sets the font family
  36132. */
  36133. fontFamily: string;
  36134. /**
  36135. * Gets or sets the font style
  36136. */
  36137. fontStyle: string;
  36138. /** Gets or sets font weight */
  36139. fontWeight: string;
  36140. /** Dispose all associated resources */
  36141. dispose(): void;
  36142. }
  36143. }
  36144. declare module BABYLON.GUI {
  36145. /**
  36146. * Class used to specific a value and its associated unit
  36147. */
  36148. class ValueAndUnit {
  36149. /** defines the unit to store */
  36150. unit: number;
  36151. /** defines a boolean indicating if the value can be negative */
  36152. negativeValueAllowed: boolean;
  36153. private _value;
  36154. /**
  36155. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  36156. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  36157. */
  36158. ignoreAdaptiveScaling: boolean;
  36159. /**
  36160. * Creates a new ValueAndUnit
  36161. * @param value defines the value to store
  36162. * @param unit defines the unit to store
  36163. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  36164. */
  36165. constructor(value: number,
  36166. /** defines the unit to store */
  36167. unit?: number,
  36168. /** defines a boolean indicating if the value can be negative */
  36169. negativeValueAllowed?: boolean);
  36170. /** Gets a boolean indicating if the value is a percentage */
  36171. readonly isPercentage: boolean;
  36172. /** Gets a boolean indicating if the value is store as pixel */
  36173. readonly isPixel: boolean;
  36174. /** Gets direct internal value */
  36175. readonly internalValue: number;
  36176. /**
  36177. * Gets value as pixel
  36178. * @param host defines the root host
  36179. * @param refValue defines the reference value for percentages
  36180. * @returns the value as pixel
  36181. */
  36182. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  36183. /**
  36184. * Gets the value accordingly to its unit
  36185. * @param host defines the root host
  36186. * @returns the value
  36187. */
  36188. getValue(host: AdvancedDynamicTexture): number;
  36189. /**
  36190. * Gets a string representation of the value
  36191. * @param host defines the root host
  36192. * @returns a string
  36193. */
  36194. toString(host: AdvancedDynamicTexture): string;
  36195. /**
  36196. * Store a value parsed from a string
  36197. * @param source defines the source string
  36198. * @returns true if the value was successfully parsed
  36199. */
  36200. fromString(source: string | number): boolean;
  36201. private static _Regex;
  36202. private static _UNITMODE_PERCENTAGE;
  36203. private static _UNITMODE_PIXEL;
  36204. /** UNITMODE_PERCENTAGE */
  36205. static readonly UNITMODE_PERCENTAGE: number;
  36206. /** UNITMODE_PIXEL */
  36207. static readonly UNITMODE_PIXEL: number;
  36208. }
  36209. }
  36210. /**
  36211. * This module hosts all controls for 2D and 3D GUIs
  36212. * @see http://doc.babylonjs.com/how_to/gui
  36213. */
  36214. declare module BABYLON.GUI {
  36215. /**
  36216. * Interface used to define a control that can receive focus
  36217. */
  36218. interface IFocusableControl {
  36219. /**
  36220. * Function called when the control receives the focus
  36221. */
  36222. onFocus(): void;
  36223. /**
  36224. * Function called when the control loses the focus
  36225. */
  36226. onBlur(): void;
  36227. /**
  36228. * Function called to let the control handle keyboard events
  36229. * @param evt defines the current keyboard event
  36230. */
  36231. processKeyboard(evt: KeyboardEvent): void;
  36232. }
  36233. /**
  36234. * Class used to create texture to support 2D GUI elements
  36235. * @see http://doc.babylonjs.com/how_to/gui
  36236. */
  36237. class AdvancedDynamicTexture extends DynamicTexture {
  36238. private _isDirty;
  36239. private _renderObserver;
  36240. private _resizeObserver;
  36241. private _preKeyboardObserver;
  36242. private _pointerMoveObserver;
  36243. private _pointerObserver;
  36244. private _canvasPointerOutObserver;
  36245. private _background;
  36246. /** @hidden */
  36247. /** @hidden */
  36248. /** @hidden */
  36249. ;
  36250. /** @hidden */
  36251. ;
  36252. /** @hidden */
  36253. ;
  36254. /** @hidden */
  36255. /** @hidden */
  36256. /** @hidden */
  36257. private _isFullscreen;
  36258. private _fullscreenViewport;
  36259. private _idealWidth;
  36260. private _idealHeight;
  36261. private _useSmallestIdeal;
  36262. private _renderAtIdealSize;
  36263. private _focusedControl;
  36264. private _blockNextFocusCheck;
  36265. private _renderScale;
  36266. /**
  36267. * Gets or sets a boolean defining if alpha is stored as premultiplied
  36268. */
  36269. premulAlpha: boolean;
  36270. /**
  36271. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  36272. * Useful when you want more antialiasing
  36273. */
  36274. renderScale: number;
  36275. /** Gets or sets the background color */
  36276. background: string;
  36277. /**
  36278. * Gets or sets the ideal width used to design controls.
  36279. * The GUI will then rescale everything accordingly
  36280. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  36281. */
  36282. idealWidth: number;
  36283. /**
  36284. * Gets or sets the ideal height used to design controls.
  36285. * The GUI will then rescale everything accordingly
  36286. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  36287. */
  36288. idealHeight: number;
  36289. /**
  36290. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  36291. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  36292. */
  36293. useSmallestIdeal: boolean;
  36294. /**
  36295. * Gets or sets a boolean indicating if adaptive scaling must be used
  36296. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  36297. */
  36298. renderAtIdealSize: boolean;
  36299. /**
  36300. * Gets the underlying layer used to render the texture when in fullscreen mode
  36301. */
  36302. readonly layer: Nullable<Layer>;
  36303. /**
  36304. * Gets the root container control
  36305. */
  36306. readonly rootContainer: Container;
  36307. /**
  36308. * Gets or sets the current focused control
  36309. */
  36310. focusedControl: Nullable<IFocusableControl>;
  36311. /**
  36312. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  36313. */
  36314. isForeground: boolean;
  36315. /**
  36316. * Creates a new AdvancedDynamicTexture
  36317. * @param name defines the name of the texture
  36318. * @param width defines the width of the texture
  36319. * @param height defines the height of the texture
  36320. * @param scene defines the hosting scene
  36321. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  36322. * @param samplingMode defines the texture sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  36323. */
  36324. constructor(name: string, width: number | undefined, height: number | undefined, scene: Nullable<Scene>, generateMipMaps?: boolean, samplingMode?: number);
  36325. /**
  36326. * Function used to execute a function on all controls
  36327. * @param func defines the function to execute
  36328. * @param container defines the container where controls belong. If null the root container will be used
  36329. */
  36330. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  36331. /**
  36332. * Marks the texture as dirty forcing a complete update
  36333. */
  36334. markAsDirty(): void;
  36335. /**
  36336. * Helper function used to create a new style
  36337. * @returns a new style
  36338. * @see http://doc.babylonjs.com/how_to/gui#styles
  36339. */
  36340. createStyle(): Style;
  36341. /**
  36342. * Adds a new control to the root container
  36343. * @param control defines the control to add
  36344. * @returns the current texture
  36345. */
  36346. addControl(control: Control): AdvancedDynamicTexture;
  36347. /**
  36348. * Removes a control from the root container
  36349. * @param control defines the control to remove
  36350. * @returns the current texture
  36351. */
  36352. removeControl(control: Control): AdvancedDynamicTexture;
  36353. /**
  36354. * Release all resources
  36355. */
  36356. dispose(): void;
  36357. private _onResize();
  36358. /** @hidden */
  36359. /**
  36360. * Get screen coordinates for a vector3
  36361. * @param position defines the position to project
  36362. * @param worldMatrix defines the world matrix to use
  36363. * @returns the projected position
  36364. */
  36365. getProjectedPosition(position: Vector3, worldMatrix: Matrix): Vector2;
  36366. private _checkUpdate(camera);
  36367. private _render();
  36368. private _doPicking(x, y, type, pointerId, buttonIndex);
  36369. /** @hidden */
  36370. , control: Control): void;
  36371. /** @hidden */
  36372. /** Attach to all scene events required to support pointer events */
  36373. attach(): void;
  36374. /**
  36375. * Connect the texture to a hosting mesh to enable interactions
  36376. * @param mesh defines the mesh to attach to
  36377. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  36378. */
  36379. attachToMesh(mesh: AbstractMesh, supportPointerMove?: boolean): void;
  36380. /**
  36381. * Move the focus to a specific control
  36382. * @param control defines the control which will receive the focus
  36383. */
  36384. moveFocusToControl(control: IFocusableControl): void;
  36385. private _manageFocus();
  36386. private _attachToOnPointerOut(scene);
  36387. /**
  36388. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  36389. * @param mesh defines the mesh which will receive the texture
  36390. * @param width defines the texture width (1024 by default)
  36391. * @param height defines the texture height (1024 by default)
  36392. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  36393. * @returns a new AdvancedDynamicTexture
  36394. */
  36395. static CreateForMesh(mesh: AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean): AdvancedDynamicTexture;
  36396. /**
  36397. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  36398. * In this mode the texture will rely on a layer for its rendering.
  36399. * This allows it to be treated like any other layer.
  36400. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  36401. * LayerMask is set through advancedTexture.layer.layerMask
  36402. * @param name defines name for the texture
  36403. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  36404. * @param scene defines the hsoting scene
  36405. * @param sampling defines the texture sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  36406. * @returns a new AdvancedDynamicTexture
  36407. */
  36408. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: Nullable<Scene>, sampling?: number): AdvancedDynamicTexture;
  36409. }
  36410. }
  36411. declare module BABYLON.GUI {
  36412. /**
  36413. * Class used to store 2D control sizes
  36414. */
  36415. class Measure {
  36416. /** defines left coordinate */
  36417. left: number;
  36418. /** defines top coordinate */
  36419. top: number;
  36420. /** defines width dimension */
  36421. width: number;
  36422. /** defines height dimension */
  36423. height: number;
  36424. /**
  36425. * Creates a new measure
  36426. * @param left defines left coordinate
  36427. * @param top defines top coordinate
  36428. * @param width defines width dimension
  36429. * @param height defines height dimension
  36430. */
  36431. constructor(
  36432. /** defines left coordinate */
  36433. left: number,
  36434. /** defines top coordinate */
  36435. top: number,
  36436. /** defines width dimension */
  36437. width: number,
  36438. /** defines height dimension */
  36439. height: number);
  36440. /**
  36441. * Copy from another measure
  36442. * @param other defines the other measure to copy from
  36443. */
  36444. copyFrom(other: Measure): void;
  36445. /**
  36446. * Check equality between this measure and another one
  36447. * @param other defines the other measures
  36448. * @returns true if both measures are equals
  36449. */
  36450. isEqualsTo(other: Measure): boolean;
  36451. /**
  36452. * Creates an empty measure
  36453. * @returns a new measure
  36454. */
  36455. static Empty(): Measure;
  36456. }
  36457. }
  36458. declare module BABYLON.GUI {
  36459. /**
  36460. * Class used to transport Vector2 information for pointer events
  36461. */
  36462. class Vector2WithInfo extends Vector2 {
  36463. /** defines the current mouse button index */
  36464. buttonIndex: number;
  36465. /**
  36466. * Creates a new Vector2WithInfo
  36467. * @param source defines the vector2 data to transport
  36468. * @param buttonIndex defines the current mouse button index
  36469. */
  36470. constructor(source: Vector2,
  36471. /** defines the current mouse button index */
  36472. buttonIndex?: number);
  36473. }
  36474. /** Class used to provide 2D matrix features */
  36475. class Matrix2D {
  36476. /** Gets the internal array of 6 floats used to store matrix data */
  36477. m: Float32Array;
  36478. /**
  36479. * Creates a new matrix
  36480. * @param m00 defines value for (0, 0)
  36481. * @param m01 defines value for (0, 1)
  36482. * @param m10 defines value for (1, 0)
  36483. * @param m11 defines value for (1, 1)
  36484. * @param m20 defines value for (2, 0)
  36485. * @param m21 defines value for (2, 1)
  36486. */
  36487. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  36488. /**
  36489. * Fills the matrix from direct values
  36490. * @param m00 defines value for (0, 0)
  36491. * @param m01 defines value for (0, 1)
  36492. * @param m10 defines value for (1, 0)
  36493. * @param m11 defines value for (1, 1)
  36494. * @param m20 defines value for (2, 0)
  36495. * @param m21 defines value for (2, 1)
  36496. * @returns the current modified matrix
  36497. */
  36498. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  36499. /**
  36500. * Gets matrix determinant
  36501. * @returns the determinant
  36502. */
  36503. determinant(): number;
  36504. /**
  36505. * Inverses the matrix and stores it in a target matrix
  36506. * @param result defines the target matrix
  36507. * @returns the current matrix
  36508. */
  36509. invertToRef(result: Matrix2D): Matrix2D;
  36510. /**
  36511. * Multiplies the current matrix with another one
  36512. * @param other defines the second operand
  36513. * @param result defines the target matrix
  36514. * @returns the current matrix
  36515. */
  36516. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  36517. /**
  36518. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  36519. * @param x defines the x coordinate to transform
  36520. * @param y defines the x coordinate to transform
  36521. * @param result defines the target vector2
  36522. * @returns the current matrix
  36523. */
  36524. transformCoordinates(x: number, y: number, result: Vector2): Matrix2D;
  36525. /**
  36526. * Creates an identity matrix
  36527. * @returns a new matrix
  36528. */
  36529. static Identity(): Matrix2D;
  36530. /**
  36531. * Creates a translation matrix and stores it in a target matrix
  36532. * @param x defines the x coordinate of the translation
  36533. * @param y defines the y coordinate of the translation
  36534. * @param result defines the target matrix
  36535. */
  36536. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  36537. /**
  36538. * Creates a scaling matrix and stores it in a target matrix
  36539. * @param x defines the x coordinate of the scaling
  36540. * @param y defines the y coordinate of the scaling
  36541. * @param result defines the target matrix
  36542. */
  36543. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  36544. /**
  36545. * Creates a rotation matrix and stores it in a target matrix
  36546. * @param angle defines the rotation angle
  36547. * @param result defines the target matrix
  36548. */
  36549. static RotationToRef(angle: number, result: Matrix2D): void;
  36550. private static _TempPreTranslationMatrix;
  36551. private static _TempPostTranslationMatrix;
  36552. private static _TempRotationMatrix;
  36553. private static _TempScalingMatrix;
  36554. private static _TempCompose0;
  36555. private static _TempCompose1;
  36556. private static _TempCompose2;
  36557. /**
  36558. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  36559. * @param tx defines the x coordinate of the translation
  36560. * @param ty defines the y coordinate of the translation
  36561. * @param angle defines the rotation angle
  36562. * @param scaleX defines the x coordinate of the scaling
  36563. * @param scaleY defines the y coordinate of the scaling
  36564. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  36565. * @param result defines the target matrix
  36566. */
  36567. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: Nullable<Matrix2D>, result: Matrix2D): void;
  36568. }
  36569. }
  36570. declare module BABYLON.GUI {
  36571. /**
  36572. * Class used to store a point for a MultiLine object.
  36573. * The point can be pure 2D coordinates, a mesh or a control
  36574. */
  36575. class MultiLinePoint {
  36576. private _multiLine;
  36577. private _x;
  36578. private _y;
  36579. private _control;
  36580. private _mesh;
  36581. private _controlObserver;
  36582. private _meshObserver;
  36583. /** @hidden */
  36584. /**
  36585. * Creates a new MultiLinePoint
  36586. * @param multiLine defines the source MultiLine object
  36587. */
  36588. constructor(multiLine: MultiLine);
  36589. /** Gets or sets x coordinate */
  36590. x: string | number;
  36591. /** Gets or sets y coordinate */
  36592. y: string | number;
  36593. /** Gets or sets the control associated with this point */
  36594. control: Nullable<Control>;
  36595. /** Gets or sets the mesh associated with this point */
  36596. mesh: Nullable<AbstractMesh>;
  36597. /**
  36598. * Gets a translation vector
  36599. * @returns the translation vector
  36600. */
  36601. translate(): Vector2;
  36602. private _translatePoint();
  36603. /** Release associated resources */
  36604. dispose(): void;
  36605. }
  36606. }
  36607. declare module BABYLON.GUI {
  36608. /**
  36609. * Root class used for all 2D controls
  36610. * @see http://doc.babylonjs.com/how_to/gui#controls
  36611. */
  36612. class Control {
  36613. /** defines the name of the control */
  36614. name: string | undefined;
  36615. private _alpha;
  36616. private _alphaSet;
  36617. private _zIndex;
  36618. /** @hidden */
  36619. /** @hidden */
  36620. /** Gets or sets the control parent */
  36621. parent: Nullable<Container>;
  36622. /** @hidden */
  36623. private _fontFamily;
  36624. private _fontStyle;
  36625. private _fontWeight;
  36626. private _fontSize;
  36627. private _font;
  36628. /** @hidden */
  36629. /** @hidden */
  36630. /** @hidden */
  36631. protected _fontOffset: {
  36632. ascent: number;
  36633. height: number;
  36634. descent: number;
  36635. };
  36636. private _color;
  36637. private _style;
  36638. private _styleObserver;
  36639. /** @hidden */
  36640. protected _horizontalAlignment: number;
  36641. /** @hidden */
  36642. protected _verticalAlignment: number;
  36643. private _isDirty;
  36644. /** @hidden */
  36645. /** @hidden */
  36646. protected _cachedParentMeasure: Measure;
  36647. private _paddingLeft;
  36648. private _paddingRight;
  36649. private _paddingTop;
  36650. private _paddingBottom;
  36651. /** @hidden */
  36652. /** @hidden */
  36653. private _scaleX;
  36654. private _scaleY;
  36655. private _rotation;
  36656. private _transformCenterX;
  36657. private _transformCenterY;
  36658. private _transformMatrix;
  36659. /** @hidden */
  36660. protected _invertTransformMatrix: Matrix2D;
  36661. /** @hidden */
  36662. protected _transformedPosition: Vector2;
  36663. private _onlyMeasureMode;
  36664. private _isMatrixDirty;
  36665. private _cachedOffsetX;
  36666. private _cachedOffsetY;
  36667. private _isVisible;
  36668. /** @hidden */
  36669. private _fontSet;
  36670. private _dummyVector2;
  36671. private _downCount;
  36672. private _enterCount;
  36673. private _doNotRender;
  36674. private _downPointerIds;
  36675. /** @hidden */
  36676. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  36677. isHitTestVisible: boolean;
  36678. /** Gets or sets a boolean indicating if the control can block pointer events */
  36679. isPointerBlocker: boolean;
  36680. /** Gets or sets a boolean indicating if the control can be focusable */
  36681. isFocusInvisible: boolean;
  36682. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  36683. shadowOffsetX: number;
  36684. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  36685. shadowOffsetY: number;
  36686. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  36687. shadowBlur: number;
  36688. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  36689. shadowColor: string;
  36690. /** @hidden */
  36691. protected _linkOffsetX: ValueAndUnit;
  36692. /** @hidden */
  36693. protected _linkOffsetY: ValueAndUnit;
  36694. /** Gets the control type name */
  36695. readonly typeName: string;
  36696. /**
  36697. * An event triggered when the pointer move over the control.
  36698. */
  36699. onPointerMoveObservable: Observable<Vector2>;
  36700. /**
  36701. * An event triggered when the pointer move out of the control.
  36702. */
  36703. onPointerOutObservable: Observable<Control>;
  36704. /**
  36705. * An event triggered when the pointer taps the control
  36706. */
  36707. onPointerDownObservable: Observable<Vector2WithInfo>;
  36708. /**
  36709. * An event triggered when pointer up
  36710. */
  36711. onPointerUpObservable: Observable<Vector2WithInfo>;
  36712. /**
  36713. * An event triggered when a control is clicked on
  36714. */
  36715. onPointerClickObservable: Observable<Vector2WithInfo>;
  36716. /**
  36717. * An event triggered when pointer enters the control
  36718. */
  36719. onPointerEnterObservable: Observable<Control>;
  36720. /**
  36721. * An event triggered when the control is marked as dirty
  36722. */
  36723. onDirtyObservable: Observable<Control>;
  36724. /**
  36725. * An event triggered after the control is drawn
  36726. */
  36727. onAfterDrawObservable: Observable<Control>;
  36728. /** Gets or set information about font offsets (used to render and align text) */
  36729. fontOffset: {
  36730. ascent: number;
  36731. height: number;
  36732. descent: number;
  36733. };
  36734. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  36735. alpha: number;
  36736. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  36737. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  36738. */
  36739. scaleX: number;
  36740. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  36741. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  36742. */
  36743. scaleY: number;
  36744. /** Gets or sets the rotation angle (0 by default)
  36745. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  36746. */
  36747. rotation: number;
  36748. /** Gets or sets the transformation center on Y axis (0 by default)
  36749. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  36750. */
  36751. transformCenterY: number;
  36752. /** Gets or sets the transformation center on X axis (0 by default)
  36753. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  36754. */
  36755. transformCenterX: number;
  36756. /**
  36757. * Gets or sets the horizontal alignment
  36758. * @see http://doc.babylonjs.com/how_to/gui#alignments
  36759. */
  36760. horizontalAlignment: number;
  36761. /**
  36762. * Gets or sets the vertical alignment
  36763. * @see http://doc.babylonjs.com/how_to/gui#alignments
  36764. */
  36765. verticalAlignment: number;
  36766. /**
  36767. * Gets or sets control width
  36768. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  36769. */
  36770. width: string | number;
  36771. /**
  36772. * Gets control width in pixel
  36773. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  36774. */
  36775. readonly widthInPixels: number;
  36776. /**
  36777. * Gets or sets control height
  36778. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  36779. */
  36780. height: string | number;
  36781. /**
  36782. * Gets control height in pixel
  36783. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  36784. */
  36785. readonly heightInPixels: number;
  36786. /** Gets or set font family */
  36787. fontFamily: string;
  36788. /** Gets or sets font style */
  36789. fontStyle: string;
  36790. /** Gets or sets font weight */
  36791. fontWeight: string;
  36792. /**
  36793. * Gets or sets style
  36794. * @see http://doc.babylonjs.com/how_to/gui#styles
  36795. */
  36796. style: BABYLON.Nullable<Style>;
  36797. /** @hidden */
  36798. protected readonly _isFontSizeInPercentage: boolean;
  36799. /** Gets font size in pixels */
  36800. readonly fontSizeInPixels: number;
  36801. /** Gets or sets font size */
  36802. fontSize: string | number;
  36803. /** Gets or sets foreground color */
  36804. color: string;
  36805. /** Gets or sets z index which is used to reorder controls on the z axis */
  36806. zIndex: number;
  36807. /** Gets or sets a boolean indicating if the control can be rendered */
  36808. notRenderable: boolean;
  36809. /** Gets or sets a boolean indicating if the control is visible */
  36810. isVisible: boolean;
  36811. /** Gets a boolean indicating that the control needs to update its rendering */
  36812. readonly isDirty: boolean;
  36813. /**
  36814. * Gets or sets a value indicating the padding to use on the left of the control
  36815. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  36816. */
  36817. paddingLeft: string | number;
  36818. /**
  36819. * Gets a value indicating the padding in pixels to use on the left of the control
  36820. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  36821. */
  36822. readonly paddingLeftInPixels: number;
  36823. /**
  36824. * Gets or sets a value indicating the padding to use on the right of the control
  36825. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  36826. */
  36827. paddingRight: string | number;
  36828. /**
  36829. * Gets a value indicating the padding in pixels to use on the right of the control
  36830. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  36831. */
  36832. readonly paddingRightInPixels: number;
  36833. /**
  36834. * Gets or sets a value indicating the padding to use on the top of the control
  36835. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  36836. */
  36837. paddingTop: string | number;
  36838. /**
  36839. * Gets a value indicating the padding in pixels to use on the top of the control
  36840. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  36841. */
  36842. readonly paddingTopInPixels: number;
  36843. /**
  36844. * Gets or sets a value indicating the padding to use on the bottom of the control
  36845. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  36846. */
  36847. paddingBottom: string | number;
  36848. /**
  36849. * Gets a value indicating the padding in pixels to use on the bottom of the control
  36850. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  36851. */
  36852. readonly paddingBottomInPixels: number;
  36853. /**
  36854. * Gets or sets a value indicating the left coordinate of the control
  36855. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  36856. */
  36857. left: string | number;
  36858. /**
  36859. * Gets a value indicating the left coordinate in pixels of the control
  36860. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  36861. */
  36862. readonly leftInPixels: number;
  36863. /**
  36864. * Gets or sets a value indicating the top coordinate of the control
  36865. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  36866. */
  36867. top: string | number;
  36868. /**
  36869. * Gets a value indicating the top coordinate in pixels of the control
  36870. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  36871. */
  36872. readonly topInPixels: number;
  36873. /**
  36874. * Gets or sets a value indicating the offset on X axis to the linked mesh
  36875. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  36876. */
  36877. linkOffsetX: string | number;
  36878. /**
  36879. * Gets a value indicating the offset in pixels on X axis to the linked mesh
  36880. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  36881. */
  36882. readonly linkOffsetXInPixels: number;
  36883. /**
  36884. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  36885. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  36886. */
  36887. linkOffsetY: string | number;
  36888. /**
  36889. * Gets a value indicating the offset in pixels on Y axis to the linked mesh
  36890. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  36891. */
  36892. readonly linkOffsetYInPixels: number;
  36893. /** Gets the center coordinate on X axis */
  36894. readonly centerX: number;
  36895. /** Gets the center coordinate on Y axis */
  36896. readonly centerY: number;
  36897. /**
  36898. * Creates a new control
  36899. * @param name defines the name of the control
  36900. */
  36901. constructor(
  36902. /** defines the name of the control */
  36903. name?: string | undefined);
  36904. /** @hidden */
  36905. protected _getTypeName(): string;
  36906. /** @hidden */
  36907. /**
  36908. * Gets coordinates in local control space
  36909. * @param globalCoordinates defines the coordinates to transform
  36910. * @returns the new coordinates in local space
  36911. */
  36912. getLocalCoordinates(globalCoordinates: Vector2): Vector2;
  36913. /**
  36914. * Gets coordinates in local control space
  36915. * @param globalCoordinates defines the coordinates to transform
  36916. * @param result defines the target vector2 where to store the result
  36917. * @returns the current control
  36918. */
  36919. getLocalCoordinatesToRef(globalCoordinates: Vector2, result: Vector2): Control;
  36920. /**
  36921. * Gets coordinates in parent local control space
  36922. * @param globalCoordinates defines the coordinates to transform
  36923. * @returns the new coordinates in parent local space
  36924. */
  36925. getParentLocalCoordinates(globalCoordinates: Vector2): Vector2;
  36926. /**
  36927. * Move the current control to a vector3 position projected onto the screen.
  36928. * @param position defines the target position
  36929. * @param scene defines the hosting scene
  36930. */
  36931. moveToVector3(position: Vector3, scene: Scene): void;
  36932. /**
  36933. * Link current control with a target mesh
  36934. * @param mesh defines the mesh to link with
  36935. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  36936. */
  36937. linkWithMesh(mesh: Nullable<AbstractMesh>): void;
  36938. /** @hidden */
  36939. /** @hidden */
  36940. /** @hidden */
  36941. /** @hidden */
  36942. /** @hidden */
  36943. /** @hidden */
  36944. protected _transform(context: CanvasRenderingContext2D): void;
  36945. /** @hidden */
  36946. protected _applyStates(context: CanvasRenderingContext2D): void;
  36947. /** @hidden */
  36948. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  36949. /** @hidden */
  36950. protected _clip(context: CanvasRenderingContext2D): void;
  36951. /** @hidden */
  36952. /** @hidden */
  36953. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  36954. /** @hidden */
  36955. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  36956. /** @hidden */
  36957. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  36958. /** @hidden */
  36959. /**
  36960. * Tests if a given coordinates belong to the current control
  36961. * @param x defines x coordinate to test
  36962. * @param y defines y coordinate to test
  36963. * @returns true if the coordinates are inside the control
  36964. */
  36965. contains(x: number, y: number): boolean;
  36966. /** @hidden */
  36967. /** @hidden */
  36968. /** @hidden */
  36969. /** @hidden */
  36970. /** @hidden */
  36971. /** @hidden */
  36972. /** @hidden */
  36973. /** @hidden */
  36974. private _prepareFont();
  36975. /** Releases associated resources */
  36976. dispose(): void;
  36977. private static _HORIZONTAL_ALIGNMENT_LEFT;
  36978. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  36979. private static _HORIZONTAL_ALIGNMENT_CENTER;
  36980. private static _VERTICAL_ALIGNMENT_TOP;
  36981. private static _VERTICAL_ALIGNMENT_BOTTOM;
  36982. private static _VERTICAL_ALIGNMENT_CENTER;
  36983. /** HORIZONTAL_ALIGNMENT_LEFT */
  36984. static readonly HORIZONTAL_ALIGNMENT_LEFT: number;
  36985. /** HORIZONTAL_ALIGNMENT_RIGHT */
  36986. static readonly HORIZONTAL_ALIGNMENT_RIGHT: number;
  36987. /** HORIZONTAL_ALIGNMENT_CENTER */
  36988. static readonly HORIZONTAL_ALIGNMENT_CENTER: number;
  36989. /** VERTICAL_ALIGNMENT_TOP */
  36990. static readonly VERTICAL_ALIGNMENT_TOP: number;
  36991. /** VERTICAL_ALIGNMENT_BOTTOM */
  36992. static readonly VERTICAL_ALIGNMENT_BOTTOM: number;
  36993. /** VERTICAL_ALIGNMENT_CENTER */
  36994. static readonly VERTICAL_ALIGNMENT_CENTER: number;
  36995. private static _FontHeightSizes;
  36996. /** @hidden */
  36997. private static _GetFontOffset(font: string): {
  36998. ascent: number;
  36999. height: number;
  37000. descent: number;
  37001. };
  37002. /**
  37003. * Creates a stack panel that can be used to render headers
  37004. * @param control defines the control to associate with the header
  37005. * @param text defines the text of the header
  37006. * @param size defines the size of the header
  37007. * @param options defines options used to configure the header
  37008. * @returns a new StackPanel
  37009. */
  37010. static AddHeader(control: Control, text: string, size: string | number, options: {
  37011. isHorizontal: boolean;
  37012. controlFirst: boolean;
  37013. }): StackPanel;
  37014. /** @hidden */
  37015. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  37016. }
  37017. }
  37018. declare module BABYLON.GUI {
  37019. /**
  37020. * Root class for 2D containers
  37021. * @see http://doc.babylonjs.com/how_to/gui#containers
  37022. */
  37023. class Container extends Control {
  37024. name: string | undefined;
  37025. /** @hidden */
  37026. protected _children: Control[];
  37027. /** @hidden */
  37028. protected _measureForChildren: Measure;
  37029. /** @hidden */
  37030. protected _background: string;
  37031. /** @hidden */
  37032. protected _adaptWidthToChildren: boolean;
  37033. /** @hidden */
  37034. protected _adaptHeightToChildren: boolean;
  37035. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  37036. adaptHeightToChildren: boolean;
  37037. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  37038. adaptWidthToChildren: boolean;
  37039. /** Gets or sets background color */
  37040. background: string;
  37041. /** Gets the list of children */
  37042. readonly children: Control[];
  37043. /**
  37044. * Creates a new Container
  37045. * @param name defines the name of the container
  37046. */
  37047. constructor(name?: string | undefined);
  37048. protected _getTypeName(): string;
  37049. /**
  37050. * Gets a child using its name
  37051. * @param name defines the child name to look for
  37052. * @returns the child control if found
  37053. */
  37054. getChildByName(name: string): Nullable<Control>;
  37055. /**
  37056. * Gets a child using its type and its name
  37057. * @param name defines the child name to look for
  37058. * @param type defines the child type to look for
  37059. * @returns the child control if found
  37060. */
  37061. getChildByType(name: string, type: string): Nullable<Control>;
  37062. /**
  37063. * Search for a specific control in children
  37064. * @param control defines the control to look for
  37065. * @returns true if the control is in child list
  37066. */
  37067. containsControl(control: Control): boolean;
  37068. /**
  37069. * Adds a new control to the current container
  37070. * @param control defines the control to add
  37071. * @returns the current container
  37072. */
  37073. addControl(control: Nullable<Control>): Container;
  37074. /**
  37075. * Removes a control from the current container
  37076. * @param control defines the control to remove
  37077. * @returns the current container
  37078. */
  37079. removeControl(control: Control): Container;
  37080. /** @hidden */
  37081. /** @hidden */
  37082. /** @hidden */
  37083. /** @hidden */
  37084. protected _localDraw(context: CanvasRenderingContext2D): void;
  37085. /** @hidden */
  37086. /** @hidden */
  37087. /** @hidden */
  37088. /** @hidden */
  37089. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  37090. /** @hidden */
  37091. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  37092. /** Releases associated resources */
  37093. dispose(): void;
  37094. }
  37095. }
  37096. declare module BABYLON.GUI {
  37097. /**
  37098. * Class used to create a 2D stack panel container
  37099. */
  37100. class StackPanel extends Container {
  37101. name: string | undefined;
  37102. private _isVertical;
  37103. private _manualWidth;
  37104. private _manualHeight;
  37105. private _doNotTrackManualChanges;
  37106. private _tempMeasureStore;
  37107. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  37108. isVertical: boolean;
  37109. /** Gets or sets panel width */
  37110. width: string | number;
  37111. /** Gets or sets panel height */
  37112. height: string | number;
  37113. /**
  37114. * Creates a new StackPanel
  37115. * @param name defines control name
  37116. */
  37117. constructor(name?: string | undefined);
  37118. protected _getTypeName(): string;
  37119. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  37120. }
  37121. }
  37122. declare module BABYLON.GUI {
  37123. /** Class used to create rectangle container */
  37124. class Rectangle extends Container {
  37125. name: string | undefined;
  37126. private _thickness;
  37127. private _cornerRadius;
  37128. /** Gets or sets border thickness */
  37129. thickness: number;
  37130. /** Gets or sets the corner radius angle */
  37131. cornerRadius: number;
  37132. /**
  37133. * Creates a new Rectangle
  37134. * @param name defines the control name
  37135. */
  37136. constructor(name?: string | undefined);
  37137. protected _getTypeName(): string;
  37138. protected _localDraw(context: CanvasRenderingContext2D): void;
  37139. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  37140. private _drawRoundedRect(context, offset?);
  37141. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  37142. }
  37143. }
  37144. declare module BABYLON.GUI {
  37145. /** Class used to create 2D ellipse containers */
  37146. class Ellipse extends Container {
  37147. name: string | undefined;
  37148. private _thickness;
  37149. /** Gets or sets border thickness */
  37150. thickness: number;
  37151. /**
  37152. * Creates a new Ellipse
  37153. * @param name defines the control name
  37154. */
  37155. constructor(name?: string | undefined);
  37156. protected _getTypeName(): string;
  37157. protected _localDraw(context: CanvasRenderingContext2D): void;
  37158. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  37159. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  37160. }
  37161. }
  37162. declare module BABYLON.GUI {
  37163. /** Class used to render 2D lines */
  37164. class Line extends Control {
  37165. name: string | undefined;
  37166. private _lineWidth;
  37167. private _x1;
  37168. private _y1;
  37169. private _x2;
  37170. private _y2;
  37171. private _dash;
  37172. private _connectedControl;
  37173. private _connectedControlDirtyObserver;
  37174. /** Gets or sets the dash pattern */
  37175. dash: Array<number>;
  37176. /** Gets or sets the control connected with the line end */
  37177. connectedControl: Control;
  37178. /** Gets or sets start coordinates on X axis */
  37179. x1: string | number;
  37180. /** Gets or sets start coordinates on Y axis */
  37181. y1: string | number;
  37182. /** Gets or sets end coordinates on X axis */
  37183. x2: string | number;
  37184. /** Gets or sets end coordinates on Y axis */
  37185. y2: string | number;
  37186. /** Gets or sets line width */
  37187. lineWidth: number;
  37188. /** Gets or sets horizontal alignment */
  37189. horizontalAlignment: number;
  37190. /** Gets or sets vertical alignment */
  37191. verticalAlignment: number;
  37192. private readonly _effectiveX2;
  37193. private readonly _effectiveY2;
  37194. /**
  37195. * Creates a new Line
  37196. * @param name defines the control name
  37197. */
  37198. constructor(name?: string | undefined);
  37199. protected _getTypeName(): string;
  37200. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  37201. /**
  37202. * Move one end of the line given 3D cartesian coordinates.
  37203. * @param position Targeted world position
  37204. * @param scene Scene
  37205. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  37206. */
  37207. moveToVector3(position: Vector3, scene: Scene, end?: boolean): void;
  37208. /**
  37209. * Move one end of the line to a position in screen absolute space.
  37210. * @param projectedPosition Position in screen absolute space (X, Y)
  37211. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  37212. */
  37213. }
  37214. }
  37215. declare module BABYLON.GUI {
  37216. /**
  37217. * Class used to create slider controls
  37218. */
  37219. class Slider extends Control {
  37220. name: string | undefined;
  37221. private _thumbWidth;
  37222. private _minimum;
  37223. private _maximum;
  37224. private _value;
  37225. private _background;
  37226. private _borderColor;
  37227. private _barOffset;
  37228. private _isThumbCircle;
  37229. private _isThumbClamped;
  37230. /** Observable raised when the sldier value changes */
  37231. onValueChangedObservable: Observable<number>;
  37232. /** Gets or sets border color */
  37233. borderColor: string;
  37234. /** Gets or sets background color */
  37235. background: string;
  37236. /** Gets or sets main bar offset */
  37237. barOffset: string | number;
  37238. /** Gets main bar offset in pixels*/
  37239. readonly barOffsetInPixels: number;
  37240. /** Gets or sets thumb width */
  37241. thumbWidth: string | number;
  37242. /** Gets thumb width in pixels */
  37243. readonly thumbWidthInPixels: number;
  37244. /** Gets or sets minimum value */
  37245. minimum: number;
  37246. /** Gets or sets maximum value */
  37247. maximum: number;
  37248. /** Gets or sets current value */
  37249. value: number;
  37250. /** Gets or sets a boolean indicating if the thumb should be round or square */
  37251. isThumbCircle: boolean;
  37252. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  37253. isThumbClamped: boolean;
  37254. /**
  37255. * Creates a new Slider
  37256. * @param name defines the control name
  37257. */
  37258. constructor(name?: string | undefined);
  37259. protected _getTypeName(): string;
  37260. private _pointerIsDown;
  37261. private _updateValueFromPointer(x, y);
  37262. }
  37263. }
  37264. declare module BABYLON.GUI {
  37265. /**
  37266. * Class used to represent a 2D checkbox
  37267. */
  37268. class Checkbox extends Control {
  37269. name: string | undefined;
  37270. private _isChecked;
  37271. private _background;
  37272. private _checkSizeRatio;
  37273. private _thickness;
  37274. /** Gets or sets border thickness */
  37275. thickness: number;
  37276. /**
  37277. * Observable raised when isChecked property changes
  37278. */
  37279. onIsCheckedChangedObservable: Observable<boolean>;
  37280. /** Gets or sets a value indicating the ratio between overall size and check size */
  37281. checkSizeRatio: number;
  37282. /** Gets or sets background color */
  37283. background: string;
  37284. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  37285. isChecked: boolean;
  37286. /**
  37287. * Creates a new CheckBox
  37288. * @param name defines the control name
  37289. */
  37290. constructor(name?: string | undefined);
  37291. protected _getTypeName(): string;
  37292. /** @hidden */
  37293. /** @hidden */
  37294. }
  37295. }
  37296. declare module BABYLON.GUI {
  37297. /**
  37298. * Class used to create radio button controls
  37299. */
  37300. class RadioButton extends Control {
  37301. name: string | undefined;
  37302. private _isChecked;
  37303. private _background;
  37304. private _checkSizeRatio;
  37305. private _thickness;
  37306. /** Gets or sets border thickness */
  37307. thickness: number;
  37308. /** Gets or sets group name */
  37309. group: string;
  37310. /** Observable raised when isChecked is changed */
  37311. onIsCheckedChangedObservable: Observable<boolean>;
  37312. /** Gets or sets a value indicating the ratio between overall size and check size */
  37313. checkSizeRatio: number;
  37314. /** Gets or sets background color */
  37315. background: string;
  37316. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  37317. isChecked: boolean;
  37318. /**
  37319. * Creates a new RadioButton
  37320. * @param name defines the control name
  37321. */
  37322. constructor(name?: string | undefined);
  37323. protected _getTypeName(): string;
  37324. }
  37325. }
  37326. declare module BABYLON.GUI {
  37327. /**
  37328. * Class used to create text block control
  37329. */
  37330. class TextBlock extends Control {
  37331. /**
  37332. * Defines the name of the control
  37333. */
  37334. name: string | undefined;
  37335. private _text;
  37336. private _textWrapping;
  37337. private _textHorizontalAlignment;
  37338. private _textVerticalAlignment;
  37339. private _lines;
  37340. private _resizeToFit;
  37341. private _lineSpacing;
  37342. private _outlineWidth;
  37343. private _outlineColor;
  37344. /**
  37345. * An event triggered after the text is changed
  37346. */
  37347. onTextChangedObservable: Observable<TextBlock>;
  37348. /**
  37349. * An event triggered after the text was broken up into lines
  37350. */
  37351. onLinesReadyObservable: Observable<TextBlock>;
  37352. /**
  37353. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  37354. */
  37355. readonly lines: any[];
  37356. /**
  37357. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  37358. */
  37359. /**
  37360. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  37361. */
  37362. resizeToFit: boolean;
  37363. /**
  37364. * Gets or sets a boolean indicating if text must be wrapped
  37365. */
  37366. /**
  37367. * Gets or sets a boolean indicating if text must be wrapped
  37368. */
  37369. textWrapping: boolean;
  37370. /**
  37371. * Gets or sets text to display
  37372. */
  37373. /**
  37374. * Gets or sets text to display
  37375. */
  37376. text: string;
  37377. /**
  37378. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  37379. */
  37380. /**
  37381. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  37382. */
  37383. textHorizontalAlignment: number;
  37384. /**
  37385. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  37386. */
  37387. /**
  37388. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  37389. */
  37390. textVerticalAlignment: number;
  37391. /**
  37392. * Gets or sets line spacing value
  37393. */
  37394. /**
  37395. * Gets or sets line spacing value
  37396. */
  37397. lineSpacing: string | number;
  37398. /**
  37399. * Gets or sets outlineWidth of the text to display
  37400. */
  37401. /**
  37402. * Gets or sets outlineWidth of the text to display
  37403. */
  37404. outlineWidth: number;
  37405. /**
  37406. * Gets or sets outlineColor of the text to display
  37407. */
  37408. /**
  37409. * Gets or sets outlineColor of the text to display
  37410. */
  37411. outlineColor: string;
  37412. /**
  37413. * Creates a new TextBlock object
  37414. * @param name defines the name of the control
  37415. * @param text defines the text to display (emptry string by default)
  37416. */
  37417. constructor(
  37418. /**
  37419. * Defines the name of the control
  37420. */
  37421. name?: string | undefined, text?: string);
  37422. protected _getTypeName(): string;
  37423. private _drawText(text, textWidth, y, context);
  37424. /** @hidden */
  37425. protected _applyStates(context: CanvasRenderingContext2D): void;
  37426. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  37427. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  37428. protected _parseLineWithTextWrapping(line: string | undefined, context: CanvasRenderingContext2D): object;
  37429. protected _renderLines(context: CanvasRenderingContext2D): void;
  37430. dispose(): void;
  37431. }
  37432. }
  37433. declare var DOMImage: new (width?: number | undefined, height?: number | undefined) => HTMLImageElement;
  37434. declare module BABYLON.GUI {
  37435. /**
  37436. * Class used to create 2D images
  37437. */
  37438. class Image extends Control {
  37439. name: string | undefined;
  37440. private _domImage;
  37441. private _imageWidth;
  37442. private _imageHeight;
  37443. private _loaded;
  37444. private _stretch;
  37445. private _source;
  37446. private _autoScale;
  37447. private _sourceLeft;
  37448. private _sourceTop;
  37449. private _sourceWidth;
  37450. private _sourceHeight;
  37451. private _cellWidth;
  37452. private _cellHeight;
  37453. private _cellId;
  37454. /**
  37455. * Gets or sets the left coordinate in the source image
  37456. */
  37457. sourceLeft: number;
  37458. /**
  37459. * Gets or sets the top coordinate in the source image
  37460. */
  37461. sourceTop: number;
  37462. /**
  37463. * Gets or sets the width to capture in the source image
  37464. */
  37465. sourceWidth: number;
  37466. /**
  37467. * Gets or sets the height to capture in the source image
  37468. */
  37469. sourceHeight: number;
  37470. /**
  37471. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  37472. * @see http://doc.babylonjs.com/how_to/gui#image
  37473. */
  37474. autoScale: boolean;
  37475. /** Gets or sets the streching mode used by the image */
  37476. stretch: number;
  37477. /**
  37478. * Gets or sets the internal DOM image used to render the control
  37479. */
  37480. domImage: HTMLImageElement;
  37481. private _onImageLoaded();
  37482. /**
  37483. * Gets or sets image source url
  37484. */
  37485. source: Nullable<string>;
  37486. /**
  37487. * Gets or sets the cell width to use when animation sheet is enabled
  37488. * @see http://doc.babylonjs.com/how_to/gui#image
  37489. */
  37490. cellWidth: number;
  37491. /**
  37492. * Gets or sets the cell height to use when animation sheet is enabled
  37493. * @see http://doc.babylonjs.com/how_to/gui#image
  37494. */
  37495. cellHeight: number;
  37496. /**
  37497. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  37498. * @see http://doc.babylonjs.com/how_to/gui#image
  37499. */
  37500. cellId: number;
  37501. /**
  37502. * Creates a new Image
  37503. * @param name defines the control name
  37504. * @param url defines the image url
  37505. */
  37506. constructor(name?: string | undefined, url?: Nullable<string>);
  37507. protected _getTypeName(): string;
  37508. /** Force the control to synchronize with its content */
  37509. synchronizeSizeWithContent(): void;
  37510. private static _STRETCH_NONE;
  37511. private static _STRETCH_FILL;
  37512. private static _STRETCH_UNIFORM;
  37513. private static _STRETCH_EXTEND;
  37514. /** STRETCH_NONE */
  37515. static readonly STRETCH_NONE: number;
  37516. /** STRETCH_FILL */
  37517. static readonly STRETCH_FILL: number;
  37518. /** STRETCH_UNIFORM */
  37519. static readonly STRETCH_UNIFORM: number;
  37520. /** STRETCH_EXTEND */
  37521. static readonly STRETCH_EXTEND: number;
  37522. }
  37523. }
  37524. declare module BABYLON.GUI {
  37525. /**
  37526. * Class used to create 2D buttons
  37527. */
  37528. class Button extends Rectangle {
  37529. name: string | undefined;
  37530. /**
  37531. * Function called to generate a pointer enter animation
  37532. */
  37533. pointerEnterAnimation: () => void;
  37534. /**
  37535. * Function called to generate a pointer out animation
  37536. */
  37537. pointerOutAnimation: () => void;
  37538. /**
  37539. * Function called to generate a pointer down animation
  37540. */
  37541. pointerDownAnimation: () => void;
  37542. /**
  37543. * Function called to generate a pointer up animation
  37544. */
  37545. pointerUpAnimation: () => void;
  37546. /**
  37547. * Creates a new Button
  37548. * @param name defines the name of the button
  37549. */
  37550. constructor(name?: string | undefined);
  37551. protected _getTypeName(): string;
  37552. /** @hidden */
  37553. /** @hidden */
  37554. /** @hidden */
  37555. /** @hidden */
  37556. /** @hidden */
  37557. /**
  37558. * Creates a new button made with an image and a text
  37559. * @param name defines the name of the button
  37560. * @param text defines the text of the button
  37561. * @param imageUrl defines the url of the image
  37562. * @returns a new Button
  37563. */
  37564. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  37565. /**
  37566. * Creates a new button made with an image
  37567. * @param name defines the name of the button
  37568. * @param imageUrl defines the url of the image
  37569. * @returns a new Button
  37570. */
  37571. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  37572. /**
  37573. * Creates a new button made with a text
  37574. * @param name defines the name of the button
  37575. * @param text defines the text of the button
  37576. * @returns a new Button
  37577. */
  37578. static CreateSimpleButton(name: string, text: string): Button;
  37579. /**
  37580. * Creates a new button made with an image and a centered text
  37581. * @param name defines the name of the button
  37582. * @param text defines the text of the button
  37583. * @param imageUrl defines the url of the image
  37584. * @returns a new Button
  37585. */
  37586. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  37587. }
  37588. }
  37589. declare module BABYLON.GUI {
  37590. /** Class used to create color pickers */
  37591. class ColorPicker extends Control {
  37592. name: string | undefined;
  37593. private _colorWheelCanvas;
  37594. private _value;
  37595. private _tmpColor;
  37596. private _pointerStartedOnSquare;
  37597. private _pointerStartedOnWheel;
  37598. private _squareLeft;
  37599. private _squareTop;
  37600. private _squareSize;
  37601. private _h;
  37602. private _s;
  37603. private _v;
  37604. /**
  37605. * Observable raised when the value changes
  37606. */
  37607. onValueChangedObservable: Observable<Color3>;
  37608. /** Gets or sets the color of the color picker */
  37609. value: Color3;
  37610. /** Gets or sets control width */
  37611. width: string | number;
  37612. /** Gets or sets control height */
  37613. height: string | number;
  37614. /** Gets or sets control size */
  37615. size: string | number;
  37616. /**
  37617. * Creates a new ColorPicker
  37618. * @param name defines the control name
  37619. */
  37620. constructor(name?: string | undefined);
  37621. protected _getTypeName(): string;
  37622. private _updateSquareProps();
  37623. private _drawGradientSquare(hueValue, left, top, width, height, context);
  37624. private _drawCircle(centerX, centerY, radius, context);
  37625. private _createColorWheelCanvas(radius, thickness);
  37626. private _RGBtoHSV(color, result);
  37627. private _HSVtoRGB(hue, saturation, value, result);
  37628. /** @hidden */
  37629. private _pointerIsDown;
  37630. private _updateValueFromPointer(x, y);
  37631. private _isPointOnSquare(coordinates);
  37632. private _isPointOnWheel(coordinates);
  37633. }
  37634. }
  37635. declare module BABYLON.GUI {
  37636. /**
  37637. * Class used to create input text control
  37638. */
  37639. class InputText extends Control implements IFocusableControl {
  37640. name: string | undefined;
  37641. private _text;
  37642. private _placeholderText;
  37643. private _background;
  37644. private _focusedBackground;
  37645. private _placeholderColor;
  37646. private _thickness;
  37647. private _margin;
  37648. private _autoStretchWidth;
  37649. private _maxWidth;
  37650. private _isFocused;
  37651. private _blinkTimeout;
  37652. private _blinkIsEven;
  37653. private _cursorOffset;
  37654. private _scrollLeft;
  37655. private _textWidth;
  37656. private _clickedCoordinate;
  37657. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  37658. promptMessage: string;
  37659. /** Observable raised when the text changes */
  37660. onTextChangedObservable: Observable<InputText>;
  37661. /** Observable raised when the control gets the focus */
  37662. onFocusObservable: Observable<InputText>;
  37663. /** Observable raised when the control loses the focus */
  37664. onBlurObservable: Observable<InputText>;
  37665. /** Gets or sets the maximum width allowed by the control */
  37666. maxWidth: string | number;
  37667. /** Gets the maximum width allowed by the control in pixels */
  37668. readonly maxWidthInPixels: number;
  37669. /** Gets or sets control margin */
  37670. margin: string;
  37671. /** Gets control margin in pixels */
  37672. readonly marginInPixels: number;
  37673. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  37674. autoStretchWidth: boolean;
  37675. /** Gets or sets border thickness */
  37676. thickness: number;
  37677. /** Gets or sets the background color when focused */
  37678. focusedBackground: string;
  37679. /** Gets or sets the background color */
  37680. background: string;
  37681. /** Gets or sets the placeholder color */
  37682. placeholderColor: string;
  37683. /** Gets or sets the text displayed when the control is empty */
  37684. placeholderText: string;
  37685. /** Gets or sets the text displayed in the control */
  37686. text: string;
  37687. /** Gets or sets control width */
  37688. width: string | number;
  37689. /**
  37690. * Creates a new InputText
  37691. * @param name defines the control name
  37692. * @param text defines the text of the control
  37693. */
  37694. constructor(name?: string | undefined, text?: string);
  37695. /** @hidden */
  37696. onBlur(): void;
  37697. /** @hidden */
  37698. onFocus(): void;
  37699. protected _getTypeName(): string;
  37700. /** @hidden */
  37701. processKey(keyCode: number, key?: string): void;
  37702. /** @hidden */
  37703. processKeyboard(evt: KeyboardEvent): void;
  37704. dispose(): void;
  37705. }
  37706. }
  37707. declare module BABYLON.GUI {
  37708. /**
  37709. * Class used to store key control properties
  37710. */
  37711. class KeyPropertySet {
  37712. /** Width */
  37713. width?: string;
  37714. /** Height */
  37715. height?: string;
  37716. /** Left padding */
  37717. paddingLeft?: string;
  37718. /** Right padding */
  37719. paddingRight?: string;
  37720. /** Top padding */
  37721. paddingTop?: string;
  37722. /** Bottom padding */
  37723. paddingBottom?: string;
  37724. /** Foreground color */
  37725. color?: string;
  37726. /** Background color */
  37727. background?: string;
  37728. }
  37729. /**
  37730. * Class used to create virtual keyboard
  37731. */
  37732. class VirtualKeyboard extends StackPanel {
  37733. /** Observable raised when a key is pressed */
  37734. onKeyPressObservable: Observable<string>;
  37735. /** Gets or sets default key button width */
  37736. defaultButtonWidth: string;
  37737. /** Gets or sets default key button height */
  37738. defaultButtonHeight: string;
  37739. /** Gets or sets default key button left padding */
  37740. defaultButtonPaddingLeft: string;
  37741. /** Gets or sets default key button right padding */
  37742. defaultButtonPaddingRight: string;
  37743. /** Gets or sets default key button top padding */
  37744. defaultButtonPaddingTop: string;
  37745. /** Gets or sets default key button bottom padding */
  37746. defaultButtonPaddingBottom: string;
  37747. /** Gets or sets default key button foreground color */
  37748. defaultButtonColor: string;
  37749. /** Gets or sets default key button background color */
  37750. defaultButtonBackground: string;
  37751. /** Gets or sets shift button foreground color */
  37752. shiftButtonColor: string;
  37753. /** Gets or sets shift button thickness*/
  37754. selectedShiftThickness: number;
  37755. /** Gets shift key state */
  37756. shiftState: number;
  37757. protected _getTypeName(): string;
  37758. private _createKey(key, propertySet);
  37759. /**
  37760. * Adds a new row of keys
  37761. * @param keys defines the list of keys to add
  37762. * @param propertySets defines the associated property sets
  37763. */
  37764. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  37765. /**
  37766. * Set the shift key to a specific state
  37767. * @param shiftState defines the new shift state
  37768. */
  37769. applyShiftState(shiftState: number): void;
  37770. private _connectedInputText;
  37771. private _onFocusObserver;
  37772. private _onBlurObserver;
  37773. private _onKeyPressObserver;
  37774. /** Gets the input text control attached with the keyboard */
  37775. readonly connectedInputText: Nullable<InputText>;
  37776. /**
  37777. * Connects the keyboard with an input text control
  37778. * @param input defines the target control
  37779. */
  37780. connect(input: InputText): void;
  37781. /**
  37782. * Disconnects the keyboard from an input text control
  37783. */
  37784. disconnect(): void;
  37785. /**
  37786. * Creates a new keyboard using a default layout
  37787. * @returns a new VirtualKeyboard
  37788. */
  37789. static CreateDefaultLayout(): VirtualKeyboard;
  37790. }
  37791. }
  37792. declare module BABYLON.GUI {
  37793. /**
  37794. * Class used to create multi line control
  37795. */
  37796. class MultiLine extends Control {
  37797. name: string | undefined;
  37798. private _lineWidth;
  37799. private _dash;
  37800. private _points;
  37801. private _minX;
  37802. private _minY;
  37803. private _maxX;
  37804. private _maxY;
  37805. /**
  37806. * Creates a new MultiLine
  37807. * @param name defines the control name
  37808. */
  37809. constructor(name?: string | undefined);
  37810. /** Gets or sets dash pattern */
  37811. dash: Array<number>;
  37812. /**
  37813. * Gets point stored at specified index
  37814. * @param index defines the index to look for
  37815. * @returns the requested point if found
  37816. */
  37817. getAt(index: number): MultiLinePoint;
  37818. /** Function called when a point is updated */
  37819. onPointUpdate: () => void;
  37820. /**
  37821. * Adds new points to the point collection
  37822. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  37823. * @returns the list of created MultiLinePoint
  37824. */
  37825. add(...items: (AbstractMesh | Control | {
  37826. x: string | number;
  37827. y: string | number;
  37828. })[]): MultiLinePoint[];
  37829. /**
  37830. * Adds a new point to the point collection
  37831. * @param item defines the item (mesh, control or 2d coordiantes) to add
  37832. * @returns the created MultiLinePoint
  37833. */
  37834. push(item?: (AbstractMesh | Control | {
  37835. x: string | number;
  37836. y: string | number;
  37837. })): MultiLinePoint;
  37838. /**
  37839. * Remove a specific value or point from the active point collection
  37840. * @param value defines the value or point to remove
  37841. */
  37842. remove(value: number | MultiLinePoint): void;
  37843. /** Gets or sets line width */
  37844. lineWidth: number;
  37845. horizontalAlignment: number;
  37846. verticalAlignment: number;
  37847. protected _getTypeName(): string;
  37848. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  37849. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  37850. dispose(): void;
  37851. }
  37852. }
  37853. declare module BABYLON.GUI {
  37854. /**
  37855. * Class used to create a 2D grid container
  37856. */
  37857. class Grid extends Container {
  37858. name: string | undefined;
  37859. private _rowDefinitions;
  37860. private _columnDefinitions;
  37861. private _cells;
  37862. private _childControls;
  37863. /** Gets the list of children */
  37864. readonly children: Control[];
  37865. /**
  37866. * Adds a new row to the grid
  37867. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  37868. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  37869. * @returns the current grid
  37870. */
  37871. addRowDefinition(height: number, isPixel?: boolean): Grid;
  37872. /**
  37873. * Adds a new column to the grid
  37874. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  37875. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  37876. * @returns the current grid
  37877. */
  37878. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  37879. /**
  37880. * Update a row definition
  37881. * @param index defines the index of the row to update
  37882. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  37883. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  37884. * @returns the current grid
  37885. */
  37886. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  37887. /**
  37888. * Update a column definition
  37889. * @param index defines the index of the column to update
  37890. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  37891. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  37892. * @returns the current grid
  37893. */
  37894. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  37895. private _removeCell(cell, key);
  37896. private _offsetCell(previousKey, key);
  37897. /**
  37898. * Remove a column definition at specified index
  37899. * @param index defines the index of the column to remove
  37900. * @returns the current grid
  37901. */
  37902. removeColumnDefinition(index: number): Grid;
  37903. /**
  37904. * Remove a row definition at specified index
  37905. * @param index defines the index of the row to remove
  37906. * @returns the current grid
  37907. */
  37908. removeRowDefinition(index: number): Grid;
  37909. /**
  37910. * Adds a new control to the current grid
  37911. * @param control defines the control to add
  37912. * @param row defines the row where to add the control (0 by default)
  37913. * @param column defines the column where to add the control (0 by default)
  37914. * @returns the current grid
  37915. */
  37916. addControl(control: Control, row?: number, column?: number): Grid;
  37917. /**
  37918. * Removes a control from the current container
  37919. * @param control defines the control to remove
  37920. * @returns the current container
  37921. */
  37922. removeControl(control: Control): Container;
  37923. /**
  37924. * Creates a new Grid
  37925. * @param name defines control name
  37926. */
  37927. constructor(name?: string | undefined);
  37928. protected _getTypeName(): string;
  37929. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  37930. /** Releases associated resources */
  37931. dispose(): void;
  37932. }
  37933. }
  37934. declare module BABYLON.GUI {
  37935. /**
  37936. * Class used to manage 3D user interface
  37937. * @see http://doc.babylonjs.com/how_to/gui3d
  37938. */
  37939. class GUI3DManager implements BABYLON.IDisposable {
  37940. private _scene;
  37941. private _sceneDisposeObserver;
  37942. private _utilityLayer;
  37943. private _rootContainer;
  37944. private _pointerObserver;
  37945. private _pointerOutObserver;
  37946. /** @hidden */
  37947. /** @hidden */
  37948. ;
  37949. /** @hidden */
  37950. ;
  37951. /**
  37952. * Observable raised when the point picked by the pointer events changed
  37953. */
  37954. onPickedPointChangedObservable: Observable<Nullable<Vector3>>;
  37955. /** @hidden */
  37956. ;
  37957. /** Gets the hosting scene */
  37958. readonly scene: Scene;
  37959. /** Gets associated utility layer */
  37960. readonly utilityLayer: Nullable<UtilityLayerRenderer>;
  37961. /**
  37962. * Creates a new GUI3DManager
  37963. * @param scene
  37964. */
  37965. constructor(scene?: Scene);
  37966. private _handlePointerOut(pointerId, isPointerUp);
  37967. private _doPicking(pi);
  37968. /**
  37969. * Gets the root container
  37970. */
  37971. readonly rootContainer: Container3D;
  37972. /**
  37973. * Gets a boolean indicating if the given control is in the root child list
  37974. * @param control defines the control to check
  37975. * @returns true if the control is in the root child list
  37976. */
  37977. containsControl(control: Control3D): boolean;
  37978. /**
  37979. * Adds a control to the root child list
  37980. * @param control defines the control to add
  37981. * @returns the current manager
  37982. */
  37983. addControl(control: Control3D): GUI3DManager;
  37984. /**
  37985. * Removes a control from the root child list
  37986. * @param control defines the control to remove
  37987. * @returns the current container
  37988. */
  37989. removeControl(control: Control3D): GUI3DManager;
  37990. /**
  37991. * Releases all associated resources
  37992. */
  37993. dispose(): void;
  37994. }
  37995. }
  37996. declare module BABYLON.GUI {
  37997. /** @hidden */
  37998. class FluentMaterialDefines extends MaterialDefines {
  37999. INNERGLOW: boolean;
  38000. BORDER: boolean;
  38001. HOVERLIGHT: boolean;
  38002. constructor();
  38003. }
  38004. /**
  38005. * Class used to render controls with fluent desgin
  38006. */
  38007. class FluentMaterial extends PushMaterial {
  38008. /**
  38009. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  38010. */
  38011. innerGlowColorIntensity: number;
  38012. /**
  38013. * Gets or sets the inner glow color (white by default)
  38014. */
  38015. innerGlowColor: Color3;
  38016. /**
  38017. * Gets or sets alpha value (default is 1.0)
  38018. */
  38019. alpha: number;
  38020. /**
  38021. * Gets or sets the albedo color (Default is Color3(0.3, 0.35, 0.4))
  38022. */
  38023. albedoColor: Color3;
  38024. /**
  38025. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  38026. */
  38027. renderBorders: boolean;
  38028. /**
  38029. * Gets or sets border width (default is 0.5)
  38030. */
  38031. borderWidth: number;
  38032. /**
  38033. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  38034. */
  38035. edgeSmoothingValue: number;
  38036. /**
  38037. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  38038. */
  38039. borderMinValue: number;
  38040. /**
  38041. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  38042. */
  38043. renderHoverLight: boolean;
  38044. /**
  38045. * Gets or sets the radius used to render the hover light (default is 0.15)
  38046. */
  38047. hoverRadius: number;
  38048. /**
  38049. * Gets or sets the color used to render the hover light (default is Color4(0.3, 0.3, 0.3, 1.0))
  38050. */
  38051. hoverColor: Color4;
  38052. /**
  38053. * Gets or sets the hover light position in world space (default is Vector3.Zero())
  38054. */
  38055. hoverPosition: Vector3;
  38056. /**
  38057. * Creates a new Fluent material
  38058. * @param name defines the name of the material
  38059. * @param scene defines the hosting scene
  38060. */
  38061. constructor(name: string, scene: Scene);
  38062. needAlphaBlending(): boolean;
  38063. needAlphaTesting(): boolean;
  38064. getAlphaTestTexture(): Nullable<BaseTexture>;
  38065. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  38066. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  38067. getActiveTextures(): BaseTexture[];
  38068. hasTexture(texture: BaseTexture): boolean;
  38069. dispose(forceDisposeEffect?: boolean): void;
  38070. clone(name: string): FluentMaterial;
  38071. serialize(): any;
  38072. getClassName(): string;
  38073. static Parse(source: any, scene: Scene, rootUrl: string): FluentMaterial;
  38074. }
  38075. }
  38076. declare module BABYLON.GUI {
  38077. /**
  38078. * Class used to transport Vector3 information for pointer events
  38079. */
  38080. class Vector3WithInfo extends Vector3 {
  38081. /** defines the current mouse button index */
  38082. buttonIndex: number;
  38083. /**
  38084. * Creates a new Vector3WithInfo
  38085. * @param source defines the vector3 data to transport
  38086. * @param buttonIndex defines the current mouse button index
  38087. */
  38088. constructor(source: Vector3,
  38089. /** defines the current mouse button index */
  38090. buttonIndex?: number);
  38091. }
  38092. }
  38093. declare module BABYLON.GUI {
  38094. /**
  38095. * Class used as base class for controls
  38096. */
  38097. class Control3D implements IDisposable, IBehaviorAware<Control3D> {
  38098. /** Defines the control name */
  38099. name: string | undefined;
  38100. /** @hidden */
  38101. private _node;
  38102. private _downCount;
  38103. private _enterCount;
  38104. private _downPointerIds;
  38105. private _isVisible;
  38106. /** Gets or sets the control position in world space */
  38107. position: Vector3;
  38108. /** Gets or sets the control scaling in world space */
  38109. scaling: Vector3;
  38110. /** Callback used to start pointer enter animation */
  38111. pointerEnterAnimation: () => void;
  38112. /** Callback used to start pointer out animation */
  38113. pointerOutAnimation: () => void;
  38114. /** Callback used to start pointer down animation */
  38115. pointerDownAnimation: () => void;
  38116. /** Callback used to start pointer up animation */
  38117. pointerUpAnimation: () => void;
  38118. /**
  38119. * An event triggered when the pointer move over the control
  38120. */
  38121. onPointerMoveObservable: Observable<Vector3>;
  38122. /**
  38123. * An event triggered when the pointer move out of the control
  38124. */
  38125. onPointerOutObservable: Observable<Control3D>;
  38126. /**
  38127. * An event triggered when the pointer taps the control
  38128. */
  38129. onPointerDownObservable: Observable<Vector3WithInfo>;
  38130. /**
  38131. * An event triggered when pointer is up
  38132. */
  38133. onPointerUpObservable: Observable<Vector3WithInfo>;
  38134. /**
  38135. * An event triggered when a control is clicked on (with a mouse)
  38136. */
  38137. onPointerClickObservable: Observable<Vector3WithInfo>;
  38138. /**
  38139. * An event triggered when pointer enters the control
  38140. */
  38141. onPointerEnterObservable: Observable<Control3D>;
  38142. /**
  38143. * Gets or sets the parent container
  38144. */
  38145. parent: Nullable<Container3D>;
  38146. private _behaviors;
  38147. /**
  38148. * Gets the list of attached behaviors
  38149. * @see http://doc.babylonjs.com/features/behaviour
  38150. */
  38151. readonly behaviors: Behavior<Control3D>[];
  38152. /**
  38153. * Attach a behavior to the control
  38154. * @see http://doc.babylonjs.com/features/behaviour
  38155. * @param behavior defines the behavior to attach
  38156. * @returns the current control
  38157. */
  38158. addBehavior(behavior: Behavior<Control3D>): Control3D;
  38159. /**
  38160. * Remove an attached behavior
  38161. * @see http://doc.babylonjs.com/features/behaviour
  38162. * @param behavior defines the behavior to attach
  38163. * @returns the current control
  38164. */
  38165. removeBehavior(behavior: Behavior<Control3D>): Control3D;
  38166. /**
  38167. * Gets an attached behavior by name
  38168. * @param name defines the name of the behavior to look for
  38169. * @see http://doc.babylonjs.com/features/behaviour
  38170. * @returns null if behavior was not found else the requested behavior
  38171. */
  38172. getBehaviorByName(name: string): Nullable<Behavior<Control3D>>;
  38173. /** Gets or sets a boolean indicating if the control is visible */
  38174. isVisible: boolean;
  38175. /**
  38176. * Creates a new control
  38177. * @param name defines the control name
  38178. */
  38179. constructor(
  38180. /** Defines the control name */
  38181. name?: string | undefined);
  38182. /**
  38183. * Gets a string representing the class name
  38184. */
  38185. readonly typeName: string;
  38186. protected _getTypeName(): string;
  38187. /**
  38188. * Gets the transform node used by this control
  38189. */
  38190. readonly node: Nullable<TransformNode>;
  38191. /**
  38192. * Gets the mesh used to render this control
  38193. */
  38194. readonly mesh: Nullable<AbstractMesh>;
  38195. /**
  38196. * Link the control as child of the given node
  38197. * @param node defines the node to link to. Use null to unlink the control
  38198. * @returns the current control
  38199. */
  38200. linkToTransformNode(node: Nullable<TransformNode>): Control3D;
  38201. /** @hidden **/
  38202. /**
  38203. * Node creation.
  38204. * Can be overriden by children
  38205. * @param scene defines the scene where the node must be attached
  38206. * @returns the attached node or null if none. Must return a Mesh or AbstractMesh if there is an atttached visible object
  38207. */
  38208. protected _createNode(scene: Scene): Nullable<TransformNode>;
  38209. /**
  38210. * Affect a material to the given mesh
  38211. * @param mesh defines the mesh which will represent the control
  38212. */
  38213. protected _affectMaterial(mesh: AbstractMesh): void;
  38214. /** @hidden */
  38215. /** @hidden */
  38216. /** @hidden */
  38217. /** @hidden */
  38218. /** @hidden */
  38219. /** @hidden */
  38220. forcePointerUp(pointerId?: Nullable<number>): void;
  38221. /** @hidden */
  38222. /** @hidden */
  38223. /**
  38224. * Releases all associated resources
  38225. */
  38226. dispose(): void;
  38227. }
  38228. }
  38229. declare module BABYLON.GUI {
  38230. /**
  38231. * Class used to create containers for controls
  38232. */
  38233. class Container3D extends Control3D {
  38234. private _blockLayout;
  38235. /**
  38236. * Gets the list of child controls
  38237. */
  38238. protected _children: Control3D[];
  38239. /**
  38240. * Gets the list of child controls
  38241. */
  38242. readonly children: Array<Control3D>;
  38243. /**
  38244. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  38245. * This is helpful to optimize layout operation when adding multiple children in a row
  38246. */
  38247. blockLayout: boolean;
  38248. /**
  38249. * Creates a new container
  38250. * @param name defines the container name
  38251. */
  38252. constructor(name?: string);
  38253. /**
  38254. * Gets a boolean indicating if the given control is in the children of this control
  38255. * @param control defines the control to check
  38256. * @returns true if the control is in the child list
  38257. */
  38258. containsControl(control: Control3D): boolean;
  38259. /**
  38260. * Adds a control to the children of this control
  38261. * @param control defines the control to add
  38262. * @returns the current container
  38263. */
  38264. addControl(control: Control3D): Container3D;
  38265. /**
  38266. * This function will be called everytime a new control is added
  38267. */
  38268. protected _arrangeChildren(): void;
  38269. protected _createNode(scene: Scene): Nullable<TransformNode>;
  38270. /**
  38271. * Removes a control from the children of this control
  38272. * @param control defines the control to remove
  38273. * @returns the current container
  38274. */
  38275. removeControl(control: Control3D): Container3D;
  38276. protected _getTypeName(): string;
  38277. /**
  38278. * Releases all associated resources
  38279. */
  38280. dispose(): void;
  38281. /** Control rotation will remain unchanged */
  38282. static readonly UNSET_ORIENTATION: number;
  38283. /** Control will rotate to make it look at sphere central axis */
  38284. static readonly FACEORIGIN_ORIENTATION: number;
  38285. /** Control will rotate to make it look back at sphere central axis */
  38286. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  38287. /** Control will rotate to look at z axis (0, 0, 1) */
  38288. static readonly FACEFORWARD_ORIENTATION: number;
  38289. /** Control will rotate to look at negative z axis (0, 0, -1) */
  38290. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  38291. }
  38292. }
  38293. declare module BABYLON.GUI {
  38294. /**
  38295. * Class used as a root to all buttons
  38296. */
  38297. class AbstractButton3D extends Control3D {
  38298. /**
  38299. * Creates a new button
  38300. * @param name defines the control name
  38301. */
  38302. constructor(name?: string);
  38303. protected _getTypeName(): string;
  38304. protected _createNode(scene: Scene): TransformNode;
  38305. }
  38306. }
  38307. declare module BABYLON.GUI {
  38308. /**
  38309. * Class used to create a button in 3D
  38310. */
  38311. class Button3D extends AbstractButton3D {
  38312. /** @hidden */
  38313. protected _currentMaterial: Material;
  38314. private _facadeTexture;
  38315. private _content;
  38316. private _contentResolution;
  38317. private _contentScaleRatio;
  38318. /**
  38319. * Gets or sets the texture resolution used to render content (512 by default)
  38320. */
  38321. contentResolution: int;
  38322. /**
  38323. * Gets or sets the texture scale ratio used to render content (2 by default)
  38324. */
  38325. contentScaleRatio: number;
  38326. protected _disposeFacadeTexture(): void;
  38327. protected _resetContent(): void;
  38328. /**
  38329. * Creates a new button
  38330. * @param name defines the control name
  38331. */
  38332. constructor(name?: string);
  38333. /**
  38334. * Gets or sets the GUI 2D content used to display the button's facade
  38335. */
  38336. content: Control;
  38337. /**
  38338. * Apply the facade texture (created from the content property).
  38339. * This function can be overloaded by child classes
  38340. * @param facadeTexture defines the AdvancedDynamicTexture to use
  38341. */
  38342. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  38343. protected _getTypeName(): string;
  38344. protected _createNode(scene: Scene): TransformNode;
  38345. protected _affectMaterial(mesh: AbstractMesh): void;
  38346. /**
  38347. * Releases all associated resources
  38348. */
  38349. dispose(): void;
  38350. }
  38351. }
  38352. declare module BABYLON.GUI {
  38353. /**
  38354. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  38355. */
  38356. class MeshButton3D extends Button3D {
  38357. /** @hidden */
  38358. protected _currentMesh: Mesh;
  38359. /**
  38360. * Creates a new 3D button based on a mesh
  38361. * @param mesh mesh to become a 3D button
  38362. * @param name defines the control name
  38363. */
  38364. constructor(mesh: Mesh, name?: string);
  38365. protected _getTypeName(): string;
  38366. protected _createNode(scene: Scene): TransformNode;
  38367. protected _affectMaterial(mesh: AbstractMesh): void;
  38368. }
  38369. }
  38370. declare module BABYLON.GUI {
  38371. /**
  38372. * Class used to create a holographic button in 3D
  38373. */
  38374. class HolographicButton extends Button3D {
  38375. private _backPlate;
  38376. private _textPlate;
  38377. private _frontPlate;
  38378. private _text;
  38379. private _imageUrl;
  38380. private _shareMaterials;
  38381. private _frontMaterial;
  38382. private _backMaterial;
  38383. private _plateMaterial;
  38384. private _pickedPointObserver;
  38385. /**
  38386. * Gets or sets text for the button
  38387. */
  38388. text: string;
  38389. /**
  38390. * Gets or sets the image url for the button
  38391. */
  38392. imageUrl: string;
  38393. /**
  38394. * Gets the back material used by this button
  38395. */
  38396. readonly backMaterial: FluentMaterial;
  38397. /**
  38398. * Gets the front material used by this button
  38399. */
  38400. readonly frontMaterial: FluentMaterial;
  38401. /**
  38402. * Gets the plate material used by this button
  38403. */
  38404. readonly plateMaterial: StandardMaterial;
  38405. /**
  38406. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  38407. */
  38408. readonly shareMaterials: boolean;
  38409. /**
  38410. * Creates a new button
  38411. * @param name defines the control name
  38412. */
  38413. constructor(name?: string, shareMaterials?: boolean);
  38414. protected _getTypeName(): string;
  38415. private _rebuildContent();
  38416. protected _createNode(scene: Scene): TransformNode;
  38417. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  38418. private _createBackMaterial(mesh);
  38419. private _createFrontMaterial(mesh);
  38420. private _createPlateMaterial(mesh);
  38421. protected _affectMaterial(mesh: Mesh): void;
  38422. /**
  38423. * Releases all associated resources
  38424. */
  38425. dispose(): void;
  38426. }
  38427. }
  38428. declare module BABYLON.GUI {
  38429. /**
  38430. * Class used to create a stack panel in 3D on XY plane
  38431. */
  38432. class StackPanel3D extends Container3D {
  38433. private _isVertical;
  38434. /**
  38435. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  38436. */
  38437. isVertical: boolean;
  38438. /**
  38439. * Gets or sets the distance between elements
  38440. */
  38441. margin: number;
  38442. /**
  38443. * Creates new StackPanel
  38444. * @param isVertical
  38445. */
  38446. constructor(isVertical?: boolean);
  38447. protected _arrangeChildren(): void;
  38448. }
  38449. }
  38450. declare module BABYLON.GUI {
  38451. /**
  38452. * Abstract class used to create a container panel deployed on the surface of a volume
  38453. */
  38454. abstract class VolumeBasedPanel extends Container3D {
  38455. private _columns;
  38456. private _rows;
  38457. private _rowThenColum;
  38458. private _orientation;
  38459. protected _cellWidth: number;
  38460. protected _cellHeight: number;
  38461. /**
  38462. * Gets or sets the distance between elements
  38463. */
  38464. margin: number;
  38465. /**
  38466. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  38467. * | Value | Type | Description |
  38468. * | ----- | ----------------------------------- | ----------- |
  38469. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  38470. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  38471. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  38472. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  38473. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  38474. */
  38475. orientation: number;
  38476. /**
  38477. * Gets or sets the number of columns requested (10 by default).
  38478. * The panel will automatically compute the number of rows based on number of child controls.
  38479. */
  38480. columns: int;
  38481. /**
  38482. * Gets or sets a the number of rows requested.
  38483. * The panel will automatically compute the number of columns based on number of child controls.
  38484. */
  38485. rows: int;
  38486. /**
  38487. * Creates new SpherePanel
  38488. */
  38489. constructor();
  38490. protected _arrangeChildren(): void;
  38491. /** Child classes must implement this function to provide correct control positioning */
  38492. protected abstract _mapGridNode(control: Control3D, nodePosition: Vector3): void;
  38493. /** Child classes can implement this function to provide additional processing */
  38494. protected _finalProcessing(): void;
  38495. }
  38496. }
  38497. declare module BABYLON.GUI {
  38498. /**
  38499. * Class used to create a container panel deployed on the surface of a sphere
  38500. */
  38501. class SpherePanel extends VolumeBasedPanel {
  38502. private _radius;
  38503. /**
  38504. * Gets or sets the radius of the sphere where to project controls (5 by default)
  38505. */
  38506. radius: float;
  38507. protected _mapGridNode(control: Control3D, nodePosition: Vector3): void;
  38508. private _sphericalMapping(source);
  38509. }
  38510. }
  38511. declare module BABYLON.GUI {
  38512. /**
  38513. * Class used to create a container panel deployed on the surface of a plane
  38514. */
  38515. class PlanePanel extends VolumeBasedPanel {
  38516. protected _mapGridNode(control: Control3D, nodePosition: Vector3): void;
  38517. }
  38518. }
  38519. declare module BABYLON.GUI {
  38520. /**
  38521. * Class used to create a container panel where items get randomized planar mapping
  38522. */
  38523. class ScatterPanel extends VolumeBasedPanel {
  38524. private _iteration;
  38525. /**
  38526. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  38527. */
  38528. iteration: float;
  38529. protected _mapGridNode(control: Control3D, nodePosition: Vector3): void;
  38530. private _scatterMapping(source);
  38531. protected _finalProcessing(): void;
  38532. }
  38533. }
  38534. declare module BABYLON.GUI {
  38535. /**
  38536. * Class used to create a container panel deployed on the surface of a cylinder
  38537. */
  38538. class CylinderPanel extends VolumeBasedPanel {
  38539. private _radius;
  38540. /**
  38541. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  38542. */
  38543. radius: float;
  38544. protected _mapGridNode(control: Control3D, nodePosition: Vector3): void;
  38545. private _cylindricalMapping(source);
  38546. }
  38547. }
  38548. declare module BABYLON {
  38549. /**
  38550. * Mode that determines the coordinate system to use.
  38551. */
  38552. enum GLTFLoaderCoordinateSystemMode {
  38553. /**
  38554. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  38555. */
  38556. AUTO = 0,
  38557. /**
  38558. * Sets the useRightHandedSystem flag on the scene.
  38559. */
  38560. FORCE_RIGHT_HANDED = 1,
  38561. }
  38562. /**
  38563. * Mode that determines what animations will start.
  38564. */
  38565. enum GLTFLoaderAnimationStartMode {
  38566. /**
  38567. * No animation will start.
  38568. */
  38569. NONE = 0,
  38570. /**
  38571. * The first animation will start.
  38572. */
  38573. FIRST = 1,
  38574. /**
  38575. * All animations will start.
  38576. */
  38577. ALL = 2,
  38578. }
  38579. /**
  38580. * Interface that contains the data for the glTF asset.
  38581. */
  38582. interface IGLTFLoaderData {
  38583. /**
  38584. * JSON that represents the glTF.
  38585. */
  38586. json: Object;
  38587. /**
  38588. * The BIN chunk of a binary glTF
  38589. */
  38590. bin: Nullable<ArrayBufferView>;
  38591. }
  38592. /**
  38593. * Interface for extending the loader.
  38594. */
  38595. interface IGLTFLoaderExtension {
  38596. /**
  38597. * The name of this extension.
  38598. */
  38599. readonly name: string;
  38600. /**
  38601. * Defines whether this extension is enabled.
  38602. */
  38603. enabled: boolean;
  38604. }
  38605. /**
  38606. * Loader state.
  38607. */
  38608. enum GLTFLoaderState {
  38609. /**
  38610. * The asset is loading.
  38611. */
  38612. LOADING = 0,
  38613. /**
  38614. * The asset is ready for rendering.
  38615. */
  38616. READY = 1,
  38617. /**
  38618. * The asset is completely loaded.
  38619. */
  38620. COMPLETE = 2,
  38621. }
  38622. /** @hidden */
  38623. interface IGLTFLoader extends IDisposable {
  38624. readonly state: Nullable<GLTFLoaderState>;
  38625. importMeshAsync: (meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void) => Promise<{
  38626. meshes: AbstractMesh[];
  38627. particleSystems: ParticleSystem[];
  38628. skeletons: Skeleton[];
  38629. animationGroups: AnimationGroup[];
  38630. }>;
  38631. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void) => Promise<void>;
  38632. }
  38633. /**
  38634. * File loader for loading glTF files into a scene.
  38635. */
  38636. class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  38637. /** @hidden */
  38638. private static _CreateGLTFLoaderV1: (parent: GLTFFileLoader) => IGLTFLoader;
  38639. /** @hidden */
  38640. private static _CreateGLTFLoaderV2: (parent: GLTFFileLoader) => IGLTFLoader;
  38641. /**
  38642. * Raised when the asset has been parsed
  38643. */
  38644. onParsedObservable: Observable<IGLTFLoaderData>;
  38645. private _onParsedObserver;
  38646. /**
  38647. * Raised when the asset has been parsed
  38648. */
  38649. onParsed: (loaderData: IGLTFLoaderData) => void;
  38650. /**
  38651. * 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.
  38652. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  38653. * Defaults to true.
  38654. * @hidden
  38655. */
  38656. static IncrementalLoading: boolean;
  38657. /**
  38658. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  38659. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  38660. * @hidden
  38661. */
  38662. static HomogeneousCoordinates: boolean;
  38663. /**
  38664. * The coordinate system mode. Defaults to AUTO.
  38665. */
  38666. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  38667. /**
  38668. * The animation start mode. Defaults to FIRST.
  38669. */
  38670. animationStartMode: GLTFLoaderAnimationStartMode;
  38671. /**
  38672. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  38673. */
  38674. compileMaterials: boolean;
  38675. /**
  38676. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  38677. */
  38678. useClipPlane: boolean;
  38679. /**
  38680. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  38681. */
  38682. compileShadowGenerators: boolean;
  38683. /**
  38684. * Defines if the Alpha blended materials are only applied as coverage.
  38685. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  38686. * If true, no extra effects are applied to transparent pixels.
  38687. */
  38688. transparencyAsCoverage: boolean;
  38689. /** @hidden */
  38690. /**
  38691. * Function called before loading a url referenced by the asset.
  38692. */
  38693. preprocessUrlAsync: (url: string) => Promise<string>;
  38694. /**
  38695. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  38696. */
  38697. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  38698. private _onMeshLoadedObserver;
  38699. /**
  38700. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  38701. */
  38702. onMeshLoaded: (mesh: AbstractMesh) => void;
  38703. /**
  38704. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  38705. */
  38706. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  38707. private _onTextureLoadedObserver;
  38708. /**
  38709. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  38710. */
  38711. onTextureLoaded: (texture: BaseTexture) => void;
  38712. /**
  38713. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  38714. */
  38715. readonly onMaterialLoadedObservable: Observable<Material>;
  38716. private _onMaterialLoadedObserver;
  38717. /**
  38718. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  38719. */
  38720. onMaterialLoaded: (material: Material) => void;
  38721. /**
  38722. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  38723. */
  38724. readonly onCameraLoadedObservable: Observable<Camera>;
  38725. private _onCameraLoadedObserver;
  38726. /**
  38727. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  38728. */
  38729. onCameraLoaded: (camera: Camera) => void;
  38730. /**
  38731. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  38732. * For assets with LODs, raised when all of the LODs are complete.
  38733. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  38734. */
  38735. readonly onCompleteObservable: Observable<void>;
  38736. private _onCompleteObserver;
  38737. /**
  38738. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  38739. */
  38740. onComplete: () => void;
  38741. /**
  38742. * Observable raised after the loader is disposed.
  38743. */
  38744. readonly onDisposeObservable: Observable<void>;
  38745. private _onDisposeObserver;
  38746. /**
  38747. * Callback raised after the loader is disposed.
  38748. */
  38749. onDispose: () => void;
  38750. /**
  38751. * Observable raised after a loader extension is created.
  38752. * Set additional options for a loader extension in this event.
  38753. */
  38754. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  38755. private _onExtensionLoadedObserver;
  38756. /**
  38757. * Callback raised after a loader extension is created.
  38758. */
  38759. onExtensionLoaded: (extension: IGLTFLoaderExtension) => void;
  38760. /**
  38761. * Returns a promise that resolves when the asset is completely loaded.
  38762. * @returns a promise that resolves when the asset is completely loaded.
  38763. */
  38764. whenCompleteAsync(): Promise<void>;
  38765. /**
  38766. * The loader state or null if the loader is not active.
  38767. */
  38768. readonly loaderState: Nullable<GLTFLoaderState>;
  38769. /**
  38770. * Defines if the loader logging is enabled.
  38771. */
  38772. loggingEnabled: boolean;
  38773. /**
  38774. * Defines if the loader should capture performance counters.
  38775. */
  38776. capturePerformanceCounters: boolean;
  38777. private _loader;
  38778. /**
  38779. * Name of the loader ("gltf")
  38780. */
  38781. name: string;
  38782. /**
  38783. * Supported file extensions of the loader (.gltf, .glb)
  38784. */
  38785. extensions: ISceneLoaderPluginExtensions;
  38786. /**
  38787. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  38788. */
  38789. dispose(): void;
  38790. /** @hidden */
  38791. /**
  38792. * Imports one or more meshes from the loaded glTF data and adds them to the scene
  38793. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  38794. * @param scene the scene the meshes should be added to
  38795. * @param data the glTF data to load
  38796. * @param rootUrl root url to load from
  38797. * @param onProgress event that fires when loading progress has occured
  38798. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  38799. */
  38800. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<{
  38801. meshes: AbstractMesh[];
  38802. particleSystems: ParticleSystem[];
  38803. skeletons: Skeleton[];
  38804. animationGroups: AnimationGroup[];
  38805. }>;
  38806. /**
  38807. * Imports all objects from the loaded glTF data and adds them to the scene
  38808. * @param scene the scene the objects should be added to
  38809. * @param data the glTF data to load
  38810. * @param rootUrl root url to load from
  38811. * @param onProgress event that fires when loading progress has occured
  38812. * @returns a promise which completes when objects have been loaded to the scene
  38813. */
  38814. loadAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  38815. /**
  38816. * Load into an asset container.
  38817. * @param scene The scene to load into
  38818. * @param data The data to import
  38819. * @param rootUrl The root url for scene and resources
  38820. * @param onProgress The callback when the load progresses
  38821. * @returns The loaded asset container
  38822. */
  38823. loadAssetContainerAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<AssetContainer>;
  38824. /**
  38825. * If the data string can be loaded directly.
  38826. * @param data string contianing the file data
  38827. * @returns if the data can be loaded directly
  38828. */
  38829. canDirectLoad(data: string): boolean;
  38830. /**
  38831. * Rewrites a url by combining a root url and response url.
  38832. */
  38833. rewriteRootURL: (rootUrl: string, responseURL?: string) => string;
  38834. /**
  38835. * Instantiates a glTF file loader plugin.
  38836. * @returns the created plugin
  38837. */
  38838. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  38839. private _parse(data);
  38840. private _getLoader(loaderData);
  38841. private _parseBinary(data);
  38842. private _parseV1(binaryReader);
  38843. private _parseV2(binaryReader);
  38844. private static _parseVersion(version);
  38845. private static _compareVersion(a, b);
  38846. private static _decodeBufferToText(buffer);
  38847. private static readonly _logSpaces;
  38848. private _logIndentLevel;
  38849. private _loggingEnabled;
  38850. /** @hidden */
  38851. /** @hidden */
  38852. /** @hidden */
  38853. private _logEnabled(message);
  38854. private _logDisabled(message);
  38855. private _capturePerformanceCounters;
  38856. /** @hidden */
  38857. /** @hidden */
  38858. private _startPerformanceCounterEnabled(counterName);
  38859. private _startPerformanceCounterDisabled(counterName);
  38860. private _endPerformanceCounterEnabled(counterName);
  38861. private _endPerformanceCounterDisabled(counterName);
  38862. }
  38863. }
  38864. declare module BABYLON.GLTF2 {
  38865. /** @hidden */
  38866. interface _IArrayItem {
  38867. }
  38868. /** @hidden */
  38869. interface _ILoaderAccessor extends IAccessor, _IArrayItem {
  38870. }
  38871. /** @hidden */
  38872. interface _ILoaderAnimationChannel extends IAnimationChannel, _IArrayItem {
  38873. }
  38874. /** @hidden */
  38875. interface _ILoaderAnimationSamplerData {
  38876. input: Float32Array;
  38877. interpolation: AnimationSamplerInterpolation;
  38878. output: Float32Array;
  38879. }
  38880. /** @hidden */
  38881. interface _ILoaderAnimationSampler extends IAnimationSampler, _IArrayItem {
  38882. }
  38883. /** @hidden */
  38884. interface _ILoaderAnimation extends IAnimation, _IArrayItem {
  38885. channels: _ILoaderAnimationChannel[];
  38886. samplers: _ILoaderAnimationSampler[];
  38887. }
  38888. /** @hidden */
  38889. interface _ILoaderBuffer extends IBuffer, _IArrayItem {
  38890. }
  38891. /** @hidden */
  38892. interface _ILoaderBufferView extends IBufferView, _IArrayItem {
  38893. }
  38894. /** @hidden */
  38895. interface _ILoaderCamera extends ICamera, _IArrayItem {
  38896. }
  38897. /** @hidden */
  38898. interface _ILoaderImage extends IImage, _IArrayItem {
  38899. }
  38900. /** @hidden */
  38901. interface _ILoaderMaterial extends IMaterial, _IArrayItem {
  38902. ;
  38903. };
  38904. }
  38905. /** @hidden */
  38906. interface _ILoaderMesh extends IMesh, _IArrayItem {
  38907. primitives: _ILoaderMeshPrimitive[];
  38908. }
  38909. /** @hidden */
  38910. interface _ILoaderMeshPrimitive extends IMeshPrimitive, _IArrayItem {
  38911. }
  38912. /** @hidden */
  38913. interface _ILoaderNode extends INode, _IArrayItem {
  38914. }
  38915. /** @hidden */
  38916. interface _ILoaderSamplerData {
  38917. noMipMaps: boolean;
  38918. samplingMode: number;
  38919. wrapU: number;
  38920. wrapV: number;
  38921. }
  38922. /** @hidden */
  38923. interface _ILoaderSampler extends ISampler, _IArrayItem {
  38924. }
  38925. /** @hidden */
  38926. interface _ILoaderScene extends IScene, _IArrayItem {
  38927. }
  38928. /** @hidden */
  38929. interface _ILoaderSkin extends ISkin, _IArrayItem {
  38930. }
  38931. /** @hidden */
  38932. interface _ILoaderTexture extends ITexture, _IArrayItem {
  38933. }
  38934. /** @hidden */
  38935. interface _ILoaderGLTF extends IGLTF {
  38936. accessors?: _ILoaderAccessor[];
  38937. animations?: _ILoaderAnimation[];
  38938. buffers?: _ILoaderBuffer[];
  38939. bufferViews?: _ILoaderBufferView[];
  38940. cameras?: _ILoaderCamera[];
  38941. images?: _ILoaderImage[];
  38942. materials?: _ILoaderMaterial[];
  38943. meshes?: _ILoaderMesh[];
  38944. nodes?: _ILoaderNode[];
  38945. samplers?: _ILoaderSampler[];
  38946. scenes?: _ILoaderScene[];
  38947. skins?: _ILoaderSkin[];
  38948. textures?: _ILoaderTexture[];
  38949. }
  38950. }
  38951. /**
  38952. * Defines the module used to import/export glTF 2.0 assets
  38953. */
  38954. declare module BABYLON.GLTF2 {
  38955. /** @hidden */
  38956. class GLTFLoader implements IGLTFLoader {
  38957. private _disposed;
  38958. private _state;
  38959. private _extensions;
  38960. private _rootUrl;
  38961. private _rootBabylonMesh;
  38962. private _defaultSampler;
  38963. private _defaultBabylonMaterials;
  38964. private _progressCallback?;
  38965. private _requests;
  38966. private static _ExtensionNames;
  38967. private static _ExtensionFactories;
  38968. private static _Register(name: string, factory: (loader: GLTFLoader) => GLTFLoaderExtension): void;
  38969. /**
  38970. * Loader state or null if the loader is not active.
  38971. */
  38972. readonly state: Nullable<GLTFLoaderState>;
  38973. constructor(parent: GLTFFileLoader);
  38974. dispose(): void;
  38975. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<{
  38976. meshes: AbstractMesh[];
  38977. particleSystems: ParticleSystem[];
  38978. skeletons: Skeleton[];
  38979. animationGroups: AnimationGroup[];
  38980. }>;
  38981. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  38982. private _loadAsync(nodes);
  38983. private _loadData(data);
  38984. private _setupData();
  38985. private _loadExtensions();
  38986. private _checkExtensions();
  38987. private _createRootNode();
  38988. private _forEachPrimitive(node, callback);
  38989. private _getMeshes();
  38990. private _getSkeletons();
  38991. private _getAnimationGroups();
  38992. private _startAnimations();
  38993. private _loadMeshAsync(context, node, mesh, babylonMesh);
  38994. private _loadPrimitiveAsync(context, node, mesh, primitive, babylonMesh);
  38995. private _loadVertexDataAsync(context, primitive, babylonMesh);
  38996. private _createMorphTargets(context, node, mesh, primitive, babylonMesh);
  38997. private _loadMorphTargetsAsync(context, primitive, babylonMesh, babylonGeometry);
  38998. private _loadMorphTargetVertexDataAsync(context, babylonGeometry, attributes, babylonMorphTarget);
  38999. private static _LoadTransform(node, babylonNode);
  39000. private _loadSkinAsync(context, node, mesh, skin);
  39001. private _loadBones(context, skin);
  39002. private _loadBone(node, skin, babylonBones);
  39003. private _loadSkinInverseBindMatricesDataAsync(context, skin);
  39004. private _updateBoneMatrices(babylonSkeleton, inverseBindMatricesData);
  39005. private _getNodeMatrix(node);
  39006. private _loadCamera(context, camera, babylonMesh);
  39007. private _loadAnimationsAsync();
  39008. private _loadAnimationAsync(context, animation);
  39009. private _loadAnimationChannelAsync(context, animationContext, animation, channel, babylonAnimationGroup);
  39010. private _loadAnimationSamplerAsync(context, sampler);
  39011. private _loadBufferAsync(context, buffer);
  39012. private _loadIndicesAccessorAsync(context, accessor);
  39013. private _loadFloatAccessorAsync(context, accessor);
  39014. private _loadVertexAccessorAsync(context, accessor, kind);
  39015. private _getDefaultMaterial(drawMode);
  39016. private _loadMaterialMetallicRoughnessPropertiesAsync(context, material, babylonMaterial);
  39017. private _loadSampler(context, sampler);
  39018. private _loadImageAsync(context, image);
  39019. private _onProgress();
  39020. private static _GetProperty<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  39021. private static _GetTextureWrapMode(context, mode);
  39022. private static _GetTextureSamplingMode(context, magFilter?, minFilter?);
  39023. private static _GetTypedArray(context, componentType, bufferView, byteOffset, length);
  39024. private static _GetNumComponents(context, type);
  39025. private static _ValidateUri(uri);
  39026. private static _GetDrawMode(context, mode);
  39027. private _compileMaterialsAsync();
  39028. private _compileShadowGeneratorsAsync();
  39029. }
  39030. }
  39031. declare module BABYLON.GLTF2 {
  39032. /**
  39033. * Abstract class that can be implemented to extend existing glTF loader behavior.
  39034. */
  39035. abstract class GLTFLoaderExtension implements IGLTFLoaderExtension, IDisposable {
  39036. /**
  39037. * Gets or sets a boolean indicating if the extension is enabled
  39038. */
  39039. enabled: boolean;
  39040. /**
  39041. * Gets or sets extension name
  39042. */
  39043. readonly abstract name: string;
  39044. protected _loader: GLTFLoader;
  39045. /**
  39046. * Creates new GLTFLoaderExtension
  39047. * @param loader defines the GLTFLoader to use
  39048. */
  39049. constructor(loader: GLTFLoader);
  39050. /**
  39051. * Release all resources
  39052. */
  39053. dispose(): void;
  39054. /**
  39055. * Override this method to modify the default behavior for loading scenes.
  39056. * @hidden
  39057. */
  39058. protected _loadSceneAsync(context: string, node: _ILoaderScene): Nullable<Promise<void>>;
  39059. /**
  39060. * Override this method to modify the default behavior for loading nodes.
  39061. * @hidden
  39062. */
  39063. protected _loadNodeAsync(context: string, node: _ILoaderNode): Nullable<Promise<void>>;
  39064. /**
  39065. * Override this method to modify the default behavior for loading mesh primitive vertex data.
  39066. * @hidden
  39067. */
  39068. protected _loadVertexDataAsync(context: string, primitive: _ILoaderMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  39069. /**
  39070. * Override this method to modify the default behavior for loading materials.
  39071. * @hidden
  39072. */
  39073. protected _loadMaterialAsync(context: string, material: _ILoaderMaterial, mesh: _ILoaderMesh, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<void>>;
  39074. /**
  39075. * Override this method to modify the default behavior for loading material properties.
  39076. * @hidden
  39077. */
  39078. protected _loadMaterialPropertiesAsync(context: string, material: _ILoaderMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  39079. /**
  39080. * Override this method to modify the default behavior for loading textures.
  39081. * @hidden
  39082. */
  39083. protected _loadTextureAsync(context: string, textureInfo: ITextureInfo, assign: (texture: Texture) => void): Nullable<Promise<void>>;
  39084. /**
  39085. * Override this method to modify the default behavior for loading uris.
  39086. * @hidden
  39087. */
  39088. protected _loadUriAsync(context: string, uri: string): Nullable<Promise<ArrayBufferView>>;
  39089. /**
  39090. * Helper method called by a loader extension to load an glTF extension.
  39091. * @hidden
  39092. */
  39093. protected _loadExtensionAsync<TProperty, TResult = void>(context: string, property: IProperty, actionAsync: (extensionContext: string, extension: TProperty) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  39094. /**
  39095. * Helper method called by the loader to allow extensions to override loading scenes.
  39096. * @hidden
  39097. */
  39098. protected _loadExtrasValueAsync<TProperty, TResult = void>(context: string, property: IProperty, actionAsync: (extensionContext: string, value: TProperty) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  39099. /**
  39100. * Helper method called by the loader to allow extensions to override loading scenes.
  39101. * @hidden
  39102. */
  39103. private static _LoadSceneAsync(loader: GLTFLoader, context: string, scene: _ILoaderScene): Nullable<Promise<void>>;
  39104. /**
  39105. * Helper method called by the loader to allow extensions to override loading nodes.
  39106. * @hidden
  39107. */
  39108. private static _LoadNodeAsync(loader: GLTFLoader, context: string, node: _ILoaderNode): Nullable<Promise<void>>;
  39109. /**
  39110. * Helper method called by the loader to allow extensions to override loading mesh primitive vertex data.
  39111. * @hidden
  39112. */
  39113. private static _LoadVertexDataAsync(loader: GLTFLoader, context: string, primitive: _ILoaderMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  39114. /**
  39115. * Helper method called by the loader to allow extensions to override loading materials.
  39116. * @hidden
  39117. */
  39118. private static _LoadMaterialAsync(loader: GLTFLoader, context: string, material: _ILoaderMaterial, mesh: _ILoaderMesh, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<void>>;
  39119. /**
  39120. * Helper method called by the loader to allow extensions to override loading material properties.
  39121. * @hidden
  39122. */
  39123. private static _LoadMaterialPropertiesAsync(loader: GLTFLoader, context: string, material: _ILoaderMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  39124. /**
  39125. * Helper method called by the loader to allow extensions to override loading textures.
  39126. * @hidden
  39127. */
  39128. private static _LoadTextureAsync(loader: GLTFLoader, context: string, textureInfo: ITextureInfo, assign: (texture: Texture) => void): Nullable<Promise<void>>;
  39129. /**
  39130. * Helper method called by the loader to allow extensions to override loading uris.
  39131. * @hidden
  39132. */
  39133. private static _LoadUriAsync(loader: GLTFLoader, context: string, uri: string): Nullable<Promise<ArrayBufferView>>;
  39134. }
  39135. }
  39136. /**
  39137. * Defines the module of the glTF 2.0 loader extensions.
  39138. */
  39139. declare module BABYLON.GLTF2.Extensions {
  39140. }
  39141. declare module BABYLON.GLTF2.Extensions {
  39142. /**
  39143. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  39144. */
  39145. class MSFT_lod extends GLTFLoaderExtension {
  39146. readonly name: string;
  39147. /**
  39148. * Maximum number of LODs to load, starting from the lowest LOD.
  39149. */
  39150. maxLODsToLoad: number;
  39151. /**
  39152. * Observable raised when all node LODs of one level are loaded.
  39153. * The event data is the index of the loaded LOD starting from zero.
  39154. * Dispose the loader to cancel the loading of the next level of LODs.
  39155. */
  39156. onNodeLODsLoadedObservable: Observable<number>;
  39157. /**
  39158. * Observable raised when all material LODs of one level are loaded.
  39159. * The event data is the index of the loaded LOD starting from zero.
  39160. * Dispose the loader to cancel the loading of the next level of LODs.
  39161. */
  39162. onMaterialLODsLoadedObservable: Observable<number>;
  39163. private _nodeIndexLOD;
  39164. private _nodeSignalLODs;
  39165. private _nodePromiseLODs;
  39166. private _materialIndexLOD;
  39167. private _materialSignalLODs;
  39168. private _materialPromiseLODs;
  39169. constructor(loader: GLTFLoader);
  39170. dispose(): void;
  39171. protected _loadNodeAsync(context: string, node: _ILoaderNode): Nullable<Promise<void>>;
  39172. protected _loadMaterialAsync(context: string, material: _ILoaderMaterial, mesh: _ILoaderMesh, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<void>>;
  39173. protected _loadUriAsync(context: string, uri: string): Nullable<Promise<ArrayBufferView>>;
  39174. /**
  39175. * Gets an array of LOD properties from lowest to highest.
  39176. */
  39177. private _getLODs<T>(context, property, array, ids);
  39178. private _disposeUnusedMaterials();
  39179. }
  39180. }
  39181. declare module BABYLON.GLTF2.Extensions {
  39182. /** @hidden */
  39183. class MSFT_minecraftMesh extends GLTFLoaderExtension {
  39184. readonly name: string;
  39185. protected _loadMaterialAsync(context: string, material: _ILoaderMaterial, mesh: _ILoaderMesh, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<void>>;
  39186. }
  39187. }
  39188. declare module BABYLON.GLTF2.Extensions {
  39189. /** @hidden */
  39190. class MSFT_sRGBFactors extends GLTFLoaderExtension {
  39191. readonly name: string;
  39192. protected _loadMaterialAsync(context: string, material: _ILoaderMaterial, mesh: _ILoaderMesh, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<void>>;
  39193. }
  39194. }
  39195. declare module BABYLON.GLTF2.Extensions {
  39196. /**
  39197. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  39198. */
  39199. class KHR_draco_mesh_compression extends GLTFLoaderExtension {
  39200. readonly name: string;
  39201. private _dracoCompression;
  39202. constructor(loader: GLTFLoader);
  39203. dispose(): void;
  39204. protected _loadVertexDataAsync(context: string, primitive: _ILoaderMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  39205. }
  39206. }
  39207. declare module BABYLON.GLTF2.Extensions {
  39208. /**
  39209. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  39210. */
  39211. class KHR_materials_pbrSpecularGlossiness extends GLTFLoaderExtension {
  39212. readonly name: string;
  39213. protected _loadMaterialPropertiesAsync(context: string, material: _ILoaderMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  39214. private _loadSpecularGlossinessPropertiesAsync(context, material, properties, babylonMaterial);
  39215. }
  39216. }
  39217. declare module BABYLON.GLTF2.Extensions {
  39218. /**
  39219. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  39220. */
  39221. class KHR_materials_unlit extends GLTFLoaderExtension {
  39222. readonly name: string;
  39223. protected _loadMaterialPropertiesAsync(context: string, material: _ILoaderMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  39224. private _loadUnlitPropertiesAsync(context, material, babylonMaterial);
  39225. }
  39226. }
  39227. declare module BABYLON.GLTF2.Extensions {
  39228. /**
  39229. * [Specification](https://github.com/MiiBond/glTF/tree/khr_lights_v1/extensions/Khronos/KHR_lights) (Experimental)
  39230. */
  39231. class KHR_lights extends GLTFLoaderExtension {
  39232. readonly name: string;
  39233. protected _loadSceneAsync(context: string, scene: _ILoaderScene): Nullable<Promise<void>>;
  39234. protected _loadNodeAsync(context: string, node: _ILoaderNode): Nullable<Promise<void>>;
  39235. private readonly _lights;
  39236. }
  39237. }
  39238. declare module BABYLON.GLTF2.Extensions {
  39239. /**
  39240. * [Specification](https://github.com/AltspaceVR/glTF/blob/avr-sampler-offset-tile/extensions/2.0/Khronos/KHR_texture_transform/README.md) (Experimental)
  39241. */
  39242. class KHR_texture_transform extends GLTFLoaderExtension {
  39243. readonly name: string;
  39244. protected _loadTextureAsync(context: string, textureInfo: ITextureInfo, assign: (texture: Texture) => void): Nullable<Promise<void>>;
  39245. }
  39246. }
  39247. declare module BABYLON {
  39248. /**
  39249. * Holds a collection of exporter options and parameters
  39250. */
  39251. interface IExportOptions {
  39252. /**
  39253. * Function which indicates whether a babylon mesh should be exported or not
  39254. * @param transformNode source Babylon transform node. It is used to check whether it should be exported to glTF or not
  39255. * @returns boolean, which indicates whether the mesh should be exported (true) or not (false)
  39256. */
  39257. shouldExportTransformNode?(transformNode: TransformNode): boolean;
  39258. /**
  39259. * The sample rate to bake animation curves
  39260. */
  39261. animationSampleRate?: number;
  39262. }
  39263. /**
  39264. * Class for generating glTF data from a Babylon scene.
  39265. */
  39266. class GLTF2Export {
  39267. /**
  39268. * Exports the geometry of the scene to .gltf file format asynchronously
  39269. * @param scene Babylon scene with scene hierarchy information
  39270. * @param filePrefix File prefix to use when generating the glTF file
  39271. * @param options Exporter options
  39272. * @returns Returns an object with a .gltf file and associates texture names
  39273. * as keys and their data and paths as values
  39274. */
  39275. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  39276. /**
  39277. * Exports the geometry of the scene to .glb file format asychronously
  39278. * @param scene Babylon scene with scene hierarchy information
  39279. * @param filePrefix File prefix to use when generating glb file
  39280. * @param options Exporter options
  39281. * @returns Returns an object with a .glb filename as key and data as value
  39282. */
  39283. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  39284. }
  39285. }
  39286. declare module BABYLON.GLTF2 {
  39287. /**
  39288. * Converts Babylon Scene into glTF 2.0.
  39289. * @hidden
  39290. */
  39291. class _Exporter {
  39292. /**
  39293. * Stores all generated buffer views, which represents views into the main glTF buffer data
  39294. */
  39295. private bufferViews;
  39296. /**
  39297. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  39298. */
  39299. private accessors;
  39300. /**
  39301. * Stores all the generated nodes, which contains transform and/or mesh information per node
  39302. */
  39303. private nodes;
  39304. /**
  39305. * Stores the glTF asset information, which represents the glTF version and this file generator
  39306. */
  39307. private asset;
  39308. /**
  39309. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  39310. */
  39311. private scenes;
  39312. /**
  39313. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  39314. */
  39315. private meshes;
  39316. /**
  39317. * Stores all the generated material information, which represents the appearance of each primitive
  39318. */
  39319. private materials;
  39320. private materialMap;
  39321. /**
  39322. * Stores all the generated texture information, which is referenced by glTF materials
  39323. */
  39324. private textures;
  39325. /**
  39326. * Stores all the generated image information, which is referenced by glTF textures
  39327. */
  39328. private images;
  39329. /**
  39330. * Stores all the texture samplers
  39331. */
  39332. private samplers;
  39333. /**
  39334. * Stores all the generated animation samplers, which is referenced by glTF animations
  39335. */
  39336. /**
  39337. * Stores the animations for glTF models
  39338. */
  39339. private animations;
  39340. /**
  39341. * Stores the total amount of bytes stored in the glTF buffer
  39342. */
  39343. private totalByteLength;
  39344. /**
  39345. * Stores a reference to the Babylon scene containing the source geometry and material information
  39346. */
  39347. private babylonScene;
  39348. /**
  39349. * Stores a map of the image data, where the key is the file name and the value
  39350. * is the image data
  39351. */
  39352. private imageData;
  39353. /**
  39354. * Stores a map of the unique id of a node to its index in the node array
  39355. */
  39356. private nodeMap;
  39357. /**
  39358. * Specifies if the Babylon scene should be converted to right-handed on export
  39359. */
  39360. private convertToRightHandedSystem;
  39361. /**
  39362. * Baked animation sample rate
  39363. */
  39364. private animationSampleRate;
  39365. /**
  39366. * Callback which specifies if a transform node should be exported or not
  39367. */
  39368. private shouldExportTransformNode;
  39369. /**
  39370. * Creates a glTF Exporter instance, which can accept optional exporter options
  39371. * @param babylonScene Babylon scene object
  39372. * @param options Options to modify the behavior of the exporter
  39373. */
  39374. constructor(babylonScene: Scene, options?: IExportOptions);
  39375. private reorderIndicesBasedOnPrimitiveMode(submesh, primitiveMode, babylonIndices, byteOffset, binaryWriter);
  39376. /**
  39377. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  39378. * clock-wise during export to glTF
  39379. * @param submesh BabylonJS submesh
  39380. * @param primitiveMode Primitive mode of the mesh
  39381. * @param sideOrientation the winding order of the submesh
  39382. * @param vertexBufferKind The type of vertex attribute
  39383. * @param meshAttributeArray The vertex attribute data
  39384. * @param byteOffset The offset to the binary data
  39385. * @param binaryWriter The binary data for the glTF file
  39386. */
  39387. private reorderVertexAttributeDataBasedOnPrimitiveMode(submesh, primitiveMode, sideOrientation, vertexBufferKind, meshAttributeArray, byteOffset, binaryWriter);
  39388. /**
  39389. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  39390. * clock-wise during export to glTF
  39391. * @param submesh BabylonJS submesh
  39392. * @param primitiveMode Primitive mode of the mesh
  39393. * @param sideOrientation the winding order of the submesh
  39394. * @param vertexBufferKind The type of vertex attribute
  39395. * @param meshAttributeArray The vertex attribute data
  39396. * @param byteOffset The offset to the binary data
  39397. * @param binaryWriter The binary data for the glTF file
  39398. */
  39399. private reorderTriangleFillMode(submesh, primitiveMode, sideOrientation, vertexBufferKind, meshAttributeArray, byteOffset, binaryWriter);
  39400. /**
  39401. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  39402. * clock-wise during export to glTF
  39403. * @param submesh BabylonJS submesh
  39404. * @param primitiveMode Primitive mode of the mesh
  39405. * @param sideOrientation the winding order of the submesh
  39406. * @param vertexBufferKind The type of vertex attribute
  39407. * @param meshAttributeArray The vertex attribute data
  39408. * @param byteOffset The offset to the binary data
  39409. * @param binaryWriter The binary data for the glTF file
  39410. */
  39411. private reorderTriangleStripDrawMode(submesh, primitiveMode, sideOrientation, vertexBufferKind, meshAttributeArray, byteOffset, binaryWriter);
  39412. /**
  39413. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  39414. * clock-wise during export to glTF
  39415. * @param submesh BabylonJS submesh
  39416. * @param primitiveMode Primitive mode of the mesh
  39417. * @param sideOrientation the winding order of the submesh
  39418. * @param vertexBufferKind The type of vertex attribute
  39419. * @param meshAttributeArray The vertex attribute data
  39420. * @param byteOffset The offset to the binary data
  39421. * @param binaryWriter The binary data for the glTF file
  39422. */
  39423. private reorderTriangleFanMode(submesh, primitiveMode, sideOrientation, vertexBufferKind, meshAttributeArray, byteOffset, binaryWriter);
  39424. /**
  39425. * Writes the vertex attribute data to binary
  39426. * @param vertices The vertices to write to the binary writer
  39427. * @param byteOffset The offset into the binary writer to overwrite binary data
  39428. * @param vertexAttributeKind The vertex attribute type
  39429. * @param meshAttributeArray The vertex attribute data
  39430. * @param binaryWriter The writer containing the binary data
  39431. */
  39432. private writeVertexAttributeData(vertices, byteOffset, vertexAttributeKind, meshAttributeArray, binaryWriter);
  39433. /**
  39434. * Writes mesh attribute data to a data buffer
  39435. * Returns the bytelength of the data
  39436. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  39437. * @param meshAttributeArray Array containing the attribute data
  39438. * @param binaryWriter The buffer to write the binary data to
  39439. * @param indices Used to specify the order of the vertex data
  39440. */
  39441. private writeAttributeData(vertexBufferKind, meshAttributeArray, byteStride, binaryWriter);
  39442. /**
  39443. * Generates glTF json data
  39444. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  39445. * @param glTFPrefix Text to use when prefixing a glTF file
  39446. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  39447. * @returns json data as string
  39448. */
  39449. private generateJSON(shouldUseGlb, glTFPrefix?, prettyPrint?);
  39450. /**
  39451. * Generates data for .gltf and .bin files based on the glTF prefix string
  39452. * @param glTFPrefix Text to use when prefixing a glTF file
  39453. * @returns GLTFData with glTF file data
  39454. */
  39455. /**
  39456. * Creates a binary buffer for glTF
  39457. * @returns array buffer for binary data
  39458. */
  39459. private _generateBinaryAsync();
  39460. /**
  39461. * Pads the number to a multiple of 4
  39462. * @param num number to pad
  39463. * @returns padded number
  39464. */
  39465. private _getPadding(num);
  39466. /**
  39467. * Generates a glb file from the json and binary data
  39468. * Returns an object with the glb file name as the key and data as the value
  39469. * @param glTFPrefix
  39470. * @returns object with glb filename as key and data as value
  39471. */
  39472. /**
  39473. * Sets the TRS for each node
  39474. * @param node glTF Node for storing the transformation data
  39475. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  39476. */
  39477. private setNodeTransformation(node, babylonTransformNode);
  39478. private getVertexBufferFromMesh(attributeKind, bufferMesh);
  39479. /**
  39480. * Creates a bufferview based on the vertices type for the Babylon mesh
  39481. * @param kind Indicates the type of vertices data
  39482. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  39483. * @param binaryWriter The buffer to write the bufferview data to
  39484. */
  39485. private createBufferViewKind(kind, babylonTransformNode, binaryWriter, byteStride);
  39486. /**
  39487. * The primitive mode of the Babylon mesh
  39488. * @param babylonMesh The BabylonJS mesh
  39489. */
  39490. private getMeshPrimitiveMode(babylonMesh);
  39491. /**
  39492. * Sets the primitive mode of the glTF mesh primitive
  39493. * @param meshPrimitive glTF mesh primitive
  39494. * @param primitiveMode The primitive mode
  39495. */
  39496. private setPrimitiveMode(meshPrimitive, primitiveMode);
  39497. /**
  39498. * Sets the vertex attribute accessor based of the glTF mesh primitive
  39499. * @param meshPrimitive glTF mesh primitive
  39500. * @param attributeKind vertex attribute
  39501. * @returns boolean specifying if uv coordinates are present
  39502. */
  39503. private setAttributeKind(meshPrimitive, attributeKind);
  39504. /**
  39505. * Sets data for the primitive attributes of each submesh
  39506. * @param mesh glTF Mesh object to store the primitive attribute information
  39507. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  39508. * @param binaryWriter Buffer to write the attribute data to
  39509. */
  39510. private setPrimitiveAttributes(mesh, babylonTransformNode, binaryWriter);
  39511. /**
  39512. * Creates a glTF scene based on the array of meshes
  39513. * Returns the the total byte offset
  39514. * @param babylonScene Babylon scene to get the mesh data from
  39515. * @param binaryWriter Buffer to write binary data to
  39516. */
  39517. private createSceneAsync(babylonScene, binaryWriter);
  39518. /**
  39519. * Creates a mapping of Node unique id to node index and handles animations
  39520. * @param babylonScene Babylon Scene
  39521. * @param nodes Babylon transform nodes
  39522. * @param shouldExportTransformNode Callback specifying if a transform node should be exported
  39523. * @param binaryWriter Buffer to write binary data to
  39524. * @returns Node mapping of unique id to index
  39525. */
  39526. private createNodeMapAndAnimations(babylonScene, nodes, shouldExportTransformNode, binaryWriter);
  39527. /**
  39528. * Creates a glTF node from a Babylon mesh
  39529. * @param babylonMesh Source Babylon mesh
  39530. * @param binaryWriter Buffer for storing geometry data
  39531. * @returns glTF node
  39532. */
  39533. private createNode(babylonTransformNode, binaryWriter);
  39534. }
  39535. /**
  39536. * @hidden
  39537. *
  39538. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  39539. */
  39540. class _BinaryWriter {
  39541. /**
  39542. * Array buffer which stores all binary data
  39543. */
  39544. private _arrayBuffer;
  39545. /**
  39546. * View of the array buffer
  39547. */
  39548. private _dataView;
  39549. /**
  39550. * byte offset of data in array buffer
  39551. */
  39552. private _byteOffset;
  39553. /**
  39554. * Initialize binary writer with an initial byte length
  39555. * @param byteLength Initial byte length of the array buffer
  39556. */
  39557. constructor(byteLength: number);
  39558. /**
  39559. * Resize the array buffer to the specified byte length
  39560. * @param byteLength
  39561. */
  39562. private resizeBuffer(byteLength);
  39563. /**
  39564. * Get an array buffer with the length of the byte offset
  39565. * @returns ArrayBuffer resized to the byte offset
  39566. */
  39567. getArrayBuffer(): ArrayBuffer;
  39568. /**
  39569. * Get the byte offset of the array buffer
  39570. * @returns byte offset
  39571. */
  39572. getByteOffset(): number;
  39573. /**
  39574. * Stores an UInt8 in the array buffer
  39575. * @param entry
  39576. * @param byteOffset If defined, specifies where to set the value as an offset.
  39577. */
  39578. setUInt8(entry: number, byteOffset?: number): void;
  39579. /**
  39580. * Gets an UInt32 in the array buffer
  39581. * @param entry
  39582. * @param byteOffset If defined, specifies where to set the value as an offset.
  39583. */
  39584. getUInt32(byteOffset: number): number;
  39585. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  39586. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  39587. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  39588. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  39589. /**
  39590. * Stores a Float32 in the array buffer
  39591. * @param entry
  39592. */
  39593. setFloat32(entry: number, byteOffset?: number): void;
  39594. /**
  39595. * Stores an UInt32 in the array buffer
  39596. * @param entry
  39597. * @param byteOffset If defined, specifies where to set the value as an offset.
  39598. */
  39599. setUInt32(entry: number, byteOffset?: number): void;
  39600. }
  39601. }
  39602. declare module BABYLON {
  39603. /**
  39604. * Class for holding and downloading glTF file data
  39605. */
  39606. class GLTFData {
  39607. /**
  39608. * Object which contains the file name as the key and its data as the value
  39609. */
  39610. glTFFiles: {
  39611. [fileName: string]: string | Blob;
  39612. };
  39613. /**
  39614. * Initializes the glTF file object
  39615. */
  39616. constructor();
  39617. /**
  39618. * Downloads the glTF data as files based on their names and data
  39619. */
  39620. downloadFiles(): void;
  39621. }
  39622. }
  39623. declare module BABYLON.GLTF2 {
  39624. /**
  39625. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  39626. * @hidden
  39627. */
  39628. class _GLTFMaterial {
  39629. /**
  39630. * Represents the dielectric specular values for R, G and B
  39631. */
  39632. private static readonly _dielectricSpecular;
  39633. /**
  39634. * Allows the maximum specular power to be defined for material calculations
  39635. */
  39636. private static _maxSpecularPower;
  39637. /**
  39638. * Numeric tolerance value
  39639. */
  39640. private static _epsilon;
  39641. /**
  39642. * Specifies if two colors are approximately equal in value
  39643. * @param color1 first color to compare to
  39644. * @param color2 second color to compare to
  39645. * @param epsilon threshold value
  39646. */
  39647. private static FuzzyEquals(color1, color2, epsilon);
  39648. /**
  39649. * Gets the materials from a Babylon scene and converts them to glTF materials
  39650. * @param scene babylonjs scene
  39651. * @param mimeType texture mime type
  39652. * @param images array of images
  39653. * @param textures array of textures
  39654. * @param materials array of materials
  39655. * @param imageData mapping of texture names to base64 textures
  39656. * @param hasTextureCoords specifies if texture coordinates are present on the material
  39657. */
  39658. private static _ConvertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, images: IImage[], textures: ITexture[], samplers: ISampler[], materials: IMaterial[], materialMap: {
  39659. [materialID: number]: number;
  39660. }, imageData: {
  39661. [fileName: string]: {
  39662. data: Uint8Array;
  39663. mimeType: ImageMimeType;
  39664. };
  39665. }, hasTextureCoords: boolean): Promise<void>;
  39666. /**
  39667. * Makes a copy of the glTF material without the texture parameters
  39668. * @param originalMaterial original glTF material
  39669. * @returns glTF material without texture parameters
  39670. */
  39671. private static _StripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  39672. /**
  39673. * Specifies if the material has any texture parameters present
  39674. * @param material glTF Material
  39675. * @returns boolean specifying if texture parameters are present
  39676. */
  39677. private static _HasTexturesPresent(material: IMaterial): boolean;
  39678. /**
  39679. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  39680. * @param babylonStandardMaterial
  39681. * @returns glTF Metallic Roughness Material representation
  39682. */
  39683. private static _ConvertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  39684. /**
  39685. * Computes the metallic factor
  39686. * @param diffuse diffused value
  39687. * @param specular specular value
  39688. * @param oneMinusSpecularStrength one minus the specular strength
  39689. * @returns metallic value
  39690. */
  39691. private static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  39692. /**
  39693. * Gets the glTF alpha mode from the Babylon Material
  39694. * @param babylonMaterial Babylon Material
  39695. * @returns The Babylon alpha mode value
  39696. */
  39697. private static _GetAlphaMode(babylonMaterial: Material): MaterialAlphaMode;
  39698. /**
  39699. * Converts a Babylon Standard Material to a glTF Material
  39700. * @param babylonStandardMaterial BJS Standard Material
  39701. * @param mimeType mime type to use for the textures
  39702. * @param images array of glTF image interfaces
  39703. * @param textures array of glTF texture interfaces
  39704. * @param materials array of glTF material interfaces
  39705. * @param imageData map of image file name to data
  39706. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  39707. */
  39708. private static _ConvertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, images: IImage[], textures: ITexture[], samplers: ISampler[], materials: IMaterial[], materialMap: {
  39709. [materialID: number]: number;
  39710. }, imageData: {
  39711. [fileName: string]: {
  39712. data: Uint8Array;
  39713. mimeType: ImageMimeType;
  39714. };
  39715. }, hasTextureCoords: boolean): Promise<void>;
  39716. /**
  39717. *
  39718. * @param texture Texture with alpha to overwrite to one
  39719. * @param useAlpha Specifies if alpha should be preserved or not
  39720. * @returns Promise with texture
  39721. */
  39722. private static _SetAlphaToOneAsync(texture: BaseTexture, useAlpha: boolean): Promise<BaseTexture>;
  39723. /**
  39724. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  39725. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  39726. * @param mimeType mime type to use for the textures
  39727. * @param images array of glTF image interfaces
  39728. * @param textures array of glTF texture interfaces
  39729. * @param materials array of glTF material interfaces
  39730. * @param imageData map of image file name to data
  39731. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  39732. */
  39733. private static _ConvertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, images: IImage[], textures: ITexture[], samplers: ISampler[], materials: IMaterial[], materialMap: {
  39734. [materialID: number]: number;
  39735. }, imageData: {
  39736. [fileName: string]: {
  39737. data: Uint8Array;
  39738. mimeType: ImageMimeType;
  39739. };
  39740. }, hasTextureCoords: boolean): Promise<void>;
  39741. /**
  39742. * Converts an image typed array buffer to a base64 image
  39743. * @param buffer typed array buffer
  39744. * @param width width of the image
  39745. * @param height height of the image
  39746. * @param mimeType mimetype of the image
  39747. * @returns base64 image string
  39748. */
  39749. private static _CreateBase64FromCanvas(buffer, width, height, mimeType);
  39750. /**
  39751. * Generates a white texture based on the specified width and height
  39752. * @param width width of the texture in pixels
  39753. * @param height height of the texture in pixels
  39754. * @param scene babylonjs scene
  39755. * @returns white texture
  39756. */
  39757. private static _CreateWhiteTexture(width, height, scene);
  39758. /**
  39759. * 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
  39760. * @param texture1 first texture to resize
  39761. * @param texture2 second texture to resize
  39762. * @param scene babylonjs scene
  39763. * @returns resized textures or null
  39764. */
  39765. private static _ResizeTexturesToSameDimensions(texture1, texture2, scene);
  39766. /**
  39767. * Convert Specular Glossiness Textures to Metallic Roughness
  39768. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  39769. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  39770. * @param diffuseTexture texture used to store diffuse information
  39771. * @param specularGlossinessTexture texture used to store specular and glossiness information
  39772. * @param factors specular glossiness material factors
  39773. * @param mimeType the mime type to use for the texture
  39774. * @returns pbr metallic roughness interface or null
  39775. */
  39776. private static _ConvertSpecularGlossinessTexturesToMetallicRoughness(diffuseTexture, specularGlossinessTexture, factors, mimeType);
  39777. /**
  39778. * Converts specular glossiness material properties to metallic roughness
  39779. * @param specularGlossiness interface with specular glossiness material properties
  39780. * @returns interface with metallic roughness material properties
  39781. */
  39782. private static _ConvertSpecularGlossinessToMetallicRoughness(specularGlossiness);
  39783. /**
  39784. * Calculates the surface reflectance, independent of lighting conditions
  39785. * @param color Color source to calculate brightness from
  39786. * @returns number representing the perceived brightness, or zero if color is undefined
  39787. */
  39788. private static _GetPerceivedBrightness(color);
  39789. /**
  39790. * Returns the maximum color component value
  39791. * @param color
  39792. * @returns maximum color component value, or zero if color is null or undefined
  39793. */
  39794. private static _GetMaxComponent(color);
  39795. /**
  39796. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  39797. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  39798. * @param mimeType mime type to use for the textures
  39799. * @param images array of glTF image interfaces
  39800. * @param textures array of glTF texture interfaces
  39801. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  39802. * @param imageData map of image file name to data
  39803. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  39804. * @returns glTF PBR Metallic Roughness factors
  39805. */
  39806. private static _ConvertMetalRoughFactorsToMetallicRoughnessAsync(babylonPBRMaterial, mimeType, images, textures, samplers, glTFPbrMetallicRoughness, imageData, hasTextureCoords);
  39807. private static _GetGLTFTextureSampler(texture);
  39808. private static _GetGLTFTextureWrapMode(wrapMode);
  39809. private static _GetGLTFTextureWrapModesSampler(texture);
  39810. /**
  39811. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  39812. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  39813. * @param mimeType mime type to use for the textures
  39814. * @param images array of glTF image interfaces
  39815. * @param textures array of glTF texture interfaces
  39816. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  39817. * @param imageData map of image file name to data
  39818. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  39819. * @returns glTF PBR Metallic Roughness factors
  39820. */
  39821. private static _ConvertSpecGlossFactorsToMetallicRoughness(babylonPBRMaterial, mimeType, images, textures, samplers, glTFPbrMetallicRoughness, imageData, hasTextureCoords);
  39822. /**
  39823. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  39824. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  39825. * @param mimeType mime type to use for the textures
  39826. * @param images array of glTF image interfaces
  39827. * @param textures array of glTF texture interfaces
  39828. * @param materials array of glTF material interfaces
  39829. * @param imageData map of image file name to data
  39830. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  39831. */
  39832. private static _ConvertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, images: IImage[], textures: ITexture[], samplers: ISampler[], materials: IMaterial[], materialMap: {
  39833. [materialID: number]: number;
  39834. }, imageData: {
  39835. [fileName: string]: {
  39836. data: Uint8Array;
  39837. mimeType: ImageMimeType;
  39838. };
  39839. }, hasTextureCoords: boolean): Promise<void>;
  39840. private static SetMetallicRoughnessPbrMaterial(metallicRoughness, babylonPBRMaterial, glTFMaterial, glTFPbrMetallicRoughness, mimeType, images, textures, samplers, materials, materialMap, imageData, hasTextureCoords);
  39841. private static GetPixelsFromTexture(babylonTexture);
  39842. /**
  39843. * Extracts a texture from a Babylon texture into file data and glTF data
  39844. * @param babylonTexture Babylon texture to extract
  39845. * @param mimeType Mime Type of the babylonTexture
  39846. * @param images Array of glTF images
  39847. * @param textures Array of glTF textures
  39848. * @param imageData map of image file name and data
  39849. * @return glTF texture info, or null if the texture format is not supported
  39850. */
  39851. private static _ExportTextureAsync(babylonTexture, mimeType, images, textures, samplers, imageData, useAlpha);
  39852. /**
  39853. * Builds a texture from base64 string
  39854. * @param base64Texture base64 texture string
  39855. * @param baseTextureName Name to use for the texture
  39856. * @param mimeType image mime type for the texture
  39857. * @param images array of images
  39858. * @param textures array of textures
  39859. * @param imageData map of image data
  39860. * @returns glTF texture info, or null if the texture format is not supported
  39861. */
  39862. private static _GetTextureInfoFromBase64(base64Texture, baseTextureName, mimeType, images, textures, texCoordIndex, samplerIndex, imageData);
  39863. }
  39864. }
  39865. declare module BABYLON.GLTF2 {
  39866. /**
  39867. * @hidden
  39868. * Interface to store animation data.
  39869. */
  39870. interface _IAnimationData {
  39871. /**
  39872. * Keyframe data.
  39873. */
  39874. inputs: number[];
  39875. /**
  39876. * Value data.
  39877. */
  39878. outputs: number[][];
  39879. /**
  39880. * Animation interpolation data.
  39881. */
  39882. samplerInterpolation: AnimationSamplerInterpolation;
  39883. /**
  39884. * Minimum keyframe value.
  39885. */
  39886. inputsMin: number;
  39887. /**
  39888. * Maximum keyframe value.
  39889. */
  39890. inputsMax: number;
  39891. }
  39892. /**
  39893. * @hidden
  39894. */
  39895. interface _IAnimationInfo {
  39896. /**
  39897. * The target channel for the animation
  39898. */
  39899. animationChannelTargetPath: AnimationChannelTargetPath;
  39900. /**
  39901. * The glTF accessor type for the data.
  39902. */
  39903. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4;
  39904. /**
  39905. * Specifies if quaternions should be used.
  39906. */
  39907. useQuaternion: boolean;
  39908. }
  39909. /**
  39910. * @hidden
  39911. * Utility class for generating glTF animation data from BabylonJS.
  39912. */
  39913. class _GLTFAnimation {
  39914. /**
  39915. * @ignore
  39916. *
  39917. * Creates glTF channel animation from BabylonJS animation.
  39918. * @param babylonTransformNode - BabylonJS mesh.
  39919. * @param animation - animation.
  39920. * @param animationChannelTargetPath - The target animation channel.
  39921. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  39922. * @param useQuaternion - Specifies if quaternions are used.
  39923. * @returns nullable IAnimationData
  39924. */
  39925. private static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  39926. private static _DeduceAnimationInfo(animation);
  39927. /**
  39928. * @ignore
  39929. * Create node animations from the transform node animations
  39930. * @param babylonTransformNode
  39931. * @param runtimeGLTFAnimation
  39932. * @param idleGLTFAnimations
  39933. * @param nodeMap
  39934. * @param nodes
  39935. * @param binaryWriter
  39936. * @param bufferViews
  39937. * @param accessors
  39938. * @param convertToRightHandedSystem
  39939. */
  39940. private static _CreateNodeAnimationFromTransformNodeAnimations(babylonTransformNode: TransformNode, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  39941. [key: number]: number;
  39942. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  39943. /**
  39944. * @ignore
  39945. * Create node animations from the animation groups
  39946. * @param babylonScene
  39947. * @param glTFAnimations
  39948. * @param nodeMap
  39949. * @param nodes
  39950. * @param binaryWriter
  39951. * @param bufferViews
  39952. * @param accessors
  39953. * @param convertToRightHandedSystem
  39954. */
  39955. private static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  39956. [key: number]: number;
  39957. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  39958. private static AddAnimation(name, glTFAnimation, babylonTransformNode, animation, dataAccessorType, animationChannelTargetPath, nodeMap, binaryWriter, bufferViews, accessors, convertToRightHandedSystem, useQuaternion, animationSampleRate);
  39959. /**
  39960. * Create a baked animation
  39961. * @param babylonTransformNode BabylonJS mesh
  39962. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  39963. * @param animationChannelTargetPath animation target channel
  39964. * @param minFrame minimum animation frame
  39965. * @param maxFrame maximum animation frame
  39966. * @param fps frames per second of the animation
  39967. * @param inputs input key frames of the animation
  39968. * @param outputs output key frame data of the animation
  39969. * @param convertToRightHandedSystem converts the values to right-handed
  39970. * @param useQuaternion specifies if quaternions should be used
  39971. */
  39972. private static _CreateBakedAnimation(babylonTransformNode, animation, animationChannelTargetPath, minFrame, maxFrame, fps, sampleRate, inputs, outputs, minMaxFrames, convertToRightHandedSystem, useQuaternion);
  39973. private static _ConvertFactorToVector3OrQuaternion(factor, babylonTransformNode, animation, animationType, animationChannelTargetPath, convertToRightHandedSystem, useQuaternion);
  39974. private static _SetInterpolatedValue(babylonTransformNode, value, time, animation, animationChannelTargetPath, quaternionCache, inputs, outputs, convertToRightHandedSystem, useQuaternion);
  39975. /**
  39976. * Creates linear animation from the animation key frames
  39977. * @param babylonTransformNode BabylonJS mesh
  39978. * @param animation BabylonJS animation
  39979. * @param animationChannelTargetPath The target animation channel
  39980. * @param frameDelta The difference between the last and first frame of the animation
  39981. * @param inputs Array to store the key frame times
  39982. * @param outputs Array to store the key frame data
  39983. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  39984. * @param useQuaternion Specifies if quaternions are used in the animation
  39985. */
  39986. private static _CreateLinearOrStepAnimation(babylonTransformNode, animation, animationChannelTargetPath, frameDelta, inputs, outputs, convertToRightHandedSystem, useQuaternion);
  39987. /**
  39988. * Creates cubic spline animation from the animation key frames
  39989. * @param babylonTransformNode BabylonJS mesh
  39990. * @param animation BabylonJS animation
  39991. * @param animationChannelTargetPath The target animation channel
  39992. * @param frameDelta The difference between the last and first frame of the animation
  39993. * @param inputs Array to store the key frame times
  39994. * @param outputs Array to store the key frame data
  39995. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  39996. * @param useQuaternion Specifies if quaternions are used in the animation
  39997. */
  39998. private static _CreateCubicSplineAnimation(babylonTransformNode, animation, animationChannelTargetPath, frameDelta, inputs, outputs, convertToRightHandedSystem, useQuaternion);
  39999. private static _GetBasePositionRotationOrScale(babylonTransformNode, animationChannelTargetPath, convertToRightHandedSystem, useQuaternion);
  40000. /**
  40001. * Adds a key frame value
  40002. * @param keyFrame
  40003. * @param animation
  40004. * @param outputs
  40005. * @param animationChannelTargetPath
  40006. * @param basePositionRotationOrScale
  40007. * @param convertToRightHandedSystem
  40008. * @param useQuaternion
  40009. */
  40010. private static _AddKeyframeValue(keyFrame, animation, outputs, animationChannelTargetPath, babylonTransformNode, convertToRightHandedSystem, useQuaternion);
  40011. /**
  40012. * Determine the interpolation based on the key frames
  40013. * @param keyFrames
  40014. * @param animationChannelTargetPath
  40015. * @param useQuaternion
  40016. */
  40017. private static _DeduceInterpolation(keyFrames, animationChannelTargetPath, useQuaternion);
  40018. /**
  40019. * Adds an input tangent or output tangent to the output data
  40020. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  40021. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  40022. * @param outputs The animation data by keyframe
  40023. * @param animationChannelTargetPath The target animation channel
  40024. * @param interpolation The interpolation type
  40025. * @param keyFrame The key frame with the animation data
  40026. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  40027. * @param useQuaternion Specifies if quaternions are used
  40028. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  40029. */
  40030. private static AddSplineTangent(babylonTransformNode, tangentType, outputs, animationChannelTargetPath, interpolation, keyFrame, frameDelta, useQuaternion, convertToRightHandedSystem);
  40031. /**
  40032. * Get the minimum and maximum key frames' frame values
  40033. * @param keyFrames animation key frames
  40034. * @returns the minimum and maximum key frame value
  40035. */
  40036. private static calculateMinMaxKeyFrames(keyFrames);
  40037. }
  40038. }
  40039. declare module BABYLON.GLTF2 {
  40040. /**
  40041. * @hidden
  40042. */
  40043. class _GLTFUtilities {
  40044. /**
  40045. * Creates a buffer view based on the supplied arguments
  40046. * @param bufferIndex index value of the specified buffer
  40047. * @param byteOffset byte offset value
  40048. * @param byteLength byte length of the bufferView
  40049. * @param byteStride byte distance between conequential elements
  40050. * @param name name of the buffer view
  40051. * @returns bufferView for glTF
  40052. */
  40053. static CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  40054. /**
  40055. * Creates an accessor based on the supplied arguments
  40056. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  40057. * @param name The name of the accessor
  40058. * @param type The type of the accessor
  40059. * @param componentType The datatype of components in the attribute
  40060. * @param count The number of attributes referenced by this accessor
  40061. * @param byteOffset The offset relative to the start of the bufferView in bytes
  40062. * @param min Minimum value of each component in this attribute
  40063. * @param max Maximum value of each component in this attribute
  40064. * @returns accessor for glTF
  40065. */
  40066. static CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  40067. /**
  40068. * Calculates the minimum and maximum values of an array of position floats
  40069. * @param positions Positions array of a mesh
  40070. * @param vertexStart Starting vertex offset to calculate min and max values
  40071. * @param vertexCount Number of vertices to check for min and max values
  40072. * @returns min number array and max number array
  40073. */
  40074. static CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  40075. min: number[];
  40076. max: number[];
  40077. };
  40078. /**
  40079. * Converts a new right-handed Vector3
  40080. * @param vector vector3 array
  40081. * @returns right-handed Vector3
  40082. */
  40083. static GetRightHandedPositionVector3(vector: Vector3): Vector3;
  40084. /**
  40085. * Converts a Vector3 to right-handed
  40086. * @param vector Vector3 to convert to right-handed
  40087. */
  40088. static GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  40089. /**
  40090. * Converts a three element number array to right-handed
  40091. * @param vector number array to convert to right-handed
  40092. */
  40093. static GetRightHandedPositionArray3FromRef(vector: number[]): void;
  40094. /**
  40095. * Converts a new right-handed Vector3
  40096. * @param vector vector3 array
  40097. * @returns right-handed Vector3
  40098. */
  40099. static GetRightHandedNormalVector3(vector: Vector3): Vector3;
  40100. /**
  40101. * Converts a Vector3 to right-handed
  40102. * @param vector Vector3 to convert to right-handed
  40103. */
  40104. static GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  40105. /**
  40106. * Converts a three element number array to right-handed
  40107. * @param vector number array to convert to right-handed
  40108. */
  40109. static GetRightHandedNormalArray3FromRef(vector: number[]): void;
  40110. /**
  40111. * Converts a Vector4 to right-handed
  40112. * @param vector Vector4 to convert to right-handed
  40113. */
  40114. static GetRightHandedVector4FromRef(vector: Vector4): void;
  40115. /**
  40116. * Converts a Vector4 to right-handed
  40117. * @param vector Vector4 to convert to right-handed
  40118. */
  40119. static GetRightHandedArray4FromRef(vector: number[]): void;
  40120. /**
  40121. * Converts a Quaternion to right-handed
  40122. * @param quaternion Source quaternion to convert to right-handed
  40123. */
  40124. static GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  40125. /**
  40126. * Converts a Quaternion to right-handed
  40127. * @param quaternion Source quaternion to convert to right-handed
  40128. */
  40129. static GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  40130. }
  40131. }
  40132. /**
  40133. * @ignoreChildren
  40134. * @ignore
  40135. */
  40136. declare module "babylonjs-gltf2interface" {
  40137. export = BABYLON.GLTF2;
  40138. }
  40139. /**
  40140. * Moduel for glTF 2.0 Interface
  40141. */
  40142. declare module BABYLON.GLTF2 {
  40143. /**
  40144. * The datatype of the components in the attribute
  40145. */
  40146. const enum AccessorComponentType {
  40147. /**
  40148. * Byte
  40149. */
  40150. BYTE = 5120,
  40151. /**
  40152. * Unsigned Byte
  40153. */
  40154. UNSIGNED_BYTE = 5121,
  40155. /**
  40156. * Short
  40157. */
  40158. SHORT = 5122,
  40159. /**
  40160. * Unsigned Short
  40161. */
  40162. UNSIGNED_SHORT = 5123,
  40163. /**
  40164. * Unsigned Int
  40165. */
  40166. UNSIGNED_INT = 5125,
  40167. /**
  40168. * Float
  40169. */
  40170. FLOAT = 5126,
  40171. }
  40172. /**
  40173. * Specifies if the attirbute is a scalar, vector, or matrix
  40174. */
  40175. const enum AccessorType {
  40176. /**
  40177. * Scalar
  40178. */
  40179. SCALAR = "SCALAR",
  40180. /**
  40181. * Vector2
  40182. */
  40183. VEC2 = "VEC2",
  40184. /**
  40185. * Vector3
  40186. */
  40187. VEC3 = "VEC3",
  40188. /**
  40189. * Vector4
  40190. */
  40191. VEC4 = "VEC4",
  40192. /**
  40193. * Matrix2x2
  40194. */
  40195. MAT2 = "MAT2",
  40196. /**
  40197. * Matrix3x3
  40198. */
  40199. MAT3 = "MAT3",
  40200. /**
  40201. * Matrix4x4
  40202. */
  40203. MAT4 = "MAT4",
  40204. }
  40205. /**
  40206. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  40207. */
  40208. const enum AnimationChannelTargetPath {
  40209. /**
  40210. * Translation
  40211. */
  40212. TRANSLATION = "translation",
  40213. /**
  40214. * Rotation
  40215. */
  40216. ROTATION = "rotation",
  40217. /**
  40218. * Scale
  40219. */
  40220. SCALE = "scale",
  40221. /**
  40222. * Weights
  40223. */
  40224. WEIGHTS = "weights",
  40225. }
  40226. /**
  40227. * Interpolation algorithm
  40228. */
  40229. const enum AnimationSamplerInterpolation {
  40230. /**
  40231. * The animated values are linearly interpolated between keyframes
  40232. */
  40233. LINEAR = "LINEAR",
  40234. /**
  40235. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  40236. */
  40237. STEP = "STEP",
  40238. /**
  40239. * The animation's interpolation is computed using a cubic spline with specified tangents
  40240. */
  40241. CUBICSPLINE = "CUBICSPLINE",
  40242. }
  40243. /**
  40244. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  40245. */
  40246. const enum CameraType {
  40247. /**
  40248. * A perspective camera containing properties to create a perspective projection matrix
  40249. */
  40250. PERSPECTIVE = "perspective",
  40251. /**
  40252. * An orthographic camera containing properties to create an orthographic projection matrix
  40253. */
  40254. ORTHOGRAPHIC = "orthographic",
  40255. }
  40256. /**
  40257. * The mime-type of the image
  40258. */
  40259. const enum ImageMimeType {
  40260. /**
  40261. * JPEG Mime-type
  40262. */
  40263. JPEG = "image/jpeg",
  40264. /**
  40265. * PNG Mime-type
  40266. */
  40267. PNG = "image/png",
  40268. }
  40269. /**
  40270. * The alpha rendering mode of the material
  40271. */
  40272. const enum MaterialAlphaMode {
  40273. /**
  40274. * The alpha value is ignored and the rendered output is fully opaque
  40275. */
  40276. OPAQUE = "OPAQUE",
  40277. /**
  40278. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  40279. */
  40280. MASK = "MASK",
  40281. /**
  40282. * 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)
  40283. */
  40284. BLEND = "BLEND",
  40285. }
  40286. /**
  40287. * The type of the primitives to render
  40288. */
  40289. const enum MeshPrimitiveMode {
  40290. /**
  40291. * Points
  40292. */
  40293. POINTS = 0,
  40294. /**
  40295. * Lines
  40296. */
  40297. LINES = 1,
  40298. /**
  40299. * Line Loop
  40300. */
  40301. LINE_LOOP = 2,
  40302. /**
  40303. * Line Strip
  40304. */
  40305. LINE_STRIP = 3,
  40306. /**
  40307. * Triangles
  40308. */
  40309. TRIANGLES = 4,
  40310. /**
  40311. * Triangle Strip
  40312. */
  40313. TRIANGLE_STRIP = 5,
  40314. /**
  40315. * Triangle Fan
  40316. */
  40317. TRIANGLE_FAN = 6,
  40318. }
  40319. /**
  40320. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  40321. */
  40322. const enum TextureMagFilter {
  40323. /**
  40324. * Nearest
  40325. */
  40326. NEAREST = 9728,
  40327. /**
  40328. * Linear
  40329. */
  40330. LINEAR = 9729,
  40331. }
  40332. /**
  40333. * Minification filter. All valid values correspond to WebGL enums
  40334. */
  40335. const enum TextureMinFilter {
  40336. /**
  40337. * Nearest
  40338. */
  40339. NEAREST = 9728,
  40340. /**
  40341. * Linear
  40342. */
  40343. LINEAR = 9729,
  40344. /**
  40345. * Nearest Mip-Map Nearest
  40346. */
  40347. NEAREST_MIPMAP_NEAREST = 9984,
  40348. /**
  40349. * Linear Mipmap Nearest
  40350. */
  40351. LINEAR_MIPMAP_NEAREST = 9985,
  40352. /**
  40353. * Nearest Mipmap Linear
  40354. */
  40355. NEAREST_MIPMAP_LINEAR = 9986,
  40356. /**
  40357. * Linear Mipmap Linear
  40358. */
  40359. LINEAR_MIPMAP_LINEAR = 9987,
  40360. }
  40361. /**
  40362. * S (U) wrapping mode. All valid values correspond to WebGL enums
  40363. */
  40364. const enum TextureWrapMode {
  40365. /**
  40366. * Clamp to Edge
  40367. */
  40368. CLAMP_TO_EDGE = 33071,
  40369. /**
  40370. * Mirrored Repeat
  40371. */
  40372. MIRRORED_REPEAT = 33648,
  40373. /**
  40374. * Repeat
  40375. */
  40376. REPEAT = 10497,
  40377. }
  40378. /**
  40379. * glTF Property
  40380. */
  40381. interface IProperty {
  40382. /**
  40383. * Dictionary object with extension-specific objects
  40384. */
  40385. extensions?: {
  40386. [key: string]: any;
  40387. };
  40388. /**
  40389. * Application-Specific data
  40390. */
  40391. extras?: any;
  40392. }
  40393. /**
  40394. * glTF Child of Root Property
  40395. */
  40396. interface IChildRootProperty extends IProperty {
  40397. /**
  40398. * The user-defined name of this object
  40399. */
  40400. name?: string;
  40401. }
  40402. /**
  40403. * Indices of those attributes that deviate from their initialization value
  40404. */
  40405. interface IAccessorSparseIndices extends IProperty {
  40406. /**
  40407. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  40408. */
  40409. bufferView: number;
  40410. /**
  40411. * The offset relative to the start of the bufferView in bytes. Must be aligned
  40412. */
  40413. byteOffset?: number;
  40414. /**
  40415. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  40416. */
  40417. componentType: AccessorComponentType;
  40418. }
  40419. /**
  40420. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  40421. */
  40422. interface IAccessorSparseValues extends IProperty {
  40423. /**
  40424. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  40425. */
  40426. bufferView: number;
  40427. /**
  40428. * The offset relative to the start of the bufferView in bytes. Must be aligned
  40429. */
  40430. byteOffset?: number;
  40431. }
  40432. /**
  40433. * Sparse storage of attributes that deviate from their initialization value
  40434. */
  40435. interface IAccessorSparse extends IProperty {
  40436. /**
  40437. * The number of attributes encoded in this sparse accessor
  40438. */
  40439. count: number;
  40440. /**
  40441. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  40442. */
  40443. indices: IAccessorSparseIndices;
  40444. /**
  40445. * 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
  40446. */
  40447. values: IAccessorSparseValues;
  40448. }
  40449. /**
  40450. * 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
  40451. */
  40452. interface IAccessor extends IChildRootProperty {
  40453. /**
  40454. * The index of the bufferview
  40455. */
  40456. bufferView?: number;
  40457. /**
  40458. * The offset relative to the start of the bufferView in bytes
  40459. */
  40460. byteOffset?: number;
  40461. /**
  40462. * The datatype of components in the attribute
  40463. */
  40464. componentType: AccessorComponentType;
  40465. /**
  40466. * Specifies whether integer data values should be normalized
  40467. */
  40468. normalized?: boolean;
  40469. /**
  40470. * The number of attributes referenced by this accessor
  40471. */
  40472. count: number;
  40473. /**
  40474. * Specifies if the attribute is a scalar, vector, or matrix
  40475. */
  40476. type: AccessorType;
  40477. /**
  40478. * Maximum value of each component in this attribute
  40479. */
  40480. max?: number[];
  40481. /**
  40482. * Minimum value of each component in this attribute
  40483. */
  40484. min?: number[];
  40485. /**
  40486. * Sparse storage of attributes that deviate from their initialization value
  40487. */
  40488. sparse?: IAccessorSparse;
  40489. }
  40490. /**
  40491. * Targets an animation's sampler at a node's property
  40492. */
  40493. interface IAnimationChannel extends IProperty {
  40494. /**
  40495. * The index of a sampler in this animation used to compute the value for the target
  40496. */
  40497. sampler: number;
  40498. /**
  40499. * The index of the node and TRS property to target
  40500. */
  40501. target: IAnimationChannelTarget;
  40502. }
  40503. /**
  40504. * The index of the node and TRS property that an animation channel targets
  40505. */
  40506. interface IAnimationChannelTarget extends IProperty {
  40507. /**
  40508. * The index of the node to target
  40509. */
  40510. node: number;
  40511. /**
  40512. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  40513. */
  40514. path: AnimationChannelTargetPath;
  40515. }
  40516. /**
  40517. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  40518. */
  40519. interface IAnimationSampler extends IProperty {
  40520. /**
  40521. * The index of an accessor containing keyframe input values, e.g., time
  40522. */
  40523. input: number;
  40524. /**
  40525. * Interpolation algorithm
  40526. */
  40527. interpolation?: AnimationSamplerInterpolation;
  40528. /**
  40529. * The index of an accessor, containing keyframe output values
  40530. */
  40531. output: number;
  40532. }
  40533. /**
  40534. * A keyframe animation
  40535. */
  40536. interface IAnimation extends IChildRootProperty {
  40537. /**
  40538. * An array of channels, each of which targets an animation's sampler at a node's property
  40539. */
  40540. channels: IAnimationChannel[];
  40541. /**
  40542. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  40543. */
  40544. samplers: IAnimationSampler[];
  40545. }
  40546. /**
  40547. * Metadata about the glTF asset
  40548. */
  40549. interface IAsset extends IChildRootProperty {
  40550. /**
  40551. * A copyright message suitable for display to credit the content creator
  40552. */
  40553. copyright?: string;
  40554. /**
  40555. * Tool that generated this glTF model. Useful for debugging
  40556. */
  40557. generator?: string;
  40558. /**
  40559. * The glTF version that this asset targets
  40560. */
  40561. version: string;
  40562. /**
  40563. * The minimum glTF version that this asset targets
  40564. */
  40565. minVersion?: string;
  40566. }
  40567. /**
  40568. * A buffer points to binary geometry, animation, or skins
  40569. */
  40570. interface IBuffer extends IChildRootProperty {
  40571. /**
  40572. * 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
  40573. */
  40574. uri?: string;
  40575. /**
  40576. * The length of the buffer in bytes
  40577. */
  40578. byteLength: number;
  40579. }
  40580. /**
  40581. * A view into a buffer generally representing a subset of the buffer
  40582. */
  40583. interface IBufferView extends IChildRootProperty {
  40584. /**
  40585. * The index of the buffer
  40586. */
  40587. buffer: number;
  40588. /**
  40589. * The offset into the buffer in bytes
  40590. */
  40591. byteOffset?: number;
  40592. /**
  40593. * The lenth of the bufferView in bytes
  40594. */
  40595. byteLength: number;
  40596. /**
  40597. * The stride, in bytes
  40598. */
  40599. byteStride?: number;
  40600. }
  40601. /**
  40602. * An orthographic camera containing properties to create an orthographic projection matrix
  40603. */
  40604. interface ICameraOrthographic extends IProperty {
  40605. /**
  40606. * The floating-point horizontal magnification of the view. Must not be zero
  40607. */
  40608. xmag: number;
  40609. /**
  40610. * The floating-point vertical magnification of the view. Must not be zero
  40611. */
  40612. ymag: number;
  40613. /**
  40614. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  40615. */
  40616. zfar: number;
  40617. /**
  40618. * The floating-point distance to the near clipping plane
  40619. */
  40620. znear: number;
  40621. }
  40622. /**
  40623. * A perspective camera containing properties to create a perspective projection matrix
  40624. */
  40625. interface ICameraPerspective extends IProperty {
  40626. /**
  40627. * The floating-point aspect ratio of the field of view
  40628. */
  40629. aspectRatio?: number;
  40630. /**
  40631. * The floating-point vertical field of view in radians
  40632. */
  40633. yfov: number;
  40634. /**
  40635. * The floating-point distance to the far clipping plane
  40636. */
  40637. zfar?: number;
  40638. /**
  40639. * The floating-point distance to the near clipping plane
  40640. */
  40641. znear: number;
  40642. }
  40643. /**
  40644. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  40645. */
  40646. interface ICamera extends IChildRootProperty {
  40647. /**
  40648. * An orthographic camera containing properties to create an orthographic projection matrix
  40649. */
  40650. orthographic?: ICameraOrthographic;
  40651. /**
  40652. * A perspective camera containing properties to create a perspective projection matrix
  40653. */
  40654. perspective?: ICameraPerspective;
  40655. /**
  40656. * Specifies if the camera uses a perspective or orthographic projection
  40657. */
  40658. type: CameraType;
  40659. }
  40660. /**
  40661. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  40662. */
  40663. interface IImage extends IChildRootProperty {
  40664. /**
  40665. * 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
  40666. */
  40667. uri?: string;
  40668. /**
  40669. * The image's MIME type
  40670. */
  40671. mimeType?: ImageMimeType;
  40672. /**
  40673. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  40674. */
  40675. bufferView?: number;
  40676. }
  40677. /**
  40678. * Material Normal Texture Info
  40679. */
  40680. interface IMaterialNormalTextureInfo extends ITextureInfo {
  40681. /**
  40682. * The scalar multiplier applied to each normal vector of the normal texture
  40683. */
  40684. scale?: number;
  40685. }
  40686. /**
  40687. * Material Occlusion Texture Info
  40688. */
  40689. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  40690. /**
  40691. * A scalar multiplier controlling the amount of occlusion applied
  40692. */
  40693. strength?: number;
  40694. }
  40695. /**
  40696. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  40697. */
  40698. interface IMaterialPbrMetallicRoughness {
  40699. /**
  40700. * The material's base color factor
  40701. */
  40702. baseColorFactor?: number[];
  40703. /**
  40704. * The base color texture
  40705. */
  40706. baseColorTexture?: ITextureInfo;
  40707. /**
  40708. * The metalness of the material
  40709. */
  40710. metallicFactor?: number;
  40711. /**
  40712. * The roughness of the material
  40713. */
  40714. roughnessFactor?: number;
  40715. /**
  40716. * The metallic-roughness texture
  40717. */
  40718. metallicRoughnessTexture?: ITextureInfo;
  40719. }
  40720. /**
  40721. * The material appearance of a primitive
  40722. */
  40723. interface IMaterial extends IChildRootProperty {
  40724. /**
  40725. * 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
  40726. */
  40727. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  40728. /**
  40729. * The normal map texture
  40730. */
  40731. normalTexture?: IMaterialNormalTextureInfo;
  40732. /**
  40733. * The occlusion map texture
  40734. */
  40735. occlusionTexture?: IMaterialOcclusionTextureInfo;
  40736. /**
  40737. * The emissive map texture
  40738. */
  40739. emissiveTexture?: ITextureInfo;
  40740. /**
  40741. * 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
  40742. */
  40743. emissiveFactor?: number[];
  40744. /**
  40745. * The alpha rendering mode of the material
  40746. */
  40747. alphaMode?: MaterialAlphaMode;
  40748. /**
  40749. * The alpha cutoff value of the material
  40750. */
  40751. alphaCutoff?: number;
  40752. /**
  40753. * Specifies whether the material is double sided
  40754. */
  40755. doubleSided?: boolean;
  40756. }
  40757. /**
  40758. * Geometry to be rendered with the given material
  40759. */
  40760. interface IMeshPrimitive extends IProperty {
  40761. /**
  40762. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  40763. */
  40764. attributes: {
  40765. [name: string]: number;
  40766. };
  40767. /**
  40768. * The index of the accessor that contains the indices
  40769. */
  40770. indices?: number;
  40771. /**
  40772. * The index of the material to apply to this primitive when rendering
  40773. */
  40774. material?: number;
  40775. /**
  40776. * The type of primitives to render. All valid values correspond to WebGL enums
  40777. */
  40778. mode?: MeshPrimitiveMode;
  40779. /**
  40780. * 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
  40781. */
  40782. targets?: {
  40783. [name: string]: number;
  40784. }[];
  40785. }
  40786. /**
  40787. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  40788. */
  40789. interface IMesh extends IChildRootProperty {
  40790. /**
  40791. * An array of primitives, each defining geometry to be rendered with a material
  40792. */
  40793. primitives: IMeshPrimitive[];
  40794. /**
  40795. * Array of weights to be applied to the Morph Targets
  40796. */
  40797. weights?: number[];
  40798. }
  40799. /**
  40800. * A node in the node hierarchy
  40801. */
  40802. interface INode extends IChildRootProperty {
  40803. /**
  40804. * The index of the camera referenced by this node
  40805. */
  40806. camera?: number;
  40807. /**
  40808. * The indices of this node's children
  40809. */
  40810. children?: number[];
  40811. /**
  40812. * The index of the skin referenced by this node
  40813. */
  40814. skin?: number;
  40815. /**
  40816. * A floating-point 4x4 transformation matrix stored in column-major order
  40817. */
  40818. matrix?: number[];
  40819. /**
  40820. * The index of the mesh in this node
  40821. */
  40822. mesh?: number;
  40823. /**
  40824. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  40825. */
  40826. rotation?: number[];
  40827. /**
  40828. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  40829. */
  40830. scale?: number[];
  40831. /**
  40832. * The node's translation along the x, y, and z axes
  40833. */
  40834. translation?: number[];
  40835. /**
  40836. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  40837. */
  40838. weights?: number[];
  40839. }
  40840. /**
  40841. * Texture sampler properties for filtering and wrapping modes
  40842. */
  40843. interface ISampler extends IChildRootProperty {
  40844. /**
  40845. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  40846. */
  40847. magFilter?: TextureMagFilter;
  40848. /**
  40849. * Minification filter. All valid values correspond to WebGL enums
  40850. */
  40851. minFilter?: TextureMinFilter;
  40852. /**
  40853. * S (U) wrapping mode. All valid values correspond to WebGL enums
  40854. */
  40855. wrapS?: TextureWrapMode;
  40856. /**
  40857. * T (V) wrapping mode. All valid values correspond to WebGL enums
  40858. */
  40859. wrapT?: TextureWrapMode;
  40860. }
  40861. /**
  40862. * The root nodes of a scene
  40863. */
  40864. interface IScene extends IChildRootProperty {
  40865. /**
  40866. * The indices of each root node
  40867. */
  40868. nodes: number[];
  40869. }
  40870. /**
  40871. * Joints and matrices defining a skin
  40872. */
  40873. interface ISkin extends IChildRootProperty {
  40874. /**
  40875. * 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
  40876. */
  40877. inverseBindMatrices?: number;
  40878. /**
  40879. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  40880. */
  40881. skeleton?: number;
  40882. /**
  40883. * 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)
  40884. */
  40885. joints: number[];
  40886. }
  40887. /**
  40888. * A texture and its sampler
  40889. */
  40890. interface ITexture extends IChildRootProperty {
  40891. /**
  40892. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  40893. */
  40894. sampler?: number;
  40895. /**
  40896. * The index of the image used by this texture
  40897. */
  40898. source: number;
  40899. }
  40900. /**
  40901. * Reference to a texture
  40902. */
  40903. interface ITextureInfo extends IProperty {
  40904. /**
  40905. * The index of the texture
  40906. */
  40907. index: number;
  40908. /**
  40909. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  40910. */
  40911. texCoord?: number;
  40912. }
  40913. /**
  40914. * The root object for a glTF asset
  40915. */
  40916. interface IGLTF extends IProperty {
  40917. /**
  40918. * An array of accessors. An accessor is a typed view into a bufferView
  40919. */
  40920. accessors?: IAccessor[];
  40921. /**
  40922. * An array of keyframe animations
  40923. */
  40924. animations?: IAnimation[];
  40925. /**
  40926. * Metadata about the glTF asset
  40927. */
  40928. asset: IAsset;
  40929. /**
  40930. * An array of buffers. A buffer points to binary geometry, animation, or skins
  40931. */
  40932. buffers?: IBuffer[];
  40933. /**
  40934. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  40935. */
  40936. bufferViews?: IBufferView[];
  40937. /**
  40938. * An array of cameras
  40939. */
  40940. cameras?: ICamera[];
  40941. /**
  40942. * Names of glTF extensions used somewhere in this asset
  40943. */
  40944. extensionsUsed?: string[];
  40945. /**
  40946. * Names of glTF extensions required to properly load this asset
  40947. */
  40948. extensionsRequired?: string[];
  40949. /**
  40950. * An array of images. An image defines data used to create a texture
  40951. */
  40952. images?: IImage[];
  40953. /**
  40954. * An array of materials. A material defines the appearance of a primitive
  40955. */
  40956. materials?: IMaterial[];
  40957. /**
  40958. * An array of meshes. A mesh is a set of primitives to be rendered
  40959. */
  40960. meshes?: IMesh[];
  40961. /**
  40962. * An array of nodes
  40963. */
  40964. nodes?: INode[];
  40965. /**
  40966. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  40967. */
  40968. samplers?: ISampler[];
  40969. /**
  40970. * The index of the default scene
  40971. */
  40972. scene?: number;
  40973. /**
  40974. * An array of scenes
  40975. */
  40976. scenes?: IScene[];
  40977. /**
  40978. * An array of skins. A skin is defined by joints and matrices
  40979. */
  40980. skins?: ISkin[];
  40981. /**
  40982. * An array of textures
  40983. */
  40984. textures?: ITexture[];
  40985. }
  40986. }